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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int64_t msb(int64_t v){
  v = v | (v >>  1);
  v = v | (v >>  2);
  v = v | (v >>  4);
  v = v | (v >>  8);
  v = v | (v >> 16);
  v = v | (v >> 32);
  return v ^ (v >> 1);
}

struct GJ_Xor{
    vector<int64_t> V;

    void add(int64_t a){
        for(int64_t v : V) if(msb(v)&a) a ^= v;
        if(a > 0){
            for(int64_t& v : V) if(msb(a)&v) v ^= a;
            V.push_back(a);
            sort(V.rbegin(), V.rend());
        }
    }

    bool belong(int64_t a){
        for(int64_t v : V) if(msb(v)&a) a ^= v;
        return a == 0;
    }
};

bool solve(){
    int N;
    cin >> N;
    vector<int64_t> A(N), S(N);
    for(int i=0; i<N; i++) cin >> A[i];
    string str;
    cin >> str;
    for(int i=0; i<N; i++) S[i] = (str[i] == '1');

    reverse(A.begin(), A.end());
    reverse(S.begin(), S.end());
    GJ_Xor gj;
    for(int i=0; i<N; i++){
        if(S[i] == 0){
            gj.add(A[i]);
        }else{
            if(!gj.belong(A[i])) return 1;
        }
    }
    return 0;
}

int main(){
    int T;
    cin >> T;
    while(T--) cout << (solve() ? 1 : 0) << endl;
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int Taka = ((A + D - 1) / D); // 高橋が負けるまでのターン数 
  int Aoki = ((C + B - 1) / B); //青木が負けるまでのターン数

  if (Taka < Aoki) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
 #define MAX 500001
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node r;
 
void insert(int);
void inorder(Node);
void preorder(Node);
 
void insert(int k){
  Node y = NULL;
  Node x = r;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;
 
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
    z->parent = y;
  }
 
  if(y == NULL) r = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
 
}
 
void inorder(Node u){
    if(u->left != NULL) inorder(u->left);
    printf(" %d", u->key);
    if(u->right != NULL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NULL) preorder(u->left);
  if(u->right != NULL) preorder(u->right);
}
 
 
int main(){
  int i,j,n;
  int x[MAX];
  char com[MAX][7];
  Node t;
 
  scanf("%d", &n);
 
  for( i = 0, j = 0;i < n;i++){
    scanf("%s", com[i]);
    if(com[i][0] == 'i'){
      scanf("%d", &x[j]);
      j++;
    }
  }
   
  r= malloc(sizeof(struct node));
  t = malloc(sizeof(struct node));
  r->left = NULL;
  r->right = NULL;
  r->parent = NULL;
 
  t = r;
 
  for( i = 0,j = 0;i < n;i++){
    if(com[i][0] == 'i' && i == 0){
      r->key = x[j];
      j++;
    }
    else if(com[i][0] == 'i'){
      insert(x[j]);
      j++;
    }
    else {
      inorder(t);
      printf("\n");
      preorder(t);
      printf("\n");
    }
  }
 
  free(r);
  return 0;
}

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

int main(void) {
  	int N,K;
  	string S;
  	cin >> N >> S >> K;
  	--K;
  	for(int i=0; i<N; ++i) {
    	if(S[i]!=S[K]) S[i]='*'; 
    }
  	cout << S << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        int[][] g = new int[h][w];
        for(int i=0; i<h; i++) {
            char[] c = sc.next().toCharArray();
            for(int j=0; j<w; j++) {
                if(c[j] == '#') g[i][j] = 1;
            }
        }

        int res = 0;
        for(int i=0; i<(1<<h); i++) {
            for(int j=0; j<(1<<w); j++) {
                int sum = 0;
                for(int a = 0; a < h; a ++) {
                    for(int b = 0; b< w; b++) {
                        if((i>>a) %2 == 1 && (j>>b) %2 ==1) sum+=g[a][b];
                    }
                }
                if(sum == k) res++;
            }
        }
        System.out.println(res);

    }


}

Measured memory_bytes: 35780
N=int(input())
ab=[]
for i in range(N):
  ab.append(list(map(int,input().split())))

ab.sort(key=lambda x:x[1])

t=0
for i in ab:
  t+=i[0]
  if t>i[1]:
    print("No")
    exit()

print("Yes")

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

typedef long long ll;
typedef unsigned long long ull;

class UnionFind{
public:
    UnionFind(size_t n){
        m_parent.resize(n);
        iota(m_parent.begin(), m_parent.end(), 0);

        m_rank.resize(n);
        fill(m_rank.begin(), m_rank.end(), 0);
    }

    int Find(int x){
        if(m_parent[x] == x){
            return x;
        }else{
            m_parent[x] = Find(m_parent[x]);
            return m_parent[x];
        }
    }

    void Union(int x, int y){
        auto xroot = Find(x);
        auto yroot = Find(y);
        if(m_rank[xroot] > m_rank[yroot]){
            m_parent[yroot] = xroot;
        }else if(m_rank[xroot] < m_rank[yroot]){
            m_parent[xroot] = yroot;
        }else if(xroot != yroot){
            m_parent[yroot] = xroot;
            m_rank[xroot] = m_rank[xroot] + 1;
        }
    }

