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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}

ll pw[Sz];
ll f[Sz*3];

ll inv (ll a) {
	ll b = Mod-2;
	a%=Mod;
	ll ans = 1;
	while(b) {
		if (b&1)
			ans = (ans*a)%Mod;
		a = (a * a) % Mod;
		b >>= 1;
	}
	return ans;
}

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int x, y;
  cin >> x >> y;
  
  f[0] = 1;
  for (int i = 1; i <= (int)3e6; i++)
  	f[i] = (f[i-1] * i)%Mod;

  ll ans = 0;
  for (int i = 0; i <= min(x,y); i++) {
  	int nx = x-i;
  	int ny = y-2*i;
  	if (nx%2 == 1 || nx < 0 || ny < 0)
  		continue;
  	int j = nx/2;
  	if (nx/2==ny)
  	{
  		ll pw = f[i+j] * inv(f[i] * f[j]) % Mod;
  		cout << pw << endl;
  		return 0;
  	}
  }
  cout << ans;
  return 0;
}






// Coded by Z..

Measured memory_bytes: 24832
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, k, a[N * 2], last;
ll ps[N * 2], ans;
std::map<int, int> map;

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), ps[i] = ps[i - 1] + a[i];
    last = 0;
    map[0] = 1;
    for (int i = 1; i <= n; i++) {
        if (i - last >= k) {
            map[(int)((ps[last] - last) % k)]--;
            last++;
        }
        ans += map[(int)((ps[i] - i) % k)];
        map[(int)((ps[i] - i) % k)]++;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 11904
def framod(n, a=1, mod=10**9+7):
    for i in range(1,n+1):
        a = a * i % mod
    return a


def power(n, r, mod=10**9+7):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod


def comb(n, k, mod=10**9+7):
    if n < k or k < 0:
        result = 0
    else:
        print(n, k)
        a = framod(n, a=1, mod=mod)
        b = framod(k, a=1, mod=mod)
        c = framod(n-k, a=1, mod=mod)
        result = (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod
    return result


MOD = 10**9 + 7
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

comb1 = [0]*N
comb1[K-1] = 1
for j in range(K+1, N+1):
  comb1[j-1] = comb1[j-2]*(j-1)*power(j-K, MOD-2) % MOD

comb2 = comb1[::-1]
ans = 0
for c1, c2, a in zip(comb1, comb2, A):
  ans = (ans + (c1-c2)*a)%MOD

print(ans)

Measured memory_bytes: 14416
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(unsigned int i=1;i<=s.size();i++)
    {
        if(i%2==1&&s[i-1]=='L')
        {
            cout<<"No";
            return 0;
        }
        if(i%2==0&&s[i-1]=='R')
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<int> v[2005];
string s;
int cnt[2005],sum[2005];
void pre(int node,int p)
{
	cnt[node]=s[node-1]-'0';
	sum[node]=0;
	for (int u:v[node])
	{
		if (u!=p)
		{
			pre(u,node);
			cnt[node]+=cnt[u];
			sum[node]+=sum[u]+cnt[u];
		}
	}
}
int dfs(int node,int p)
{
	int h=-1,mx=0;
	for (int u:v[node])
	{
		if (u!=p && sum[u]+cnt[u]>mx)
		{
			h=u;
			mx=sum[u]+cnt[u];
		}
	}
	if (h==-1)
	return 0;
	int s=sum[node]-mx;
	mx=dfs(h,node)+cnt[h];
	if (mx<=s)
	return sum[node]%2;
	else
	return mx-s;
}
int main()
{
	int n,ans=1e9;
	cin >> n >> s;
	for (int i=1;i<n;i++)
	{
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i=1;i<=n;i++)
	{
		pre(i,0);
		if (!dfs(i,0))
		ans=min(ans,sum[i]/2);
	}
	if (ans==1e9)
	ans=-1;
	cout << ans;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll a;
    cin >> a;
    cout << a + a * a + a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3652
n = int(input())
List = [list(map(int,input().split())) for i in range(n)]

def dis(a, b):
  return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**(1/2)

def sumdis(m):
  res = 0
  for i in range(0,n-1):
    for j in range(i+1,n):
      res += dis(m[i], m[j])
  return res*2/n

print(sumdis(List))

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
void solve(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair 
# define all(x) x.begin(),x.end()                                                      
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;

ll power(ll x,ll y,ll m){            //power(x,y)=x^y  %m;
	if(y==0)return 1;
	int ll a=power(x,y/2,m);
	if(y%2){
		return (a*((a*x)%m))%m;
	}
	else{
		return (a*a)%m;
	}
}
ll mod_inverse(ll x,ll m){
	return power(x,m-2,m);
}
ll fact(ll n,ll m){
	if(n<=1)return 1;
	return (fact(n-1,m)*n)%m;
}
ll ncr(ll n,ll r,ll m){
	ll n1=1,d1=1,d2=1;
	n1=fact(n,m);d1=fact(r,m);d2=fact(n-r,m);
	ll ans=mod_inverse((d1*d2)%m,m);
	ans=(ans*n1)%m;
	return ans;
}
int main()
{
	ll n;
	cin>>n;
	while(n!=0){
		if(n%10==7){
			cout<<"Yes"<<'\n';return 0;
		}
		n=n/10;
	}
	cout<<"No"<<'\n';
	return 0;
}




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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long k = sc.nextLong();
    int n = sc.nextInt();

    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }

    long sum = 0;

    long[] data = new long[n+1];
    data[n] = k-a[n-1];
    data[0] = a[0];

    for (int i = 1; i < n; i++) {
      data[i] = a[i]-a[i-1];
    }

    // for (int i = 0; i <= n; i++) {
    //   System.out.println(data[i]);
    // }

    Arrays.sort(data);

    for (int i = 0; i < n; i++) {
      sum += data[i];
    }

    long ans = 0;

    for (int i = n-1; i > 0; i--) {
      ans += a[i]-a[i-1];
    }

    System.out.println(Math.min(ans,sum));

  }

}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    int64 n;
    map<PLL, int64> mp;
    cin >> n;
    REP(i, n) {
        REP(j, n) {
            int64 a;
            cin >> a;
            if (mp.count(minmax(i, j))) {
                chmin(mp[minmax(i, j)], a);
            } else {
                mp[minmax(i, j)] = a;
            }
        }
    }
    int64 res = 0;
    for (auto &x : mp) {
        res += x.sc;
    }
    cout << res << endl;
}


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

int main()
{
	string S,T;
	cin >> S >> T;
	cout << T+S << endl;
	return 0;
}

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

// Caracal vs Monster

long long sum(long long a, map<long long, long long> &memo) {
  //ベースケース
  if (a == 1) {
    return 1;
  }

  //再帰ステップ
  if (memo.count(a) > 0) {
    return memo[a];
  }

  memo[a] = sum(a / 2, memo) + sum(a / 2, memo) + 1;
  return memo[a];
}

long long sum2(long long a) {
  //ベースケース
  if (a == 1) {
    return 1;
  }
  return 2 * sum2(a / 2) + 1;
}

int main() {
  long long H;
  // vector<long long> memo(H, -1);
  map<long long, long long> memo;
  cin >> H;

  cout << sum(H, memo) << endl;
  // cout << sum2(H) << endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    h = list(map(int, readline().split()))

    cur = h[0]
    ans = 1

    for i in range(1, n):
        if h[i] >= cur:
            ans += 1
            cur = h[i]

    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int x[3];
    x[0] = a;
    x[1] = b;
    x[2] = c;
    sort(x, x+3);

    int ma, mid, min;
    ma = x[2];
    mid = x[1];
    min = x[0];

    if ((ma-min)%2==0 && (ma-mid)%2==0){cout << (ma-mid)/2+(ma-min)/2;}
    if ((ma-min)%2==0 && (ma-mid)%2!=0){cout << (ma-mid+1)/2+(ma-min)/2+1;}
    if ((ma-min)%2!=0 && (ma-mid)%2==0){cout << (ma-mid)/2+(ma-min+1)/2+1;}
    if ((ma-min)%2!=0 && (ma-mid)%2!=0){cout << (ma-mid-1)/2+(ma-min-1)/2+1;}
}

Measured memory_bytes: 256
// Last Change: 03/28/2020 21:04:25.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll X, happy = 0;
  cin >> X;
  happy += (X / 500) * 1000;
  X %= 500;
  happy += (X / 5) * 5;
  cout << happy << endl;
}


