akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    int N;
    long[] A;
    List<int>[] es;

    public void calc()
    {
        N = cin.nextInt();
        A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextLong();
        }
        es = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            es[i] = new List<int>();
        }

        for (int i = 0; i < N - 1; i++)
        {
            int a = cin.nextInt() - 1;
            int b = cin.nextInt() - 1;
            es[a].Add(b);
            es[b].Add(a);
        }

        check = new bool[N];
        win = new bool[N];
        for (int i = 0; i < N; i++)
        {
            if (dfs(i)) Console.Write((i + 1) + " ");
        }
        Console.WriteLine();
    }

    bool[] check;
    bool[] win;

    bool dfs(int now)
    {
        long T = A[now];
        check[now] = true;
        foreach (var next in es[now])
        {
            if (A[now] <= A[next]) continue;
            if (!dfs(next))
            {
                win[now] = true;
                return true;
            }
        }
        return false;
    }
    
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 4312
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll power(ll x, ll y){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod-2)%mod;}
int a[10000001];
void sieve() {
	ll i,j;
	fli(i,2,10000001) {
		if(a[i]==0) {
			a[i]=i;
			for(j=i*i;j<=10000000;j+=i) {
				if(a[j]==0) a[j]=i;
			}
		}
	}
}
void comp() {
	ll i,j,k,n,m;
	sieve();
	cin>>n;
	int arr[n+1]={0};
	arr[1]=1;
	ll ans=1;
	fli(i,2,n+1) {
		vector<ll>v1;
		ll temp=i;
		ll spf=a[temp];
		ll count1=1;
		while(temp>1) {
			temp/=spf;
			count1++;
			if(spf!=a[temp]) {
				v1.pb(count1);
				count1=1;
				spf=a[temp];
			}
		}
		ll ans1=1;
		fl(j,v1.size()) ans1*=v1[j];
		ans1*=i;
		ans+=ans1;
	}
	cout<<ans<<"\n";

}
int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 81768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int N; cin >> N;
    vl d(N); rep(i,N) cin >> d[i];
    ll ans = 0LL;
    rep(i,N) repk(j,i+1,N){
        ans += d[i] * d[j];
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    char a;
    cin >> a;
    if (a >= 'a' && a <= 'z') {
        cout << 'a' << endl;
    }
    else {
        cout << 'A' << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K,X,Y;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>X>>Y;
	if(K%2==0 && (abs(X)+abs(Y))%2) {
		cout<<"-1"<<endl;
		return;
	}
	vector<pair<int,int>> V;
	if(K%2&&(abs(X)+abs(Y))%2) {
		V.push_back({X,Y});
		x=min(K,abs(X));
		if(X>0) X-=x;
		else X+=x;
		int lef=K-x;
		if(Y>0) Y-=lef;
		else Y+=lef;
	}
	
	while(abs(X)+abs(Y)>=2*K) {
		FOR(j,1+(K%2)) {
			V.push_back({X,Y});
			int lef=K;
			if(X>0) {
				i=min(X,lef);
				X-=i;
				lef-=i;
			}
			else if(X<0) {
				i=min(abs(X),lef);
				X+=i;
				lef-=i;
			}
			if(Y>0) {
				i=min(abs(Y),lef);
				Y-=i;
				lef-=i;
			}
			else if(Y<0) {
				i=min(abs(Y),lef);
				Y+=i;
				lef-=i;
			}
		}
	}
	
	if(abs(X)+abs(Y)==K) {
		V.push_back({X,Y});
	}
	else if(X||Y) {
		V.push_back({X,Y});
		if(abs(X)>abs(Y)) {
			x=(abs(X)+abs(Y))/2;
			y=K-abs(x);
			
			if(X>0) X=x;
			else X=-x;
			if(Y>=0) Y=-y;
			else Y=y;
		}
		else {
			y=(abs(X)+abs(Y))/2;
			x=K-abs(y);
			
			if(Y>0) Y=y;
			else Y=-y;
			if(X>=0) X=-x;
			else X=x;
		}
		V.push_back({X,Y});
	}
	
	reverse(ALL(V));
	cout<<V.size()<<endl;
	FORR(v,V) cout<<v.first<<" "<<v.second<<endl;
}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3952
N,M,X,Y = map(int, input().split())
x =list(map(int, input().split()))
y =list(map(int, input().split()))

l = range(X+1,Y)

x.sort()
y.sort()

maxx = x[N-1]
miny = y[0]

def decs():
    for i in l:
        if maxx < i and i <= miny:
            return True
        
    return False

            
if decs():
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,m;
  cin>>n>>m;
  char c[n];
  int d[n+1];
  d[0]=d[1]=0;
  for(int i=1;i<=n;i++){
    cin>>c[i-1];
    if(i!=1){
      int j=0;
      if(c[i-2]=='A'&&c[i-1]=='C'){
        j++;
      }
      d[i]=d[i-1]+j;
    }
  }
  for(int i=0;i<m;i++){
    int r,s;
    cin>>r>>s;
    cout<<d[s]-d[r]<<endl;
  }
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	int mi; cin >> mi;
	int ma = mi;
	for (int i = 1; i < N; i++) {
		int v; cin >> v;
		mi = min(mi, v);
		ma = max(ma, v);
	}
	cout << ma-mi << '\n';

	return 0;
}