    int GetSize(){
      	for(size_t i=0;i<m_parent.size();i++){
            m_parent[i] = Find(m_parent[i]);
        }	
        std::set<int> s(m_parent.begin(), m_parent.end());
        return s.size();
    }

    std::vector<int> m_parent;
    std::vector<int> m_rank;
};

int main()
{
    ll N, M;
    cin >> N >> M;
    ll xi, yi, zi;
    UnionFind uf(N);

    for(int i=0;i<M;i++){
        cin >> xi >> yi >> zi;
        uf.Union(xi-1, yi-1);
    }
    cout<<uf.GetSize()<<endl;

    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

void deer(int a, int b, int c) {
  int ans = 1;
  if (a != b) ans++;
  if (c != a && c != b) ans++;
  printf("%d\n", ans);
}

int main(void) {
  int a, b, c;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  deer(a, b, c);
  return 0;
}

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

int main()
{
	char b;
  	cin >> b;
  	if(b == 'A')
      cout << 'T';
  	else if(b == 'T')
      cout << 'A';
 	else if(b == 'C')
      cout << 'G';
  	else
      cout << 'C';
  	return 0;
}
  


Measured memory_bytes: 3564
from math import floor
A, B = map(int, input().split())

ans = 10**9
for i in range(1, 100000):
    a = floor(i * 0.08)
    b = floor(i * 0.1)

    if a == A and b == B:
        ans = min(ans, i)

if ans == 10**9:
    print(-1)
else:
    print(ans)

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

//typedef
typedef long long LL;
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef set<int, greater<int> > setdownINT;
typedef set<long long, greater<long long> > setdownLL;
typedef priority_queue<int, vector<int>, greater<int> > priqueupINT;
typedef priority_queue<long long, vector<long long>, greater<long long> > priqueupLL;
//container utill
#define ALL(v) (v).begin(),(v).end()
#define sortdown(v) sort((v).begin(),(v).end()), reverse((v).begin(),(v).end())
#define PB(a) push_back(a)
#define MP make_pair
#define MT make_tuple
//constant
#define PI 3.141592653589793

int main(){
    //input
    int N, M;
    cin >> N >> M;
    int counta[N];
    fill(counta,counta+N,0);
    int a,b;
    int i;
    for(i=1; i<=M; i++){
        cin >> a >> b;
        a--;
        b--;
        counta[a]++;
        counta[b]++;
    }

    //calc
    for(i=0; i<N; i++){
        if(counta[i]%2==1){
            cout << "NO" << endl;
            system("pause");
            return 0;
        }
    }
    
    cout << "YES" << endl;
    system("pause");
    return 0;
}

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

using namespace std;

const int inf = 1000000007;

int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d,d+n);
    cout << d[n/2] - d[(n-2)/2] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"


#define MAX LLONG_MAX

#define MIN LLONG_MIN

using namespace std;

