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

const int maxn = 500010, P = 998244353;
int n, K, ans, fact[maxn], inv[maxn], finv[maxn];

int qp(int x, int y) {
    int z = 1;
    for (; y; y >>= 1, x = 1LL * x * x % P) {
        if (y & 1) z = 1LL * z * x % P;
    }
    return z;
}

int C(int x, int y) {
    if (x < y || y < 0) return 0;
    return 1LL * fact[x] * finv[y] % P * finv[x - y] % P;
}

int main() {
    scanf("%d %d", &n, &K);
    fact[0] = finv[0] = inv[0] = inv[1] = 1;
    for (int i = 1; i <= K; i++) {
        fact[i] = 1LL * i * fact[i - 1] % P;
        if (i > 1) inv[i] = 1LL * (P - P / i) * inv[P % i] % P;
        finv[i] = 1LL * finv[i - 1] * inv[i] % P;
    }
    for (int i = n; i <= K; i++) {
        ans = (ans + 1LL * C(K, i) - C(K, i * 2 - n + 1) + P) % P;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  bool judge = false;
  if (a == 5) {
    if (b == 7 && c == 5) {
      judge = true;
    } else if (b == 5 && c == 7) {
      judge = true;
    }
  } else if (a == 7) {
    if (b == 5 && c == 5) {
      judge = true;
    }
  }

  if (judge) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define bit(x,n) (x & (1<<(n)))
#define EPS 1e-8
#define all(x) (x).begin(),(x).end()
#define INF 0x3f3f3f3f3f3f3f
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<long long, long long> > vll;

ii DR8[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
ii DR4[] = {{-1,0},{0,-1},{0,1},{1,0}};

const ll mod = 1e9+7;

ll nop = 2;
vi primes(nop+1,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll gcd(ll a,ll b){
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

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

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans *num)%mod;
        }
        num *= num;
        num %= mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    a %= mod;
    return mexp(a,mod-2);
}

void solve() {
    ll n;
    cin>>n;
    ll ans = 0;
    for1(i,n) {
        ans += i*(n-i+1);
    }
    for0(i,n-1) {
        ll u,v;
        cin>>u>>v;
        if(u > v) swap(u,v);
        ans -= (n-v+1)*(u);
    }
    deb1(ans)
}


int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t){
        //cout<<fixed<<setprecision(8);
        //cout<<"Case #"<<T<<": ";
        solve();
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;

int main() {
	int n; cin >> n;
	vector<int> v(n), c(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	for (int i = 0; i < n; i++) cin >> c[i];
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		int s = 0;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) s += v[j] - c[j];
		}
		ans = max(ans, s);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int ary[3];
    rep(i,3) cin >> ary[i];
    sort(ary, ary+3);
    if (ary[0]+ary[1]==ary[2]) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

vector<vector<int>> memo;
vector<int> sz;

int dp(int l, int r) {
  // dp[i,j] := [i,j]で出せるブロックの最大値
  if (memo[l][r] != -1)
    return memo[l][r];
  if (l == r)
    return memo[l][r] = 0;
  if (r - l == 1) {
    if (abs(sz[r] - sz[l]) <= 1)
      return memo[l][r] = 2;
    else
      return memo[l][r] = 0;
  }
  if (dp(l + 1, r - 1) == r - l - 1 && abs(sz[r] - sz[l]) <= 1) {
    return memo[l][r] = r - l + 1;
  } else {
    int res = 0;
    for (int i = l; i <= r - 1; i++) {
      res = max(res, dp(l, i) + dp(i + 1, r));
    }
    return memo[l][r] = res;
  }
}

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    sz.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> sz[i];
    }
    memo.assign(n, vector<int>(n, -1));
    cout << dp(0, n - 1) << endl;
  }
}



Measured memory_bytes: 3244
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1)
  {
    c=c-b;
    if(c<=0)
      break;
    a=a-d;
    if(a<=0)
      break;
  }
  if(c<=0) cout<<"Yes";
  if(a<=0) cout<<"No";
  return 0;
}

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

using Graph = vector<vector<int>>;

Graph g;
vector<int> p;
vector<int> x;
vector<bool> seen;

