akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000000007
#define MAXN 100005
#define ll long long
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define tc(t) int t;cin>>t;while(t--)
#define copy copy_n
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define frr(i,a,b) for(long long i=a;i>=b;i--)
#define frn(i,a,b,n) for(long long i=a;i<=b;i=i+n)
#define gcd(x,y) __gcd(x,y)
#define ld long double
#define um unordered_map
#define mkp make_pair
#define b_s binary_search
#define des greater<ll>()
#define fi first
#define se second
#define PI 3.1415926535
#define FP(n) fixed<<setprecision(n)
ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
void input(ll a[], ll sz) {fr(i, 0, sz) cin >> a[i];}
void print(ll a[], ll sz) {fr(i, 0, sz) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll maxr(ll a[], ll sz) {ll ma; fr(i, 0, sz) {if (i == 0) ma = a[i]; else if (a[i] > ma) ma = a[i];} return ma;}
ll minr(ll a[], ll sz) {ll mi; fr(i, 0, sz) {if (i == 0) mi = a[i]; else if (a[i] < mi) mi = a[i];} return mi;}
ll isprm(ll n) {
    if (n <= 1)  return 0;
    if (n <= 3)  return 1;
    if (n % 2 == 0 || n % 3 == 0) return 0;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return 0;
    return 1;
}
/*ll spf[MAXN];
void sieve()
{
    spf[1]=1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for(ll i=3;i*i<MAXN;i++)
    {
        if (spf[i]==i)
        {
            for (int j=i*i;j<MAXN;j+=i)
                if (spf[j]==j)
                    spf[j]=i;
        }
    }
}*/
ll power(ll x, ll y, ll p = mod)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
//a+b=xor(a,b)+2*(a&b)//
struct comp
{
    bool operator()(const pair<ll, ll> &a,
                    const pair<ll, ll> &b)const
    {
        if (a.fi == b.fi)
        {
            return (a.se > b.se); //second elem in descending
        }
        return (a.first < b.first);//first elem in ascending
    }
};














int main()
{
    fio;
    ll n,w;
    ll c[105],v[105],dp[105][100005];
    cin>>n>>w;
    fr(i,0,n)
    {
        cin>>c[i]>>v[i];
    }
    fr(i,0,105)
    fr(j,0,100005)
    dp[i][j]=0;
    for(ll i=n-1;i>=0;i--)
    {
        fr(j,0,w+1)
        {
            ll a=0,b=0;
            if((j+c[i])<=w)
            a=v[i]+dp[i+1][j+c[i]];
            b=dp[i+1][j];
            dp[i][j]=max(a,b);
        }
    }
    cout<<dp[0][0]<<"\n";
    return 0;
}


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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int H, W, N;
	cin >> N >> H >> W;
	N++;
	cout << (N-H) * (N-W) << endl;
}


void solve()
{
}





Measured memory_bytes: 256
# n = int(input())
a, b, c, d = map(int, input().split())
# x = list(map(int, input().split()))
i = 0
while True:
    if i%2 == 0:
        c -= b
        if c<=0:
            print("Yes")
            exit()
    else:
        a -= d
        if a<=0:
            print("No")
            exit()
    i += 1


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

using namespace std;


#define tie() ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long