int main()
{
  ll n;
  cin >> n;
  
  ll *a = new ll[n];
  
  for01(0,n)
    cin >> a[i];
  
  sort(a,a+n);
  ll min = MAX;
  
  for(ll i = a[0]; i <= a[n-1] ;i++)
  {
    ll sum = 0;
    for02(0,n)
      sum += (i-a[j])*(i-a[j]);
 	
    if (sum <= min)
      min = sum;
    
  }
  
  p1(min);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

int main()
{
	int a[3];
	scanf("%d%d%d", a,a + 1, a + 2);

	std::sort(a, a + 3);

	printf("%d\n", a[2] * 10 + a[0] + a[1]);

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int b,e;

    for ( int i = 0 ; i < s.size(); i++ ){
        if ( s.at(i) == 'A') {
            b = i;
            break;
        }
    }
    for ( int i = 0 ; i < s.size(); i++ ){
        if ( s.at(i) == 'Z') {
            e = i;
        }
    }   
    cout << e-b+1 << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define vss vector< vector<string> >
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

struct SegmentTree {
    private:
        vl arr;
        ll size;
        ll n;
        vl value;
    public:
        SegmentTree(vl array){
            arr = array; 
            size = calc_size(arr);
            n = (size + 1) / 2;
            value = vl(size, 0); // custom
        }

        ll calc_size(vl array){
            int i = 1;
            while(i < array.size()) i <<= 1;
            return (i << 1) - 1;
        }

        void update(ll i, ll x){
            i += n - 1;
            value[i] = x;
            while(i > 0){
                i = (i-1) / 2;
                value[i] = value[2*i+1] || value[2*i+2];
            }
        }

        ll query(ll l, ll r){
            return _query(l, r+1, 0, 0, n);
        }
    
        ll _query(ll l, ll r, ll node_i, ll node_l, ll node_r){
            if(node_r <= l || r <= node_l) return 0; // custom
            if(l <= node_l && node_r <= r) return value[node_i];
            ll c1 = _query(l, r, 2 * node_i + 1, node_l, (node_l + node_r) / 2);
            ll c2 = _query(l, r, 2 * node_i + 2, (node_l + node_r) / 2, node_r);
            return c1 || c2;
        }
        void print(){
            DEBUG_VEC(value);
        }
};

int main(){
    ll N; cin >> N;
    string S; cin >> S;
    ll Q; cin >> Q;

    vector<SegmentTree> trees(26, SegmentTree(vl(N, 0)));

    for(int i=0; i<S.length(); i++){
        int j = (S[i] - 'a');
        trees[j].update(i, 1);
    }
    int t, l, r;
    char c;
    vi ans;
    rep(k, 0, Q){
        cin >> t;
        if(t == 1){
            cin >> l >> c;
            l--;
            trees[S[l] - 'a'].update(l, 0); 
            S[l] = c;
            trees[S[l] - 'a'].update(l, 1);
        } else {
            cin >> l >> r;
            l--; r--;
            ll cnt = 0;
            rep(i, 0, 26){
                cnt += trees[i].query(l, r);
            }
            ans.pb(cnt);
        }
    }
    rep(i, 0, ans.size()) cout << ans[i] << endl;
    return 0;
}




Measured memory_bytes: 331456
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int INF = 1e+9;
int n, m;
int a[1000], b[1000], c[1000][12];
int dp[1 << 12];

void chmin(int &a, int b) { a = min(a, b); }

signed main() {
	int i, j, k;
	
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		rep(j, b[i]) {
			cin >> c[i][j];
			c[i][j]--;
		}
	}
	
	rep(i, (1 << n)) dp[i] = INF;
	dp[0] = 0;
	
	rep(i, (1 << n)) {
		rep(j, m) {
			int ni = i;
			rep(k, b[j]) {
				ni = (ni | (1 << c[j][k]));
			}
			chmin(dp[ni], dp[i] + a[j]);
		}
	}
	
	if (dp[(1 << n) - 1] >= INF) cout << -1 << endl;
	else cout << dp[(1 << n) - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

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


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

int main() {
	string s;
	cin >> s;
	int num = s.size() - 2;

	cout << s[0] << num << s[s.size() - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	ll n;
	cin>>n;
	double sum=0;
	for(int i=0;i<n;i++){
		double x;
		cin>>x;
		x=1/x;
		sum+=x;
	}
	printf("%0.7f",1/sum);
	return 0;
}

Measured memory_bytes: 256
using System;

class Training
{
	static public void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());

		long m = 1;
		for(int i=0; i<9; i++)
			m *= 10;
		m += 7;

		long ans = 1;
		for(int i=1; i<=N; i++)
		{
			ans = ans * i % m;
		}
		Console.WriteLine(ans);
	}
}



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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,n;
    cin >> x >> n;
    set<int> s;
    for(int i=0;i<n;i++)
    {
        int a;
        cin >> a;
        s.insert(a);
    }
    for(int i=0;;i++)
    {
        if(s.find(x-i)==s.end())
        {
            cout << x-i << "\n";
            break;
        }
        if(s.find(x+i)==s.end())
        {
            cout << x+i << "\n";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
//@author :  |< U $ |-|
#include<iostream>
#include<vector>
#include<math.h>
#include<unordered_map>
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;



int main(){
    
    #ifndef ONLINE_JUDGE
    TakeInput
    #endif
    
    int i,j,k,n,m;
    string a;
    cin>>a;
    n=0;
    int maxi =0;
    for(i=0;i<3;i++){
        if(a[i] == 'R')n++;
        else n=0;
        maxi =max(maxi,n);
    }
    cout<<maxi;
}
 
 
 

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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

using namespace std;


int32_t main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  	string s,t;
  	cin>>s;
  	cin>>t;
  	bool ans=true;
  	for(int i=0; i<s.length(); i++) {
  		if(s[i]!=t[i]){
  			ans = false;
  			break;
  		}
  	}
  	if(ans){
  		cout<<"Yes\n";
  	}
  	else{
  		cout<<"No"<<'\n';
  	}
    return 0;
}

Measured memory_bytes: 3648
<?php

while (TRUE) {
    $a = fscanf(STDIN, '%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d');
    if (feof(STDIN)) {
        break;
    }
    $v = array($a[10], $a[11]);
    $l = array(0);
    $sum = 0;
    for ($i = 0; $i < 10; $i++) {
        $l[$i + 1] = $l[$i] + $a[$i];
        $sum += $a[$i];
    }

    $m = $sum * $v[0] / ($v[0] + $v[1]);
    for ($i = 0; $i < 10; $i++) {
        if ($m > $l[$i] && $m <= $l[$i + 1]) {
            echo $i + 1;
            echo PHP_EOL;
            break;
        }
    }
}

Measured memory_bytes: 6640
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n,d;
  cin>>n>>d;
 vector<pair<long long int,long long int>> hoge(n);
 for(long long int i=0; i<n; i++){
   cin>>hoge.at(i).first>>hoge.at(i).second;
 }
 long long int ans=0;
 for(long long int i=0; i<n; i++){
   long double pre=sqrt(pow(hoge.at(i).first,2)+pow(hoge.at(i).second,2));
   if(pre<=d){
     ans++;
   }
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 6484
N = int(input())

*H, = map(int, input().split())
count = 0
flg = 1
for i in range(len(H)):
    flg = 1
    for j in range(0,i,1):
        if H[i]>=H[j]:
            continue
        else:
            flg = 0
            break
    if flg==1:
        count = count + 1
    
print(count)

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

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    ans += min(A, K);
    K -= min(A, K);
    K -= min(B, K);
    ans -= min(C, K);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
k=int(input())
ans=[]
for i in range(1,10): #1桁の数
  ans.append(str(i))
  
for i in range(1,10): #2桁の数
  ans.append(str(i)+'9')
  
for i in range(1,10): #3桁の数
  ans.append(str(i)+'99')
  
for i in range(10): #4桁の数
  ans.append('1'+str(i)+'99')
for i in range(2,10): #4桁の数
  ans.append(str(i)+'999')
  
for i in range(1,3): #5桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'999')
for i in range(3,10): #5桁の数
  ans.append(str(i)+'9999')
  
for i in range(1,4): #6桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'9999')
for i in range(4,10): #6桁の数
  ans.append(str(i)+'99999')
  
for i in range(1,5): #7桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'99999')
for i in range(5,10): #7桁の数
  ans.append(str(i)+'999999')

for i in range(1,6): #8桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'999999')
for i in range(6,10): #8桁の数
  ans.append(str(i)+'9999999')
  
for i in range(1,7): #9桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'9999999')
for i in range(7,10): #9桁の数
  ans.append(str(i)+'99999999')

for i in range(1,8): #10桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'99999999')
for i in range(8,10): #10桁の数
  ans.append(str(i)+'999999999')

for i in range(1,9): #11桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'999999999')
for i in range(9,10): #11桁の数
  ans.append(str(i)+'9999999999')
  
for i in range(1,10): #12桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'9999999999')
for i in range(10,10): #12桁の数
  ans.append(str(i)+'99999999999')

for i in range(1,10): #13桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'99999999999')
for i in range(10,10): #13桁の数
  ans.append(str(i)+'999999999999')
  
for i in range(1,10): #14桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'999999999999')
for i in range(10,10): #14桁の数
  ans.append(str(i)+'9999999999999')

for i in range(10): #15桁の数
  ans.append('10'+str(i)+'999999999999')
for i in range(1,10): #15桁の数
  ans.append('1'+str(i)+'9999999999999')
for i in range(2,10): #15桁の数
  for j in range(10):
    ans.append(str(i)+str(j)+'9999999999999')
  
for val in ans[:k]:
  print(val)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  double N,M;
  cin>>N>>M;
  double v=pow(2,M);
  cout<<v*(1900*M+100*(N-M))<<endl;
  return 0;
}

Measured memory_bytes: 4168
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    vector<vector<pair<int, ll>>> g(N);
    for (int i = 0; i < N - 1; i++) {
      int a, b;
      ll c;
      cin >> a >> b >> c;
      --a;
      --b;
      g[a].emplace_back(b, c);
      g[b].emplace_back(a, c);
    }
    int Q, K;
    cin >> Q >> K;
    --K;
    vector<ll> depth(N);
    function<void(int, int, ll)> dfs = [&](int v, int p, ll d) {
      depth[v] = d;
      for (auto &e : g[v]) {
        if (e.first != p) dfs(e.first, v, d + e.second);
      }
    };
    dfs(K, -1, 0);
    for (int q = 0; q < Q; q++) {
      int x, y;
      cin >> x >> y;
      --x;
      --y;
      ll ans = depth[x] + depth[y];
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 17408
#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;

int N;
int sz[100000];
int dp[100000];
int pa[100000];
void dfs1(VVI& G, int u, int p = -1){
  sz[u] = 1;
  for(int to: G[u]){
	if(to == p) continue;
	dp[to] = dp[u] + 1;
	pa[to] = u;
	dfs1(G, to, u);
	sz[u] += sz[to];
  }
}

int dfs(VVI& G, int u, int p, int d){
  if(d > 0)
	return dfs(G, pa[u], u, d-1);
  
  int res = 1;
  for(int to: G[u]){
	if(to == p || to == pa[u]) continue;
	res += sz[to];
  }

  if(u == 0) return res;
  return res + dfs(G, pa[u], u, d);
}

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

  cin >> N;
  VVI G(N);
  REP(i,N-1){
	int a, b;
	cin >> a >> b;
	--a;
	--b;
	G[a].PB(b);
	G[b].PB(a);
  }
  pa[0] = -1;
  dfs1(G, 0);
  int b = dfs(G, N-1, N-1, 1+(dp[N-1]-1)/2);
  int w = N - b;
  cout << (b>w? "Fennec": "Snuke") << endl;

  return 0;
}


Measured memory_bytes: 14720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProconTemplate
{

    class Class2
    {
        public static void Main(string[] args)
        {
            //string[] asInput = Console.ReadLine().Split(' ');
            //int N = int.Parse(asInput[0]);
            //int K = int.Parse(asInput[1]);
            //int[] p = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            string s = Console.ReadLine();
            bool bRetYes = true;
            for (int i = 0; i < s.Length; i++)
            {
                if ( (i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R'))
                {
                    bRetYes = false;
                }
            }

            Console.WriteLine(bRetYes ? "Yes" : "No");

        }
    }
}


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

city = [-1 for i in range(0,N,1)]#0~N-1
count = 0
nex_city = 0
city[0]=0
while True:
    city[nex_city] = count
    nex_city = A[nex_city]-1
    count+=1
    if city[nex_city] >= 0:
        break

X = city[nex_city]
Y = count - city[nex_city]

nex_city = 0
if K < X:
    for i in range(0,K,1):
        nex_city = A[nex_city]-1
    print(nex_city+1)
    exit()

nex_city = 0
for i in range(0,X+(K-X)%Y,1):
    nex_city = A[nex_city]-1
print(nex_city+1)



Measured memory_bytes: 102440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15


 
int main(){
	int n;
	cin >> n;
	if(n / 10 == 9 || n%10 == 9)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a <= 5)
        cout << 0 << endl;
    else if (a <= 12)
        cout << b/2 << endl;
    else
        cout << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
bool gd[514514],rd[514514];
signed main(){
	string s,r;
	cin>>s;
	r = s;
	reverse( r.begin(), r.end() );
	int n = s.size();
	vector<int> a(n),b(n);
	a[0] = n;
	int i=1,j=0;
	while( i < s.size() ){
		while( i + j < s.size() && s[j] == s[i+j] ) j++;
		a[i] = j;
		if( j == 0 ){ i++; continue; }
		int k=1;
		while( i+k < s.size() && k+a[k] < j ){
			a[i+k] = a[k];
			k++;
		}
		i+=k; j-=k;
	}
	for(int i=0;i<n;i++)gd[i]=true;
	for(int i=1;i<n;i++){
		for(int j=2;(j-1)*i<=a[i];j++){
			gd[i*j-1] = false;

		}
	}
	i=1;j=0;
	while( i < r.size() ){
		while( i + j < r.size() && r[j] == r[i+j] ) j++;
		b[i] = j;
		if( j == 0 ){ i++; continue; }
		int k=1;
		while( i+k < r.size() && k+b[k] < j ){
			b[i+k] = b[k];
			k++;
		}
		i+=k; j-=k;
	}
	for(int i=0;i<n;i++)rd[i]=true;
	for(int i=1;i<n;i++){
		for(int j=2;(j-1)*i<=b[i];j++){
			rd[i*j-1] = false;

		}
	}
	if( gd[n-1] == true ){
		cout<<1<<endl<<1<<endl;
		return 0;
	}
	int cnt = 0;
	for(int i=0;i<n-1;i++){
		if( gd[i] == true && rd[n-2-i] == true)cnt++;
	}
	if( cnt == 0 ){
		cout<<n<<endl<<1<<endl;
		return 0;
	}
	else{
		cout<<2<<endl<<cnt<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 10116
n = gets.to_i
k = gets.to_i
a = []
while n > 0
  a << n % 10
  n /= 10
end

def solve(a, i, k, same)
  return 0 if k < 0
  return k == 0 ? 1 : 0 if i < 0
  sum = 0
  if same
    sum += solve(a, i-1, k-1, true) if a[i] >= 1
    sum += (a[i]-1) * solve(a, i-1, k-1, false) if a[i] >= 2
    sum += solve(a, i-1, k, a[i] == 0)
  else
    sum += 9 * solve(a, i-1, k-1, false)
    sum += solve(a, i-1, k, false)
  end
  sum
end

p solve(a, a.size-1, k, true)

Measured memory_bytes: 14328
import sys
input = sys.stdin.readline

h, n = map(int, input().split())
a = []
b = []
for _ in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)

dp=[float("inf")]*(2*10000+1)
dp[0]=0

for i in range(h):
    for j in range(n):
        if (i+a[j])>2*10000:
            dp[2*10000]=min(dp[2*10000],dp[i]+b[j])
            continue
        dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j])

ans=float("inf")
for j in range(h,2*10000+1):
    ans=min(ans,dp[j])
print(ans)
    
            


Measured memory_bytes: 42716
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e3+100;
int a[N][N],top[N],vis[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        top[i]=1;
        for(int j=1; j<=n-1; j++)
        {
            cin>>a[i][j];
        }
    }
    int cnt=1;
    while(1)
    {
        int f=0;
        for(int i=1;i<=n;i++)//模拟N天
        {
            if(top[i]>=n||vis[i]==cnt)
                continue;
            int v=a[i][top[i]];
            if(vis[v]!=cnt && top[v]<n && a[v][top[v]]==i)
            {
                top[v]++; top[i]++;
				vis[i]=vis[v]=cnt;
				f=1;

            }
        }
        if(f==0)
        {
            break;
        }
        cnt++;
    }
    for(int i=1;i<=n;i++)
    {
        if(top[i]!=n)
        {
            cout<<-1;
            return 0;
        }
    }
    cout<<cnt-1;
    return 0;
}


Measured memory_bytes: 7948
#include <cstdio>
using namespace std;
const int MaxN = 1e5;

int n;
int a[MaxN + 5];
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		int ji = 0, ou = 0;
		for(int i = 1; i <= n; i++)
		{
			scanf("%d", &a[i]);
			if(a[i] & 1)
				ji++;
			else ou++;
		}
		if(ji & 1) printf("NO\n");
		else
			printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		cin >> h[i];
		if(h[i]>=k)
			cnt++;
	}
	
	cout << cnt << endl;




}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int N,a[100002],shu;
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>shu;
		a[shu]=i;
	}
	for(int i=1;i<=N;i++)
	{
		cout<<a[i];
		if(i==N)cout<<endl;
		else cout<<" ";
	}
 } 

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

