akhauriyash/Code-Regression huggingface dataset:
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n;in(n);
  vector<ll> A(n);
  loop(i,0,n) in(A[i]);
  ll min_ = 100000000000000000;
  {
    /* /\/\ */
    ll sum = 0;
    ll op = 0;
    loop(i,0,n) {
      ll a = A[i];
      sum += a;
      if (i%2==0 and sum >= 0) op += sum+1,sum=-1;
      else if (i%2==1 and sum <= 0) op += -(sum-1),sum=1;
    }
    min_ = min(min_, op);
  }
  {
    /* \/\/ */
    ll sum = 0;
    ll op = 0;
    loop(i,0,n) {
      ll a = A[i];
      sum += a;
      if (i%2==1 and sum >= 0) op += sum+1,sum=-1;
      else if (i%2==0 and sum <= 0) op += -(sum-1),sum=1;
    }
    min_ = min(min_, op);
  }
  print(min_);
  return 0;
}


Measured memory_bytes: 4024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll n, a, b;
	cin >> n >> a >> b;

	if (abs(a - b) % 2LL == 0) {
		cout << abs(a - b) / 2LL << endl;
		return 0;
	}

	ll dist = min(a + b - 2LL, n * 2LL - a - b);
	cout << (dist + 1LL) / 2LL << endl;

	return 0;
}

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

	solve();

	return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    vector<int64_t> x(n);
    for (auto&& xx : x) {
        cin >> xx;
    }

    int64_t l, q;
    cin >> l >> q;
    vector<pair<int64_t, int64_t>> ab(q);
    for (auto&& t : ab) {
        cin >> t.first >> t.second;
        --t.first;
        --t.second;
        if (t.first > t.second) {
            swap(t.first, t.second);
        }
    }

    constexpr auto D = 20L;

    vector<vector<int64_t>> next(D, vector<int64_t>(n + 1, n));
    int64_t j = 1;
    for (auto i : irange(0L, n - 1)) {
        while (j + 1 < n && x[j + 1] - x[i] <= l) {
            ++j;
        }

        next[0][i] = j;
    }

    for (auto d : irange(1L, D)) {
        for (auto i : irange(0L, n - 1)) {
            next[d][i] = next[d - 1][next[d - 1][i]];
        }
    }

    for (const auto& t : ab) {
        int64_t ans = 0;
        int64_t i = t.first;

        for (auto d : irange(0L, D) | reversed) {
            if (next[d][i] <= t.second) {
                i = next[d][i];
                ans += (1L << d);
            }
        }

        if (i < t.second) {
            ++ans;
        }

        cout << ans << "\n";
    }
}

Measured memory_bytes: 19072
import itertools

n, m = map(int, input().split())
g = [[0]*n for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a][b] = 1
    g[b][a] = 1

a = list(itertools.permutations(range(n)))
ans = 0
for i in a:
    if i[0] != 0:
        break
    for j in range(n-1):
        if g[i[j]][i[j+1]] == 0:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 13868
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>