void dfs (int a, int cur) {
  seen[a] = true;
  x[a] = cur + p[a];
  for(auto b : g[a]) {
    if(seen[b]) continue;
    dfs(b, x[a]);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  g.resize(n+1);
  p.resize(n+1);
  x.resize(n+1);
  seen.resize(n+1);

  rep(i, n-1) {
    int ai, bi;
    cin >> ai >> bi;
    g[ai].push_back(bi);
    g[bi].push_back(ai);
  }
  rep(i, q) {
    int pi, xi;
    cin >> pi >> xi;
    p[pi] += xi;
  }

  dfs(1, 0);

  for(int i=1;i<=n;i++) {
    if(i != n) {
      cout << x[i] << " ";
      continue;
    }
    cout << x[n] << endl;
  }
  return 0;
}


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

int main() {
    string S;
    cin >> S;

    int N = S.size();
    vector<int> children(N);
    int i = 0;
    while (i < N) {
        int j = i;
        while (S[j] != 'L' && j < N) j++;
        int r = j - 1, l = j;
        while (S[j] != 'R' && j < N) j++;
        int cnt = j - i;
        if (cnt % 2 == 0) {
            children[r] = children[l] = cnt / 2;
        } else {
            int cntR = l - i, cntL = j - l;
            if (cntR > cntL) {
                children[l] = cnt / 2;
                children[r] = cnt - children[l];
                if (cntR % 2 == 0) swap(children[r], children[l]);
            } else {
                children[r] = cnt / 2;
                children[l] = cnt - children[r];
                if (cntL % 2 == 0) swap(children[r], children[l]);
            }
        }
        i = j;
    }

    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << children[i];
    }
    cout << endl;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
      ll n,i,k,j;
      cin>>n>>k;
      ll x[n+1],y[n+1];
      for(i=1;i<=n;i++){
            cin>>x[i];
      }
      for(i=1;i<=n;i++)
      {
            if(i==1){y[i]=0;}
            else if(i==2)
            {
                  y[i]=abs(x[i]-x[i-1]);
            }
            else{
                  if(k==1){y[i]=y[i-1]+abs(x[i]-x[i-1]);}
                        else{y[i]=min(y[i-1]+abs(x[i]-x[i-1]),y[i-2]+abs(x[i-2]-x[i]));}
                  
                  for(j=i-1;j>=1 && j>=i-k;j--)
                  {
                        y[i]=min(y[i],y[j]+abs(x[j]-x[i]));
                  }
            }
      }
      cout<<y[n]<<"\n";
}

Measured memory_bytes: 1920
#include<iostream>
#include<queue>
using namespace std;
int main()
{
    int n,x,total=0;
    priority_queue<int> a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        a.push(x);
    }

    int temp,cnt;
    while(a.size()){
        temp = a.top();
        //cout<<temp<<endl;
        cnt = 1;
        a.pop();
        while(a.top() == temp&&a.size()){
            cnt++;
            a.pop();
        }
        if(cnt%2==1) total++;
        //cout<<a.size()<<endl;
    }
    cout<<total<<endl;
}


Measured memory_bytes: 892
from operator import itemgetter
N,M = map(int,input().split())
l_a = sorted(list(map(int,input().split())))
#O(NlogN)
l_bc = [list(map(int,input().split())) for i in range(M)]
l_bc.sort(key = itemgetter(1), reverse = True)
#O(MlogM)
for b,c in l_bc:
    l_a.extend([c]*b)
    if len(l_a) > N*2:
        break
l_a.sort(reverse = True)
print(sum(l_a[:N]))