int main() {
  int N, A, B, C, D;
  // A < B < D かつ　A < C
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  for (int i = A; i < C - 1; i++) {
    if (S.at(i) == '#' && S.at(i + 1) == '#') {
    cout << "No" << endl;
    return 0;
    }
  }
  for (int i = B; i < D - 1; i++) {
    if (S.at(i) == '#' && S.at(i + 1) == '#') {
    cout << "No" << endl;
    return 0;
    }
  }
  if (C < D) {
    cout << "Yes" << endl;
  }
  // A < B < D < C
  else {
    for (int i = B; i < D + 1; i++) {
      if (S.at(i - 2) == '.' && S.at(i - 1) == '.' && S.at(i) == '.') {
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#include<cstdio>
#define N 300003
int a[N],i,j,k,l,n,r;
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%d",a+i);
    for(i=1;i<=n;i=j+1)if(a[j=i]!=i)
    {
        for(l=n+1,r=0,j--;l!=i||r!=j;)l=a[++j]<l?a[j]:l,r=r<a[j]?a[j]:r;
        for(k=i+1;k<=j;k+=2)if(a[k]!=k)return 0&puts("No");
        for(k=i,l=r=0;k<=j;k+=2)
        if(k<a[k])
        if(a[k]<l)return 0&puts("No");
        else l=a[k];
        else if(a[k]<k)
        if(a[k]<r)return 0&puts("No");
        else r=a[k];
        else return 0&puts("No");
    }
    return 0&puts("Yes");
}

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

int main() {
    string N;
    cin >> N;
    if (N[0] != '7' && N[1] != '7' && N[2] != '7') {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;      
    }
}

Measured memory_bytes: 3628
toInt :: (String -> Int)
toInt x = read x ::Int


getInts = do
    x <- getLine
    let y = (map$toInt)$words x
    return y


check :: Int -> Int -> String
check n m
    | n == m = "Yes"
    | otherwise = "No"


main = do
    x <- getInts
    let n = head x
    let m = last x
    let r = check n m
    putStrLn r


Measured memory_bytes: 508
#include<bits/stdc++.h>
#include <iostream>
#define ll long long
#define MOD (int)1e9+7
#define N 2*(int)10e5+10
using namespace std;
int p[N]={0};
int cmp[N]={0};
int sp(int cn){
    return ((cn==p[cn])?cn:(p[cn]=sp(p[cn])));
}

void unite(int x,int y){
    if(x>y) return unite(y,x);
    // find the sp of x,y;
    int spx = sp(x);
    int spy = sp(y);
    if(spx!=spy){
    p[spy] = spx;
    cmp[spx] += cmp[spy];
    }
}



int main() {
    ll n,m; cin>>n>>m;
    
    for(int i=0;i<=n+5;i++){
        p[i] =i,cmp[i]=1;
    }
    //memset(cmp,1,sizeof cmp);
    set<pair<int,int>> st;
    for(int i=0;i<m;i++){
        int x,y; cin>>x>>y;
        if(st.find({x,y})==st.end() && st.find({y,x})==st.end())
        st.insert({x,y});
       
    }
    auto it= st.begin();
    while(it!=st.end()){
        pair<int,int> tmp =*it;
        //cout<<tmp.first<<" "<<tmp.second<<"\n";
        unite(tmp.first,tmp.second);
        it++;
    }
    int ans=1;
    for(int i=1;i<=n;i++){
       // cout<<cmp[sp(i)]<<" ";
        ans =max(ans,cmp[sp(i)]);
    }
    //cout<<"\n";
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 14584
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

const int INF = 10000000;

typedef pair<int, int> P;

//入力
int n, m;
char maze[100][101];
int sx, sy;
int gx, gy;

//各点までの最小距離
int d[100][100];

//移動ベクトル
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int bfs()
{
	//Pを作ったのは、x, y座標の2つの組み合わせが欲しかったため
	queue<P> q;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			//最大で初期化
			d[i][j] = INF;
		}
	}

	//スタート地点をキューに入れて、最短距離を0とする
	d[sx][sy] = 0;
	q.push(make_pair(sx, sy));

	while (q.size() > 0)
	{
		//キューの先頭を受け取る
		P next = q.front();
		q.pop();

		int nx = next.first;
		int ny = next.second;

		if (nx == gx && ny == gy)
		{
			//ゴールなら探索終了
			break;
		}

		//4方向を調べる
		for (int i = 0; i < 4; i++)
		{
			if (!(nx + dx[i] >= 0 && ny + dy[i] >= 0 && nx + dx[i] < n && ny + dy[i] < m))
			{
				continue;
			}

			if (maze[nx + dx[i]][ny + dy[i]] == '#' || d[nx + dx[i]][ny + dy[i]] != INF)
			{
				continue;
			}

			d[nx + dx[i]][ny + dy[i]] = d[nx][ny] + 1;
			q.push(make_pair(nx + dx[i], ny + dy[i]));
		}
	}

	return d[gx][gy];
}

int main()
{
	sx = sy = 0;
	cin >> n >> m;
	gx = n - 1;
	gy = m - 1;

	int blackPosition = 0;

	//入力を行う
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		for (int j = 0; j < m; j++)
		{
			maze[i][j] = s[j];
			if (s[j] == '#')
			{
				blackPosition++;
			}
		}
	}
	if (bfs() == INF)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << n * m - 1 - bfs() - blackPosition << endl;
	}
}


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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d%d",&a[i],&b[i]);

	bool ok=false;
	rep(i,n-2) if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]) ok=true;
	puts(ok?"Yes":"No");

	return 0;
}