int32_t main()
{
    int t = 1;
    //cin >> t;
    while(t--)
    {
    	string a , b;
        cin >> a >> b;
        for(int i = 0 ; i < (int)a.size();  i++)
        {
            if(a[i] != b[i])
            {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 3568
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int N, K;
int blackPointSumTable[1000][1000];
int whitePointSumTable[1000][1000];

int getBlackPointSum(int x, int y)
{
	if (x >= 0 && y >= 0) { return blackPointSumTable[x][y]; }
	else { return 0; }
}

int getWhitePointSum(int x, int y)
{
	if (x >= 0 && y >= 0) { return whitePointSumTable[x][y]; }
	else { return 0; }
}

int calcBlack(int x0, int y0, int x1, int y1)
{
	if (x0 >= K || y0 >= K) { return 0; }
	return getBlackPointSum(x1, y1)
	 - getBlackPointSum(x0 - 1, y1)
	 - getBlackPointSum(x1, y0 - 1) 
	 + getBlackPointSum(x0 - 1, y0 - 1);
}

int calcWhite(int x0, int y0, int x1, int y1)
{
	if (x0 >= K || y0 >= K) { return 0; }
	return getWhitePointSum(x1, y1)
	 - getWhitePointSum(x0 - 1, y1)
	 - getWhitePointSum(x1, y0 - 1) 
	 + getWhitePointSum(x0 - 1, y0 - 1);
}

int main() {
	cin >> N >> K;
	int blackPointTable[1000][1000];
	int whitePointTable[1000][1000];
	for (int i = 0; i < K; ++i)
	{
		for (int j = 0; j < K; ++j)
		{
			blackPointTable[i][j] = 0;
			blackPointSumTable[i][j] = 0;
			whitePointTable[i][j] = 0;
			whitePointSumTable[i][j] = 0;
		}
	}

	for (int i = 0; i < N; ++i)
	{
		char c;
		int x, y;
		cin >> x >> y >> c;
		if ((((x / K) + (y / K)) % 2 == 0) == (c == 'B'))
		{
			++blackPointTable[x % K][y % K];
		}
		else
		{
			++whitePointTable[x % K][y % K];
		}
	}

	blackPointSumTable[0][0] = blackPointTable[0][0];
	whitePointSumTable[0][0] = whitePointTable[0][0];
	for (int i = 1; i < K; ++i)
	{
		blackPointSumTable[0][i] = blackPointSumTable[0][i - 1] + blackPointTable[0][i];
		blackPointSumTable[i][0] = blackPointSumTable[i - 1][0] + blackPointTable[i][0];
		whitePointSumTable[0][i] = whitePointSumTable[0][i - 1] + whitePointTable[0][i];
		whitePointSumTable[i][0] = whitePointSumTable[i - 1][0] + whitePointTable[i][0];
	}

	for (int x = 1; x < K; ++x)
	{
		for (int y = 1; y < K; ++y)
		{
			blackPointSumTable[x][y] = 
			 blackPointSumTable[x - 1][y]
			 + blackPointSumTable[x][y - 1]
			 - blackPointSumTable[x - 1][y - 1]
			 + blackPointTable[x][y];
			whitePointSumTable[x][y] = 
			 whitePointSumTable[x - 1][y]
			 + whitePointSumTable[x][y - 1]
			 - whitePointSumTable[x - 1][y - 1]
			 + whitePointTable[x][y];
		}
	}

	int maxPoint = 0;
	for (int x = 0; x < K; ++x)
	{
		for (int y = 0; y < K; ++y)
		{
			int point = calcBlack(0, 0, x, y)
			+ calcBlack(x + 1, y + 1, K - 1, K - 1)
			+ calcWhite(0, y + 1, x, K - 1)
			+ calcWhite(x + 1, 0, K - 1, y);

			if (point < N - point)
			{
				point = N - point;
			}
			if (point > maxPoint)
			{
				maxPoint = point;
			}
		}
	}
	cout << maxPoint << endl;

	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;

vector<vector<ll>> dp_arr;

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> arr(n, vector<int>(n));
	for(int i = 0 ;i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> arr[i][j];
		}
	}
	vector<vector<int>> dp_arr(n+1, vector<int>((1<<n)+1,0));
	dp_arr[0][0] = 1;
	for(int j = 1; j < (1<<n); j++)
	{
		int i = __builtin_popcount(j);
		for(int k = 0; k < n; k++)
		{
			// cout << "i: " << i << " k: " << k << " arr: " << arr[i-1][k] << " j: " << j << " res: " << (((j >> k) & 1) != 1) << endl;
			if(arr[i-1][k] == 1 && ((j >> k) & 1) == 1)
			{
				// cout << "hello" << endl;
				dp_arr[i][j] = (dp_arr[i][j]%MOD + dp_arr[i-1][j ^ (1 << k)]%MOD)%MOD;
			}
		}
		// cout << "i: " << i << " j: " << j << " dp: " << dp_arr[i][j] << endl;
	}
	cout << dp_arr[n][(1<<n)-1] << endl;
	return 0;
}


Measured memory_bytes: 188800
#include <stdio.h>
#include <string.h>

int main(void){
   
   int N;
   
   scanf("%d",&N);
   
   char S[N];
   
   scanf("%s",S);
   
   int red = 0;
   int blue = 0;
   int i;
   
   for(i = 0;i < N;i++){
      if(S[i] == 'R'){
         red = red + 1;
      }
      else {
         blue = blue + 1;
      }
   }
   
   
   if(red > blue){
      printf("Yes\n");
   }
   else {
      printf("No\n");
   }
   
   return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')] * n
dp[0] = 0

for i in range(1, n):
  for j in range(1, k+1):
    if(i-j < 0):
      break
    dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]))

print(dp[-1])


Measured memory_bytes: 85676
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    cin>>n>>k;
    ll cnt=0;
    FOR(i,n)
    {
        cin>>a;
        if(a>=k) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}
/*
5
4
3
2
3
4
4
3
3
4
2
3
*/


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


void Main(){
   int N;
   cin >> N;
   vector<int> a(N);
  rep(i,N)cin >> a[i];
  
  auto f = [&](int j){
     int sum = 0;
      rep(i,N){
         sum += (j-a[i])*(j-a[i]);
      }
    return sum; 
  };
  
  int mintemp = INT_MAX;
  int jtemp;
  rep3(j,-100,100){
    if(mintemp > f(j)){
       mintemp = f(j);
       jtemp = j;
    }
  }
  cout << mintemp << endl;
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int N;cin >> N;
    vector<LL> A(N+1);
    vector<LL> B(N);
    rep(i,N+1){
        cin >> A[i];
    }
    rep(j,N){
        cin >> B[j];
    }
    LL sum = 0;
    vector<LL> t(N+1);
    t = A;
    for(int i = N;i > 0;i--){
        if(i == N)A[i-1] += A[i];
        if(A[i-1] - B[i-1] >= 0){
            if(i != 1){
                if(t[i-1] < A[i-1] - B[i-1]){
                    A[i-2] += t[i-1];
                }
                else{
                    A[i-2] += (A[i-1] - B[i-1]);
                }              
            }
            sum += B[i-1];
        }
        else{
            sum += A[i-1];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int main(){
	while(true){
		int n,m,h,k;	cin>>n>>m>>h>>k;
		if(n==0)	return 0;
		vector<int> s(n);
		for(int i=0;i<n;i++)	cin>>s[i];
		vector<pii> d;
		for(int i=0;i<m;i++){
			int a,b;	cin>>a>>b;	a--;
			d.push_back(make_pair(b,a));
		}
		sort(d.begin(),d.end());
		vector<int> point(n),iti(n);
		for(int i=0;i<n;i++)	iti[i]=i;
		vector<pii> e(m);
		for(int i=0;i<m;i++){
			e[i].first=iti[d[i].second];	e[i].second=iti[d[i].second+1];
			swap(iti[d[i].second],iti[d[i].second+1]);
		}
		for(int i=0;i<n;i++)	point[iti[i]]=s[i];
		int sum=0;
		for(int i=0;i<k;i++)	sum+=point[i];
		int ans=sum;
		for(int i=0;i<m;i++){
			int a=e[i].first,b=e[i].second;
			if(a>b)	swap(a,b);
			if(a<k&&k<=b){
				int tmp=sum-point[a]+point[b];
				ans=min(ans,tmp);
			}
		}
		cout<<ans<<endl;
	}
}

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

void program(); 
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    program();
}

#define INF 0x7fffffffffffffff
#define UINF 0xffffffffffffffff
#define MOD 1000000007

#define int long long
#define unsigned unsigned long long
#define double long double

#define endl "\n"

int pow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

class UF{
public:
    int n;
    vector<int> par, sz;
    UF(int size) : n(size), par(size), sz(size){
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }
    void join(int x, int y){
        if ((x = find(x)) == (y = find(y))) return;
        if (sz[y] < sz[x]) std::swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        sz[x] = 0;
    }
    int find(int x){ return par[x] = (x == par[x] ? x : find(par[x])); }
    bool connected(int x, int y){ return find(x) == find(y); }
};

template<class Iter> void _print_range(ostream& o, Iter s, Iter e){
    for(;s != e;s++) o << *s << " ";
    o << endl;
} 
template<class T> std::ostream& operator<<(ostream& o, const std::vector<T> &ds)
{
    _print_range(o,ds.begin(),ds.end()); 
    return o;
}
template<class T> std::ostream& operator<<(ostream& o, const std::set<T> &ds)
{
    _print_range(o,ds.begin(),ds.end()); 
    return o;
}
template<class T, class U> std::ostream& operator<<(ostream& o, const std::pair<T,U> &ds)
{
    o << "<" << ds.first << "," << ds.second << ">" << endl;
    return o;
}
template<typename ...Args>
void print(Args&&... args) {
    for(auto&& x: {args...})
        cout << x << " ";
    cout << endl;
}

#define debug(x) cout << "DEBUG    " <<  #x << ": " << x << endl;

#define fr(i, a, b) for(int i = a; i != (b); i += (a<b ? 1 : -1))
#define rep(i, a) for(int i = 0; i < (a); i++)

#define trav(x, a) for(auto& x : a)
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define vi vector<int>
#define si set<int>
#define pii pair<int,int>


#define N 105
#define W 100005
int weight[N], v[N];
int dp[W];
void program(){
    int n,w;
    cin>>n>>w;
    rep(i,n) cin>>weight[i]>>v[i];
    fill(dp,dp+W,0);
    for(int j=0;j<n;j++) for(int i=w;i>=0;i--) if(i-weight[j]>=0)
            dp[i] = max(dp[i], v[j]+dp[i-weight[j]]);
    cout << *max_element(dp,dp+w+1) << endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-bruteforce?
-reduce dimensionality with problem contraints?
*/


Measured memory_bytes: 1024
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int n;
int64 a[3030];
//int64 dp[3030][3030];
int64 memo[3030][3030];
bool used[3030][3030];

int64 dp(int left, int right) {
  if (left > right) return 0;
  if (used[left][right]) return memo[left][right];
  used[left][right] = true;

  int turn = (left + right + 1) - n;

  int64 res;

  if (turn % 2 == 0) {
    res = -INF64;
    chmax(res, dp(left + 1, right) + a[left]);
    chmax(res, dp(left, right - 1) + a[right]);
  } else {
    res = INF64;
    chmin(res, dp(left + 1, right) - a[left]);
    chmin(res, dp(left, right - 1) - a[right]);
  }
  
  memo[left][right] = res;

  return memo[left][right];
}

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

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

  cout << dp(0, n - 1) << '\n';
  
  return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll k;
    cin >> k;
    vl ans(50,k/50-k%50);
    rep(i,50) ans[i] += i;
    rep(i,k%50) ans[i] += 51;
    cout << 50 << endl;
    rep(i,50) cout << ans[i] << (i == 49 ? "\n" : " ");
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdlib.h>
#include <string.h>

using namespace std;

int N,M,r,q;
typedef struct{
	int t,n,m,s;
} LOG;

bool time_table[10000+1][1260 - 540 + 1];

void solve()
{
	memset(time_table,0,sizeof(time_table));

	cin>>r;
	vector<LOG> logs(r);
	for(int i = 0;i < r; i++){
		cin >> logs[i].t >> logs[i].n >> logs[i].m >> logs[i].s;
	}

	int count[10001]={0},t[10001] = {0};
	for(int j = 0; j < r; j++){
		int m = logs[j].m;
		if(count[m] == 1 && logs[j].s == 0)
			for(int k = t[m]; k < logs[j].t - 540; k++)
				time_table[m][k] = true;

		if(count[m] == 0 && logs[j].s == 1)
			t[m] = logs[j].t - 540;
		count[m] += (logs[j].s == 1) ? 1 : -1; //ツカツウツδ督トツづーツ堕敖個クツつウツつケツづゥ
	}

	cin >> q;
	for(int i = 0;i < q; i++){
		int ts,te,m;
		cin >> ts >> te >> m;
		int ans = 0;
		for(int i = ts - 540; i < te - 540; i++){
			ans += time_table[m][i];
		}
		cout << ans << endl;
	}


}

int main()
{
	while(cin >>N >>M,(N||M)){
		solve();
	}
	return 0;
}

Measured memory_bytes: 8036
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    // Your code here!
 ll ans,n,x,m;
 m=INT_MIN;
 ans=0;
 cin >> n;
 while(n--)
 {
  cin >> x;
  if(m!=INT_MIN)
  ans+=max((ll)0,m-x);
  m=max(m,x);
 }
 cout << ans;
 return 0;
}

Measured memory_bytes: 3616
import sys

def binarySearch(A,key):

	left = 0
	right = len(A)

	while left < right:

		mid = (left + right) // 2

		if A[mid] == key:
			return mid
		elif key < A[mid]:
			right = mid
		else:# A[mid] < key
			left = mid + 1

	return -1

def test():

	n = int(sys.stdin.readline())
	S = list(map(int,sys.stdin.readline().split()))
	q = int(sys.stdin.readline())
	T = list(map(int,sys.stdin.readline().split()))

	count = 0

	for i in range(q):
		find = binarySearch(S,T[i])
		if find != -1:
			count += 1

	print(f"{count}")

if __name__ == "__main__":
	test()



Measured memory_bytes: 16188
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A[2001];
typedef pair<LL,int>P;
vector<P>v;
LL dp[3001][3001];
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		v.push_back(P(A[i],i));
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	REP(i,N+1){
		REP(j,3000){
			dp[i][j]=-1e18;
		}
	}
	dp[0][0]=0;
	REP(i,N){
		P p=v[i];
		int now=p.second;
		REP(j,2500){
			dp[i+1][j+1]=max(dp[i+1][j+1],abs(j-now)*A[now]+dp[i][j]);
			dp[i+1][j]=max(dp[i+1][j],abs(N-1-(i-j)-now)*A[now]+dp[i][j]);
		}
		/*REP(j,5){
			cout<<dp[i+1][j]<<endl;
		}
		cout<<endl;*/
	}
	LL ans=0;
	REP(i,2001){
		ans=max(ans,dp[N][i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int prob;
    int allprob[n+1] = {0};
    int allpenalties[n+1] = {0};
    string verdict;
    int solved = 0;
    int total_penalty = 0;
    for (int i=0; i<m; i++){
        cin>>prob>>verdict;
        if (verdict=="AC" and allprob[prob]==0){
            allprob[prob] = 1;
            total_penalty += allpenalties[prob];
            solved++;
        }
        else if(verdict=="WA" and allprob[prob]==0){
            allpenalties[prob]++;
        }
    }
    cout<<solved<<" "<<total_penalty;
    return 0;
}

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


void solve(std::string S){
  cout << S.substr(0,3) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
  std::cin >> S;
    solve(S);
    return 0;
}


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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    int right = 0, now[25] = {0};
    lint ans = 0;
    rep(left, n){
        while(right < n){
            bool flag = false;
            int tmp[25];
            rep(j, 20){
                if(a[right] >> j & 1){
                    if(now[j] > 0){
                        flag = true;
                        break;
                    }
                    tmp[j] = 1;
                }else{
                    tmp[j] = 0;
                }
            }
            if(flag){
                break;
            }
            rep(j, 20){
                now[j] += tmp[j];
            }
            right++;
        }
        ans += (right - left);
        rep(j, 20){
            if(a[left] >> j & 1){
                now[j]--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main(){
  int N,V[20],C[20],ans = 0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }

  for(int i = 0; i < N; i++){
    if(V[i] > C[i])
      ans+= V[i] - C[i];
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;class Main{public static void main(String[]g)throws Exception{int i,a,x,y;float b;BufferedReader B=new BufferedReader(new InputStreamReader(System.in));for(String s;(s=B.readLine())!=null;){g=s.split(",");x=Integer.valueOf(g[10]);y=Integer.valueOf(g[11]);for(a=i=0;i<10;)a+=Integer.valueOf(g[i++]);b=x+y;b=a*x/b;for(a=i=0;i<10;i++){a+=Integer.valueOf(g[i]);if(b<=a){System.out.println(i+1);break;}}}}}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll n, x,diff=100000000;
	bool res = true;
	cin >> n >> x;
	vector<ll>city(n),vdiff(n-1);
	rep(i, n)cin >> city[i];
	if (n == 1) { cout << abs(x - city[0]); return 0; }
	rep(i, n - 1)diff = min(diff, gcd(abs(city[i] - x), abs(city[i + 1] - x)));
	cout << diff << endl;
	return 0;
}



Measured memory_bytes: 4852
using System;

namespace atcoder_2
{
    class Class1
    {

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

            if (N >= 30)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 27464
use proconio::input;
use proconio::marker::Chars;

fn main() {
	input! {
		mut a: i32,
		mut b: i32,
		mut c: i32,
		mut k: i32,
	}
	if k < a {
		println!("{}", k);
	} else if k >= a && k <= a + b {
		println!("{}", a);
	} else if k > a + b && k <= a + b + c {
		println!("{}", a - (k - (a + b)));
	} else if k > a + b + c {
		if a - c < 0 {
			println!("0");
			return;
		}
		println!("{}", a - c);
	}
}


Measured memory_bytes: 2144
import sys
inp = lambda t: t(sys.stdin.readline().strip())
inpm = lambda t: map(t, sys.stdin.readline().split())
inpl = lambda t: list(map(t, sys.stdin.readline().split()))

s = inp(str)

p = set()
for i in s:
	if i not in p:
		p.add(i)

for i in range(ord('a'), ord('z') + 1):
	if chr(i) not in p:
		print(chr(i))
		break
else:
	print('None')

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

int main(){
	int a,b;
	cin >> a >> b;
	if((a * b )%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;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}
 
int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  ll ans = a+b+c;
  ans -= max(a, max(b, c));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 
string change(string s, char c){
	string ret;

	if(c == 'J'){
		ret += s[s.size() - 1];
		for(int i = 0; i < s.size() - 1; i++) ret += s[i];
	}else if(c == 'C'){
		for(int i = 1; i < s.size(); i++) ret += s[i];
		ret += s[0];
	}else if(c == 'E'){
		ret = s;
		for(int i = 0; i < s.size() / 2; i++){
			ret[i] = s[(s.size() - 1) / 2 + 1 + i];
			ret[(s.size() - 1) / 2 + 1 + i] = s[i];
		}
	}else if(c == 'A'){
		ret = s;
		reverse(all(ret));
	}else if(c == 'M'){
		ret = s;
		for(int i = 0; i < ret.size(); i++){
			if(ret[i] >= '0' && ret[i] < '9') ret[i]++;
			else if(ret[i] == '9') ret[i] = '0';
		}
	}else{
		ret = s;
		for(int i = 0; i < ret.size(); i++){
			if(ret[i] == '0') ret[i] = '9';
			else if(ret[i] > '0' && ret[i] <= '9') ret[i]--;
		}
	}

	return ret;
}


int main(){
	int n;
	cin>>n;
	string s, t;
	for(int i = 0; i < n; i++){
		cin>>s>>t;
		for(int i = 0; i < s.size(); i++){
			t = change(t, s[s.size() -1 -i]);
			//cout<<s[i]<<" "<<t<<endl;
		}
		cout<<t<<endl;
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N, vector<int>());
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> C(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        sum += C[i];
    }

    sort(C.begin(), C.end(), greater<int>());
    int res = sum - C[0];

    vector<int> D(N, 0);
    queue<int> que;
    vector<bool> visited(N, false);
    que.push(0);
    visited[0] = true;
    int cnt = 0;
    while (!que.empty()) {
        int u = que.front(); que.pop();
        D[u] = C[cnt++];
        for (int v : G[u]) {
            if (visited[v]) continue;
            visited[v] = true;
            que.push(v);
        }
    }

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

    return 0;
}

Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem118c(n, a))
}

fun problem118c(n: Int, a: List<Long>): Long {
    /**
     * 最大公約数
     * @param big 2つの値の大きな方
     * @param small 2つの値の小さな方
     */
    fun computeGreatestCommonDivisor(big: Long, small: Long): Long {
        val rest = big % small
        return if (rest == 0L) small else computeGreatestCommonDivisor(small, rest)
    }
    var num = a[0]
    for (i in 1 until n) {
        num = computeGreatestCommonDivisor(Math.min(a[i], num), Math.max(a[i], num))
    }
    return num
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int n, k, x, y; cin >> n >> k >> x >> y;
  int64_t ans = 0;
  rep(i, n) {
    if (i < k) {
      ans += x;
    } else {
      ans += y;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N,M,X=map(int, input().split())
a_ls=[[0]*(M+1) for i in range(N)]
for i in range(N):
	a_ls[i]=list(map(int, input().split()))


def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

flag=0
cost=[]

import numpy as np

for i in range(2**N):
	price=0
	target=str(Base_10_to_n(i,2)).zfill(N)
	training=np.array([0]*M)
	for j in range(len(target)):
		if target[j]=="1":
			training=training+np.array(a_ls[j][1:])
			price+=a_ls[j][0]
	
	if sum(training>=np.array([X]*M))==M:
		flag=1
		cost+=[price]


if flag==1:
	print(str(min(cost)))
else:
	print("-1")



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

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

int main() {
    int n, t;
    cin >> n >> t;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll s[n], b[n];
    b[0] = a[0];
    s[n - 1] = a[n - 1];
    for (int i = 1; i < n; i++) {
        b[i] = min(b[i - 1], a[i]);
    }
    for (int i = n - 2; i >= 0; i--) {
        s[i] = max(s[i + 1], a[i]);
    }

    ll dif[n];
    ll mx = 0;
    for (int i = 0; i < n; i++) {
        dif[i] = s[i] - b[i];
        mx = max(mx, dif[i]);
    }

    set<pair<ll, ll> > st;
    for (int i = 0; i < n; i++) {
        if (dif[i] == mx) {
            st.insert(pair<ll, ll>(b[i], s[i]));
        }
    }

    cout << st.size() << endl;




    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 


fast;

ll a,b,c,k;
cin>>a>>b>>c>>k;

if(a>=k)
  cout<<k<<endl;
else if(a+b>=k)
  cout<<a<<endl;
else 
{
  ll rem=k-a-b;
  cout<<a-rem<<endl;
}



}

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

const int N = 5007, mo = 1e9 + 7;
int n, dp[N][N], sz[N], g[N], tmp[N];
int tot, to[N << 1], nex[N << 1] , head[N << 1];

void add(int x, int y) {
	to[++tot] = y;
	nex[tot] = head[x];
	head[x] = tot;
}

void dfs(int u, int fa) {
	sz[u] = 1;
	dp[u][1] = 1;
	for (int i = head[u]; i; i = nex[i]) {
		int v = to[i];
		if (v ^ fa) {
			dfs(v, u);
			for (int A = 0; A <= sz[u] + sz[v]; ++ A) tmp[A] = 0;
			for (int A = 1; A <= sz[u]; ++ A) {
				for (int B = 0; B <= sz[v]; ++ B) {
					(tmp[A + B] += (dp[u][A] * dp[v][B]) % mo) %= mo;
				}
			}
			for (int A = 1; A <= sz[u] + sz[v]; ++ A) dp[u][A] = tmp[A];
			sz[u] += sz[v];
		}
	}
	for (int i = 2; i <= sz[u]; i += 2) {
		(dp[u][0] += (mo - dp[u][i] * g[i] % mo) % mo) %= mo;
	}
//	if (u == 1) std::cerr << '\n';
//	for (int i = 0; i <= sz[u]; ++ i)
//	std::cerr << u << ' ' << dp[u][i] << '\n';
//	std::cerr << '\n';
}

signed main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
	std::cin >> n;
	for (int i = 1, x, y; i < n; ++ i) {
		std::cin >> x >> y;
		add(x, y);
		add(y, x);
	}
	g[0] = 1;
	for (int i = 2; i <= n; i += 2) g[i] = g[i - 2] * (i - 1) % mo;
	dfs(1, 0);
	std::cout << (-dp[1][0] + mo) % mo << '\n';
	return 0;
}

Measured memory_bytes: 92556
#include <algorithm>
#include <cstdio>
#include <cstring>

const int MaxN = 100, MaxM = 100;
const int INF = 0x7F7F7F7F;

int N, M;
char Mp[MaxN + 5][MaxM + 5];
int Dp[MaxN + 5][MaxM + 5];

void init() {
  scanf("%d %d", &N, &M);
  memset(Mp, '.', sizeof Mp);
  for (int i = 1; i <= N; ++i)
    scanf("%s", Mp[i] + 1);
}

void solve() {
  memset(Dp, 0x7F, sizeof Dp);
  Dp[1][1] = (Mp[1][1] == '#');
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) {
      if (Mp[i][j] == '.') {
        Dp[i][j] = std::min(Dp[i][j], Dp[i - 1][j]);
        Dp[i][j] = std::min(Dp[i][j], Dp[i][j - 1]);
      } else {
        Dp[i][j] = std::min(Dp[i][j], Dp[i - 1][j] + (Mp[i - 1][j] == '.'));
        Dp[i][j] = std::min(Dp[i][j], Dp[i][j - 1] + (Mp[i][j - 1] == '.'));
      }
    }
  printf("%d\n", Dp[N][M]);
}

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


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

using namespace std;

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

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a.size() < b.size()) {
        a = b;
        return 1;
    }

    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

string dp[10010];


void solve(long long N, long long M, std::vector<long long> A) {
    for (int i = 0; i < 10010; i++)
        dp[i] = "";

    int cnt[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < A.size(); j++) {
            if( i == 0 || dp[i] != "") {
                if (i + cnt[A[j]] > N) continue;
                chmax(dp[i + cnt[A[j]]], dp[i] + string(1, '0' + A[j]));
            }
        }
    }
    cout << dp[N] << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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

mod = 10**9 + 7
tota = 0
totd = 0

for i in range(N): # iは0からN-1
    for j in range(i+1, N): # jはi+1からN-1
        if A[i] > A[j]:
            tota += 1
    for k in range(N): # kは0からN-1
        if A[i] > A[k]:
            totd += 1

ans = (tota * K + K*(K-1)//2 * totd) % mod # ここで除算の小数点以下は切り捨てなかったせいで答えが合わなかった...
print(int(ans))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+1;
int n,k,h[maxn],dp[maxn];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>h[i];
	fill(dp,dp+maxn,1e9+5);dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+k;j++)
		{
			if(j<n)dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	if(n%2==0){
		ll c = 10;
		while(n/c>0){
			ans += n/c;
			c*=5;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math


N = int(input())

AB = []

for a in range(1, int(N ** 0.5) + 1):
    if N % a == 0:
        b = math.log10(N // a) + 1
        a = math.log10(a) + 1
        AB.append((a, b))

ans = min([max(a, b) for a, b in AB])
print(int(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <iomanip>

int main(int argc, char const *argv[])
{
	int a, b;
	std::cin >> a >> b;
	std::cout << a/b << " " << a%b << " " << std::fixed << std::setprecision(11) << (double)a/b << std::endl;
	return 0;
}


Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define INFL 1000000000000000018
#define MOD 1000000007
#define MAXN 200005
#define MAXM 200005

ll h, w, ans = INFL;

ll mx(ll a, ll b){
    return a > b ? a : b;
}

ll mn(ll a, ll b){
    return a < b ? a : b;
}

int main()
{
    cin >> h >> w;
    if((h * w) % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    REP(i, 1, h){
        ll a = i * w, b = (h - i) * ((w + 1) / 2), c = (h - i) * (w / 2);
        ll ma = mx(a, mx(b, c));
        ll mi = mn(a, mn(b, c));
        ans = mn(ans, (ma - mi));
        //printf("ans %lld\n", ans);
    }
    REP(i, 1, w){
        ll a = i * h, b = (w - i) * ((h + 1) / 2), c = (w - i) * (h / 2);
        ll ma = mx(a, mx(b, c));
        ll mi = mn(a, mn(b, c));
        ans = mn(ans, (ma - mi));
        //printf("ans %lld\n", ans);
    }
    if(w != 2 && h != 2){
        ll a = ((w + 2) / 3) * h - (w / 3) * h;
        ans = mn(ans, a);
        //printf("ans %lld\n", ans);
        ll b = ((h + 2) / 3) * w - (h / 3) * w;
        ans = mn(ans, b);
        //printf("ans %lld\n", ans);
    }
    cout << ans << endl;


    return 0;
}
/*
*/





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll ncr(int a,int b)
{
    if(b==1)
        return a;
    if(a==b)
        return 1;
    return ncr(a-1,b-1)+ncr(a-1,b);
}
int main()
{
    ll n,m,a,b;
    cin>>n>>m;
    if(n<=1)
        a=0;
    else
        a=ncr(n,2);
    if(m<=1)
        b=0;
    else
        b=ncr(m,2);
    cout<<a+b<<endl;

    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  string N;
  cin>>N;
  for(auto it:N){
    if(it=='7'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
 
 
int main(){
    ll H; cin >> H;
    int cnt = 0;
    ll ans = 0;
    while(H > 0){
        ans += 1LL<<cnt;
        H /= 2;
        cnt++;
    }
    cout << ans << endl;
}

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

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

int main(void){
	long long N,M,K;
	cin >> N >> M >> K;
	if(K<=N) cout << N-K <<' '<< M << endl;
	else if(M-K+N>0) cout << 0 <<' '<< M-K+N << endl;
	else cout << 0 << ' ' << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
    {
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        iter.next().unwrap().parse::<$t>().unwrap()
    }
);

( $( $t:ty), +) => (
{
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace();
    ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
}
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(n: u32) -> Vec<u32> {

    if n == 3 {
        return vec![2,5,63];
    } else if n == 4 {
        return vec![2,5,20,63];
    } else if n == 5 {
        return vec![2,5,20,30,63];
    }

    let mut k = 0;
    let mut v = Vec::new();
    let mut sum = 0;
    for i in 1..n+1 {
        let x = match i % 4 {
            1 => { 6*k + 2},
            2 => { 6*k + 3},
            3 => { 6*k + 4},
            0 => {
                k += 1;
                6*k
            },
            _ => unreachable!()
        };
        v.push(x);
        sum += x;
    }

    match sum % 6 {
        0 => {},
        2 => {
            v[4] = 30000;
        },
        5 => {
            v[5] = 29998;
        },
        3 => {
            v[5] = 30000;
        },
        _ => unreachable!()
    }
    v
}

fn main() {
    let n = parse_line!(u32);
    println!("{}", solve(n).iter().map(|i| i.to_string()).collect::<Vec<String>>().join(" "));
}

#[cfg(test)]
mod unit_test {
    use super::*;

    fn gcd(a: u64, b: u64) -> u64 {
        let x = a % b;
        if x == 0 {
            b
        } else {
            gcd(b, x)
        }
    }

    #[test]
    fn gcd_test() {
        assert_eq!(gcd(2,3), 1);
        assert_eq!(gcd(63, 49) , 7);
    }

    fn check(v: Vec<u32>) {
        let sum = v.iter().fold(0 as u64, |sum, x| sum + *x as u64);
        for x in v.iter() {
            assert_ne!(gcd(*x as u64, sum),1);
        }
        assert_eq!(v.iter().fold(v[0] as u64, |g, x| gcd(g as u64, *x as u64)), 1);

        let m = v.iter().fold(0, |max, x| if max < *x { *x} else { max });
        println!("m = {}", m);
        assert!(m <= 30000);
    }

    #[test]
    fn solve_test() {
        for n in 3..100 {
            check(solve(n));
        }

        check(solve(20000));
        check(solve(19999));
        check(solve(19998));
    }
}


Measured memory_bytes: 4476
//In The Name of Allah
//Fri 12/2/97
#include <bits/stdc++.h>

#define Init ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define forar(i,n) for(long long int i = 0; i < n;i++)
#define fori(i,a,b) for(long long int i = a; i < b;i++)
#define WFile freopen("test.in","r",stdin),freopen("test.out","w",stdout)
#define Log(x) cout << "Log: " << x << endl;
#define F first
#define S second
#define pb push_back
#define mp make_pair

using namespace std;

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

const ll mod = 1e9+7,M = 2e5+100;

void Solution();

int32_t main()
{
	Init;
	Solution();
	return 0;
}

inline void Solution(){
	int n;
	cin >> n;
	vector<bool> sve(55555);
	fori(i,2,55555){
		if(!sve[i]){
			if(i%5==1){
				cout << i << " ";
				if(--n == 0)
					return;
			}
		}
		for(int j = 2*i;j < 55555;j+=i)
			sve[j] = 1;
	}
}


Measured memory_bytes: 256