akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> x >> y >> s;
	string t = "Yes";
	n = s.size();

	rep(i, n){
		if(i == x){
			if(s[i] != '-'){
				t = "No";
				break;
			}
			continue;
		}
		if(!(s[i] >= '0' && s[i] <= '9')){
			t = "No";
			break;
		}
	}
	cout << t << endl;
}


Measured memory_bytes: 256
n,*l=map(int,open(0).read().split())
d=sorted([a-b for a,b in zip(l[:n],l[n:])])
s=sum(d)
if s<0:
	print(-1)
else:
	minus=[x for x in d if x<0]
	ms=sum(minus)
	cnt=len(minus) if minus!=[] else -1
	for i in d[::-1]:
		ms+=i
		cnt+=1
		if ms>=0:
			print(cnt)
			exit()

Measured memory_bytes: 25076
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    ll n=in,sum=0;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end());
    map<int,int> map;
    for (int i=0;i<n;i++){
        if (map.count(a[i])){
            map[a[i]]++;
        }
        else map[a[i]]=1;
    }
    int q=in,b,c;
    for (int i=0;i<q;i++){
        cin >> b >> c;
        if (map.count(c)){
            map[c]+=map[b];
        }
        else {
            map[c]=map[b];
        }
        sum+=(c-b)*map[b];
        map.erase(b);
        out(sum);
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

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

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;
const int INF = 1 << 30;

int score[400000];

void solve()
{

  int d, g, p_input, c_input;
  cin >> d >> g;
  g /= 100;
  vector<int> point(d);
  vector<int> comp(d);

  for(int i = 0; i < d; ++i)
  {
    cin >> p_input >> c_input;
    c_input /= 100;
    point[i] = p_input;
    comp[i] = p_input * (i + 1) + c_input;
  }

  int mask = 1 << d;
  int ans = INF;
  while(mask--, mask >= 0)
  {
    int score = 0;
    int cost = 0;
    for(int i = 0; i < d; ++i)
    {
      if ((mask & (1 << i)) == 0) continue;
      score += comp[i];
      cost += point[i];
    }

    if (score >= g) 
    {
      ans = min(ans, cost);
      continue;
    }

    for(int i = d - 1; i >= 0; --i)
    {
      if(mask & (1 << i)) continue;

      int rest = (g - score) / (i + 1);
      score += min(rest, point[i] - 1) * (i + 1);
      cost += min(rest, point[i] - 1);

      if (score >= g) 
      {
        ans = min(ans, cost);
        break;
      }
    }
  }

  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3676
# Square869120Contest #4 B - Buildings are Colorful!　
# 分割統治法 ver
import sys

N, K = map(int, sys.stdin.readline().strip().split())
a = list(map(int, sys.stdin.readline().strip().split()))

if K == 0:
    sys.exit()

def dfs(height=a[0], cost=0, target=K, can_see=1, i=1):
    if can_see == target:
        # print('height', height)
        # print('can_see', can_see)
        # print('cost', cost)
        return cost

    # 端まで探索したとき
    if i == len(a):
        return float('inf')

    # 建物 i を選ばない場合
    if height >= a[i]:
        cost1 = dfs(height=height, cost=cost, target=K, can_see=can_see, i=i+1)
    else:
        cost1 = dfs(height=a[i], cost=cost, target=K, can_see=can_see+1, i=i+1)
    # print('cost1', cost1, 'can_see', can_see, 'i', i)

    # 建物　i を選んだ場合
    cost += max(0, height + 1 - a[i])
    height = max(a[i], height + 1)
    cost2 = dfs(height=height, cost=cost, target=K, can_see=can_see+1, i=i+1)
    # print('cost2', cost2)

    return min(cost1, cost2)


print(dfs(a[0], cost=0, target=K, can_see=1, i=1))



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

int main(){
  int N;  cin >> N;
  vector<int>A(N);
  vector<int>B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    B.at(i) = A.at(i);
  }
  sort(B.begin(),B.end());
  int max1 = B.at(N-1);
  int max2 = B.at(N-2);
  for(int i=0;i<N;i++){
    if(A.at(i) != max1) cout << max1 << endl;
    else cout << max2 << endl;
  }
}


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

int n, m, k, cnt, ans;
bool memo[105][105] = {0};
int l[105] = {0};

int main() {
  int i, j;
  while(1) {
    cin >> n;
    if(n == 0) break;
    cnt = 0;
    for(i = 1; i <= n; ++i)
      for(j = 1; j <= n; ++j) memo[i][j] = 0;
    for(i = 1; i <= n; ++i) {
      cin >> m;
      for(j = 0; j < m; ++j) {
        int x;
        cin >> x;
        memo[i][x] = 1;
      }
    }
    cin >> k;
    for(i = 0; i < k; ++i) cin >> l[i];
    for(i = 1; i <= n; ++i) {
      for(j = 0; j < k; ++j) {
        if(memo[i][l[j]] == 0) break;
        if(j == k - 1) {
          ++cnt;
          ans = i;
        }
      }
      if(cnt > 1) break;
    }
    if(cnt == 1)
      cout << ans << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
n=int(input())
arr=list(map(int,input().split()))
d={}
for i in arr:
	if i in d:
		d[i]+=1
	else:
		d[i]=1
ans=0
for key,value in d.items():
	ans+=(value*(value-1))//2
for i in range(len(arr)):
	print(ans-(d[arr[i]]-1))


Measured memory_bytes: 26212
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(ll i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const ll N=1e5+7;
const ll INF=1e9+7;
ll n,m,q;
ll a[N],b[N],c[N],f[N],sz[N];
ll ff(ll x){return (f[x]==x)?x:f[x]=ff(f[x]);}

int main(){
	scanf("%lld%lld%lld",&n,&m,&q);
	rep(i,q)scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
	rep(i,q)a[i]++,b[i]++;
	if(m==n-1)rep(i,q)if(c[i]){puts("No"); return 0;}
	rep(i,n)f[i]=i,sz[i]=1;
	rep(i,q){
		if(!c[i]){
			ll u=ff(a[i]),v=ff(b[i]);
			if(u!=v){
				sz[v]+=sz[u];
				f[u]=v;
			}
		}
	}
	rep(i,q)if(c[i])if(ff(a[i])==ff(b[i])){puts("No"); return 0;}
	ll hh=0;
	rep(i,n)if(ff(i)==i)hh++;
	if(m>n+hh*(hh-3)/2){puts("No"); return 0;}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 4096
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	for i := 1; i < 1000000000; i++ {
		if a-i == -(b-i) {
			fmt.Println(i)
			return
		} else if  -(a-i) == b-i {
			fmt.Println(i)
		}
	}
	fmt.Println("IMPOSSIBLE")


}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
/*{{ x | (1 << k) sets the kth bit of x to one
x & ~(1 << k) sets the kth bit of x to zero
x ^ (1 << k) inverts the kth bit of x.
x & (x-1) sets the last one bit of x to zero
x & -x sets all the one bits to zero, except for the last one bit. 
x | (x-1) inverts all the bits after the last one bit.}} SOME BIT MANIPULATION*/
//__builtin_clz(x): the number of zeros at the beginning of the number
//__builtin_ctz(x): the number of zeros at the end of the number
//__builtin_popcount(x): the number of ones in the number
//__builtin_parity(x): the parity (even or odd) of the number of ones 
struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
	{
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const 
	{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/*//DSU 
int parent[200005];
int rankr[200005];
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rankr[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rankr[a] < rankr[b])
            swap(a, b);
        parent[b] = a;
        if (rankr[a] == rankr[b])
            rankr[a]++;
    }
} */

int main()
{  
	fast; 
	ll n; cin>>n;
	if(n & 1)
	{
		cout << (n/2)*(n/2+1) << endl;
	}
	else
		cout << (n/2)*(n/2) << endl;
	return 0;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,M; cin >> N >> M;
	V<P<ll,ll>> AB(N);
	REP(i,N) {
		ll A,B; cin >> A >> B;
		AB[i] = {A,B};
	}
	sort(ALL(AB));
	ll ans = 0;
	REP(i,N){
		for(int j = 0; j < AB[i].second; ++j){
			ans += AB[i].first;
			M--;
			if(M == 0) break;
		}
		if(M == 0) break;
	}
	cout << ans << endl;

	return 0;
}


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

int n,a[20];

bool dfs(int j,int t){
  if(!t)return 1;
  bool res=0;
  for(int i=j;i<n;i++)res|=dfs(i+1,t-a[i]);
  return res;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int q,m;
  cin>>q;
  while(q--){
    cin>>m;
    if(dfs(0,m))cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B =sc.nextInt();
		int C =sc.nextInt();
		if (A<=C&&B>=C) {
			System.out.println("Yes");
			return ;
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21588
while True:
    H,W = map(int,input().split())
    if (H == 0 and W == 0):
        break
    for h in range(1,H+1):
        if (h==1 or h==H):
            for i in range(1,W+1):
                print('#',end = '')
            print('')
        else:
            for j in range(1,W+1):
                if j==1 or j==W:
                    print('#',end = '')
                else:
                    print('.',end = '')
            print('')
    print('')



Measured memory_bytes: 7016
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int N = 505;

char g[N][N];
int r[N][N], b[N][N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m;
	scanf("%d %d",&n,&m);
	rep(i,0,n){
		rep(j,0,m){
			scanf(" %c",&g[i][j]);
		}
	}
	for(int i = 0;i < n;i+=2){
		rep(j,0,m-1)r[i][j] = 1;
	}
	rep(i,0,n)r[i][0] = 1;

	for(int i = 1;i < n;i+=2){
		rep(j,1,m)b[i][j] = 1;
	}
	rep(i,0,n)b[i][m-1] = 1;

	rep(i,0,n){
		rep(j,0,m){
			if(g[i][j] == '#')printf("%c",'#');
			else printf("%c", (r[i][j] == 1?'#':'.'));
		}
		printf("\n");
	}
	printf("\n");
	rep(i,0,n){
		rep(j,0,m){
			if(g[i][j] == '#')printf("%c",'#');
			else printf("%c", (b[i][j] == 1?'#':'.'));
		}
		printf("\n");
	}
}


Measured memory_bytes: 2944
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<vector<ll>> edge;

vector<ll> ret;
vector<bool> used;
pair<ll,ll> cy;
bool done=false;

void dfs(ll where,ll parent){
    //cout<<where<<endl;
    ll count=0;
    used[where]=true;
    ret.push_back(where);
    for(int i=0;i<edge[where].size() && !done;i++){
        ll to=edge[where][i];
        if(to==parent && count==0){count++; continue;}
        if(used[to]){cy={to,where}; done=true; break;}
        dfs(to,where);
    }
    if(!done){ret.pop_back();}
}


int main(){
    ll n;
    cin>>n;
    edge.resize(n);
    used.resize(n,false);
    for(int i=0;i<n;i++){
        ll u,v;
        cin>>u>>v;
        u--; v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(0,-1);
    set<ll> s;
    bool in=false;
    for(int i=0;i<ret.size();i++){
        if(ret[i]==cy.F){in=true;}
        if(in){s.insert(ret[i]);}
        if(ret[i]==cy.S){in=false;}
    }
    ll q;
    cin>>q;
    while(q--){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        if(s.find(a)!=s.end() && s.find(b)!=s.end()){cout<<2<<endl;}
        else{cout<<1<<endl;}
    }
    
    
    return 0;
}



Measured memory_bytes: 18464
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos(0))
#define linf (1ll << 60)

#define maxn 1000005

int n, a;

int main(){

//	freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    int res = 0;
    Rep(i, n){
    	cin >> a;
    	if(a & 1) res++;
    }
    if(res % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    ll H;
    cin >> H;
    ll cnt = 1;
    ll ret = 0;
    while(H > 0) {
        ret += cnt;
        H /= 2;
        cnt *= 2;
    }
    cout << ret << endl;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (size_t i = 0; i < N; i++) {
		cin >> a[i];
	}

	int x = 0;
	for (size_t i = 0; i < N; i++) {
		while (true) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
				x++;
			} else {
				break;
			}
		}
	}

	cout << x;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];

    bool is[4] = {};
    rep(i, 4){
        if(a[i]==1)is[0]=true;
        else if(a[i]==9)is[1]=true;
        else if(a[i]==7)is[2]=true;
        else if(a[i]==4)is[3]=true;
        else{
            cout << "NO\n";
            return 0;
        }
    }
    if(is[0]&is[1]&is[2]&is[3])cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 256
#include <cstdio>
int N,M;
bool vis[105][105];
int main(){
	scanf("%d",&N),M=N*(N-1)>>1;
	if (N&1) for (int i=1;i<N-i;++i) vis[i][N-i]=true,--M;
		else for (int i=1;i<N-i+1;++i) vis[i][N-i+1]=true,--M;
	printf("%d\n",M);
	for (int i=1;i<N;++i)
		for (int j=N;j>i;--j) if (!vis[i][j]) printf("%d %d\n",i,j);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

string strmax( string a, string b ){
	if( a.l_ength() == b.l_ength() ) return ( a > b ) ? a : b;
	else return ( a.l_ength() > b.l_ength() ) ? a : b;
}

vector<string> dp(10100);
const int gs[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
	int n, m; cin >> n >> m;
	vector<char> match(m);
	for( auto &k : match ) cin >> k;
	fill_n( dp.begin(), 10000, "" );
	for( int i = 0; i <= n; ++i ){
		for( char k : match ){
			if( !( i != 0 && dp[i] == "") ){
				dp[i+gs[k-'0']] = strmax( dp[i+gs[k-'0']], dp[i]+k );
			}
		}
    }
	cout << dp[n] << endl;
}

Measured memory_bytes: 43776
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DShortestPathOnALine {

    struct {
        int N;
        vector<long long> dat;

        void init(int n) {
          N = 1;
          while(N < n) N *= 2;
          dat.resize(2*N-1);
          rep(i, 2*N-1) {
            dat[i] = LLONG_MAX/2;
          }
        }

        // update k-th element
        void update(int k, long long a) {
          k += N-1;
          dat[k] = a;
          while(k > 0) {
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
          }
        }

        // add k-th element by a
        void add(int k, long long a) {
          k += N-1;
          dat[k] += a;
          while(k > 0) {
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
          }
        }

        // return k-th element
        long long get(int k) {
          return dat[k+N-1];
        }

        // return min[a, b)
        long long query(int a, int b) {
          return query(a, b, 0, 0, N);
        }
        long long query(int a, int b, int k, int l, int r) {
          if (r <= a || b <= l) return LLONG_MAX/2;
          if (a <= l && r <= b) return dat[k];
          int m = (l+r)/2;
          return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
        }
    } RMQ;

public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      vector<pair<P, int>> vec(m);
      rep(i, m) {
        cin >> vec[i].first.first >> vec[i].first.second >> vec[i].second;
      }
      sort(all(vec));

      RMQ.init(n+2);
      RMQ.update(1, 0);
      rep(i, m) {
        auto st = RMQ.query(vec[i].first.first, n+1);
        debug(vec[i].first.first, vec[i].first.second, st);
        if (st == LLONG_MAX/2) continue;
        if (st+vec[i].second < RMQ.get(vec[i].first.second)) {
          RMQ.update(vec[i].first.second, st+vec[i].second);
        }
      }

      if (RMQ.get(n) == LLONG_MAX/2) {
        cout << -1 << endl;
        return;
      }

      cout << RMQ.get(n) << endl;
    }
};

signed main() {
  DShortestPathOnALine solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int N, L, ans;
    cin >> N >> L;
    ans = (L + (L + N - 1)) * N / 2;
    if(L > 0)ans -= L;
    else if(L + N - 1 < 0)ans -= L + N - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

S = input()
T = input()

ans = 0

for i in range(0,len(S)):
    if not S[i] == T[i]:
        ans += 1

print(ans)

Measured memory_bytes: 27276
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	string s,t;
	//long long n, A[1000000000];
	long long n, m;
	long long  z[100000];
//	cin >> n;

	//cin >> a;
	//cin >> b;
	//cin >> c;
	//cin >> d;
	//m = 0;
	cin >> s;
	cin >> t;
	for ( a = 0; a < s.length(); a++)
	{
		for ( b = 0; b < s.length(); b++)
		{
			if (s[(a+b)%s.length()]!=t[b])
			{
				break;
			}
			if (b==s.length()-1)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	//std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	cout << "No"  << endl;

	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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; }

int main() {
	ll N,M;
	cin >> N >> M;
	if(N == 1 && M == 1) cout << 1 << endl;
	else if(N == 1) cout << max((ll)0, M-2) << endl;
	else if(M == 1) cout << max((ll)0, N-2) << endl;
	else cout << (N-2)*(M-2) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
from bisect import bisect_left

def main():
    N = int(input())
    L = sorted(input_nums())
    count = 0
    for i in range(N-2):
        a = L[i]
        for j in range(i+1, N-1):
            count += bisect_left(L, a+L[j]) - j - 1
    print(count)

if __name__ == '__main__':
    main()

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

int main() {
  int h,w;cin>>h>>w;
  int dy[4]={0,1,0,-1};
  int dx[4]={1,0,-1,0};
  vector<string> field(h);
  int count=0;
  rep(i,h) {
    cin>>field[i];
    rep(j,w) {
      if (field[i][j]=='.') count++;
    }
  }
  queue<pair<int,int>> q;
  vector<vector<int>> dist;
  dist.assign(h,vector<int>(w,-1));
  dist[0][0]=0;
  q.push(make_pair(0,0));
  while (!q.empty()) {
    int y=q.front().first;
    int x=q.front().second;q.pop();
    rep(i,4) {
      int ny=y+dy[i];
      int nx=x+dx[i];
      if (0 <= ny && ny < h && 0 <= nx && nx < w &&
                field[ny][nx] == '.' && dist[ny][nx] == -1) {
        q.push(make_pair(ny, nx));
        dist[ny][nx] = dist[y][x] + 1;
      }
    }
  }
  int best=dist[h-1][w-1];
  if (best==-1) {
    cout<<-1<<endl;
  }
  else cout<<count-best-1<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    dp=[2**60]*N
    dp[0]=0
    for i in range(1,N):
        for st in range(max(0,i-K), i):
            dp[i]=min(dp[i], dp[st]+abs(h[st]-h[i]))
    print(dp[N-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()

Measured memory_bytes: 53284
import java.util.*;
import java.math.*;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a, b;
        a = sc.nextInt();
	b = sc.nextInt();

        for (int c = 1; c <= 3; c++) {
            if ((a * b * c) % 2 != 0) {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");
    }

}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def is_pal(s):
    return s == s[::-1]

def solve(S: str):
    N = len(S)
    return YES if is_pal(S) and is_pal(S[:N//2]) and is_pal(S[N//2+1:]) else NO


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a, b;
    for(int i = 0; i<3000; i++){
        cin >> a >> b;
        if(a == 0 && b == 0){
            return 0;
        } 
        cout << min(a, b) << " " << max(a, b) << endl;
    }
}


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



using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
#define REP(i,n) for(int i=0;i<n;i++)



int main() {

	int x;
	cin >> x;

	if (x == 3 || x == 5 || x == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;;

	return 0;

}

Measured memory_bytes: 256
while True:
    a,b= map(int,input().split())
    if(a==0 and b==0):
        break;
    for i in range(a):
        for j in range(b):
            if( i == 0 or i == a-1):
                print('#',end='') 
            elif(j == 0):
                    print('#',end='')
            elif(j > 0 and j < b-1):
                    print('.',end='')
            elif(j==b-1):
                    print('#',end='')
        print()
    print()
               


Measured memory_bytes: 7000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    int t,n,i,j;
    string s;
    cin>>s;
    if(s=="ABC")
    cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template <typename P, typename Q>
ostream& operator<<(ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T> v)
{
  os << "(";
  each (i, v)
    os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char* argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b;
  while (cin >> a >> b) {
    cout << (a * b % 2 ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;



int main()
{
    int n;
    cin >> n;
    vi a(n);
    in(n,a);
    
    vi b(100000+2,0);
    
    rep(i,n) b[a[i]]++;
    
    int ans = 0;
    reps(i,1,100001){
        if(ans < b[i]+b[i-1]+b[i+1]){
            ans = b[i]+b[i-1]+b[i+1];
        }
    }
    out(ans);


    
    return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll a = in(), b = in(), q = in();
    vll s = in(a), t = in(b);
    s.insert(s.begin(), -LINF);
    s.pb(LINF);
    t.insert(t.begin(), -LINF);
    t.pb(LINF);

    while (q--)
    {
        ll x = in();

        ll si = lower_bound(ALL(s), x) - s.begin();
        ll ti = lower_bound(ALL(t), x) - t.begin();
        vll ss = {x - s[si - 1], x - s[si]};
        vll tt = {x - t[ti - 1], x - t[ti]};

        ll ans = LINF;
        for (auto e : ss)
        {
            for (auto f : tt)
            {
                ll tmp = ((e >= 0 && f >= 0) || (e <= 0 && f <= 0)) ? max(abs(e), abs(f)) : min(abs(e), abs(f)) * 2 + max(abs(e), abs(f));
                ans = min(ans, tmp);
            }
        }
        cout << ans << endl;
    }
}

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


Measured memory_bytes: 2912
# include<iostream>
# include<cstdio>
# include<cstring>
# include<algorithm>
using namespace std;
const int N=100005;
const int INF=1<<30;
struct node{
	int x,y,v;
}line[100005];
bool cmp1(node p,node q)
{
	return p.x<q.x;
}
bool cmp2(node p,node q)
{
	return p.y<q.y;
}
struct edge
{
    int fr,to,w,nxt;
    bool operator < (const edge &a) const {
        return w<a.w;
    }
};
int pre[N],n,head[N],cnt;
edge e[500005+5];
void add(int fr,int to,int w)
{
    e[cnt].fr=fr;
    e[cnt].to=to;
    e[cnt].w=w;
    e[cnt].nxt=head[fr];
    head[fr]=cnt++;
}
int fin(int x)
{
    if(x==pre[x])
        return x;
    return pre[x]=fin(pre[x]);
}
void Kruskal()
{
    for(int i=1;i<=n;++i)
        pre[i]=i;
    sort(e,e+cnt);
    int ans=0;
    int p,q,s;
    for(int i=0;i<cnt;i++){
        int u=fin(e[i].fr);
        int v=fin(e[i].to);
        if(u!=v){
            pre[u]=v;
            ans+=e[i].w; 
        }
    }
    printf("%d\n",ans);
}
int main()
{
    int a,b,c,m;
    scanf("%d\n",&n);
    for (int i=1;i<=n;i++)
    {
    	scanf("%d%d\n",&line[i].x,&line[i].y);
    	line[i].v=i;
    }
    cnt=0;
    memset(head,-1,sizeof(head));
    sort(line+1,line+1+n,cmp1);
    for (int i=1;i<n;i++)
    {
        add(line[i].v,line[i+1].v,line[i+1].x-line[i].x);
        add(line[i+1].v,line[i].v,line[i+1].x-line[i].x);
    }
    sort(line+1,line+1+n,cmp2);
    for (int i=1;i<n;i++)
    {
        add(line[i].v,line[i+1].v,line[i+1].y-line[i].y);
        add(line[i+1].v,line[i].v,line[i+1].y-line[i].y);
    }
    Kruskal();
    return 0;
}

Measured memory_bytes: 10112
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        ans += s[i] == t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define f first
#define s second
#define pli pair<long long,int>
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back

const int maxn=1e6+10;
const int maxt=2e5+10;
const long long inf=1e16;
const int mod=1e9;

using namespace std;

int a,b,k;
map<int,bool> c;

inline void init(){
    cin>>a>>b>>k;
}

inline void prepare(){
    for(int i=a;i<=min(a+k-1,b);i++) cout<<i<<'\n',c[i]=true;
    for(int i=max(b-k+1,a);i<=b;i++)
        if(c[i]) continue;
        else cout<<i<<'\n';
}

inline void solve(){

}

inline void file(){
    #define task "TEST"
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    freopen(task".INP","r",stdin);
    freopen(task".OUT","w",stdout);
}

int main(){
    //file();
    init();
    prepare();
    //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define det(x1, y1, x2, y2) ((x1) * (y2) - (x2) * (y1))
#define distance(x, y) (abs(x) + abs(y))
#define max(x, y) ((x) > (y) ? (x) : (y))

using lint = long long;

typedef struct {
	lint x;
	lint y;
} Point;

int compare(Point, Point);
void qsort1(int, int, Point*);
int convex_hull(Point*, Point*, int);
lint caliper(Point*, int);
int main()
{
	int i, size, qsize;
	Point* ps, * qs;
	cin >> size;
	ps = (Point*)malloc(sizeof(Point) * size);
	qs = (Point*)malloc(sizeof(Point) * size * 2);
	for (i = 0; i < size; i++) {
		cin >> ps[i].x >> ps[i].y;
	}
	qsize = convex_hull(qs, ps, size);
	cout << caliper(qs, qsize) << endl;
	free(ps);
	free(qs);
}

int compare(Point arg1, Point arg2)
{
	lint p1 = arg1.x - arg2.x, p2 = arg1.y - arg2.y;
	if (p1 > 0 || (p1 == 0 && p2 > 0)) {
		return 1;
	}
	else if (p1 < 0 || (p1 == 0 && p2 < 0)) {
		return -1;
	}
	else {
		return 0;
	}
}

void qsort1(int left, int right, Point* p)
{
	int i = left, j = right;
	Point pivot = p[(left + right) / 2];
	if (left >= right) return;
	do {
		while (compare(pivot, p[i]) == 1) i++;
		while (compare(pivot, p[j]) == -1) j--;
		if (i <= j) {
			Point temp = p[i];
			p[i] = p[j];
			p[j] = temp;
			i++;
			j--;
		}
	} while (i <= j);
	qsort1(left, j, p);
	qsort1(i, right, p);
}

int convex_hull(Point* qs, Point* ps, int size)
{
	int i, t, k = 0;
	qsort1(0, size - 1, ps);
	for (i = 0; i < size; i++) {
		while (k > 1 && det(qs[k - 1].x - qs[k - 2].x, qs[k - 1].y - qs[k - 2].y,
			ps[i].x - qs[k - 1].x, ps[i].y - qs[k - 1].y) <= 0) {
			k--;
		}
		qs[k++] = ps[i];
	}
	for (i = size - 2, t = k; i >= 0; i--) {
		while (k > t && det(qs[k - 1].x - qs[k - 2].x, qs[k - 1].y - qs[k - 2].y,
			ps[i].x - qs[k - 1].x, ps[i].y - qs[k - 1].y) <= 0) {
			k--;
		}
		qs[k++] = ps[i];
	}
	qs = (Point*)realloc(qs, sizeof(Point) * (k - 1));
	return (k - 1);
}

lint caliper(Point* qs, int qsize)
{
	int i, j, k, si, sj;
	lint result = 0;
	if (qsize == 2) {
		return distance(qs[0].x - qs[1].x, qs[0].y - qs[1].y);
	}
	for (i = j = k = 0; k < qsize; k++) {
		if (compare(qs[i], qs[k]) == -1) i = k;
		if (compare(qs[j], qs[k]) == 1) j = k;
	}
	si = i;
	sj = j;
	while (i != sj || j != si) {
		result = max(result, distance(qs[i].x - qs[j].x, qs[i].y - qs[j].y));
		if (det(qs[(i + 1) % qsize].x - qs[i].x, qs[(i + 1) % qsize].y - qs[i].y,
			qs[(j + 1) % qsize].x - qs[j].x, qs[(j + 1) % qsize].y - qs[j].y) < 0) {
			i = (i + 1) % qsize;
		}
		else {
			j = (j + 1) % qsize;
		}
	}
	return result;
}

Measured memory_bytes: 6464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    double a,b;
    cin >> a >> b;
    double c, d;
    cin >> c >> d;
    cout << a*b/2.0 << " ";
    if (a / c == 2 && b / d == 2) {
        cout << 1 << endl;
    }
    else cout << 0 << endl;
}

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

using namespace std;

int N;
bool prime[60000];
vector<int> vec;

int main(void)
{
	cin >> N;
	
	for(int i = 2; i <= 50000; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 60000; j+=i) prime[j] = true;
	}
	
	for(int i = 2; i <= 55555; i++) if(!prime[i] && i % 5 == 1) vec.push_back(i);
	for(int i = 0; i < N; i++) cout << vec[i] << " ";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1ll) res=(res*x)%INF;y=y>>1ll;x=(x*x)%INF;}return res%INF;} // modular exponent
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
	cin>>n;
	ll ans=0;
	ans=power(10,n);
	ans%=INF;
	ans+=power(8,n);
	ans%=INF;
	ans-=power(9,n);ans+=INF;ans%=INF;
	ans-=power(9,n);ans+=INF;ans%=INF;
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



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

int main () {
  
  int N;
  cin >> N;
  
  vector<long long> A(N, 0);
  vector<long long> B(N, 0);
  vector<long long> C(N, 0);
  
  int a, b, c;
  cin >> a >> b >> c;
  A[0] = a;
  B[0] = b;
  C[0] = c;
  
  for (int i = 1; i < N; i++) {
    
    int a, b, c;
    cin >> a >> b >> c;
    
    A[i] = a + max(B[i - 1], C[i - 1]);
    B[i] = b + max(C[i - 1], A[i - 1]);
    C[i] = c + max(A[i - 1], B[i - 1]);
    
  }
  
  cout << max(A[N - 1], max(B[N - 1], C[N - 1])) << endl;
  
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    i64 N = input(), K = input();

    i64 a = N / K;
    a = a * a * a;

    if ((K & 1) == 0) {
        i64 b = (N + K / 2) / K;
        b = b * b * b;
        a += b;
    }

    cout << a << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}

Measured memory_bytes: 256