Measured memory_bytes: 888
#include <cstdio>
#include <vector>
using namespace std;
int main(){
	int N,S,R=0,s=0;
	scanf("%d%d",&N,&S);
	vector<int>v(N);
	for(int i=0;i<N;i++)scanf("%d",&v[i]);
	int start=0,stop=0;
	for(;;){
		for(;stop<N&&s<S;stop++)s+=v[stop];
		if(s<S)break;
		for(;start<N&&s>=S;start++)s-=v[start];
		R=R?min(R,stop-start+1):stop-start+1;
	}
	printf("%d\n",R);
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //入力を受けとる
    int n;
    std::cin >> n;
    std::vector<int> a(n),b(n),c(n);
    long long sum=0;//答えの出力用
    
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }for (int i = 0; i < n; i++) {
        std::cin >> c[i];
    }
    //sort
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    //bを走査
    for (int i = 0; i < n; i++) {
    //二分探索でa,cを探索
    //aはb以下の個数を、cはb以上の個数を求める
    //それをかけて、sumに足す
        auto it1=lower_bound(a.begin(),a.end(),b[i]);
        auto it2=upper_bound(c.begin(),c.end(),b[i]);
        sum+=(it1-a.begin())*(c.end()-it2);
    }
    //sumを出力
    std::cout << sum << std::endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