Measured memory_bytes: 256
#abc of ABC

#入力
S = list(input())

#計算
count = 0
if S.count('a'):
	count += 1
if S.count('b'):
	count += 1
if S.count('c'):
	count += 1

#出力
if count == 3:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 2940
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        n: usize,
        m: usize,
        aisles: [(usize, usize); m],
    }

    let mut map : HashMap<usize, Vec<usize>> = HashMap::new();
    let mut guideposts = vec![None ; n+1];

    for aisle in &aisles {
        if let Some(rooms) = map.get_mut(&aisle.0) {
            rooms.push(aisle.1);
        } else {
            map.insert(aisle.0 , vec![aisle.1]);
        }
        if let Some(rooms) = map.get_mut(&aisle.1) {
            rooms.push(aisle.0);
        } else {
            map.insert(aisle.1 , vec![aisle.0]);
        }
    }

    let mut que = VecDeque::new();
    que.push_back(1);

    while !que.is_empty() {
        let now = que.pop_front().unwrap();
        if let Some(rooms) = map.get(&now) {
            for room in rooms {
                if guideposts[*room] == None {
                    guideposts[*room] = Some(now);
                    que.push_back(*room);
                }
            }
        }
    }

    if guideposts.iter().skip(2).all(|x| *x != None) {
        println!("Yes");
        for guidepost in guideposts.iter().skip(2) {
            if let Some(post) = guidepost {
                println!("{}", post);
            }
        }
    } else {
        println!("No");
    }
}


Measured memory_bytes: 19824
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    cin >> n;
    vector<int> B(n);
    for (int i = 0; i < n; i++)
        cin >> B[i];
    if (lexicographical_compare(begin(A), end(A), begin(B), end(B)))
        cout << "1" << endl;
    else cout << "0" << endl;
}


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

s=sum(A)
if s%(N*(N+1)//2)!=0:
    print("NO")
    exit()
else:
    count=s//(N*(N+1)//2)

data=[0 for i in range(0,N)]
for i in range(N):
    if (count-(A[i]-A[i-1]))%N!=0:
        print("NO")
        exit()
    else:
        data[i]=(count-(A[i]-A[i-1]))//N
        if data[i]<0:
            print("NO")
            exit()

check=0
for i in range(N):
    check+=data[i]*((N-i)%N+1)

if check==A[0]:
    print("YES")
else:
    print("NO")

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

using namespace std;
using ll = long long int;


int main(){
    ll a;
    cin >> a;

    ll minNum = a;

    for(ll i=1; i*i<= a; i++){
        if(a % i == 0){
              ll f = a / i;
              minNum = min(minNum, (f + i - 2));
        }
    }

    cout << minNum << endl;

}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <list>
#include <vector>
#include <map>
#include <time.h>
#include <cstdlib>
#include <iomanip>
#include <array>

#pragma warning(disable:4996)

using namespace std;

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



int main(void) {
	int n, a, b,sum=0,l_sum=1;
	cin >> n >> a >> b;
	string str;
	cin >> str;

	FOR(i, 0, n) {
		switch (str[i]) {
		case 'c':
			cout << "No" << endl;
			break;
		case 'a':
			if (sum < a + b) {
				cout << "Yes" << endl;
				sum++;
			}
			else
				cout << "No" << endl;
			break;
		case 'b':
			if (sum < a + b && l_sum<=b) {
				cout << "Yes" << endl;
				sum++;
				l_sum++;
			}
			else
				cout << "No" << endl;
			break;


		}
	}

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
bool vis[10001][100][2];
int dp[10001][100][2];
string k;
int d;
int dfs(int i, int small, int rem){
	if(i>sz(k)){
		if(rem==0) return 1;
		else return 0;
	}
	if(vis[i][rem][small]) return dp[i][rem][small];
	vis[i][rem][small] = 1;
	int ans = 0;
	if(small==0){
		rep(j,0,k[i-1]-'0') ans = (ans+dfs(i+1,1,(rem+j)%d))%M;
		ans = (ans+dfs(i+1,0,(rem+k[i-1]-'0')%d))%M;
	}
	else{
		rep(j,0,10) ans = (ans+dfs(i+1,1,(rem+j)%d))%M;
	}
	dp[i][rem][small] = ans;
	return ans;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		cin >> k >> d;
		cout<<(M+dfs(1,0,0)-1)%M;
	}
}

Measured memory_bytes: 18688
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc140_a.cpp
 * time   : Sat May  2 01:51:06 2020
 * quest  : A - Password
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cout << n * n * n << "\n";
  return 0;
}