Measured memory_bytes: 34764
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int x,y; cin>> x >> y;
    rep(i, x+1) {
        if((x-i)*2 + i*4 == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
            cout << "No" << endl;
            return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstring>

using namespace std; 

int main(void){
  int n,m,j;
  bool fg;
  char ch,str[2][100];
 
 
  while(cin >> n,n){
    j=0;
    for(int i=0;i<n;i++,j++)
      cin >> str[0][i] >> str[1][i];
    
    cin >> m;

    for(int k=0;k<m;k++){
      cin >> ch;
      fg=false;
      for(int i=0;i<j+1;i++){
	if(ch==str[0][i]){
	  cout << str[1][i];
	  fg=true;
	  break;
	}
      }
      if(!fg)cout << ch;
    }
    cout << endl;
  }
   
  return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<set>
#include<iomanip>
#include<queue>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
int n,m,i,j,a[100005],x,y;
vector<int> bi[100005];
priority_queue<pair<int,int> > pq;
int main()
{
	scanf("%d",&n);
	fz1(i,n-1)
	{
		scanf("%d%d",&x,&y);
		bi[x].push_back(y);
		bi[y].push_back(x);
	}
	scanf("%d",&m);
	memset(a,15,sizeof(a));
	fz1(i,m)
	{
		scanf("%d%d",&x,&y);
		a[x]=y;
		pq.push(make_pair(y,x));
	}
	while (!pq.empty())
	{
		int x=pq.top().second;pq.pop();
		ff(bi[x],it)
		{
			if (a[*it]==0xf0f0f0f)
			{
				a[*it]=a[x]-1;
				pq.push(make_pair(a[x]-1,*it));
			}
		}
	}
	fz1(i,n)
	{
		ff(bi[i],it)
		{
			if (abs(a[i]-a[*it])!=1)
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	fz1(i,n)
	{
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 7924
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

long long int isqrt(long long int n) {
    int i;
    for(i = 1; n > 0; i++) {
        n -= i * 2 + 1;
    }
    return i - 1;
}

long long min(long long a, long long b) {
    if(a >= b) {
        return b;
    } else {
        return a;
    }
}

int main() {
    long long N;
    cin >> N;
    vector<long long> div;
    long long root = isqrt(N);

    // 約数すべて出す
    long long count = 0;
    for(long long i = 1; i <= root; i++) {
        if(N % i == 0) {
            div.push_back(i);
            div.push_back(N / i);
            count += 2;
        }
    }

    long long sum = 1000000000000;
    for(long long i = 0; i < count; i += 2) {
        sum = min(div[i] + div[i + 1], sum);
    }

    cout << sum - 2 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll n;
    cin>>n;
    for(ll i=0;i<101;++i){
        for(ll j=0;j<101;++j){
            if(4*i+7*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
class abc160_c{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int lakesize = int.Parse(str[0]);
    int numofhouse = int.Parse(str[1]);
    String[] pos = Console.ReadLine().Split(' ');
    int[] dis = new int[numofhouse];
    for(int i=0; i<numofhouse-1; i++){
      dis[i] = int.Parse(pos[i+1]) - int.Parse(pos[i]);
    }
    dis[numofhouse-1] = lakesize - int.Parse(pos[numofhouse-1]) + int.Parse(pos[0]);
    int max = dis[0];
    int sum = dis[0];
    for(int i=1; i<numofhouse; i++){
      sum+=dis[i];
      if(max < dis[i])
        max = dis[i];
    }
    Console.WriteLine(sum - max);
  }
}


Measured memory_bytes: 35676
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, K;
int modK[200010];


void makeModK(){
	repe(i, 1, N)  modK[i%K]++;
}


int solve(){
	if(K%2 == 1) return POW(modK[0], 3);
	return POW(modK[K/2], 3)+POW(modK[0], 3);
}


signed main(){
	cin >> N >> K;

	makeModK();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1024
import sys
import bisect

input = sys.stdin.readline
N = int(input())
A = [int(input()) for _ in range(N)]
# - bisect_right(=bisect)(iter, x): (iter[i] < x)を満たす最小のiを返す
# - bisect_left: (iter[i] <= x)を満たす最小のiを返す
c = []
for a in A:
    a *= -1
    i = bisect.bisect_right(c, a)
    if i == len(c):
        c.append(a)
    else:
        c[i] = a
print(len(c))


Measured memory_bytes: 79592
#include<bits/stdc++.h>
#define ll long long int 

using namespace std;

int main(){
    
    string s,t;
    cin >>s;
    cin >>t;
    int ss=s.size();
    int tt=t.size();
    int ans[ss+1][tt+1];
    for(int i=0;i<=s.size();i++) ans[i][0]=0;
    for(int i=0;i<=t.size();i++) ans[0][i]=0;
    for(int i=1;i<=s.size();i++){
        for(int j=1;j<=t.size();j++){
            if(s[i-1]==t[j-1]){
                ans[i][j]=ans[i-1][j-1]+1;
            }
            else{
                ans[i][j]=max(ans[i-1][j],ans[i][j-1]);
            }
        }
    }
    int i=ss;int j=tt;
    stack<char> res;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            res.push(s[i-1]);
            i-=1;j-=1;
        }
        else{
            if(ans[i-1][j]>=ans[i][j-1]){
                i-=1;
            }else{
                j-=1;
            }
        }
        
    }
    while(!res.empty()){
        cout <<res.top();
        res.pop();
        
    }
    cout <<endl;
    //cout << ans[s.size()][t.size()]<<endl;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    string S, T;
    cin >> S >> T;
    if (S == T.substr(0, T.size() - 1)) {
        Yes;
    } else {
        No;
    }
}

Measured memory_bytes: 3600
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,j,H,W;cin>>H>>W;
	vector<string>aaa(H);
	for(i=0;i<H;i++){cin>>aaa[i];}
	static int dp[1001][1001]={0};dp[0][0]=1;
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(aaa[i][j]=='#'){dp[i][j]=0;}
			dp[i][j]%=mod;
			dp[i+1][j]+=dp[i][j];
			dp[i][j+1]+=dp[i][j];
		}
	}
	cout<<dp[H-1][W-1]<<endl;
	return 0;
}


Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        //static int N;
        static string ss,S;
        

        public static void Input()
        {
            var cin = new Scanner();
            
            ss = Console.ReadLine();
            S = Swap(ss);
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            string ans = "YES";
            int res = S.Length;
            int st = 0;
            string[] c = { "maerd", "remaerd", "esare", "resare" };

            while (res > 0) 
            {
                if (res >= 5)
                {
                    if (c.Contains(S.Substring(st, 5)))
                    {
                        res -= 5;
                        st += 5;
                        continue;
                    }
                }
                if (res >= 6)
                {
                    if (c.Contains(S.Substring(st, 6)))
                    {
                        res -= 6;
                        st += 6;
                        continue;
                    }
                }
                if (res >= 7)
                {
                    if (c.Contains(S.Substring(st, 7)))
                    {
                        res -= 7;
                        st += 7;
                        continue;
                    }
                }

                ans = "NO";
                break;
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

        public static string Swap(string str)
        {
            var rs = new StringBuilder();
            var swapstr = str.ToCharArray();
            for(var i = 0; i < str.Length; i++)
            {
                rs.Append(swapstr[str.Length - 1 - i]);
            }
            return rs.ToString();
        }

        
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 14292
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    string str,cstr;
    cin >> str;
    cstr=str;
    for(int i=0;str.length()!=0;){
        if(str[i]=='('&&str[i+1]==')'){
            str.erase(str.begin()+i,str.begin()+i+2);
            i=0;
            
        }else if(str[i]==')'){
            str="("+str;
            cstr="("+cstr;
            
        }else if(str[i]=='('&&i==str.length()-1){
            str=str+")";
            cstr=cstr+")";
            i=0;
            
        }else{i++;}
        
        
    }
    
    cout << cstr <<"\n";
    
    return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e6 + 17;

int n;
vector<int> pt, pth;
int col[maxn];
vector<int> g[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	forn (i, n - 1)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		g[u - 1].push_back(v - 1);
		g[v - 1].push_back(u - 1);
	}

	return true;
}

void dfs(int v, int p)
{
	pt.push_back(v);

	if (pt.back() == n - 1)
		pth = pt;

	for (auto to : g[v])
		if (to != p)
			dfs(to, v);

	pt.pop_back();
}

void dfs1(int v, int p)
{
	col[v] = 0;

	for (auto to : g[v])
		if (to != p && col[to] != 1)
			dfs1(to, v);
}

void solve()
{
	fill(col, col + n, -1);
	dfs(0, -1);

	for (int l = 0, r = size(pth) - 1; l <= r; ++l, --r)
	{
		col[pth[l]] = 0;
		
		if (l != r)
			col[pth[r]] = 1;
	}

	dfs1(0, -1);
	int cnt0 = 0;

	forn (i, n)
		cnt0 += col[i] == 0;

	int cnt1 = n - cnt0;

	if (cnt0 <= cnt1)
		printf("Snuke\n");
	else
		printf("Fennec\n");
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 61304
#include <stdio.h>
#include <math.h>

int main()
{
    double a,b,c,d,e,f;
    double x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){

    y = (((f)*(a)-(d)*(c))/((e)*(a)-(d)*(b)));
    x = (((c)-(b)*(y))/(a));
    printf("%0.3lf %0.3lf\n",x,y);
    }
return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    int count = 0;
    cin >> s >> t;
    for(int i = 0 ; i < 3 ; i++)
        if(s[i] == t[i])
            count++;
    cout << count;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    int ans;
    if (M % N == 0)
    {
        ans = M / N;
    }else
    {
        vector<int> div;
        for (int i = 1; i * i <= M; i++)
        {
            if (M % i == 0)
            {
                div.emplace_back(i);
                div.emplace_back(M / i);
            }
            
        }
        sort(div.begin(), div.end());
        for (int a : div)
        {
            if (a >= N)
            {
                ans = M / a;
                break;
            }
            
        }
           
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int ans;
char str[1000005];
int main()
{
	int i,j,k,l;
	scanf("%s",str); l=strlen(str);
	for(i=l;i>=1;i--)str[i]=str[i-1];
	int mi=1e9;
	for(i=0;i<26;i++)
	{
		str[l+1]='a'+i;
		ans=0;
		for(j=1;j<=l;j++)
		{
			for(k=j;k<=l+1;k++)
				if(str[k]=='a'+i)
				{
					ans=max(ans,k-j);
					break;
				}
		}
		mi=min(mi,ans);
	}
	printf("%d\n",mi);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#define INF 1<<29
#define MAX 3000
using namespace std;
int cost[MAX][MAX],V,d[MAX];
bool used[MAX];

void dijkstra(int);

int main(){
  int m,s,g1,g2,b1,b2,c;

  while(true)
    {
      cin >> V >> m >> s >> g1 >> g2;
      if(V == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0)break;
      for(int i=1;i<=V;i++){
for(int j=1;j<=V;j++){
cost[i][j]=INF;
}
}
      for(int i=0;i<m;i++)
	{
	  cin >> b1 >> b2 >> c;
	  cost[b1][b2]=c;
	}
      dijkstra(s);
      int ans = d[g1]+d[g2];
      //cout << ans << endl;
      int dr[MAX];
      for(int i=1;i<=V;i++)dr[i]=d[i];
      for(int i=1;i<=V;i++)
	{
	  if(i == s)continue;
	  dijkstra(i);
	  ans = min(ans,dr[i]+d[g1]+d[g2]);
	}
      cout << ans << endl;
    }
}

void dijkstra(int s)
{
  for(int i=1;i<=V;i++)
    {
      d[i]=INF;
      used[i]=false;
    }
  d[s] = 0;
  while(true)
    {
      int v=-1;
      for(int u=1;u<=V;u++)
	{
	  if(!used[u] && (v == -1 || d[u] < d[v]))v = u;
	}
      if(v == -1)break;
      used[v]=true;
      for(int u=1;u<=V;u++)
	{
	  d[u]=min(d[u],d[v]+cost[v][u]);
	}
    }
}

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int a,b;
  cin >> a >> b;
  print(a*a-b);
  return 0;
}

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

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

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n, m;
vector< vector<int> > g;
vector<int> col;

void dfs(int v, int c){
    col[v] = c;

    for(auto e : g[v]){
        if(col[e] == -1){
            dfs(e, c ^ 1);
        }
    }

    return;
}

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

    cin >> n >> m;

    g.resize(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        g[--a].emplace_back(--b);
        g[b].emplace_back(a);
    }

    col.resize(n, -1);
    dfs(0, 0);

    bool flag = true;
    rep(i, n){
        for(auto e : g[i]){
            flag &= col[i] != col[e];
        }
    }

    if(flag){
        vector<int> cnt(2);
        rep(i, n){
            ++cnt[col[i]];
        }
        cout << (lint)cnt[0] * cnt[1] - m << endl;
    }else{
        cout << (lint)n * (n - 1LL) / 2LL - m << endl;
    }

    return 0;
}

Measured memory_bytes: 6400
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	cin >> k;
	REP(f, k) {
		vvi d(26, vi(26, INF));
		int h, w;
		cin >> h >> w;
		vector<string> v(h);
		REP(i, h)cin >> v[i];
		FOR(c,'A','Z'+1){
			int minh = INF, maxh = -INF,minw=INF,maxw=-INF;
			REP(i, h) {
				REP(j, w) {
					if (v[i][j] == c) {
						minh = min(minh, i);
						maxh = max(maxh, i);
						minw = min(minw, j);
						maxw = max(maxw, j);
					}
				}
			}
			if (minh == INF)continue;
		
			FOR(i, minh, maxh + 1) {
				FOR(j, minw, maxw + 1) {
					if (v[i][j] == '.') {
						cout << "SUSPICIOUS" << endl;
						goto a;
					}
					else if (v[i][j] != c) {
						d[v[i][j]-'A'][c - 'A'] = -1;
					}
				}
			}
			REP(i, 26)d[i][i] = 0;
			REP(k, 26) {
				REP(i, 26) {
					REP(j, 26) {
						d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
					}
				}
			}
			
		}
		REP(i, 26) {
			if (d[i][i] < 0) {
				cout << "SUSPICIOUS" << endl;
				goto a;
			}

		}
		cout << "SAFE" << endl;
	a:;
	}
}

Measured memory_bytes: 3176
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i, j in enumerate(A):
    ans += B[j - 1]
    if i == N - 1:
        break
    elif j + 1 == A[i + 1]:
        ans += C[j - 1]

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)

using namespace std;

typedef long long ll;

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

int main(){

   ll A, B, K;

   cin >> A >> B >> K;

   ll total = A + B;

   if(K >= total) cout << 0 << " " << 0;

   else {
       ll res = A - K; 
       if(A >= K) {
           
           cout << res << " " << B;
       } 

       else {
           res = B + res;
            cout << 0 << " " << res;

       }

   }

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int x; cin >> x;
    int mx = int(sqrt(double(x))+0.1);
    bool ok=true;
    while(true){
        ok = true;
        repi(i,2,mx+1){
            if(x % i == 0){
                ok=false;
                break;
            }
        }
        if(ok){
            cout << x << endl;
            break;
        }
        x++;
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x.at(i);
    vector<int> sorted = x;
    sort(sorted.begin(), sorted.end());
    int left = sorted.at(n / 2), right = sorted.at(n / 2 - 1);
    for (int i = 0; i < n; i++) cout << (x.at(i) < left ? left : right) << endl;
    return 0;
}


Measured memory_bytes: 3712
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t countDivisors(const size_t n)
{
	size_t count = 1;

	for (size_t i = 2; i <= n; i++) {
		if (n%i == 0) {
			count++;
		}
	}

	return count;
}

static int32_t dp[10000];

int main(void) {
	size_t N, M, A[9], cost[9];
	size_t count[8][9];

	dp[0] = 0;

	for (size_t i = 0; i < 8; i++) {
		for (size_t j = 0; j < 9; j++) {
			count[i][j] = 0;
		}
	}

	scanf("%zu %zu\n", &N, &M);
	for (size_t idx = 0; idx < M; idx++) {
		scanf("%zu", &(A[idx]));
		if (idx < M - 1) {
			scanf(" ");
		}
	}

	qsort(A, M, sizeof(size_t), compare_f);

	for (size_t idx = 0; idx < M; idx++) {
		if (A[idx] == 1) {
			cost[idx] = 2;
		}
		else if (A[idx] == 7) {
			cost[idx] = 3;
		}
		else if (A[idx] == 4) {
			cost[idx] = 4;
		}
		else if (A[idx] == 2 || A[idx] == 3 || A[idx] == 5) {
			cost[idx] = 5;
		}
		else if (A[idx] == 6 || A[idx] == 9) {
			cost[idx] = 6;
		}
		else {
			cost[idx] = 7;
		}
	}

	for (size_t i = 1; i <= N; i++) {
		dp[i] = INT32_MIN;
		for (size_t j = 0; j < M; j++) {
			count[i % 8][j] = 0;
		}

		size_t select = (size_t)UINT32_MAX;
		for (size_t j = 0; j < M; j++) {
			if (cost[j] <= i) {
				if (dp[i] < dp[i - cost[j]] + 1) {
					select = j;

					dp[i] = dp[i - cost[j]] + 1;
				}
			}
		}

		if (select != (size_t)UINT32_MAX) {
			memcpy(count[i % 8], count[(i + 8 - cost[select]) % 8], sizeof(size_t) * 9);
			count[i % 8][select]++;
		}
	}

	size_t select = 0;
	for (size_t i = 0; i < M; i++) {
		for (size_t j = 0; j < count[N%8][i]; j++) {
			printf("%zu", A[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int N,M;
int A=0;
int day[10000];
cin>>N>>M;
for(int i = 0; i<M;i++){
    cin>>day[i];
    A+=day[i];
};

if((N-A)>=0){
    cout<<N-A<<endl;
}else
{
    cout<< -1 <<endl;
}
return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll n; cin >> n;
  fin(1. - (n / 2) * 1. / n);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

int main() {
    int a, b;
    cin >> a >> b;
    if (b < a) cout << a - 1 << endl;
    else cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	ll n, a;
	cin >> n;
	a = n;
	ll cnt = 0;
	while (a) {
		cnt += a % 10;
		a /= 10;
	}
	cout << (n%cnt ? "No" : "Yes") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.lang.Math.*;

public class Main {

	class Pair implements Comparable<Pair> {
		int a;
		int b;

		public Pair(int a, int b) {
			this.a = a;
			this.b = b;
		}

		public int compareTo(Pair p) {
			return this.b - p.b;
		}
	}

	void run() {
		// input
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if (m == 0) {
			System.out.println(n + 1);
			return;
		}
		Pair[] pair = new Pair[m];
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			pair[i] = new Pair(a, b);
		}
		Arrays.sort(pair);

		// debug
		// for (int i = 0; i < m; i++) {
		// System.out.println(pair[i].a + " " + pair[i].b);
		// }
		// System.out.println();

		Map<Integer, Integer> res = new TreeMap<Integer, Integer>();
		int key = pair[m - 1].b;
		int val = pair[m - 1].a;
		for (int i = m - 2; i >= 0; i--) {
			if (val <= pair[i].b) {
				val = min(val, pair[i].a);
				key = max(key, pair[i].b);
			} else {
				// ??????????????????
				if (res.containsKey(key)) {
					val = min(val, res.get(key));
				}
				res.put(key, val);
				key = pair[i].b;
				val = pair[i].a;
			}
		}
		res.put(key, val);

		// debug
		// for (Integer k : res.keySet()) {
		// System.out.println(k + " " + res.get(k));
		// }

		int count = 0;
		int pos = 0;
		for (Integer k : res.keySet()) {
			int back = res.get(k);
			count += ((k - pos) + (k - back) * 2);
			pos = k;
		}
		count += (n - pos + 1);
		System.out.println(count);
	}

	void run1() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		Pair[] pair = new Pair[m];
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			pair[i] = new Pair(a, b);
		}
		Arrays.sort(pair);

		int[] mark = new int[n];
		for (int i = 0; i < m; i++) {
			int s = pair[i].b - 1;
			int e = pair[i].a - 1;
			for (int j = e; j <= s; j++) {
				mark[j] = 1;
			}
		}

		int count = 0;
		int s = 0;
		for (int i = 0; i < n; i++) {
			if (mark[i] == 0) {
				count += s;
			} else {
				s++;
			}
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 30724
n = int(input())
a = [[0 for i in range(2)]for j in range(n)]
b = [[0 for i in range(2)]for j in range(n)]

for i in range(n):
    a[i][0] , a[i][1] = map(int, input().split())
for i in range(n):
    b[i][0] , b[i][1] = map(int, input().split())
    
ans = 0
    
a.sort(key=lambda x: x[1] , reverse = True)
b.sort(key=lambda x: x[0])

for j in b:
    for i in a:
        if i[0] < j[0] and i[1] < j[1]:
            a.remove(i)
            ans += 1
            break
            
print(ans)

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve() {
  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll mx = -1e18;
  mx = max(mx, a * c);
  mx = max(mx, a * d);
  mx = max(mx, b * c);
  mx = max(mx, b * d);
  cout << mx;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3648