akhauriyash/Code-Regression huggingface dataset:
/*
* じょえチャンネル
* 高評価・チャンネル登録よろしくおねがいします！
* https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
*/

#include <bits/stdc++.h>


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


#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)

#define intt long long
#define P pair<int,int>

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

using namespace std;

//Library
//モッドパウ
int modpow(int x, int y, int m = mod) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
            res %= m;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}

int mypow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
        }
        x = x * x;
        y /= 2;
    }
    return res;
}
//is the number (x) a prime number?
bool prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (!(x % i)) {
            return false;
        }
    }
    return true;
}


//saidai-kouyakusuu
inline int gcd(int x, int y) {
    if (!y) {
        return x;
    }
    return gcd(y, x % y);
}


//number of keta
int keta(int x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}

//sum of keta
int ketasum(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

inline int lcm(int x, int y) {
    int ans = x / gcd(x, y) * y;
    return ans;
}
int twobeki(int x) {
    int ans = 0;
    while (1) {
        if (!(x & 1)) {
            ans++;
            x /= 2;
        }
        else {
            break;
        }
    }
    return ans;
}


template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
    if (lhs < rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
void YES(){
    cout<<"YES"<<endl;
}
void NO(){
    cout<<"NO"<<endl;
}


#define fin(i) scanf("%lld",&i)
#define fout(i) printf("%lld",i)
#define fendl printf("\n")
//Library-End

int n,m,ans,a[100004];
signed main() {
    cin>>n;
//    cin>>m;
//    rep(i,n)fin(a[i]);
    ans=n/2;
    ans+=n&1;
    cout<<ans<<endl;
}


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

int main() {
  int N,K,i,x,A,B,RR=0;
  cin >> N >> K;
  deque<int> D;
  priority_queue<int, vector<int>, greater<int>> j;
  
  for(i=0; i<N; i++) {
    cin >> x;
    D.push_back(x);
  }
  
  for(A=0; A<=min(N,K); A++) {
    for(B=0; B<=min(N,K)-A; B++) {
      deque<int> td=D;
      priority_queue<int, vector<int>, greater<int>> tj=j;
      int r=0;
      
      for(i=0; i<A; i++) {
        tj.push(td.front());
        td.pop_front();
      }
      for(i=0; i<B; i++) {
        tj.push(td.back());
        td.pop_back();
      }
        
      for(i=0; i<K-(A+B); i++) {
        if(!tj.empty() && tj.top() < 0)
       	 tj.pop();
        else
          break;
      }
        
      while (!tj.empty()) {
   	    r += tj.top();
        tj.pop();
      }
      
      if(RR < r)
        RR = r;
    }
  }

  cout << RR << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす組の数
ans = r * g * b

# 2つ目の条件を満たす組の数
c = 0
for i in range(n):
    for j in range(i+1,n):
        k = 2 * j -i
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c += 1

print(ans - c)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n = inl();
        vl a(n);
        ll maxa = -1, nexta = -1;
        rep(i, n) {
            cin >> a[i];
            if (maxa == -1) maxa = a[i];
            else {
                if (a[i] >= maxa) nexta = maxa, maxa = a[i];
                else if (a[i] >= nexta) nexta = a[i];
            }
        }

        rep(i, n) {
            if (a[i] == maxa)cout << nexta << endl;
            else cout << maxa << endl;
        }

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3200
N = int(input())
V = 2*N
Red = [list(map(int, input().split())) for _ in range(N)]
Blue = [list(map(int, input().split())) for _ in range(N)]

graph = [[] for _ in range(V)]
for i in range(N):
    for j in range(N):
        a, b = Red[i]
        c, d = Blue[j]
        if a < c and b < d:
            j += N
            graph[i].append(j)
            graph[j].append(i)

match = [-1]*V # マッチングペア
used = [False]*V # DFSですでに調べたか

# search increasing path
def dfs(v):
    used[v] = True
    for nv in graph[v]:
        w = match[nv]
        if w < 0 or (not used[w] and dfs(w)):
            match[v] = nv
            match[nv] = v
            return True
    return False


def bipartite_matching():
    res = 0
    global match
    match = [-1]*V
    for v in range(V):
        if match[v] < 0:
            global used
            used = [0]*V
            if dfs(v):
                res += 1
    return res


if __name__ == '__main__':
    print(bipartite_matching())

Measured memory_bytes: 3188
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, v[100005];

char S[100005];

string H[] = {"dream", "dreamer", "erase", "eraser"};

bool good(int x, int j) {
	for (int i = 0; i < H[j].length(); i++, x++)
		if (S[x]!=H[j][i]) return 0;
	return 1;
}

int main()
{
	scanf("%s", S);
	
	n = strlen(S);
	
	FOR (i, 0, n-1)
		for (int h = 0; h < 4; h++)
			if (i+H[h].length() <= n) {
				if (good(i, h))
					v[i]++, v[i+H[h].length()]--;
			}
	
	FOR (i, 1, n)
		v[i]+=v[i-1];
	
	int mn = inf;
	FOR (i, 0, n-1)
		mn = min(mn, v[i]);
	
	if (mn != 0)
		printf("YES");
	else
		printf("NO");
}


Measured memory_bytes: 768
#include <complex>
#include <vector>
#include <cmath>
#include <iostream>

const double EPS=1e-10;

#define equals(a, b) (fabs((a)-(b))<EPS)
#define X real()
#define Y imag()

using namespace std;

typedef complex<double> Point;
typedef Point Vector;

struct Segment {
    Point p1, p2;
};
typedef Segment Line;

struct Circle {
    Point c;
    double r;
    Circle(Point c=Point(), double r=0.0) :
        c(c),r(r){}
};

typedef vector<Point> Polygon;

double dot(Vector a, Vector b) {
    return a.X*b.X + a.Y*b.Y;
}

double cross(Vector a,Vector b) {
    return a.X*b.Y - a.Y*b.X;
}

int main(void) {
    int n;
    cin>>n;
    while(n-->0) {
        double x1,y1;
        double x2,y2;
        double x3,y3;
        double x4,y4;
        cin>>x1>>y1;
        cin>>x2>>y2;
        cin>>x3>>y3;
        cin>>x4>>y4;
        Segment s1,s2;
        s1.p1=Point(x1,y1);
        s1.p2=Point(x2,y2);
        s2.p1=Point(x3,y3);
        s2.p2=Point(x4,y4);
        if(equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0)) {
            cout<<"1"<<endl;
        }
        else if(equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0)) {
            cout<<"2"<<endl;
        }
        else cout<<"0"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std; 

int main(void){
 int a,n,ans;
 vector<int> A;
 ans=0;

 cin>>n;
 for(int i=0; i<n; i++){
  cin>>a;
  A.push_back(a);
 }
 for(int i=1; i<(A.size()-1);i++)if((A[i]>A[i-1] && A[i]<A[i+1]) || (A[i]<A[i-1] && A[i]>A[i+1]))ans++;
 
 cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
n=int(input())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ab = sorted(ab, key=lambda x: x[1])

memo = 0
flag = True
for a,b in ab:
    memo += a
    if b < memo:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 114808
<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$vallance = trim(fgets(STDIN));
$ans = 0;

for($i = 0;$i<=$a;++$i){
	for($j = 0;$j<=$b;++$j){
    	for($k = 0;$k<=$c;++$k){
        	if($i * 500 + $j * 100 + $k * 50 ==$vallance){
            	$ans++;
            }
        }
    }
}
echo $ans;

Measured memory_bytes: 4984
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,a[5]; cin>>n; rep(i,5) cin>>a[i];
    long long mi=LINF;
    rep(i,5) mi=min(mi,a[i]);
    cout<<4+(n+mi-1)/mi<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int INF = 1000000;


int main()
{  
   //int n,res; cin>>n;
    string s,t; cin>>s>>t;

   cout<<t+s<<endl;
}

Measured memory_bytes: 256
s = list(input())
ans = 0
if len(s) == 1:
    pass
else:
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            ans += 1
            if s[i] == "1":
                s[i] = "0"
            else:
                s[i] = "1"

print(ans)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	//const int MOD=998244353;
    int MOD;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=3e2+10;
	//------------------FIXED------------------
    int C[N][N];
	int f[N][N],f2[N][N],g[N][N];
	void main()
	{
		int n=qread(),K=qread();MOD=qread();C[0][0]=1;fo(i,1,N-1){ C[i][0]=1;fo(j,1,i) C[i][j]=mm(C[i-1][j]+C[i-1][j-1]); }
		fd(val,K,0)
		{
            f[1][val]=1,f2[1][val]=(K-val+1)%MOD,g[0][val]=1;//debug 模数很小时会漏模
			fo(S,1,n){ g[S][val]=f2[S][val+1];fo(ad,1,S-1) add(g[S][val],1ll*g[S-ad][val]*f2[ad][val+1]%MOD*C[S-1][ad-1]%MOD); }
			fo(S,2,n+1){ f[S][val]=g[S-1][val];f2[S][val]=mm(f2[S][val+1]+f[S][val]); }
		}write(f[n+1][0]);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 1792
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

map<pii,int>id;int tot;
pii all[400111];
int f[400111];
int gf(int x){return x==f[x]?x:f[x]=gf(f[x]);}
int getid(int x,int c)
{
	if(id[mp(x,c)]==0)
	{
		id[mp(x,c)]=++tot;
		all[tot]=mp(x,c);
		f[tot]=tot;
	}
	return id[mp(x,c)];
}

vector<int> g[100111],con[400111];
set<int>col[100111];
int n,m,q[400111],fr,rr,lvl[400111];
bool removed[400111];
void remove(int id)
{
	removed[id]=1;
	for(int i=0;i<(int)con[id].size();i++)
		col[con[id][i]].erase(all[id].ss);
}
int main()
{
	get2(n,m);
	for(int i=1,x,y,c;i<=m;i++)
	{
		get3(x,y,c);
		g[x].pb(y);col[x].insert(c);
		g[y].pb(x);col[y].insert(c);
		f[gf(getid(x,c))]=gf(getid(y,c));
	}
	for(int i=1;i<=tot;i++)con[gf(i)].pb(all[i].ff);
	fr=rr=0;
//	for(int i=1;i<=tot;i++)printf("all i= %d %d %d gf= %d\n",i,all[i].ff,all[i].ss,gf(i));
	for(int i=1;i<=tot;i++)if(all[i].ff==1&&!removed[gf(i)])
	{
		q[rr++]=gf(i);
//		printf("add= %d\n",gf(i));
		remove(gf(i));
	}
	for(fr=0;fr<rr;fr++)
	{
		int x=q[fr];
//		printf("now= %d col= %d dis= %d\n",all[x].ff,all[x].ss,lvl[x]);
		for(int i=0;i<(int)con[x].size();i++)
		{
			int v=con[x][i];
			if(v==n)
			{
				printf("%d\n",lvl[x]+1);
				return 0;
			}
			vector<int> tmp;
			for(set<int>::iterator it=col[v].begin();it!=col[v].end();it++)
				tmp.pb(*it);
			for(int j=0;j<(int)tmp.size();j++)
			{
				int id=getid(v,tmp[j]);
				if(!removed[gf(id)])
				{
					q[rr++]=gf(id);lvl[gf(id)]=lvl[x]+1;
					remove(gf(id));
				}
			}
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 78592
/* Author rumoisen */
/* date 2018/10/07 */

#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include<iostream>
#include <algorithm>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;
int main()
    {
        int r;
        cin>>r;
        if(r<1200) cout<<"ABC"<<endl;
        if(1200<=r&&r<2800) cout<<"ARC"<<endl;
        if(2800<=r) cout<<"AGC"<<endl;
        return 0;
    }

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-9;

int main(){
	double n;

	while(cin >> n){
		double sum = n;
		for(int i = 2; i <= 10; i++){
			if(i%2 == 0){
				n*=2;
			}else{
				n/=3;
			}
			sum += n;
		}
		cout.flags(ios::fixed);
		cout.precision(8);

		cout << sum << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 87;
struct seg
{
    int ps;
    int mx;
} t[N * 4];
int n;
vector<int> vl[N];
void add(int i, int v, int o = 1, int l = 0, int r = n + 2)
{
    if (r - l == 1) {
        t[o].ps += v;
        t[o].mx = max(0, t[o].ps);
        return;
    }
    int m = l + (r - l) / 2;
    if (i < m)
        add(i, v, o * 2, l, m);
    else
        add(i, v, o * 2 + 1, m, r);
    t[o].ps = t[o * 2].ps + t[o * 2 + 1].ps;
    t[o].mx = max(t[o * 2].mx, t[o * 2 + 1].mx + t[o * 2].ps);
}
int main()
{
    int m;
    scanf("%d%d", &m, &n);
    for (int i = 0; i < m; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        vl[r].push_back(l);
    }
    for (int i = 1; i <= n; ++i)
        add(i, -1);
    int ans = 0, rs = 0;
    for (int r = n + 1; r >= 1; --r) {
        if (r <= n) {
            add(r, 1);
            --rs;
        }
        for (int l : vl[r])
            add(l, 1);
        ans = max(ans, t[1].mx + rs);
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vct vector<ll>
#define umap unordered_map<ll,ll>
#define mpp map<ll,ll>
#define stt set<ll>
#define pir pair<ll,ll>
#define vpp vector<pair<ll,ll> >

ll poww(ll x,ll y,ll m){   
    ll res=1;
    while(y){if(y%2==0){x=(x*x)%m;y=y/2;}else{res=(res*x)%m;y--;}}
    return res;
}
void prt(vct v)
{
    // cout<<"\n";
    for(ll i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<"\n";
    
}
vct siev(ll n)
{
    vct ans;ll ar[n+1];
    memset(ar,-1,sizeof(ar));ar[0]=0;ar[1]=0;
    for(ll i=2;i<=n;i++)
    {if(ar[i]==-1){ans.push_back(i);ar[i]=1;for(ll j=2*i;j<=n;j=j+i)ar[j]=0;}}
    return ans;
}
bool isprime(ll n)
{
    for(ll i=2;i<=sqrt(n);i++)if(n%i==0)return false;
    return true;
}

vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            ans.push_back(i);
            if(i!=(n/i))ans.push_back(n/i);
        }
    }
    sort(ans.begin(),ans.end());
    return ans;
}
ll cnd(ll n){ll cnt=0;while(n){cnt++;n=n/10;}return cnt;}

ll fibdig(ll n)
{
    if (n == 1) 
        return 1; 
    long double d = (n * log10(1.6180339887498948)) -((log10(5)) / 2);
    return ceil(d); 
}


ll t;ll n,m,k;
// vct v;
ll t1,t2;
ll mod=1000000007;
// vct ans;
// vct mxs=1;




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // setprecision(10);
    cin>>n>>m;
    vct v1=divsors(n);
    vct v2=divsors(m);
    // cout<<v1.size();
    // prt(v1);prt(v2);
    vct v3;
    set_intersection(v1.begin(),v1.end(),v2.begin(),v2.end(),back_inserter(v3));
    // prt(v3);
    vct ans;ans.push_back(1);
    // ll vis[v3.size()];
    vct vis(v3.size(),0);
    // memset(vis,0,sizeof(v3));
    vis[0]=1;
    for(ll i=1;i<v3.size();i++)
    {
        if(vis[i]==0)
        {
            vis[i]=1;
            ans.push_back(v3[i]);
            ll cc=v3[i];
            for(ll j=i+1;j<v3.size();j++)
            {
                if(v3[j]%cc==0)vis[j]=1;
            }
        }
    }
    // prt(vis);
    cout<<ans.size();
    
    
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int l;
    cin >> l;
    int p = 0;
    while (l >= pow(2, p+1)) ++p;
    int lastn = p + 1;
    int minv = pow(2,p);
    int e = 0;
    VI a,d;
    RREP(i,0,p) if (l - minv >= pow(2,i)) {
        //cout << i + 1 << " " << lastn << " " << minv + 1 << endl;
        a.push_back(i+1);
        d.push_back(minv);
        ++e;
        minv += pow(2,i);
    }
    cout << lastn << " " << (lastn - 1) * 2 + e << endl;
    REP(i,0,p) {
        cout << i + 1 << " " << i + 2 << " " << 0 << endl;
        cout << i + 1 << " " << i + 2 << " " << (LL)pow(2,i) << endl;
    }
    REP(i,0,e) cout << a[i] << " " << lastn << " " << d[i] << endl;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.println(problem099a(n));
    }

    private static String problem099a(int n) {
        if (n <= 999) {
            return "ABC";
        }
        return "ABD";
    }
}

Measured memory_bytes: 19412
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main() {
  int ans=0,ck=0;
  string s;
  while(cin >> s && s!="=") {
    if(s=="+") ck=1;
    else if(s=="-") ck=2;
    else if(s=="*") ck=3;
    else if(s=="/") ck=4;
    else {
      stringstream ss;
      ss << s;
      int x;
      ss >> x;
      if(ck==1 || ck==0) ans+=x;
      else if(ck==2) ans-=x;
      else if(ck==3) ans*=x;
      else ans/=x;
    }
  }
  cout << ans << endl; 
  return 0;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 0, s.size() - t.size()+1){
        int cnt = 0;
        rep(j, 0, t.size()){
            if(s[i+j] == t[j]) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << t.size() - ans << endl;
    return 0;
}


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

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

    string N;
    cin >> N;

    int pos = N.find("7");
    if(pos == -1) cout << "No" << "\n";
    else cout << "Yes" << "\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int N,K;
    cin>>N>>K;
    int ans=0;
    if(N%K!=0){
        ans=1;
    }
    
    cout<<ans<<endl;
  
   
}

Measured memory_bytes: 3596
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);;
	int n,ans=0;
	cin>>n;
	for(int i=n;i>=0;i--){
		int temp=1;  
    	while(temp<=i){  
        	if(temp==i){
            	cout<<i;
            	return 0;
        	}
        	temp=temp*2;
    	}
	}
	cout<<n;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <map>
#include <queue>

using namespace std;
using ll = long long;

struct Job {
    Job(ll a, ll b) : a_(a), b_(b) {};
    ll a_{};
    ll b_{};
};
struct C {
    ll M_{};
    vector<Job> m_{};
    explicit C(ll M, vector<pair<ll, ll>> r) : M_(M){
        for (auto& p : r) {
            auto a = p.first;
            auto b = p.second;
            m_.emplace_back(Job(a, b));
        }
    }
    ll resolve() {
        auto a_cmp = [] (auto& x, auto& y) {
            if (x.a_ < y.a_) {
                return true;
            }
            if (x.a_ > y.a_) {
                return false;
            }
            return false;
        };
        auto b_cmp = [] (auto& x, auto& y) {
            if (x.b_ < y.b_) {
                return true;
            }
            if (x.b_ > y.b_) {
                return false;
            }
            return false;
        };
        std::sort(m_.begin(), m_.end(), a_cmp);
        std::priority_queue<Job, vector<Job>, decltype(b_cmp)> pq{b_cmp};
        ll ret = 0;
        for(ll i = 1; i <= M_; ++i) {
            Job job{i, 0};
            auto range = std::equal_range(m_.begin(), m_.end(), job, a_cmp);
            for(auto it = range.first; it != range.second; ++it) {
                pq.push(*it);
            }
            if (!pq.empty()) {
                auto t = pq.top();
                pq.pop();
                ret += t.b_;
            }
        }
        return ret;
    }
};

int main() {
    ll N, M;
    cin >> N >> M ;
    vector<pair<ll, ll>> r{};
    for (int i=0; i < N; ++i) {
        ll A, B;
        cin >> A >> B;
        r.emplace_back(make_pair(A, B));
    }
    C c{M, move(r)};
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 5460
<?php

    while(true){

        $num = preg_split('/ /', trim(fgets(STDIN)));

        if($num[0] == 0 && $num[1] == 0){

            break;

        }else{

            $array[] = (min($num) . " " . max($num));

        }
    }

    $i = 1;

    foreach ($array as $result){

        if($i != count($array)){

            echo($result . "\n");
$i++;

        }else{

            echo($result);

        }

    }

?>

Measured memory_bytes: 15732
# -*- coding: utf-8 -*-
"""
C - 次のアルファベット / Next Letter
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c

"""
import sys

from string import ascii_lowercase

def solve(s, K):
    ans = []
    for ch in s:
        distance = ascii_lowercase[::-1].index(ch) + 1
        if distance <= K and ch != 'a':
            K -= distance
            ans.append('a')
        else:
            ans.append(ch)
    ans[-1] = ascii_lowercase[(ord(ans[-1]) - ord('a') + K) % 26]
    return ''.join(ans)


def main(args):
    s = input()
    K = int(input())
    ans = solve(s, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 4764
#D - Triangles

N = input()
N = int(N)
L = list(map(int,input().split()))

L_sorted = sorted(L, reverse = False)#昇順

def judge(A,B,x):#cが三角形になるか判定する関数
    if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low'

count = 0
for i in range(N):#aの選び方
    for j in range(i+1,N):#bの選び方
        a = L_sorted[i]
        b = L_sorted[j]#b <= c < a+b
        sta = 0
        fin = N#Lの個数+1
        while fin > sta + 1:#cの選び方
            m = ((fin - sta) // 2) + sta
            if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
        count += sta  - j    
print(count)

Measured memory_bytes: 73852
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    int n=s.size();
    vector<int> a(n);
    rep(i,n) a[i]=s[i]-'0';
    int ans,cnt=0;
    repi(i,1,n) if(a[i]==9) cnt++;
    if(cnt==n-1) ans=a[0]+9*(n-1);
    else ans=a[0]+9*(n-1)-1;
    cout<<ans;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

mat(dis,100000,2);
vec(vis,100001);
vector<vector<int>> gra(100001,vector<int>(0));

void dfs(int d,int p,int cnt){
    vis[d]=1;
    dis[d][p]=cnt;
    cnt++;
    for(auto it:gra[d]){
        if(vis[it]==0)dfs(it,p,cnt);
    }
}

int main(){
    ll n;
    cin>>n;
    vec(a,n);
    vec(b,n);
    
    rep(i,n-1){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        gra[a[i]].push_back(b[i]);
        gra[b[i]].push_back(a[i]);
    }
    dfs(0,0,0);
    rep(i,n){
        vis[i]=0;
    }
    dfs(n-1,1,0);
    ll Cnt1=0;
    ll Cnt2=0;
    rep(i,n){
        if(dis[i][0]<=dis[i][1])Cnt1++;
        else Cnt2++;
        //cout<<dis[i][0]<<" "<<dis[i][1]<<endl;
    }
    if(Cnt1>Cnt2){ op("Fennec");}
    else {op("Snuke");}
    return 0;
}

Measured memory_bytes: 18176
#include <cstdio>
#define ll long long
int main() {
//	freopen("cpp.in", "r", stdin);
//	freopen("cpp.out", "w", stdout);
	ll K, t = 0, i = 100;
	scanf("%lld", &K);
	while (i < K) {
		i *= 1.01;
		++t;
	}
	printf("%lld", t);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int a[] ={0,1,3,1,2,1,2,1,1,2,1,2,1};
int x,y;
cin >> x>> y;
cout << (a[x]==a[y]?"Yes":"No") << endl;
return 0;
}

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

#define INF (1<<30)

#define BIT_MAX 200000

vector<long> BIT(BIT_MAX+1);

void    add_BIT(vector<long> &BIT, long ix, const long &v) {
    while (ix<=BIT_MAX) {
        BIT.at(ix) +=v;
        ix +=ix&-ix;
    }
}

long    sum_BIT(vector<long> &BIT, long ix) {
    long S=0;
    while (ix>0) {
        S +=BIT.at(ix);
        ix -=ix&-ix;
    }
    return S;
}

int main() {
    int n;
    cin >>n;
    vector<vector<long>> a(n, vector<long> (3, 0));
    for (int i=0; i<n; i++) {
        a.at(i).at(0)=0;
        cin >>a.at(i).at(1);
        a.at(i).at(2)=i;
    }
    sort(a.begin(), a.end());
    for (int i=0; i<n; i++) {
        a.at(i).at(0)=a.at(i).at(2);
        a.at(i).at(2)=i+1;
    }
    sort(a.begin(), a.end());
    long S=0;
    for (int i=n-1; i>=0; i--) {
        add_BIT(BIT, a.at(i).at(2), 1);
        S +=sum_BIT(BIT, a.at(i).at(2)-1);
    }
    cout <<S <<endl;
    return 0;
}


Measured memory_bytes: 15252
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	long double r; cin>>r;
	cout<<r*2*PI<<endl;

	return 0;
}


Measured memory_bytes: 3800
#include<stdio.h> 
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define N 1000
char s1[N],s2[N];
int lcs(){
  int i,j,maxl=0;
  int c[N+1][N+1];
  int m=strlen(s1);
  int n=strlen(s2);
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      c[i][j]=0;
    }
  }
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(s1[i-1]==s2[j-1]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else{
	if(c[i-1][j]>c[i][j-1]){
	  c[i][j]=c[i-1][j];
	}
	else{
	  c[i][j]=c[i][j-1];
	}
      }
      if(maxl>c[i][j]){
	maxl=maxl;
      }
      else{
	maxl=c[i][j];
      }
    }
  }
  return maxl; 
}
int main(){
  int i,j,n,b;
  scanf("%d",&n);
  for(i =0;i < n;i++){
    scanf("%s",s1);
    scanf("%s",s2);
    b=lcs();
    printf("%d\n",b);
  }
  return 0;
}

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

using namespace std;

typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<vector<long long>>> vvvll;

// state(sum, i, #elements)
vvvll memo(2550, vvll(55, vll(55, -1)));

long long dp(int i, long long sum, int elements, int A, vector<int> arr) {
  long ans;
  if(i == (arr.size()-1)){
    if(elements == 0)
       memo[sum][i][elements] = 0;
    else
      memo[sum][i][elements] = (sum/(float)elements == A)? 1 : 0;
    return memo[sum][i][elements];
  }
  
  if (memo[sum][i+1][elements] == -1)
    memo[sum][i+1][elements] = dp(i+1, sum, elements, A, arr);
  
  if (memo[sum+arr[i+1]][i+1][elements+1] == -1)
    memo[sum+arr[i+1]][i+1][elements+1] = dp(i+1, sum+arr[i+1], elements + 1, A, arr);

  ans = memo[sum][i+1][elements] + memo[sum+arr[i+1]][i+1][elements+1];
  return ans;  
}

int main(){
  int N, A;
  cin>>N>>A;
  vector<int> arr(N);
  for(int i=0; i<N; i++)
    cin>>arr[i];
  cout<<dp(-1,0,0,A,arr)<<endl;
  return 0;
}


Measured memory_bytes: 65152
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, a, b = sc.nextLong()
    val ab = a + b
    val div = n / ab
    val rest = n % ab
    val ans = div * a +
      (if (rest > a) a else rest)

    println(ans)
  }
}


Measured memory_bytes: 27336
#include <iostream>

using namespace std;

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define lowbit(x) ((x)&-(x))
#define debug(x) cout << #x " = " << x << endl;
namespace IO{
	const int L = 1 << 15;
	char ibuf[L|1],*iS=ibuf,*iT=ibuf;
	char obuf[L|1],*oS=obuf,*oT=obuf+L;
	char c,st[66];int tp=0,f;
	inline char gc(){
		if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);
		return (*iS++);
	}
	inline void flush() {
		fwrite(obuf,sizeof(char),oS-obuf,stdout);
		oS = obuf;
	}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){
		ll x=0;f=1,c=gc();
		for(;!isdigit(c);c=gc())if(c=='-')f=-1;
		for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);
		return x*f;
	}
	void write(ll x){
		if(!x) pc('0');if(x<0) pc('-'),x=-x;
		while(x) st[++tp]=x%10+'0',x/=10;
		while(tp) pc(st[tp--]);
	}
	void wri(ll x){write(x);pc(' ');}
	void writeln(ll x){write(x);pc('\n');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}
using IO::read;
using IO::writeln;
using IO::wri;
inline void gg(string s){cout << s << endl;exit(0);}
inline void gg(ll x){writeln(x);exit(0);}
const int maxn = 200;
int d[2][maxn][maxn][maxn],n,m,sum[maxn][maxn];
char s[maxn][maxn];
bool same(int x1,int x2,int y1,int y2){
	int tmp=sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
	return tmp==0 || tmp==(x2-x1+1)*(y2-y1+1);
}
int main(){
#ifdef LOCAL
	freopen("1.in","r",stdin);
#endif
	n = read(),m = read();
	Rep(i,1,n){
		s[i][1]=gc();while(s[i][1]!='.'&&s[i][1]!='#')s[i][1]=gc();
		Rep(j,2,m) s[i][j]=gc();
	}
	
	Rep(i,1,n) Rep(j,1,m) sum[i][j] = s[i][j]=='#';
	Rep(i,2,n) Rep(j,1,m) sum[i][j]+=sum[i-1][j];
	Rep(i,1,n) Rep(j,2,m) sum[i][j]+=sum[i][j-1];
	if(same(1,n,1,m)) gg("0");
	Rep(i,1,n)Rep(j,1,m)Rep(k,j,m){
		int l=i-1,r=n;
		while(l<r){
			int mid=(l+r+1)>>1;
			if(same(i,mid,j,k)) l=mid; else r=mid-1;
		}d[0][i][j][k]=l;
	}
	for(int dep=1;;dep++){
		int now=dep&1,pre=now^1;
		Rep(i,1,n)Rep(j,1,m){
			int p=j;
			Rep(k,j,m){
				if(d[pre][i][j][k]==n) d[now][i][j][k]=n; else{
					d[now][i][j][k]=d[pre][d[pre][i][j][k]+1][j][k];
					while(p<k&&d[pre][i][j][p]>d[pre][i][p+1][k])++p;
					if(j<p) d[now][i][j][k]=max(d[now][i][j][k],min(d[pre][i][j][p-1],d[pre][i][p][k]));
					if(p<k) d[now][i][j][k]=max(d[now][i][j][k],min(d[pre][i][j][p],d[pre][i][p+1][k]));
				}
			}
		}
		if(d[now][1][1][m]==n) gg(dep);
	}
	return 0;
}

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

int main(){
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double theta = abs((h+m/60)/12*2*M_PI - m/60*2*M_PI);
    printf("%20.20Lf\n", sqrt(abs(a*a + b*b - 2*a*b*cos(theta))));
}

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

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

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

	int ans = 0;
	for(int i = 1;i <= n;i++){
		if(i % 3 != 0 && i % 5 != 0){
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vec out;
vec dp(1e5+10);

ll cnt(ll n) {
  if(dp[n]>-1) return dp[n];
  ll res=inf;
  for(ll i=0;i<out.size();i++) {
    if(n-out[i]<0) continue;
    res=min(res,cnt(n-out[i]));
  }
  return dp[n]=res+1;
}

int main() {
  ll n;
  cin >> n;
  for(ll i=1;i<=n;i++) dp[i]=-1;
  out.push_back(1);
  ll tmp=6;
  while(tmp<=n) {
    out.push_back(tmp);
    tmp*=6;
  }
  tmp=9;
  while(tmp<=n) {
    out.push_back(tmp);
    tmp*=9;
  }
  sort(out.rbegin(),out.rend());
  cout << cnt(n) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    vector<vector<int> > g(n + m);
    auto ixa = [&](int i) { return i; };
    auto ixb = [&](int i) { return n + i; };
    repeat (i,n) {
        int k; cin >> k;
        repeat (j,k) {
            int l; cin >> l; -- l;
            g[ixa(i)].push_back(ixb(l));
            g[ixb(l)].push_back(ixa(i));
        }
    }
    vector<bool> used(n + m);
    function<void (int)> go = [&](int i) {
        used[i] = true;
        for (int j : g[i]) if (not used[j]) go(j);
    };
    go(ixa(0));
    bool ans = true;
    repeat (i,n) if (not used[ixa(i)]) ans = false;
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 8440
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	vector<long long int>num(100);
	num[0] = 2;
	num[1] = 1;
	cin >> N;
	for (int i = 2; i <= N; i++) {
		num[i] = num[i - 1] + num[i - 2];
	}
	cout << num[N] << endl;
	return 0;
}

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

int main() {
  int A,B,a,b,c,max;
  cin>>A>>B;
  	
  a=A+B;
  b=A-B;
  c=A*B;
  
  if(a>b) max=a;
  else if(a<b) max=b;
  if(max<c) max=c;
    
    cout<<max<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<a)
    {
        cout<<k;
        return 0;
    }
    else if(k<(a+b))
    {
        cout<<a;
        return 0;
    }
    else if(k<(a+b+c))
    {
        cout<<a-(k-(a+b));
        return 0;
    }
    else
    {
        cout<<a-c;
    }
}

Measured memory_bytes: 3636
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

L = [-1] * (N-1)
L[0] = A[0]
R = [-1] * (N-1)
R[0] = A[-1]

for i in range(1, N-1):
    L[i] = gcd(L[i-1], A[i])
    
for i in range(1, N-1):
    R[i] = gcd(R[i-1], A[-i-1])

ans = 0
for i in range(1, N-1):
    tmp = gcd(L[i-1], R[N-i-2])
    ans = max(ans, tmp)

ans = max(ans, L[N-2])
ans = max(ans, R[N-2])
print(ans)


Measured memory_bytes: 16116
#include<iostream>
using namespace std;
int main(){
  long long A,B,N;
  cin >> A >> B >> N;
  if(N>=B){
    long long c;
    c=A*(B-1)/B;
    cout << c << endl;
  }
  else{
    long long d;
    d=A*N/B;
    cout << d << endl;
  }
}

Measured memory_bytes: 3636