ll x[55];
ll dp[55][55][10101];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,X;
    cin>>N>>A;
    X=A;
    REP(i,N){
        cin>>x[i];
        chmax(X,x[i]);
    }

    dp[0][0][0] = 1;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=3030;k++){
                if(k<x[i-1]) dp[i][j][k] = dp[i-1][j][k];
                else if(j>0)dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=N;i++) ans += dp[N][i][i*A];
    cout<<ans<<endl;
}


Measured memory_bytes: 217344
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program 
    {
        public static void Main (string[] args)
        {
            var rx = new Regex(@"\A(dream(er)?|eraser?)+\z");
            var S = Console.ReadLine();
            Console.WriteLine(rx.IsMatch(S) ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 17356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {

	int n, l; cin >> n >> l;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += l + i;
	}
	int ans;
	int x = 100000000;
	for (int i = 0; i < n; i++) {
		int tmp = l + i;
		if (chmin(x, abs(tmp))) {
			ans = sum - tmp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N, M;
    cin >> N >> M;
    vector<vector<long long>> r(N, vector<long long> (3));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++) cin >> r[i][j];
    }
    vector<vector<long long>> a(8, vector<long long> (N));
    vector<long long> ans(8, 0);
    for(int bit = 0; bit < (1 << 3); bit++){
        for(int j = 0; j < 3; j++){
            for(int i = 0; i < N; i++){
                if(bit & (1 << j)) a[bit][i] += r[i][j];
                else a[bit][i] -= r[i][j];
            }
        }
    }
    for(int i = 0; i < 8; i++) sort(a[i].begin(), a[i].end());
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < M; j++) ans[i] += a[i][N - 1 - j];
    }
    long long res = 0;
    for(int i = 0; i < 8; i++) res = max(res, ans[i]);
    cout << res << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int maxn = 16;
const int maxs = 1 << maxn;
int a[maxn][maxn];
int f[maxs], g[maxn][maxs];
int tot, n, m, S;
void calc(int i, int s)
{
	for(int j = 0; j < n; ++j)
		if((s & (1 << j)) && a[i][j])
			g[i][s] = max(g[i][s], g[j][s - (1 << i)] + a[i][j]);
	int res = s - (1 << i);
	for(int r = res; r; r = res & (r - 1))
		g[i][s] = max(g[i][s], g[i][r | (1 << i)] + f[s - r]);
	g[i][s] = max(g[i][s], g[i][1 << i] + f[s]);
	//cout << i << ' ' << s << ' ' << g[i][s] << endl;
}
int main()
{
	scanf("%d%d", &n, &m); 
	S = (1 << n) - 1;
	for(int i = 1; i <= m; ++i)
	{
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		--u; --v;
		a[u][v] = a[v][u] = w;
		tot += w;
	}
	for(int j = 0; j < n; ++j)
	{
		int cur = 1 << j;
		for(int s = 0; s < cur; ++s)
		{
			f[s | cur] = f[s];
			for(int i = 0; i < j; ++i)
				if(s & (1 << i))
					f[s | cur] += a[i][j];
		}
	}
	for(int s = 1; s <= S; ++s)
		for(int i = 0; i < n; ++i)
			g[i][s] = -INF;
	g[0][1] = 0;
	for(int s = 1; s <= S; ++s)
		for(int i = 0; i < n; ++i)
			if(s & (1 << i))
				calc(i, s);
	//cout << g[n - 1][S] << endl;
	printf("%d\n", tot - g[n - 1][S]);
	return 0;
}
/*
4 4
1 2 100
2 4 100
1 3 100
3 4 100
*/

Measured memory_bytes: 5892
### constant

TNAMES = ['lunch', 'dinner', 'midnight']

### main

loop do
  n = gets.to_i
  break if n == 0

  totals = [0] * 3
  oks = [0] * 3

  n.times do
    hm, mm = gets.strip.split
    h, m0 = hm.split(':').map(&:to_i)
    m1 = mm.to_i

    tm = m1 - m0
    tm += 60 if tm < 0

    ok = (tm <= 8)
    h += 24 if h < 2
    id = nil

    case h
    when 11..14
      id = 0
    when 18..20
      id = 1
    when 21..25
      id = 2
    end

    if ! id.nil?
      totals[id] += 1
      oks[id] += 1 if ok
    end
  end

  for i in (0..2)
    out = (totals[i] > 0) ? (100 * oks[i] / totals[i]) : 'no guest'
    puts "#{TNAMES[i]} #{out}"
  end
end

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	ll k;
	cin >> k;
	// 幅優先探索の要領
	queue<ll> que;
	ll count = 0;
	For(i,1,10){
		que.push(i);
		count ++;
		if(count == k){
			cout << i << endl;
			return 0;
		}
	}
	while(!que.empty()){
		ll now = que.front(); que.pop();
		// 一番下の桁の数を取る
		ll get = now % 10;
		for(ll d = get - 1; d <= get + 1 ; d++) {
			// now - 1 , now , now + 1を押し込む(max 9)
			if(d < 0) continue;
			if(d > 9) continue;
			ll pu = now * 10 + d;
			que.push(pu);
			count ++;
			if(count == k){
				cout << pu << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
std::cin >> s;
string ans="";
int i=-1;

do {
  i++;
  if(s[i]=='0'){ans+="0";}
  else if(s[i]=='1'){ans+="1";}
  else if(s[i]=='B' && (ans.empty()!=1)){
    ans.erase(ans.length()-1);
  }
} while(i!=s.length()-1);

std::cout <<ans << '\n';

return 0;
}


Measured memory_bytes: 256
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
wan = 0
inu = 0

a = iin()
b = iin()
c = iin()
x = iin()

neko = x//500
if neko > a:
    neko = a#500で払えるくみあわせ
for i in range(neko+1):
    nya = x-500*i
    nuko = nya//100
    if nuko > b:
        nuko = b
    for j in range(nuko+1):
        wan = nya-100*j
        if wan%50 == 0:
            if wan//50 <= c:
                inu+=1
print(inu)

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

a_add=[]
a_2=[]
a_4=[]

for a in A:
    if a%2 != 0:
        a_add.append(a)
    if a%4 == 0: 
        a_4.append(a)
    elif a%2 == 0: 
        a_2.append(a)
        
# print(a_add,a_2,a_4)
        
ans='No'
if len(a_4) >= len(a_add):
    ans='Yes'
elif len(a_2)==0 and len(a_4) >= len(a_add)-1:
    ans='Yes'
print(ans)

Measured memory_bytes: 90868
def main():
    N, M = map(int, input().split())
    ans = (N - 1) * (M - 1)
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
#define rfor(i, a, b) for(int i = a - 1; i >= b; i--)

ll n, h[100010],dp[100010];

int main(){
    cin>>n;
    fore(i,0,n)cin>>h[i];

    dp[0] = h[0];
    dp[1] = abs(h[0]-h[1]);
    dp[2] = min(abs(h[1]-h[2])+dp[1],abs(h[0]-h[2]));

    fore(i,3,n){
        // cout<<abs(h[i-1]-h[i])<<" "<<abs(h[i-2]-h[i])<<endl;
        dp[i] = min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2]);
    }
    
    // fore(i,0,n)cout<<dp[i]<<" ";
    // cout<<endl;

    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,k) = {
        let t = read_vec::<i64>();
        (t[0],t[1])
    };
    let cn = vec!['0','1','2','3','4','5','6','7','8','9'];
    let dn:Vec<char> = read::<String>().chars().filter(|&x| x != ' ').collect();
    let use_n:Vec<char>  = cn.into_iter().filter(|x| !dn.contains(&x)).collect();

    // println!("{:?}",use_n );
    for j in n..{
        let num = j;
        let s = num.to_string();
        if s.chars().all(|x| use_n.contains(&x)){
            println!("{}",s );
            return;
        }
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
bool f[100009];
int main(){
  int n,cnt=0;
  int a[100009];
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i];
  int now=1;
  int last=-1;
  while(1){
    if(now==2)break;
    if(f[now]==1){
      cnt=-1;
      break;
    }
    f[now]=1;
    now=a[now];
    cnt++;
  }
  cout<<cnt<<endl;
  return(0);
}
  


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main(){
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> hash;
  int real_sum = 0;
  for(int i=0; i<n; i++){
    cin >> v[i];
    hash[v[i]]++;
    real_sum += v[i];
  }
  int q;
  cin >> q;
  while(q--){
    int b, c;
    cin >> b >> c;
    if(hash.find(b) == hash.end()){
      cout << real_sum << "\n";
    } else {
      cout << real_sum - b*hash[b] + c*hash[b] << "\n";
      real_sum = real_sum - b*hash[b] + c*hash[b];
      if(hash.find(c) != hash.end()){
          hash[c] += hash[b];
      } else {
          hash[c] = hash[b];
      }
      hash.erase(b);
    }
  }
}

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

int main() {
  int N;
  vector<int> A(200);
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int ans=0;
  while(true){
    bool exist_odd = false;
    for(int i=0;i<N;i++){
      if(A[i]%2 != 0){
        exist_odd=true;
       }
    }
    if(exist_odd){
      break;
    }
    for(int i=0;i<N;i++){
      A[i] /= 2;
    }
    ans++;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <list>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    unordered_set<int> m;
    int t;
    for(int i=0; i<N; i++){
        cin >> t;
        if(m.find(t) == m.end()){
            m.insert(t);
        } else {
            m.erase(t);
        }
    }
    cout << distance(m.begin(),m.end()) << endl;
    return 0;
}

Measured memory_bytes: 7268
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

dp = 1
for x in A:
    dp |= dp << x

S = bin(dp)[2:][::-1]

can_make = [i for i, x in enumerate(S) if x == '1']
n = len(can_make)
x = can_make[n // 2]
print(x)

Measured memory_bytes: 92748
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<iostream>

using namespace std;

int main(){
	int a, b, c;
	while(~scanf("%d %d %d", &a, &b, &c)){
		if(c - b == b - a) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
from fractions import gcd

input = sys.stdin.readline


def lcm(a, b):
    return (a * b) // gcd(a, b)


def main():
    N = int(input())
    T = [0] * N
    for i in range(N):
        T[i] = int(input())

    ans = T[0]
    for i in range(1, N):
        ans = lcm(ans, T[i])

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if (b <= a){
		cout << "No" << endl;
	}else if (c <= b){
		cout << "No" << endl;
	}else {
		cout << "Yes" << endl;

	}

}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    string s; cin >> s;
    vei used(26,0);

    if(s.size() != 26){
        rep(i,s.size()) used[ s[i] - 'a' ]++;
        string add;
        rep(i,26) {
            if(used[i] == 0) {
                add = (i + 'a');
                cout << s << add << endl;
                return 0;
            }
        }
    }
    else {
        for(int i = 25; i >= 0; i--){
            for(int j = 25; j > i; j--){
                if(s[i] < s[j]){
                    for(int k = 0; k < i; k++){
                        cout << s[k];
                    }
                    cout << s[j] << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100005
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(int i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(int i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = INT_MAX;

ll power(int a, int n, int mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
int gcd(int a,int b){ return __gcd(a,b);}
int lcm(int a,int b){return a*b/__gcd(a,b);}
vector<vector<int>> adj;
bool visited[mxn];


void solve(ll test){

    int n,x,t;
    cin >> n >> x >> t;

    cout << ((n+x-1)/x)*t;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
<?php
list($n, $k) = ints();
$a = ints();
for ($i = 0; $i < $n; ++$i) {
    if (isset($cnt[$a[$i]])) $cnt[$a[$i]]++;
    else $cnt[$a[$i]] = 1;
}
sort($cnt);
$ans = 0;
foreach ($cnt as $c) {
    if (count($cnt) <= $k) break;
    $ans += $c;
    $k++;
}
echo $ans;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<60);

int main() {
  int k, x; cin >> k >> x;
  cout << (k*500>=x ? "Yes" : "No") << endl;
  return 0;
}


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

#define ll long long int
#define MOD 1000000007
#define sc(a) scanf("%lld",&a)
#define f0(n) for(ll i=0;i<n;i++)
#define f1(n) for(ll i=1;i<=n;i++)
#define pb(v,a) v.push_back(a)
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end());

map<string,ll>mp;
int main()
{
	ll n;
	cin>>n;
	string s;

	while(n--)
	{
		cin>>s;
		mp[s]=mp[s]+1;
	}
	cout<<mp.size()<<endl;
}


Measured memory_bytes: 19176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n, m;
		while ((n = in.nextInt()) > 0 && (m = in.nextInt()) > 0) {
			int[] sugoroku = new int[n];
			for (int i = 1; i <= n; i++) {
				sugoroku[n - i] = in.nextInt();
			}
			int maxC = m;
			while (m-- > 0) {
				if (n > 1) {
					int saikoro = in.nextInt();
					n -= saikoro;
					if (n >= 1) {
						n -= sugoroku[n - 1];
					}
					if (n <= 1) {
						System.out.println(maxC - m);
					}
				} else {
					in.next();
				}
			}
		}
	}
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

bool res[10000000];

int main(){
  int m, n;
	while(cin >> m >> n and m + n){
		memset(res, 0, sizeof(res));
		REP(i, m)
			res[i] = true;
		int j = m;
		REP(i, n){
			while(res[j]) j++;
			for(int k = j; k < 10000000; k += j) res[k] = true;
		}
		REP(i, 10000000)
			if(!res[i]){
				cout << i << endl;
				break;
			}
	}
	return 0;
}

Measured memory_bytes: 12860
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    string s;
    cin >> s;
    char cur = 'R';
    int curStreak = 0;
    vi ans(s.length(), 0);
    for (int i = 0; i < s.length(); i++) {
        if (cur == s[i]) curStreak++;
        else {
            if (cur == 'R') {
                ans[i - 1] += (curStreak + 1) / 2;
                ans[i] += curStreak / 2; 
            }
            curStreak = 0;
        }
    }
    curStreak = 0;
    cur = 'L';
    for (int i = s.length() - 1; i > -1; i--) {
        if (cur == s[i]) curStreak++;
        else {
            if (cur == 'L') {
                ans[i + 1] += (curStreak + 1) / 2;
                ans[i] += curStreak / 2; 
            }
            curStreak = 0;
        }
    }
    for (int i = 0 ; i < ans.size(); i++) {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}

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

struct rect
{
  int W, H;
};

int main()
{
  auto list = std::vector<rect>{};
  int w, h;
  std::string s;
  while (std::cin >> h >> w)
  {
    auto r = rect{w, h};
    list.push_back(r);
  }

  for (auto r : list)
  {
    if (r.W == 0 && r.H == 0)
      break;

    auto odd_line = std::string{};
    auto even_line = std::string{};

    for (auto wi = 0; wi < r.W; wi++)
    {
      if (wi % 2 == 0)
      {
        odd_line += ".";
        even_line += "#";
      }
      else
      {
        odd_line += "#";
        even_line += ".";
      }
    }

    for (auto hi = 0; hi < r.H; hi++)
    {
      if (hi % 2 == 0)
      {
        std::cout << even_line << std::endl;
      }
      else
      {
        std::cout << odd_line << std::endl;
      }
    }

    if (&r != &list[list.size() - 1])
    {
      std::cout << std::endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3140
//Roller Coaster
    import java.util.*;
    public class Main{
      public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int[] h=new int[n];
        int count=0;
     
        for (int i=0;i<n;i++) {
         h[i]=sc.nextInt();
        }
     
        for (int i=0;i<n;i++) {
          if (h[i]>=k) {
            count++;
          }
        }
     
        System.out.println(count);
     
      }
    }

Measured memory_bytes: 50432
//#pragma comment(linker, "/STACK:102400000,102400000") 
//#include <windows.h>
//#include <unordered_map>
//#include <unordered_set>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const int dir[8][2] = { { 0,1 },{ 1,1 },{ 1,0 },{ 1,-1 },{ 0,-1 },{ -1,-1 },{ -1,0 },{ -1,1 } };
const int dir8x[8] = { -1,-1,-1,0,0,1,1,1 };
const int dir8y[8] = { -1,0,1,1,-1,-1,0,1 };
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int n;
int dp[2][maxn];
void solve()
{
	sa(n);
	repp(i, 1, 2)
	{
		repp(j, 1, n)
		{
			sa(dp[i][j]);
		}
	}
	repp(i, 1, n)
	{
		dp[1][i] += dp[1][i - 1];
	}
	for (int i = n; i >= 1; i--)
	{
		dp[2][i] += dp[2][i + 1];
	}
	int ans = 0;
	repp(i, 1, n)
	{
		ans = max(ans, dp[1][i] + dp[2][i]);
	}
	cout << ans << endl;
}

int main()
{

	solve();
	//system("pause");
	return 0;
}



Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LINF 1000000000000000001 // 1e18+1

int64_t N,M,i;

vector< int64_t > ediv(int64_t n){
  vector< int64_t > ret;
  for(i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i != 1 && i*i != n){
        ret.push_back(n/i);
      }
    }
  }
  ret.push_back(n);
  return ret;
}
int64_t mn = LINF;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin >> N >> M;
  for(auto i: ediv(M)){
    if(i >= N){
      mn = min(mn, i);
    }
  }
  cout << M/mn << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  int n,m;
  cin>>n>>m;
  int cnt=0;
  int a[n];
  int sum=0;
  for(i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  for(i=0;i<n;i++){
    if(a[i]>=(sum+4*m-1)/(4*m)) cnt++;
  }
  if(cnt>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  

}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

int parent(int);
int left(int);
int right(int);

int main() {
  int i,H,A[MAX];

  scanf("%d",&H);

  for( i = 1 ; i <= H ; i++ ) {
    scanf("%d",&A[i]);
  }

  for( i = 1 ; i <= H ; i++ ) {

    printf("node %d: key = %d, ",i,A[i]);

    if( parent(i) > 0 ) printf("parent key = %d, ",A[parent(i)]);

    if( left(i) <= H ) printf("left key = %d, ",A[left(i)]);

    if( right(i) <= H ) printf("right key = %d, ",A[right(i)]);

    printf("\n");

  }

  return 0;
}

  int parent( int x ) {
    return x/2;
  }

  int left( int x ) {
    return 2*x;
  }

  int right( int x ) {
    return 2*x+1;
  }

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0';
  int d=s[3]-'0';
  for(int i=0;i<8;i++){
    int sum=0;
    sum=sum+a;
    if(i&(1<<0)){    
      sum=sum+b;
    }
    else{
      sum=sum-b;
    }
    if(i&(1<<1)){    
      sum=sum+c;
    }
    else{
      sum=sum-c;
    }
    if(i&(1<<2)){    
      sum=sum+d;
    }
    else{
      sum=sum-d;
    }
    if(sum==7){
      cout << a;
      if(i&(1<<0)){
        cout << '+';
      }
      else{
        cout << '-';
      }
      cout << b;
      if(i&(1<<1)){
        cout << '+';
      }
      else{
        cout << '-';
      }
      cout << c;
      if(i&(1<<2)){
        cout << '+';
      }
      else{
        cout << '-';
      }
      cout << d << "=7" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3604
n,m=list(map(int,input().split()))

edge=[[] for i in range(n)]

for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)

ans=0
def search(his,nxt):
    global ans
    newhis=his.copy()
    newhis.append(nxt)
    if len(newhis)==n:
        ans+=1
        return
    for i in edge[nxt]:
        if i in newhis:continue
        search(newhis,i)




search([],0)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{int a,b,c;
while(~scanf("%d%d%d",&a,&b,&c))
   {if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5)
   printf("YES\n");
     else printf("NO\n");
   }
}

Measured memory_bytes: 760
package main

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

const MaxBuf = 200100

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	var h int
	h, _ = readInt(), readInt()
	s := make([]string, h)
	for i := 0; i < h; i++ {
		s[i] = readString()
		fmt.Println(s[i])
		fmt.Println(s[i])
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 1200005
#define MOD 1000000007
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define precise cout<<fixed<<setprecision(10)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int BIG=pow(2,20);
int32_t main(){
         getFaster;
         int n,k;
         cin>>n>>k;
         int a[n],f[n];
         rep(i,0,n)cin>>a[i];
         rep(i,0,n)cin>>f[i];
         sort(a,a+n);
         sort(f,f+n);
         reverse(a,a+n);
         int ans=INF;
         int l=0,r=1e12;
         while(l<=r)
         {
           int mid=(l+r)>>1;
           int x=0;
           rep(i,0,n)
           {
              int t=mid/f[i];
              x+=max(a[i]-t,0LL);  
           }
           if(x<=k)
           {
            ans=min(ans,mid);
            r=mid-1;
           }
           else
           l=mid+1; 
         }
         cout<<ans<<endl; 
         return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
using namespace std;
void bubble_sort(int a[], int n);   //申明函数"bubble_sort"
int number[10000000];   //在主函数外面定义数组可以更长
int num = 0;
void bubble_sort(int a[], int n)    //下面是函数bubble_sort的程序
{
    int i,j,temp;    //定义三个整型变量
    for (j=0;j<n-1;j++)    //用一个嵌套循环来遍历一遍每一对相邻元素 （所以冒泡函数慢嘛，时间复杂度高）
    {
        for (i=0;i<n-1-j;i++)
        {
            if(a[i]>a[i+1])  //从大到小排就把左边的">"改为"<" ！！！
            {
                temp=a[i];      //a[i]与a[i+1](即a[i]后面那个) 交换
                a[i]=a[i+1];    //基本的交换原理"c=a;a=b;b=c"
                a[i+1]=temp;
                num++;
            }
        }
    }
}

int main()      //主函数
{
    int i,n;
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> number[i];
    }
    bubble_sort(number,n);
    for (i = 0; i < n; i++)
    {
        if (i != 0)
        {
            cout << " ";
        }
        cout << number[i];
    }
    cout << endl;
    cout << num << endl;

    return 0;
}



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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
# define ALL(v) (v).begin(), (v).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

//vector<vector<ll> > comb(ll n, ll b){


int main(){
   ll n,a,b,p,k,x,MOD,h,w;

  ll can_max, can_min;
  
  MOD = 1000000007;
  cin >> h>>w;

  ll ans = min(h, w);  

  
  if (h%3==0 || w%3==0) {
    cout << 0 << endl;
    return 0;
  }

  ll ue3 = h / 3;
  if (h%3==2) ue3++;
  // ue shita shita
  ll ue = (ue3)*w;
  ll shita1 = (h-ue3) * (w/2); 
  ll shita2 = (h-ue3) * (w-w/2); 

  can_min = min(ue, shita1);
  can_max = max(ue, shita2);

  ans = min(ans, can_max - can_min);

  //cout << ans << endl;

  // hidari migi migi
  ll tmp = w;
  w = h;
  h = tmp;

  ue3 = h / 3;
  if (h%3==2) ue3++;
  
  ue = (ue3)*w;

  //cout << h<<h/3 <<" " << h<<endl;
  
  shita1 = (h-ue3) * (w/2); 
  shita2 = (h-ue3) * (w-w/2); 

  can_min = min(ue, shita1);
  can_max = max(ue, shita2);

  //cout << can_min<< " " << can_max<<endl;
  
  ans = min(ans, can_max - can_min);

  cout << ans << endl;
  
}


Measured memory_bytes: 256