Measured memory_bytes: 256
use std::io::stdin;

fn main () {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let s = s.trim();

    let mut t = String::new();
    stdin().read_line(&mut t).unwrap();
    let t = t.trim();

    println!("{}", s.chars().zip(t.chars()).filter(|&(a, b)| a == b).count());
}


Measured memory_bytes: 4352
// 3_abc137_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<char>> s(n, vector<char>(10));
    vector<string> s2(n);
    rep(i, n){
        rep(j, 10){
            cin >> s[i][j];
        }
        sort(s[i].begin(), s[i].end());
        string tmp(s[i].begin(), s[i].end());
        s2[i] = tmp;
    }
    sort(s2.begin(), s2.end());
    ll ans = 0;
    string cmp = s2[0];
    ll cnt = 1;
    for(int i = 1; i < n; i++){
        if(cmp == s2[i]) cnt++;
        else{
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
            cmp = s2[i];
        }
    }
    ans += cnt * (cnt - 1) / 2;
    cout << ans << endl;

    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 5;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	int n, k, a, mn = INF, mx = -1, ans = 0;
	scanf("%d%d", &n, &k);
	REP(i, 0, n){
		scanf("%d", &a);
		mn = min(mn, a);
		int d = a - mn;
		if (d > mx){
			mx = d;
			ans = 0;
		}
		if (mx == d){
			ans++;
		}
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    int ans = 1;
    while(1){
        int cnt = 0;
        for(int i = 1 ; i <= ans ; ++i){
            if(ans % i == 0){
                ++cnt;
            }
        }
        if(cnt == n){
            break;
        }
        ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;

queue<string> split(string delim,string str){
	queue<string> res;
	str += delim;
	for(int i=0;i<str.size();i++){
		for(int j=1;i+j<=str.size();j++){
			if(str.substr(i,j).find(delim) != string::npos){
				//cout << str.substr(i,j) << endl;
				if(str.substr(i,j-1).size() > 0 ) res.push(str.substr(i,j-1));
				i+=j-1;
				break;
			}
		}
	}

	return res;
}

int main(){
	string str;

	while(getline(cin,str)){
		stack<double> stk;
		queue<string> res = split(" ",str);
	
		while(!res.empty()){
			string now = res.front();
			res.pop();


			if(now == "+"){
				double a = stk.top();
				stk.pop();
				double b = stk.top();
				stk.pop();

				stk.push(b+a);
			}
			else if(now == "/"){
				double a = stk.top();
				stk.pop();
				double b = stk.top();
				stk.pop();

				stk.push(b/a);
			}
			else if(now == "*"){
				double a = stk.top();
				stk.pop();
				double b = stk.top();
				stk.pop();

				stk.push(b*a);
			}
			else if(now == "-"){
				double a = stk.top();
				stk.pop();
				double b = stk.top();
				stk.pop();

				stk.push(b-a);
			}

			else{
				double num;
				sscanf(now.c_str(),"%lf",&num);
				stk.push(num);
			}
		}

		printf("%.6f\n",stk.top());
	}

}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll N;
ll bit[1000010];

void bit_init(vector<ll> v){
	if(!v.empty()){
		N=v.size();
		for(ll x=1; x <= N; ++x) bit[x] = v[x];
		for(ll x=1; x < N; ++x) bit[x+(x&-x)] += bit[x];
	}
}
void bit_add(ll a, ll w){
		for(ll x=a; x <= N; x+=x&-x)bit[x]+=w;
}
ll bit_sum(ll a){
	ll ret=0;
	for(ll x=a;x>0;x-=x&-x) ret+=bit[x];
	return ret;
}

int main(){
	ll n,m;cin>>n>>m;
	vector<pl> x(m);
	ll a,b;
	rep(i,m){
		cin>>a>>b;
		x[i]=mp(a,b);
	}
	sort(all(x));
	vector<ll> v(n+1);
	rep(i,m){
	  v[x[i].se-1]++;
	}

	bit_init(v);

	rep(i,m){
		if(bit_sum(x[i].se-1)-bit_sum(x[i].fi-1)>1){
			bit_add(x[i].se-1,-1);
		}
	}

	cout<<bit_sum(n)<<endl;

  return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int main(){
    int n;
    for(int X=0;cin>>n,n;X++){
        int fld[10][10];
        int y=0,x=-1,pos=1;
        for(int i=0;i<n;i++){
            if(i&1)y++;
            else x++;
            int der=(i&1)?1:-1;
            while(y<n&&x<n&&y>=0&&x>=0){
                fld[y][x]=pos;
                pos++;
                y+=der;
                x+=der*-1;
            }
        }

        for(int i=n;i<n*2-1;i++){
            if(i&1){
                y+=2;
                x--;
            }
            else{
                x+=2;
                y--;
            }
            int der=i&1?1:-1;
            while(y<n&&x<n&&y>=0&&x>=0){
                fld[y][x]=pos;
                pos++;
                y+=der;
                x+=der*-1;
            }
        }
        cout<<"Case "<<X+1<<":"<<endl;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cout<<setw(3)<<fld[i][j];
            }
            cout<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1176
a = []
for _ in range(3):
    a.append(list(map(int,input().split())))
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
card = [[False,False,False],[False,False,False],[False,False,False]]
for i in range(3):
    for j in range(3):
        for x in b:
            if a[i][j] == x:
                card[i][j] = True
                break
l = [["00","01","02"],["10","11","12"],["20","21","22"],["00","10","20"],["01","11","21"],["02","12","22"],["00","11","22"],["02","11","20"]]
ans = False
for p in l:
    tmp = 0
    for q in p:
        i = int(q[0])
        j = int(q[1])
        if card[i][j]:
            tmp += 1
    if tmp == 3:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 100005
int N, K;
int A[MXN];
int c01, c10;

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

    cin>>N>>K;
    string str;
    cin>>str;
    FOR(i,1,N)
    {
        A[i] = (str[i-1]=='R');
    }

    int ans = 0;
    FOR(i,1,N-1)
    {
        if( A[i]!=A[i+1] )
        {
            if( A[i]==0 && A[i+1]==1 )c01++;
            else c10++;
        }
        else ans++;
    }

    int tnd = min(c01, c10);
    int tns = max(c01,c10)-min(c01,c10);
    int ad = ((K>=tnd) ? min(K,tnd+tns)+tnd : K*2);

    cout<<ans+ad<<'\n';

    return 0;
}


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

int main()
{
	int n, x, ans = 0;
	cin >> n;
	for (int a = 1; a <= n; ++a) {
		cin >> x;
		if (x % 2 && a % 2) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3596
s = list(input())
t = list(input())

lens = len(s)
lent = len(t)
if lens < lent:
  print("UNRESTORABLE")
else:
  for i in reversed(range(lens - lent + 1)):
    isallmatch = True
    for j in range(lent):
      if not s[i + j] in [t[j], "?"]:
        isallmatch = False
    if isallmatch == True:
      for j in range(lent):
        s[i + j] = t[j]
      ss = "".join(s).replace("?", "a")
      print(ss)
      exit()
  print("UNRESTORABLE")

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

#define endl '\n'

using namespace std;

long long x;
void read()
{
    cin >> x;
}

void solve()
{
    cout << (x / 500) * 1000 + (x % 500) / 5 * 5 << endl;
}

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

    read();
    solve();
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var sp = input.split("\n");
for( var i = 0; i < sp.length; i++ ) {
  var s = sp[i].split(" ");
  if( s[1] === "?" ) break;
  console.log( Math.floor( eval(sp[i]) ) );
}

Measured memory_bytes: 15432
#include <iostream>
#include <ios>
#include <list>
#include <iomanip>
#include <math.h>
using namespace std;
#define FOR(it) for(Points::iterator it = list.begin(); it != list.end(); ++it)
struct Point
{
	Point(double _x, double _y) :x(_x), y(_y){}
	double x;
	double y;
};
typedef list<Point> Points;

void CreatePoints(const Point& p1, const Point& p2, Points& ps)
{
	double x1, x2, x3, y1, y2, y3;
	x1 = p1.x + (p2.x - p1.x) / 3;
	x3 = p1.x + 2 * (p2.x - p1.x) / 3;
	y1 = p1.y + (p2.y - p1.y) / 3;
	y3 = p1.y + 2 * (p2.y - p1.y) / 3;
	double r3 = sqrt(3);
	x2 = ((x3 - x1) - r3 * (y3 - y1))/2 + x1;
	y2 = (r3 * (x3 - x1) + (y3 - y1))/2 + y1;
	ps.push_back(Point(x1, y1));
	ps.push_back(Point(x2, y2));
	ps.push_back(Point(x3, y3));
}

void KochCurve(int n, Points& list)
{
	if (0 == n) return;
	Points::iterator it, preit;
	for (it = list.begin(); it != list.end(); ++it){
		if (it == list.begin()){
			preit = it;
			continue;
		}

		Points addPs;
		CreatePoints(*preit, *it, addPs);
		list.insert(it, addPs.begin(), addPs.end());
		preit = it;
	}
	
	return KochCurve(n - 1, list);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	Points list;
	list.push_back(Point(0., 0.));
	list.push_back(Point(100., 0.));
	KochCurve(n, list);
	FOR(it)
		cout << fixed << std::setprecision(5) << it->x << " " << it->y << "\n";

	return 0;
}

Measured memory_bytes: 1480
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;

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

vector<int> pos[10];
bool exist[10] = {};
int main() {
    cin >> N;
    string s;
    cin >> s;
    int count = 0;
    rep(i, N){
        pos[s[i] - '0'].push_back(i);
        exist[s[i] - '0'] = true;
    }

    stack<int> st;
    rep(i, 10){
        if(!exist[i]) continue;
        st.push(pos[i][0]);
        rep(j, 10){
            if(!exist[j]) continue;
            rep(k, pos[j].size()){
                if(st.top() < pos[j][k]){
                    st.push(pos[j][k]);
                    rep(l, 10){
                        if(!exist[l]) continue;
                        rep(n, pos[l].size()){
                            if(st.top() < pos[l][n]){
                                count++;
                                break;
                            }
                        }
                    }
                    st.pop();
                    break;
                }
            }
        }
        st.pop();
    }
    cout << count;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

    static int mod = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int a = -1, b = -1;
        for (int i = 0; i <= X; i++) {
            int rx = X - i;
            if(rx % 2 != 0) continue;
            int j = rx / 2;
            if(i*2 + j == Y){
                a = i;
                b = j;
                break;
            }
        }
        long ans = 0L;
        if(0 <= a){
            Combination comb = new Combination(a+b, mod);
            ans = comb.comb(a+b, a);
        }
        System.out.println(ans);
        sc.close();

    }

}

class Combination {

    /** factorial:階乗 */
    private long fac[];
    /** inverse:逆元（ここでは、fac[i]をMOD-2乗したものをMODで割った余り） */
    private long inv[];
    /** 除数 */
    private int mod;

    /**
     * コンストラクタ
     * @param size 組み合わせの対象となる個数
     * @param mod 除数
     */
    public Combination(int size, int mod){
        this.fac = new long[size +1];
        this.inv = new long[size +1];
        this.mod = mod;

        this.fac[0] = 1;
        this.inv[0] = 1;

        for(int i = 1; i <= size; i++){
            fac[i] = (fac[i -1] * i) %mod;
            inv[i] = modPow(fac[i], (int)mod -2) %mod;
        }
    }

    /**
     * n個の中からr個選ぶ組み合わせの数（nCr）をmodで割った余りを算出する
     * @param n 元の集合の要素数
     * @param r 組み合わせる要素数
     * @return nCr % mod
     */
    public long comb(int n, int r){
        return fac[n] * inv[r] %mod * inv[n - r] %mod;
    }

    /**
     * base^exp をmodで割った余りを算出する
     * @param base 基数
     * @param exp 指数
     * @return base^exp % mod
     */
    private long modPow(long base, int exp) {
        long ret = 1;
        while(exp > 0){
            if((exp & 1) == 1){
                ret = ret * base %mod;
            }
            base = base * base %mod;
            exp >>= 1;
        }
        return ret;
    }

}


Measured memory_bytes: 46052
#include <stdio.h>

int simulate(char *s, char *t, char *d, int n, int q, int b){
    int i;
    for(i = 0; i < q; ++i) {
        if(s[b] == t[i]) {
            b += ((d[i] == 'R') ? 1 : -1);
            if(b < 0)   { return -1; }
            if(b > n-1) { return  1; }
        }
    }
    return 0;
}

int main()
{
    int n, q, i, a, b, b_prev, c, l, r;
    char s[200000], t[200000], d[200000];
    scanf("%d %d", &n, &q);
    scanf("%s", s);
    for(i = 0; i < q; ++i) {
        scanf("\n %c %c", &t[i], &d[i]);
    }

    a = 0; b_prev = -1; c = n-1;
    while(1) {
        b = (a + c + 1)/2;
        //printf("a:%d b:%d c:%d\n", a, b, c);
        if(b == b_prev) { break; }
        if(simulate(s, t, d, n, q, b) < 0) { a = b; }
        else { c = b; }
        b_prev = b;
        //printf("a:%d c:%d\n", a, c);
    }
    l = a;
    //printf("\n");
    a = 0; b_prev = -1; c = n-1;
    while(1) {
        b = (a + c + 1)/2;
        //printf("a:%d b:%d c:%d\n", a, b, c);
        if(b == b_prev) { break; }
        if(simulate(s, t, d,n, q, b) > 0) { c = b; }
        else { a = b; }
        b_prev = b;
        //printf("a:%d c:%d\n", a, c);
    }
    r = a;
    //printf("\n");
    //printf("r: %d l: %d\n", r, l);
    printf("%d\n", r - l);
    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll A[2000];
int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = INF;
	for (int i = 0; i < N; i++) {
		ll l = -1, r = INF;
		while (r - l > 1) {
			ll m = (l + r) / 2;
			int cnt = 0;
			int len = 0, a = 0, b = 0;
			for (int j = 0; j < N; j++) {
				if (A[j] < A[i]) {
					cnt += min(max(len - K + 1, 0), a);
					len = a = b = 0;
				}
				else {
					len++;
					if (A[j] <= A[i] + m) a++;
					else b++;
				}
			}
			cnt += min(max(len - K + 1, 0), a);
			if (cnt >= Q) r = m;
			else l = m;
		}
		ans = min(ans, r);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
class MCM
  def initialize(n)
    @a = Array.new(n+1)
    @mat = {}
  end
  def input(i, r, c)
    @a[i], @a[i+1] = r, c
  end
  def minMCM(s, e)
    key = "#{s} #{e}"
    unless @mat[key]
      min = 1.0 / 0.0
      s.upto(e-1){|m|
        val = minMCM(s, m) + minMCM(m+1, e) + @a[s] * @a[m+1] * @a[e+1]
        min = val if val < min
      }
      @mat[key] = min
    end
    return @mat[key]
  end
  def a2mat
    n = @a.size-1
    0.upto(n){|i|
      key = "#{i} #{i}"
      @mat[key] = 0
    }
  end
end

n = gets.to_i
mcm = MCM.new(n)
n.times{|i|
  r, c = gets.split.map(&:to_i)
  mcm.input(i, r, c)
}
mcm.a2mat
puts mcm.minMCM(0, n-1)

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

    using namespace std;
     
    int main() {
      
      int A, B, C; 
      cin >> A >> B >> C;
      
      if (A * C <= B){
        cout << C << endl;
      }
      else{
        cout << B / A << endl;
      }
      
      
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>

#define R register
#define Maxn 100010

using namespace std;

char s[Maxn];

int main() {
	
	scanf("%s",s+1);
	
	R int n = strlen(s+1);
	
	if(s[1] != 'A')	puts("WA");
	else {
		R int a = 0;
		for(R int i=3; i<n; i++)
			if(s[i] == 'C')
				a ++;
		if(a != 1)	return puts("WA") , 0;
		if(s[2] == 'C' || s[n] == 'C')	return puts("WA") , 0;
		R bool flag = true;
		for(R int i=1; i<=n; i++) {
			if(i == 3)	continue;
			if(s[i] != 'A' && s[i] != 'C' && !(s[i] >= 'a' && s[i] <= 'z')) {
				flag = false;
				break;
			}
		}
		if(!flag)	puts("WA");
		else	puts("AC");
	}
	
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,l,n;
    map<string , int >mp;
    map<string , int > :: iterator it;
    int mx=-1244244;
    cin>>n;
    string s;
    for(i=1;i<=n;i++)
    {
        cin>>s;
        mp[s]++;
        if(mp[s]>mx)
            mx=mp[s];
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        if(it->second==mx)
            cout<<it->first<<endl;
    }

}


Measured memory_bytes: 25216
from heapq import heappop, heappush

N = int(input())
costs = {}
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    costs.setdefault(a, {})
    costs[a][b] = c
    costs.setdefault(b, {})
    costs[b][a] = c

Q, K = map(int, input().split())

d = [float('inf')] * (N + 1)
d[K] = 0
#prev = [None] * (N + 1)
q = [(0, K)]
while q:
    _, u = heappop(q)
    for v in costs[u]:
        alt = d[u] + costs[u][v]
        if d[v] > alt:
            d[v] = alt
            #prev[v] = u
            heappush(q, (alt, v))

result = []
for _ in range(Q):
    x, y = map(int, input().split())
    result.append(d[x] + d[y])
print('\n'.join(str(v) for v in result))


Measured memory_bytes: 68800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
ll n,m;
vi parent;
vi depth;
ll root(ll i){
    if(parent[i]==i)return i;
    return root(parent[i]);
}
void heigou(ll x,ll y){
  x=root(x);y=root(y);
  if(x==y)return;
  if(depth[x]<depth[y])parent[x]=y;
  else if(depth[x]>depth[y])parent[y]=x;
  else{parent[y]=x;depth[x]++;}
}
int main(){
    cin>>n>>m;
  parent=vi(n);
  depth=vi(n);
    vi same(n,1);
    rep(i,n)parent[i]=i;
    vector<P> v(m);
    vi ans(m);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        v[m-i-1]=P(a,b);
    }
    rep(i,m){
        ll a=v[i].first,b=v[i].second;
        if(root(a)==root(b))continue;
        ans[i]=same[root(a)]*same[root(b)];
        same[root(a)]=same[root(a)]+same[root(b)];
        same[root(b)]=same[root(a)];
        heigou(a,b);
    }
  REP(i,1,m)ans[i]+=ans[i-1];
    REP(i,1,m)cout<<n*(n-1)/2-ans[m-i-1]<<endl;
  cout<<n*(n-1)/2<<endl;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  int n;
  cin >> n;
  if(n == 1) cout << "Hello World" <<endl;
  else{
    int a, b;
    cin >> a >> b;
    cout << a+b <<endl;
  }
}

Measured memory_bytes: 256
import sys

n = int(input())
a = input().split()
Alist = []
for I in a :
    Alist += [int(I)]

for i in Alist :
    if i%2 == 0 :
        if i%3 != 0 and i%5 != 0: 
            print('DENIED')
            sys.exit()
print('APPROVED')


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,k;
    cin >> n >> k;
    
    ll right = 0,left = 0;
    ll right_num = n,left_num = 0;
    ll answer = 0;
    REP(i,k){
        right = (right + right_num) % MOD;
        right_num--;
        left  = (left + left_num) % MOD;
        left_num++;
    }

    REP(i,n+2-k){
        answer = (answer + right) % MOD;
        answer = (answer - left) % MOD;
        if(answer < 0)answer += MOD;
        right = (right + right_num) % MOD;
        right_num--;
        left  = (left + left_num) % MOD;
        left_num++;
        answer = (answer + 1) % MOD;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

void chmax(string &a, string b) {
    if (a == "-") a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

long long num[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; ++i) cin >> A[i];

    for (int i = 0; i < 11000; ++i) dp[i] = "-";
    dp[0] = "";
    for (int i = 0; i <= N; ++i) {
        //cout << i << ": " << dp[i] << endl;
        if (dp[i] == "-") continue;
        for (auto a : A) {
            string b = dp[i] + (char)('0' + a);
            chmax(dp[i+num[a-1]], b);
        }
    }
    cout << dp[N] << endl;
}



















Measured memory_bytes: 45056
# ABC162D - RGB Triplets

def main():
    n=int(input())
    s=input()
    ans=0
    d=[[0]*n for _ in range(3)]
    m=[[0]*n for _ in range(3)]
    l=[[0,2,1],[2,1,0],[1,0,2]]

    for i in range(n):
        d[ord(s[i])%3][i]=1
        m[ord(s[i])%3][i]=1

    for j in range(3):
        for i in range(n-1,0,-1):
            m[j][i-1]+=m[j][i]

    for i in range(n-2):
        for j in range(i+1,n-1):
            if s[i]==s[j]:
                continue
            ans+=m[l[ord(s[i])%3][ord(s[j])%3]][j+1]
            if j*2-i<n:
                ans-=d[l[ord(s[i])%3][ord(s[j])%3]][j*2-i]

    print(ans)
        
main()

Measured memory_bytes: 68756
N=int(input())
C=[];S=[];F=[]
for i in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c);S.append(s);F.append(f)
for i in range(N-1):
    tim=0
    for j in range(i,N-1):
        if(tim<=S[j]):
            tim=S[j]+C[j]
        elif(tim%F[j]==0):
            tim+=C[j]
        elif(tim%F[j]!=0):
            tim+=C[j]+(F[j]-(tim%F[j]))
    print(tim)
print(0)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a, b, c;
  	cin >> a >> b >> c;
  	int count = 0;
  	
 	if(a==b) count++;
	if(b==c) count++;
	if(c==a) count++;

  	if(count==1)  cout << "Yes" << endl;
    else cout << "No" << endl;
	return;
}

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


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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int kotae=INT_MAX;
  for(int i=0;i<n;i++){
    int count=0;
    while(a[i]%2==0){
      count++;
      a[i]/=2;
    }
    kotae=min(kotae,count);
  }
  cout<<kotae<<endl;
  return 0;
}

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

int findSum(int n){
  int sum = 0;
  while (n > 0){
    sum += n%10;
    n/=10;
  }
  return sum;
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int total = 0;
  rep(i,n+1){
    int sum = findSum(i);
    if( sum >= a && sum <= b){
      total += i;
    }
  }
  cout << total <<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int N = Integer.parseInt(br.readLine());
			String input[] = new String[N];
			input = br.readLine().split("\\s+");

			int S[] = new int[N];
			for(int i = 0; i < input.length; i++){
				S[i] = Integer.parseInt(input[i]);
			}

			int Q = Integer.parseInt(br.readLine());
			String inputQ[] = new String[Q];
			inputQ = br.readLine().split("\\s+");

			int T[] = new int[Q];
			for(int i = 0; i < inputQ.length; i++){
				T[i] = Integer.parseInt(inputQ[i]);
			}

			Arrays.sort(T);

			int answer = 0;
			int left = 0;
			int right = 0;
			int middle = 0;

			for(int i = 0; i < T.length; i++){
				right = S.length-1;
				middle = (left+right)/2;

				while(left <= right){
				    
					if(S[middle] == T[i]){
						answer++;
						left = middle;
						break;
					}
					else if(S[middle] > T[i]){
						right = middle-1;
					}
					else{
						left = middle+1;
					}
					
					middle = (left+right)/2;
				}
			}

			System.out.println(answer);

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}




Measured memory_bytes: 55596
using System;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static void Main(string[] args) {
        int[] A;
        InputArray(out A);
        if(A[0] + A[1] + A[2] >= 22){
            Console.WriteLine("bust");
        }else{
            Console.WriteLine("win");
        }
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
}

Measured memory_bytes: 13268