Measured memory_bytes: 3688
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int tmp1=a+b;
	int tmp2=c+d;
	if(tmp1==tmp2)puts("Balanced");
	if(tmp1>tmp2)puts("Left");
	if(tmp1<tmp2)puts("Right");
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#include <time.h>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

string inp, enc;
map<char, char> m;

//encは各数字の出現回数をエンコードした文字列
//usedは同じ数字2つの組を作ったかどうかのフラグ
bool rec(string enc, bool used)
{
	if (enc == "000000000" && used) return true;

	bool ret = false;
	string next_enc;

	for (int i=0; i<enc.length(); i++)
	{
		if (enc[i] != '0')
		{
			//頭の判定
			if (!used && enc[i] >= '2')
			{
				next_enc = enc;
				next_enc[i] -= 2;
				ret |= rec(next_enc, true);
			}
			//同じの3つ
			if (enc[i] >= '3')
			{
				next_enc = enc;
				next_enc[i] -= 3;
				ret |= rec(next_enc, used);
			}
			//3連続のやつ
			if (i <= 6 && enc[i + 1] >= '1' && enc[i + 2] >= '1')
			{
				next_enc = enc;
				next_enc[i]--;
				next_enc[i + 1]--;
				next_enc[i + 2]--;
				ret |= rec(next_enc, used);
			}
			break;
		}
	}

	return ret;
}