using namespace std;
int main(){

int n,m;
cin >>n>>m;
vector<pair <long long ,int> > AB(n);
for(int i=0;i<n;i++){
  cin>>AB[i].first>>AB[i].second;
}
sort(AB.begin(),AB.end());

long long sum=0;
int num=0;
for(int i=0;i<n;i++){
  if(num+AB[i].second>=m){
    sum+=AB[i].first*(m-num);
    cout<<sum<<endl;
    return 0;
  }
  else{
  sum+=AB[i].first*AB[i].second;
  num+=AB[i].second;
}

}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxN 1000000
using namespace std;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	long long x, k, d, ans;
	cin >> x >> k >> d;

	x = abs(x);
	if (d >= x) {
		if (k & 1)
			ans = d - x;
		else
			ans = x;
	}
	else {
		if (x / d >= k)
			ans = x - d * k;
		else {
			k = k - x / d;
			x = x - d * (x / d);
			if (d >= x) {
				if (k & 1)
					ans = d - x;
				else
					ans = x;
			}

		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 3608
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int main() {
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    P(0);
    return 0;
  }
  vi v;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(all(v));
  printf("%lld\n",v[0] * 1LL * v[1]);
  return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  bool ans = true;
  if(S.size()+1 == T.size()){
    for(int i = 0; i < S.size(); i++){
      if(S[i] != T[i]){
        ans = false;
        break;
      }
    }
  }
  else
    ans = false;
  
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
  
}

Measured memory_bytes: 3632
N = int(input())
S = [int(input()) for _ in range(N)]

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

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}
func parseInt(s string) (n int) {
	n, _ = strconv.Atoi(s)
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n := sc.Text()
	Runes := []rune(n)
	ans := 0
	for _, v := range Runes {
		ans += parseInt(string(v))
	}

	if parseInt(n)%ans == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
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 (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int dp[500010];

int main(){
	int n;
	cin >> n;
	vi h(n);
	rep(i,n) cin >> h[i];
	rep(i,500010) dp[i] = INF;
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		if(i >= 1) dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		if(i >= 2) dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 2560
use std::collections::HashSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// fn main() {
//     input! {
//         S: chars,
//         T: chars,
//         n: i32,
//         m: i32,
//         U: chars
//     }
//     if S == U {
//         println!("{} {}", n-1, m);
//     } else {
//         println!("{} {}", n, m-1);
//     }
// }

/*
fn main() {
    input! {
        S: chars
    }
    let L = S.len();
    for i in 0..L {
        print!("x");
    }
    println!();
}*/

fn main() {
    input! {
        N: usize,
        A: [i64; N],
    }
    let mut H = HashSet::new();
    for a in &A {
        H.insert(a);
    }
    if H.len() == A.len() {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 15608
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    ll N;
    cin >> N;
    string ans;
    do {
        N -= 1;
        if (N < 26) {
            ans = char('a' + N) + ans;
            break;
        }
        ans = char('a' + N % 26) + ans;
    } while (N /= 26);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3080
n, a = map(int, input().split())
l = []
for i in map(int, input().split()):
	l.append(i - a)
l.sort()
pl = sorted([i for i in l if i > 0])
ml = sorted([-i for i in l if i < 0])
M = min(sum(pl), sum(ml))
dpp = [0] * (M + 1)
dpm = [0] * (M + 1)
dpp[0],dpm[0]=1,1
s = 1
for i in pl:
	tmp=dpp[::]
	for j in range(s):
		if i + j <= M:
			dpp[i + j] += tmp[j]
		else:
			break
	s += i
s = 1
for i in ml:
	tmp=dpm[::]
	for j in range(s):
		if i + j <= M:
			dpm[i + j] += tmp[j]
		else:
			break
	s += i
ans=0
for i in range(1,M+1):
	ans+=dpp[i]*dpm[i]
z_cnt=l.count(0)
print(ans*pow(2,z_cnt)+pow(2,z_cnt)-1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n-1];
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
	}
	int arr[n];
	for(int i=0;i<n;i++)
	{
		arr[i]=0;
	}
	for(int i=0;i<n-1;i++)
	{
		int d=a[i];
		d=d-1;
		arr[d]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<arr[i]<<endl;
	}
	return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
ll ans = 0;
int dp[10][10];

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

  int n; cin>>n;
  for (int i=1; i<=n; i++) {
    int x=i;
    while (x>=10) x=x/10;
    dp[x][i%10]++;
  }

  for (int i=1; i<=n; i++) {
    int x=i;
    while (x>=10) x=x/10;
    ans += dp[i%10][x];
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[1000],b[1000],c[1000];
    int x,y;
    cin>>a>>b>>x>>y>>c;
    if(strcmp(a,c)==0)
        cout<<x-1<<" "<<y<<endl;
    else
        cout<<x<<" "<<y-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int a,b,c,d;
	int ans=0;
	
	cin>>a>>b>>c>>d;
	if(b<c || d<a)
	{
		ans=0;
	}else{
		ans = min(b,d)-max(a,c);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  if(abs(x-a) == min(abs(x-a), abs(x-b)) ) cout << 'A' << endl;
  else cout << 'B' << endl;
  
  return 0;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int h, a; cin >> h >> a;
	if(h%a == 0) cout << h/a << endl;
	else cout << h/a + 1 << endl;
} 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {


	int n;
	cin >> n;
	vector<int>p(n);

	for (int i = 0; i < n; i++)cin >> p[i];
	int t = -999;
	for (int i = 0; i < n; i++) {
		if (t <= p[i] - 1)t = p[i] - 1;
		else if (t <= p[i] )t = p[i];
		else {
			//cout << i;
			cout << "No" << endl;
			return 0;
		}
		
	}

	cout << "Yes" << endl;

	return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 2010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    COMinit();
    rep(i,1,k+1){
        if (n-k < i-1){
            PRINT(0);
            continue;
        }
        ll blue = k-i,red = (n-k-(i-1));
        ll ans = COM(blue+i-1,i-1)*COM(red+i,i)%MOD;
        PRINT(ans);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

int main()
{
    string times;
    int x=0;
    int n;
    vector <int> number;
getline(cin,times);
stringstream s(times);
while(s>>n)
    number.push_back(n);

x=(60*(number[2]-number[0])+(number[3]-number[1]))-number[4];

    cout<<x<<endl;


    return 0;
}


Measured memory_bytes: 3628
#include<iostream> 
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
using namespace std;
//int main() {
//	int N = 0;
//	int K = 0;
//	int count = 0;
//	cin >> N;
//	cin >> K;
//
//	for (int i = 1; i <= N; i += 2) {
//		count++;
//	}
//
//	if (count < K) {
//		cout << "NO" << endl;
//	}
//	else {
//		cout << "YES" << endl;
//	}
//
//}
//int main() {
//	int Road[6];
//	int count = 0;
//	for (int i = 0; i < 6; i += 2) {
//		cin >> Road[i];
//		cin >> Road[i + 1];
//		if (Road[i + 1] == Road[i]) {
//			cout << "error" << endl;
//			break;
//			return 0;
//		}
//	}
//
//	for (int i = 0; i < 6; i++) {
//		for (int j = i + 1; j < 6; j++) {
//			if (Road[i] == Road[j]) {
//				count++;
//			}
//		}
//	}
//
//	if (count == 2) {
//		cout << "YES" << endl;
//	}
//	else {
//		cout << "NO" << endl;
//	}
//
//}
int main() {
	long long K = 0;
	long long A = 0;
	long long B = 0;

	long long b = 1;
	long long m = 0;
	long long b2 = 1;
	int count = 0;
	cin >> K;
	cin >> A;
	cin >> B;

	if (A >= B) {
		b += K;
	}
	else {
		for (int i = 0; i < K; i++) {
			b++;
		}

		for (int i = 0; i < K; i++) {
			if ((A <= b2) && (i != (K - 1)) && m == 0){
				b2 -= A;
				//m++;
				count++;
			//	cout << i << endl;
				m = 1;
				continue;
			}
			else if (m == 1) {
				//cout << "aaa" << i << endl;
				b2 += B;
				m = 0;
			
				//cout << m << endl;
				continue;
			}
			else {
			//	cout << i << endl;
				b2++;
				continue;
			}
		}
		if (b < b2) {
			b = b2;
		}
	}
	

	cout << b << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

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

    sort(v.rbegin(), v.rend());
    
    int res = 0;
    for (int i = 0; i < M - 1; i++) {
        tie(A, B) = v[i];
        if (A < N) {
            res += N - A;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3120
if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    s = input()[:-1]
    if s == 'hi':
        print('Yes')
    elif s == 'hihi':
        print('Yes')
    elif s == 'hihihi':
        print('Yes')
    elif s == 'hihihihi':
        print('Yes')
    elif s == 'hihihihihi':
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
#include <iostream>
#define REP(i, n) for(int i = 1; i <= n; i++)
#define IF(c, n) if(n < c)

int a, b, c, d, e, f = 1000000, g;
int  max1[999], m1[999], max2[999], m2[999], kekka;
int main()
{
	std::cin >> a >> b;
	REP(i, 999)
	{
		c += i;
		IF(c, a)
		{
			d += 1;
			m1[d] = d;
			max1[d] = c - a;
		}
		IF(c, b)
		{
			e += 1;
			m2[e] = e;
			max2[e] = c - b;
		}
	}
	REP(i, d)
		REP(j, e)
			if(max1[i] == max2[j])
			{
				g = m2[j] - m1[i];
				IF(f, g)
					kekka = max1[i];
			}
	std::cout << kekka << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
	int N, K;
	
	scanf("%d %d", &N, &K);
	int A[N];
	
	int i;
	int x;
	for(i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	 x = N - K;
	for(int i=0; i<x; i++){
		if(A[i]<A[i+K]){
			puts("Yes");
		}
		else{
			puts("No");
		}
	}
	return 0;
}


Measured memory_bytes: 2844
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

int n, a[N], cnt[N];
main() {
  file("threesum");
  ios;
  cin >> n;
  fo(i, 1, n, 1) cin >> a[i], ++cnt[a[i]];
  --cnt[a[1]];
  int ans = 0;
  fo(i, 1, n, 1) ans += cnt[i] * (cnt[i] - 1) / 2;
  fo(i, 1, n, 1) {
    cout << ans << "\n";
    if (i < n) {
      ans -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
      ++cnt[a[i]];
      ans += cnt[a[i]] * (cnt[a[i]] - 1) / 2;
      ans -= cnt[a[i + 1]] * (cnt[a[i + 1]] - 1) / 2;
      --cnt[a[i + 1]];
      ans += cnt[a[i + 1]] * (cnt[a[i + 1]] - 1) / 2;
    }
  }
  return 0;
}
/**

*/


Measured memory_bytes: 4736
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll dp[101][100001];

int main(int argc, char const* argv[])
{
  int n, W;
  cin >> n >> W;
  vector<int> w(n);
  vector<ll> v(n);
  rep(i, n)scanf("%d %lld", &w[i], &v[i]);
  rep(i, n){
    rep(j, W+1){
      dp[i+1][j] = dp[i][j];
      if(j-w[i]>=0)dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
    }
  }
  cout << dp[n][W] << endl;
	return 0;
}


Measured memory_bytes: 78336
def judge(Sd:str, T:str) -> str:
    lenS = len(Sd)
    lenT = len(T)
    
    #1. Tに一致する部分列を検索
    start = -1
    for i in range(lenS - lenT + 1):
        isMatch = True
        for j in range(lenT):
            if not (Sd[i+j] == T[j] or Sd[i+j] == "?"):
                isMatch = False
            
        if isMatch:
            start = i
            
    if start == -1:
        return "UNRESTORABLE"
    
    #2. あたらしい文字列を構成する
    # i:i+|T|をTで置き換え、?をaで埋める
    S = Sd[:start] + T + Sd[start+lenT:]
    ans = ""
    for i in range(lenS):
        if S[i] == "?":
            ans = ans + "a"
        else:
            ans = ans + S[i]
            
    return ans
            


Sd = input()
T = input()

S = judge(Sd, T)

print(S)

Measured memory_bytes: 3188
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
#define debug(q,x) cout<<q<<x<<endl
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+5;
const int MOD = 1e9 + 7;
const double ext = 1e-6;
int a[maxn];
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");5
	//ofstream cout("E:\\acm dream\\out.txt");
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	int a[26];
	while (cin >> s) {
		int cnt = 0;
		memset(a, 0, sizeof(a));
		_for(i, 0, s.size()) {
			a[s[i] - 'A']++;
		}
		_for(i, 0, 26) {
			if (a[i] == 2)cnt++;
		}
		if (cnt == 2)cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

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

    vi d;
    int prev = S[0];
    for (auto i = 1; i < N; i++) {
        if (prev != S[i]) {
            d.emplace_back(i);
            prev = S[i];
        }
    }

    int n_del = max(static_cast<int>(d.size() - 2 * K), 0);
    cout << N - 1 - n_del << endl;
    return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <random>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
// constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n;
	cin >> n;
	VL v(n);
	cin >> v;

	ll now = v[n - 1];
	RREPI(it, v) {
		if (*it > now + 1) { cout << "No" << endl; return 0; }
		now = std::min(*it, now);
		dump(now);
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;i++)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;
typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;
inline int rd() {
    int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
    while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
const int N=1e5+11;
int X,Y,Z,n;ll ans,f[N],g[N];priority_queue<int,vector<int>,greater<int> >h;
struct orz{int a,b,c;inline bool operator<(const orz&t)const{return a-b>t.a-t.b;}}d[N];
int main(){
#ifdef flukehn
	freopen("test.txt","r",stdin);
#endif
	X=rd(),Y=rd(),Z=rd(),n=X+Y+Z;
	rep(i,1,n)d[i].a=rd(),d[i].b=rd(),ans+=d[i].c=rd();
	rep(i,1,n)d[i].a-=d[i].c,d[i].b-=d[i].c,d[i].c=0;
	sort(d+1,d+n+1);ll th=0;
//	rep(i,1,n)printf("%d %d %d\n",d[i].a,d[i].b,d[i].c);
	rep(i,1,n){
		h.push(d[i].a),th+=d[i].a;
		if(h.size()>X)th-=h.top(),h.pop();
		f[i]=th;
	}
	while(!h.empty())h.pop();th=0;
	per(i,1,n){
		h.push(d[i].b),th+=d[i].b;
		if(h.size()>Y)th-=h.top(),h.pop();
		g[i]=th;
	}
//	dbg(ans);
	th=-LONG_LONG_MAX;
//	rep(i,1,n)printf("%d %d\n",f[i],g[i]); 
	rep(i,1,n)if(X<=i&&Y<=n-i)th=max(th,f[i]+g[i+1]);
	cout<<th+ans<<endl;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

int h[100010];

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int K, N; cin >> N >> K;
    REP(i, N) cin >> h[i];
    sort(h, h+N);

    int ans = 1000000000;
    REP(i, N-K+1) {
        ans = min(ans, h[i+K-1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N = int(input())
S = input()
dp = [[0]*(N+1) for i in range(N+1)]
ans = 0
for i in range(N-1,-1,-1):
  for j in range(i,-1,-1):
    if S[i] == S[j]:
      dp[i][j] = dp[i+1][j+1] + 1
      tmp = min(dp[i][j],i-j)
      ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 231560
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

ll comb(int n, int r) {
  std::vector<std::vector<ll>> v(n + 1,std::vector<ll>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}

ll f(int k){
    ll sum = 1;
    cout << "start:" << k << endl;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        cout << sum << endl;
    }
    cout << "end:" << k  << "," << sum << endl;
    return sum;
}

ll combination(int n, int k) {
    cout << "combination:" << f(n) << "," << f(k) << "," << f(n-k) << endl;
    return (f(n) / (f(k)*f(n-k)));
}

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb_mod(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

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

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }


    for(int i = 0; i < K; i++) {
        //cout << "start" << i << endl;
        //cout << combination(K-1, i) << endl;
        //cout <<  combination(N - K + 1, i+1) << endl;
        cout << (comb_mod(K-1, i) * comb_mod(N - K + 1, i+1))%MOD << endl;
        //cout << "end" << i << endl;
    }
}

Measured memory_bytes: 4992
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

int n, a, b, c, d, q, ans;

int main() {
	INIT
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i) {
		if(a[i] > b[i]) {
			ans += a[i] - b[i];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	A := nextInt()
	B := nextInt()

	if N*A < B {
		fmt.Println(N * A)
	} else {
		fmt.Println(B)
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int w, h, n, x, y, a;
bool d[100][100];

int main(int argc, char **argv) {
	CLEAR(d);
	cin >> w >> h >> n;
	REP(i, n) {
		cin >> x >> y >> a;
		if (a == 1) {
			REP(i, x) REP(j, h) d[i][j] = true;
		}
		else if (a == 2) {
			FOR(i, x, w) REP(j, h) d[i][j] = true;
		}
		else if (a == 3) {
			REP(i, w) REP(j, y) d[i][j] = true;
		}
		else if (a == 4) {
			REP(i, w) FOR(j, y, h) d[i][j] = true;
		}
	}
	int res = 0;
	REP(i, w) REP(j, h) if (!d[i][j]) ++res;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
n=int(input())
l1=[]
for i in range(n):
  l1.append(int(input()))
for i in range(len(l)):
    for j in range(len(l)):
        if(l[i][j] in l1):
            l[i][j]=0
f=0
if((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1][1]==0 and l[1][2]==0) or (l[2][0]==0 and l[2][1]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][0]==0 and l[2][0]==0) or (l[0][1]==0 and l[1][1]==0 and l[2][1]==0) or (l[0][2]==0 and l[1][2]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][1]==0 and l[2][2]==0) or (l[0][2]==0 and l[1][1]==0 and l[2][0]==0)):
    f=1
if(f==1):
    print("Yes")
else:
    print("No")

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
const string MINUSINF="-";
int match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

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

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] = MINUSINF;

  // 初期条件
  dp[0] = "";

  // DPループ
  for(int i = 0; i < n; ++i) {
    if(dp[i] == MINUSINF) continue;
    for(auto A : a) chmax(dp[i+match[A-1]], dp[i]+(char)('0'+A));
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 43776
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>

using namespace std;

void solve();

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

void solve(){

	bool find=false;
	long a,b,c;
	cin >>a >>b >>c;

	vector<long> v;

	for(long i=1;i<1e7;i++){
		v.push_back((i*a)%b);
		for(vector<long>::iterator i=v.begin();i<v.end()-1;i++){
			if (*i==*(v.end()-1)){
				find=true;
				v.pop_back();
				break;
			}
		}
		if (find) break;
	}

	find=false;

	for(vector<long>::iterator i=v.begin();i<v.end();i++){
		if (c==*i) {
			find=true;
			break;
		}
	}

	find?cout<<"YES"<<endl:cout<<"NO"<<endl;

}

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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);とする。
*/
}
#define MAXN 100000
int main(){
    int N;
    ll H[MAXN];
    cin >> N;
    rep(i,N)cin >> H[i];
    for(int i=N-1;i>0;i--){
        if(H[i]<H[i-1]){
            H[i-1]--;
        }
    }
    bool ok = true;
    for(int i=0;i<N-1;i++){
        if(H[i]>H[i+1]){
            ok = false;
            break;
        }
    }

    if(ok){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}

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

int main(){
 int h,w,m,n;
while(true){
 cin>>h>>w;
  if (h==0 && w==0) break;
  m=1;
  n=1;
 while(n<=h){
  if(n%2==1){
   while(m<=w){
    if(m%2==1){
     cout<<"#";
    } else cout<<".";
    m++;
   }
   cout<<endl;
   n++;
   m=1;
  } else {
   while(m<=w){
    if(m%2==1){
     cout<<".";
    } else cout<<"#";
    m++;
   }
   cout<<endl;
   n++;
   m=1;
  }
 }
cout<<endl;
}
return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int N, D, count=0;
	float dist;
	cin>>N>>D;
	int coord[N][D];
	for(int i=0; i<N; i++){
		for(int j=0; j<D; j++){
		cin>>coord[i][j];
	}
	}
	
	for(int b=1; b<N; b++){
		for(int a=0; a<b; a++){
			dist=0;
			for(int p=0; p<D; p++){
			    dist+=static_cast<float>(pow(abs(coord[a][p]-coord[b][p]),2));
		}
		    dist=sqrt(dist);
		    if(floor(dist)==ceil(dist)){
		    	count++;
			}
		}
		
	}
	
	cout<<count;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[3+1][3+1], s=0, f=0;
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin >> a[i][j];
		}
	}
	for(int i=1;i<=2;i++)
	{	
		s=a[i][1]-a[i+1][1];
		for(int j=2;j<=3;j++)
		{
				if(a[i][j]-a[i+1][j]!=s)
				{
					f=1;
					break;
				}
		}
		if(f==1)
	    {
		 	break;
		}
	}
	if(f==1)
	{
		cout << "No"<<endl;
		return 0;
	}
	else
	{
		cout << "Yes"<<endl;
		return 0;
	}
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val dance = readLine()!!.toCharArray().toList().map { it.toString() }
    var result = "Yes"

    for (i in dance.indices) {
        if (dance[i] == "R" && (i + 1) % 2 == 0) {
            result = "No"
            break
        } else if (dance[i] == "L" && (i + 1) % 2 != 0) {
            result = "No"
            break
        }
    }
    print(result)
}

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

int main(){
  int a, b, c, d, l, r;
  cin >> a >> b >> c >> d;
  l = a+b;
  r = c+d;
  if (l > r){
    cout << "Left" << endl;
  }else if (a + b < c + d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;

vector<int> dijimonAdjMat(vector<vector<int>> graph, int source){
    int n=graph.size();
    vector<int> dists(n,MOD);
    vector<bool> mark(n,false);
    dists[source]=0;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
    pq.push({dists[source],source});
    while(!pq.empty()){
        auto cur=pq.top();
        pq.pop();
        int v=cur.second;
        //cout<<v<<" "<<dists[v]<<" "<<cur.first<<endl;
        if(mark[v]) continue;
        mark[v]=true;
        for(int i=0; i<n; i++){
            if(dists[i]>dists[v]+graph[i][v]){
                dists[i]=dists[v]+graph[i][v];
                pq.push({dists[i],i});
            }
        }
    }
    return dists;
    
}
 
int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int h,w;
    cin>>h>>w;
    
    vector<vector<int>> graph(10,vector<int>(10,0));
    
    for(int i=0; i<=9; i++){
        for(int j=0; j<=9; j++){
            cin>>graph[i][j];
        }
    }
    /*
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cout<<graph[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    
    vector<int> dists=dijimonAdjMat(graph,1);
    
    /*
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            for(int k=0; k<10; k++){
                dists[k]=min(dists[k],dists[j]+graph[k][j]);
            }
        }
    }
    
    //cout<<dists[8]<<endl;
    for(int i=0; i<=9; i++){
        cout<<dists[i]<<" ";
    }
    cout<<endl;
    */
    
    int ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int x;
            cin>>x;
            if(x!=-1){
                ans+=dists[x];
            }
        }
    }
    
    cout<<ans;
    
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define Matrix vector<vector<int> >
// #define Matrix vector<vector<int> >
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
// #define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const long long INF = 5e18;
const double pi = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
double rad(double x){
    return x*pi/180.0;
}
 
bool isleft(pair<int,int> a, pair<int,int> b, pair<int,int> c){
    int det = (b.first-a.first)*(c.second-a.second) - (c.first-a.first)*(b.second-a.second);
    if(det>=0) return true;
    if(det<0) return false;
    return false;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = mod(result*a,MOD);
 
        b >>= 1;
        a = mod(a*a,MOD);
    }
    return result;
}

void solve(){
    string a,b;
    cin>>a>>b;
    int n = a.size()+1;
    int m = b.size()+1;
    int adj[n][m];
    for(int i=0;i<n;i++){
        adj[i][0]=0;
    }
    for(int i=0;i<m;i++){
        adj[0][i]=0;
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(a[i-1]==b[j-1]){
                adj[i][j] = adj[i-1][j-1]+1;
            }
            else{
                adj[i][j] = max(adj[i-1][j],adj[i][j-1]);
            }
        }
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<m;j++){
    //         cout<<adj[i][j]<<' ';
    //     }
    //     cout<<endl;
    // }
    string s="";
    int i = n-1, j=m-1;
    while(i>0 and j>0){
        if(adj[i][j]!=max(adj[i-1][j],adj[i][j-1])){
            s.push_back(b[j-1]);
            i--;
            j--;
        }
        else{
            if(adj[i][j]==adj[i-1][j]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    reverse(td(s));
    cout<<s<<endl;
}

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

Measured memory_bytes: 73948
/*  include  */
#include <iostream>
#include <vector>

/*  using namespace  */
using namespace std;

/*  local var  */
vector<int> グラフ[100005];

/*  define  */
#define loop(i,j) for(int i = 0; i < j; i++)

/*  typedef  */
typedef long long ll;

/*  function  */
void dfs(int マス,int 葉,int 距離差,int 距離配列[])
{
	距離配列[マス]=距離差;
	loop(i,グラフ[マス].size()){
		if(グラフ[マス][i] != 葉 ) dfs(グラフ[マス][i],マス,距離差+1,距離配列);
	}
}

/*  main program  */
int main()
{	
	int フェネック[100005];	
	int すぬけ[100005];
	int マス数;
	int 連結A,連結B;
	int フェネちゃんが塗れるマス数=0;

	scanf("%d",&マス数);

	loop(i,マス数-1){
		scanf("%d %d",&連結A,&連結B);
		連結A--,連結B--;
		グラフ[連結A].push_back(連結B);
		グラフ[連結B].push_back(連結A);
	}

	dfs(0,-1,0,フェネック);
	dfs(マス数-1,-1,0,すぬけ);
	loop(i,マス数)(フェネック[i]<=すぬけ[i])?フェネちゃんが塗れるマス数++:フェネちゃんが塗れるマス数--;
	printf("%s\n",(フェネちゃんが塗れるマス数>0)?"Fennec":"Snuke");
	
}

Measured memory_bytes: 12800
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

bool pr[10000001]={false};
int n;
vector<int> v;

int main(){
	pr[0]=pr[1]=true;
	for(int i = 2; i <= 10000000; i++){
		if(!pr[i]){
			for(int j = i*2; j <= 10000000; j+=i){
				pr[j] = true;
			}
		}
	}
	for(int i = 13; i <= 10000000; i++){
		if(!pr[i-8] && !pr[i-6] && !pr[i-2] && !pr[i]){
			v.push_back(i);
		}
	}
	
	while(scanf("%d",&n), n != 0){
		vector<int>::iterator itr = upper_bound(v.begin(),v.end(),n);
		itr--;
		printf("%d\n",*itr);
	}
	return 0;
}



Measured memory_bytes: 12524