int main()
{
	while (cin >> inp)
	{
		vector<char> vc;	//役を作れる数字を入れる
		string str = inp;

		for (char num='1'; num<='9'; num++)
		{
			bool cont = false;

			str = inp;
			str += num;

			//1から9までの数字の出現回数を表す文字列にエンコード
			for (char c='1'; c<='9'; c++) m[c] = '0';
			for (int i=0; i<str.length(); i++)
			{
				m[str[i]]++;
				if (m[str[i]] > '4')
				{
					cont = true;
					break;
				}
			}

			if (cont) continue;

			enc = "";
			for (char c='1'; c<='9'; c++) enc += m[c];
			//cout << enc << endl;
			
			//再帰関数で役を作れるか判定
			if (rec(enc, false)) vc.pb(num);
		}

		if (vc.size() == 0)
		{
			cout << 0 << endl;
		} else {
			for (int i=0; i<vc.size(); i++)
			{
				if (i == vc.size() - 1)
				{
					cout << vc[i];
				} else {
					cout << vc[i] << " ";
				}
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int sz;
    sz = s.size();
    string ans;
    ans = "yes";
    for(int i=0; i<sz; i++){
        for(int j=i+1; j<sz; j++){
            if(s[i]==s[j]){
                ans = "no";
                //cout << "i=" << i << "j=" << j << endl;
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
import string

N = int(input())
S = input()

result = 0
for i in range(1, N+1):
    S_forward = S[:i]
    S_backward = S[i:]
    is_same = 0
    for j in string.ascii_lowercase:
        if j in S_forward and j in S_backward:
            is_same += 1
    result = max(result, is_same)

print(result)

Measured memory_bytes: 9964
from collections import deque
N = input()
d = [float('inf')] * N
m = [[0] * N for i in range(N)]
Q = deque([])

def bfs(s):
    Q.append(s)
    d[s] = 0

    while(len(Q) != 0):
        u = Q.popleft()
        for v in range(N):
            if (m[u][v] and  d[v] == float('inf')):
                d[v] = d[u] + 1
                Q.append(v)




if __name__ == '__main__':

    for i in range(N):
        v = map(int, raw_input().split())
        for j in v[2:]:
            m[i][j-1] = 1
    
    bfs(0)

    for i in range(N):
        if d[i] == float('inf'):
            d[i] = -1
        print (i+1), d[i]

Measured memory_bytes: 6780
#include<stdio.h>
int m[]={2189,89,1232,866,1796,2603},a,b,c,d,r;char s[99];int main(){for(s[87]=1,s[78]=4,s[69]=3,s[83]=2;~scanf("%s",s);*s<60?printf(r?"%d\n":0,r),a=c=0,b=r=1:(d=s[*s],d?d=d+c&3,a=m[a]>>3*d&7,b=m[b]>>3*d&7:c+=*s-76?1:3,r+=a%3?b%3?(b+6-a)%6<3?2:5:3+!b:a?6:1));}

Measured memory_bytes: 0
# agc014_a.py]
A, B, C = map(int,input().split())
cnt = 0
inf = 10**2
for i in range(inf):
    if A%2==0 and B%2==0 and C%2==0: 
        a = (B+C)//2
        b = (A+C)//2
        c = (B+A)//2
        A = a
        B = b
        C = c
        cnt += 1
    else:
        break
if cnt == inf:
    cnt = -1
print(cnt)

Measured memory_bytes: 3064
/*		Author : Kaustubh Gangwar
		||S||A||M||R||A||T||
*/
#include <bits/stdc++.h>
using namespace std;
#define modo 1000000007
#define ff first
#define ss second 
#define ld long double
#define pb push_back
#define gcd __gcd
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x).begin(),(x).end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
typedef long long  ll;
typedef pair<int,int> pii;

ll bpow(ll a, ll b) {
	a=a; ll res = 1;
    while(b){
        if (b & 1)
        res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	ll test=1;
	//cin>>test;
	while(test--)
	{
	int a[3];
	f(i,0,3) cin>>a[i];
	int k; cin>>k;
	while(k && a[1]<=a[0])
	{
		k--;
		a[1]*=2;
	}
	
	while(k && a[2]<=a[1])
	{
		k--;
		a[2]*=2;
	}
	
	if(a[2]>a[1] && a[1]>a[0])
	cout<<"Yes"<<nl;
	else
	cout<<"No\n";
		
	}
return 0;
}


Measured memory_bytes: 3624
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var c = b.Count(x => x < a[2]);
        Console.WriteLine(Math.Min(c, b.Length - c));
    }
}


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

int main(){
  string s;
  cin >> s;
  int k=s.size();
  int su=0;
  int mo=0;
  int c;
  for (int i=0;i<k;i++){
    c = s[i] - '0';
    su = su + c;
    mo = mo + c*pow(10,k-i-1);
  }
  if (mo%su == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];

    int fmx = 0;
    int fi = 0;
    rep(i,n){
        if (fmx <= a[i]){
            fmx = a[i];
            fi = i;
        } 
    }

    int smx = 0;
    rep(i,n){
        if (smx <= a[i] && fi != i){
            smx = a[i];
        }
    }

    rep(i,n){
        if (i==fi) cout << smx << endl;
        else cout << fmx << endl;
    }
    

    

}





//              g++ -std=c++1z

Measured memory_bytes: 2432
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let b: Vec<usize> = (0..n - 1)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    // b[i] = max(a[i-1], a[i])
    let mut s = b[0] + b[n - 2];
    for i in 1..n - 1 {
        s += min(b[i - 1], b[i]);
    }
    println!("{}", s);
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
const ll mod = 998244353;
const int sz = 25;
#define afdafafafdafaf y1;
int n,m;
int ar[maxn];

char ch[maxn];

ll f[maxn], f2[maxn];
int vis[maxn];
vector<ll> divs, coe;
int main()
{
    scanf("%d", &n);
    scanf("%s", ch);
    for(int i=1;i<=n;i++){
        if(n % i == 0 && (n / i) % 2== 1){
            divs.push_back(i);
        }
    }
    coe = vector<ll>(divs.size() , 0);
    for(int i=divs.size() - 1; i>=0 ;i--){
        coe[i] = divs[i] * 2;
        for(int j=i+1; j<divs.size(); j++){
            if((divs[j] % divs[i] == 0) && ((divs[j] / divs[i]) % 2 == 1)){
                coe[i] = (coe[i] - coe[j] + mod) % mod;
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<n;i++)ar[i] = ch[i] - '0';
    for(int i=0;i<divs.size();i++){
        ll x = divs[i];
        ll mid = 0;
        for(int i=0;i<x;i++){
            mid = (mid * 2 + ar[i]) % mod;
        }
        int flag = 0;
        for(int i=1;i<n/x;i++){
            for(int j=0;j<x;j++){
                int now = ar[j] ^ (i & 1);
                assert(now == 1 || now == 0);
                if(now > ar[j + i * x])flag = -1;
                if(now < ar[j + i * x])flag = 1;
                if(flag != 0)break;
            }
            if(flag != 0)break;
        }
        if(flag >= 0)mid = (mid + 1) % mod;
        mid = mid * coe[i] % mod;
        ans = (ans + mid) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

#define N 10000

#define WHITE 0
#define GRAY 1
#define BLACK 2

static const int INFTY = (1<<20);
int n;

vector<pair<int,int> >adj[N];

void dijkstra(void);

int main(void){
  int i,j,k;
  int u, v, c;

  cin >> n;
  
  for(i = 0;i < n;i++){
    cin >> u >> k;
    
    for(j = 0;j < k;j++){
      cin >> v >> c;
      
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}




void dijkstra(void){
  priority_queue<pair<int,int> >PQ;
  int i,j;
  int u,v;
  int d[N],color[N];
  
  for(i = 0;i < n;i++){
    color[i] = WHITE;
    d[i] = INFTY;
  }

  color[0] = GRAY; 
  d[0] = 0;
  PQ.push(make_pair(0,0));

  while(!PQ.empty()){
    pair<int,int>f = PQ.top();
    PQ.pop();
    
    u = f.second;
    color[u] = BLACK;

    if(d[u] < f.first*(-1)){
      continue;
    }

    for(j = 0;j < adj[u].size();j++){
      v = adj[u][j].first;
      
      if(color[v] == BLACK){
	continue;
      }
      
      if(d[v] > d[u] + adj[u][j].second){
	color[v] = GRAY;
	d[v] = d[u] + adj[u][j].second;
	PQ.push(make_pair(d[v]*(-1),v));
	
      }
    }
    
  }

  for(i = 0;i < n;i++){
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}



Measured memory_bytes: 8088
splitOn :: Char -> String -> [String]
splitOn c s =
  let e = takeWhile (/= c) s
      r = dropWhile (/= c) s
  in
    if r == []
    then [e]
    else e:(splitOn c $ drop 1 r)

swap [] l = l
swap ([x,y]:xs) l
  | x <  y =
      let b = take (x-1) l
          m = drop x $ take (y-1) l
          e = drop y l
      in
        swap xs (b ++ [(l!!(y-1))] ++ m ++ [(l!!(x-1))] ++ e)
  | x == y = l
  | x >  y = swap ([y,x]:xs) l

ans w c = swap c [1..w]

main = do
  w <- getLine
  _ <- getLine
  c <- getContents
  let w' = read w :: Int
      c' = map (map read) $ map (splitOn ',') $ lines c :: [[Int]]
      o  = ans w' c'
  mapM_ print o
  

Measured memory_bytes: 4008