akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var h = int.Parse(s[0]);
            var n = int.Parse(s[1]);
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).Sum();

            Console.WriteLine(h - a <= 0 ? "Yes" : "No");
        }
    }
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
vector<pii> edges;
vector<int> g[N];
int deg[N];
map<pii, int> Map;
bool vis[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=1; i<n; i++){
		int u, v; cin >> u >> v;
		deg[u]++; deg[v]++;
		g[u].push_back(v);
		g[v].push_back(u);
		edges.push_back({u, v});
	}
	int num_colors = *max_element(deg+1, deg+n+1);
	queue<int> q;
	int color = 1;
	for(auto u:g[1]){
		Map[{u, 1}] = Map[{1, u}] = color++;
		q.push(u);
	}
	while(!q.empty()){
		int v = q.front(); q.pop();
		color = 1;
		int p;
		for(auto u:g[v]) {
			if (Map[{u, v}]) {
				p = u;
				break;
			}
		}
		for(auto u:g[v]){
			if (u == p) continue;
			if (color == Map[{v, p}]) color++;
			Map[{u, v}] = Map[{v, u}] = color++;
			q.push(u);
		}
	}
	cout << num_colors << endl;
	for(auto e:edges){
		cout << Map[e] << endl;
	}
	return 0;
}


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

int main() {
    string in = "";
    cin >> in;
    string check = "abcdefghijklmnopqrstuvwxyz";
    for(int i = 0; i<26; i++) {
        if(in.find(check[i]) == string::npos) {
            cout << check[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn (1<<17)+5
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int n,m;
int a[20];
ll fac[maxn],inv[maxn];
ll dp[20][maxn];
ll quickpow(ll p,ll k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)
			ans=(ans*p)%mod;
		p=(p*p)%mod;
		k>>=1;
	}
	return ans;
}
ll c(ll n1,ll m1)
{
	if(n1<m1) return 0;
	return fac[n1]*inv[m1]%mod*inv[n1-m1]%mod;
}
int getbit(int now)
{
	int res=0;
	while(now)
		res+=(now&1),now>>=1;
	return res;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[m-i+1]);
	fac[0]=1;
	for(int i=1;i<=maxn-5;i++)
		fac[i]=fac[i-1]*i%mod;
 
	inv[maxn-5]=quickpow(fac[maxn-5],mod-2);
	for(int i=maxn-5;i>=1;i--)
		inv[i-1]=inv[i]*i%mod;
	inv[0]=1;
 
	dp[0][0]=1;
 
	for(int i=0;i<m;i++)
	{
		for(int state=0;state<(1<<n);state++)
		if(dp[i][state])
		{
			dp[i+1][state]+=dp[i][state];
			dp[i+1][state]%=mod;
 
			for(int j=0;j<n;j++)
			if(((1<<j)&state)==0)
			{
				dp[i+1][state|(1<<j)]+=(dp[i][state]*fac[(1<<j)]%mod*c((1<<n)-state-a[i+1],(1<<j)-1)%mod);
				dp[i+1][state|(1<<j)]%=mod;
			}
		}
	}
 
	ll ans=0;
	for(int state=0;state<(1<<n);state++)
	{
		int cnt=getbit(state);
		ll f=(cnt&1)?-1:1;
		ans=(ans+f*dp[m][state]*fac[(1<<n)-state-1])%mod;
	}
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",(ans*(1<<n))%mod);
}//test

Measured memory_bytes: 18816
#include <iostream>
#include <vector>
#include <typeinfo>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    ll ai;
    ll m = 0;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> ai;
        a[i] = ai;
        if(m<ai){
            m = ai;
        }
    }
    ll d = 10000000000, d1 = 10000000000, d2 = 10000000000;
    bool mb = false;
    for(int i=0; i<n; i++){
        if(!mb and a[i]==m){
            mb = true;
        }else{
            if(m%2==0){
                if(abs(a[i]-m/2) < abs(d)){
                    d = a[i]-m/2;
                }
            }else{
                if(abs(a[i]-(m-1)/2) < abs(d1)){
                    d1 = a[i] - (m-1)/2;
                }
                if(abs(a[i]-(m+1)/2) < abs(d2)){
                    d2 = a[i] - (m+1)/2;
                }
            }
        }
        //cout << "d1=" << d1 << " d2=" << d2 << endl;
    }
    if(m%2==0){
        cout << m << " " << d+m/2;
    }else{
        if(d1<d2){
            cout << m << " " << d1+(m-1)/2;
        }else{
            cout << m << " " << d2+(m+1)/2;
        }
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int h,w;cin>>h>>w;
    int ah,aw;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            string s;cin>>s;
            if(s=="snuke"){
                ah=i+1;
                aw=j+1;
            }
        }
    }
    char c='A'+(aw-1);
    cout<<c<<ah<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 5e5 + 5 ;
char s[N] ; 
int a[N] ; 
signed main()
{
	cin >> ( s + 1 ) ;
	int n = strlen(s + 1) ; 
	int ans = 0, top = 0, bef = 0, cnt = 0 ;
	for( re int i = 1; i <= n; ++ i ) {
		if( s[i] == '<' ) {
			if( bef != i - 1 ) {
				for( re int j = bef; j <= i - 1; ++ j ) {
					a[j] = max( cnt, a[j] ), -- cnt ;
				}
				cnt = 0, top = 0 ;
			}
			a[i - 1] = top, ++ top, a[i] = top, bef = i ;
		}
		else ++ cnt ;
	}
	if( s[n] == '<' ) a[n] = top ; 
	else {
		for( re int j = bef; j <= n; ++ j ) {	
			a[j] = max( cnt, a[j] ), -- cnt ;
		}
		cnt = 0, top = 0 ;
	} 
	rep( i, 0, n ) ans += a[i] ;
	cout << ans << endl ;
	return 0 ;
}

Measured memory_bytes: 4608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int MAX_N = 100;

int main()
{
    long double pi = 3.14159265358979323;
    long double a,b,c;

    cin >> a;

    cout << 2*a*pi << endl;

    return 0;
}

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

struct Card{
    char suit,value;
};

void bubble(struct Card A[],int N){
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i+1;j--){
            if(A[j].value<A[j-1].value){
                Card t = A[j];A[j]=A[j-1];A[j-1]=t;
            }
        }
    }
}

void selection(struct Card A[],int N){
    for(int i=0;i<N;i++){
        int minj = i;
        for(int j=i;j<N;j++){
            if(A[j].value<A[minj].value) minj = j;   
        }
        Card t = A[i]; A[i] = A[minj]; A[minj]=t;
    }
}

void print(struct Card A[],int N){
    for(int i=0; i<N; i++){
        if(i>0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
} 

bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i=0;i<N;i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int N;
     
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i=0; i<N; i++){
        C2[i] = C1[i];
    }

    bubble(C1,N);
    selection(C2,N);

    print(C1,N);
    cout << "Stable" << endl;

    print(C2,N);
    if(isStable(C1,C2,N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
A, B, K = map(int, input().split())

if K == 0:
    print(A, B)

elif A >= K:
    A = A - K
    print(A, B)
elif A < K:
    K = K - A
    A = 0
    if B >= K:
        B = B - K
        print(A, B)
    else:
        B = 0
        print(A, B)


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

void solve(){
    int n;
    cin >> n;
    double a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    double sum = 0;
    rep(i,n){
        sum += 1.0/a[i];
    }
    cout << setprecision(10) << 1.0/sum << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

int32_t main(){
    int n;
    cin>>n;
    cout<<(n*(n-1))/2<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <boost/math/common_factor.hpp> 
using namespace std;
int main(){
  int n,ans=1,a;cin>>n;
  while(n--) cin>>a,ans=boost::math::lcm(ans,a); 
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

long n,m,q;
vector<vector<long>> vv(100,vector<long>(5,0));
long res = 0;

long dfs(vector<long> v){
    if(long(v.size()) < n){
        for(long i = v.back();i<=m;i++){
            vector<long> send(v.size(),0);
            copy(begin(v),end(v),begin(send));
            send.push_back(i);
            dfs(send);
        }
        return 0;
    }else if(long(v.size()) > n)return 0;
    else{
        long sum = 0;
        rep(i,q){
            if(v[vv[i][1]-1] - v[vv[i][0]-1] == vv[i][2])sum += vv[i][3];
            else sum += 0;
        }
        res = max(res,sum);
        return 0;
    }
}


//ミョ(-ω- ?)
int main() {
    cin >> n >> m >> q;
    vv.resize(q);
    rep(i,q)cin >> vv[i][0] >> vv[i][1] >> vv[i][2] >> vv[i][3];
    repl(i,1,10){
        vector<long> v = {i};
        dfs(v);        
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    int n;
    cin>>n;
    int f[MAX]={},h[MAX]={};
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    h[0]=0;
    f[1]=0;
    f[2]=abs(h[2]-h[1]);

    for(int i=3;i<=n;i++){
        f[i]=min(f[i-1]+abs(h[i-1]-h[i]),f[i-2]+abs(h[i-2]-h[i]));
    }

    cout<<f[n]<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int h, w; cin >> h >> w;
	char s[21][21];
	REP(i, h) {
		REP(j, w) {
			cin >> s[i][j];
		}
	}
	int ans = 0;
	int d[21][21];
	REP(i, h) {
		REP(j, w) {
			if (s[i][j] == '#')continue;
			REP(k, 21) {
				REP(l, 21) {
					d[k][l] = INF;
				}
			}
			queue<pii>Q;
			Q.push({ i,j });
			d[i][j] = 0;
			while (!Q.empty()) {
				int y = Q.front().first;
				int x = Q.front().second;
				Q.pop();
				for (int k = 0; k < 4; ++k) {
					int ny = y + dy[k];
					int nx = x + dx[k];
					if (0 <= ny && ny < h && 0 <= nx && nx < w&&s[ny][nx] == '.'&&d[ny][nx] == INF) {
						Q.push({ ny,nx });
						d[ny][nx] = d[y][x] + 1;
					}
				}
			}
			REP(k, h) {
				REP(l, w) {
					if (d[k][l] == INF)continue;
					if (s[k][l] == '#')continue;
					ans = max(ans, d[k][l]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    *e, = map(int, input())
    e.reverse()

    inf = 20 * len(e)

    dp = [0, inf]  # 繰り下がり無,有

    for x in e:
        ndp = [-1, -1]  # 繰り下がり無,有

        ndp[0] = min(
            dp[0] + x,
            dp[1] + ((x + 1) if x < 9 else inf)  # ちょうど支払えないのでinf
        )  # ちょうど支払う

        ndp[1] = min(
            dp[0] + ((10 - x) if x > 0 else inf),  # 繰り下がりにならないのでinf
            dp[1] + (10 - (x + 1))
        )  # 0枚支払って繰り下がり

        dp = ndp

    print(min(dp[0], dp[1] + 1))


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 14628
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int n=read();
    printf("%lld\n",n/3);
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <queue>


using namespace std;

#define MAX_A 100000

// i日後に支払われるのかでまとめる。
vector<int> salary[MAX_A] = {};

int main()
{
	const int MAX_N = 100000;
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < n; i++)
	{
		int _a, _b;
		cin >> _a >> _b;
		salary[_a].push_back(_b);
	}


	priority_queue<int> getMoneyJob;
	int answer = 0;

	// 期限まで1日前からはじめて、報酬を得られる仕事を追加していく。
	// 行った仕事は削除していく
	for (int i = 1; i <= m; i++)
	{
		// 報酬取得可能な仕事の追加
		int iSize = salary[i].size();
		if (iSize > 0)
		{
			for (int j = 0; j < iSize; j++)
				getMoneyJob.push(salary[i][j]);
		}

		// 最も高額なものを取り出す
		if (!getMoneyJob.empty())
		{
			answer += getMoneyJob.top();
			getMoneyJob.pop();
		}
	}

	cout << answer;


	return 0;
}



Measured memory_bytes: 5632
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	string s;
	cin >> s;
	int N = s.size();
	ll ans = 0;
	int nowA = 0;
	rep(i,N){
		if(s[i] == 'A'){
			nowA++;
		}else if(s.substr(i,2) == "BC"){
			ans += nowA;
			i++;
		}else{
			nowA = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 720
#include<stdio.h>
#include<stdlib.h>

char ha[1<<22],k[256];

int hash(char *str)
{
  int h=1;
  while(*str) h=(h<<2)+k[*str++];
    return h;
}

int main(){
  int i,h,n;
  char c[8],str[13];

  k['C']=1;
  k['G']=2;
  k['T']=3;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf(" %s %s",c,str);
    h=hash(str);

    if(c[0]=='i') 
      ha[h>>3] |= 1<<(h&7);

    else puts((ha[h>>3] & (1<<(h&7)))? "yes":"no");
  }
  return 0;
}

Measured memory_bytes: 768
import Control.Applicative
import Control.Monad
import qualified Data.Vector as V
import Data.Array.IO

main = do
  n <- readLn :: IO Int
  s <- V.fromList <$> getLine

  dp_1101 <- newArray (0, n) (-inf) :: IO (IOArray Int Int)
  dp_1011 <- newArray (0, n) (-inf) :: IO (IOArray Int Int)
  dp_wait <- newArray (0, n) (-inf) :: IO (IOArray Int Int)

  writeArray dp_wait 0 0

  forM_ [0..n-1] $ \i -> do
    when (i+3 <= n && (V.toList . V.slice i 3) s == "101") $ do
      readArray dp_wait i >>= to dp_1011 (i + 3) 1
      readArray dp_1101 i >>= to dp_wait (i + 3) 1
      readArray dp_wait i >>= to dp_wait (i + 3) 1
    when (s V.! i == '1') $ do
      readArray dp_1011 i >>= to dp_1011 (i + 1) 1
      readArray dp_1101 i >>= to dp_1101 (i + 1) 1
      readArray dp_wait i >>= to dp_1101 (i + 1) 1
      readArray dp_1011 i >>= to dp_wait (i + 1) 1
    readArray dp_wait i >>= to dp_wait (i + 1) 0

  readArray dp_wait n >>= print

to :: IOArray Int Int -> Int -> Int -> Int -> IO ()
to a i c v = readArray a i >>= writeArray a i . max (v + c)

inf :: Int
inf = 10^9

Measured memory_bytes: 201596
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);


int n;
cin>>n;
string ans="";


while(n>0)
{
   int z=n%26;
   z--;
   if(z<0)z+=26;
   ans+='a'+z;
    if(n%26==0)
    n=n/26 -1;
    else
    n/=26;
}
for(int i=ans.size()-1;i>=0;i--)
cout<<ans[i];



}

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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, maxm=5e4+10, lg=21, mod=1e9+7, inf=1e18;

ll n,L[maxn],R[maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n;
	for(int i=0;i<n;i++) cin>>L[i]>>R[i];
	sort(L,L+n,greater<ll>()), sort(R,R+n);
	ll sum=0,sub=0,mx=0;
	for(int i=0;i<n;i++){
		mx=max(mx,sum+=2*L[i]);
		mx=max(mx,sub-=2*R[i]);
		mx=max(mx,sum-=2*R[i]);
		mx=max(mx,sub+=2*L[i]);
	}
	cout<<mx;
	
	return 0;
}



 


Measured memory_bytes: 5204
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

const int N=100000+19;

char s[N];
int n,res;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	For(i,2,n+1) if (s[i]!=s[i-1]) res++;
	printf("%d\n",res);
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A,*B;
  int C[VMAX+1];
  int i,n,j;
    
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  

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

  
  for(i = 0; i < VMAX; i++)
    C[i] = 0;
  
  for(j = 1; j <= n; j++)
    C[A[j]]++;
  /*
  for(i=0;i<=2;i++){
    if( i != 0)
      printf(" ");
    printf("%d", C[i]);
  }
  
  printf("\n");
  */
  for(i = 1; i < VMAX; i++)
    C[i] += C[i-1];

  for(j = n; j > 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i = 1; i <= n; i++){
    if( i != 1)
      printf(" ");
    printf("%d", B[i]);
  }

  printf("\n");
  return 0;
}


  



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

int main(){

    int n;
    cin >> n;

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

    return 0;
}

Measured memory_bytes: 256
import copy
N = int(input())
S = input()
LAlphabet = [False] * 26
L = []
for s in S:
    LAlphabet[ord(s)-97] = True
    L.append(copy.deepcopy(LAlphabet))

RAlphabet = [False] * 26
R = []
for s in reversed(S):
    RAlphabet[ord(s)-97] = True
    R.append(copy.deepcopy(RAlphabet))
R.reverse()
ans = 0

print(max([sum([L[l][t] and R[l+1][t] for t in range(26)]) for l in range(N-1)]))

Measured memory_bytes: 41712
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto np = readln.split.to!(int[]);
    auto P = np[1];
    auto S = readln.chomp;

    if (P == 2 || P == 5) {
        long r;
        foreach (i, c; S) {
            if ((c-'0') % P == 0) r += i+1;
        }
        writeln(r);
        return;
    }

    auto cs = new long[](P);
    cs[0] = 1;
    long x, t = 1, r;
    foreach_reverse (c; S) {
        x = ((c-'0').to!long * t + x) % P;
        t = (t * 10) % P;
        r += cs[x];
        ++cs[x];
    }
    writeln(r);
}

Measured memory_bytes: 2556
import java.util.Scanner;

public class Main{
	
	private static int[] A;

	public static void main(String[] args) {
		int n;
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		A = new int[n];
		for(int i = 0; i < n; i ++) {
			A[i] = in.nextInt();
		}
		in.close();
		
		
		buildMaxHeap();
		printHeap();
		
	}
	
	public static void maxHeapify(int[] A, int i) {
		int largest = i;
		int l = 2*i + 1;
		int r = 2*i + 2;
		
		if (l < A.length && A[l] > A[largest]) {
			largest = l;
		}
		
		if (r < A.length && A[r] > A[largest]) {
			largest = r;
		}
		
		if (largest != i) {
			int temp = A[i];
			A[i] = A[largest];
			A[largest] = temp;
			maxHeapify(A, largest);
		}
		
	}
	
	public static void buildMaxHeap() {
		for (int i = (A.length / 2) - 1; i >= 0; i--) {
			maxHeapify(A, i);	
		}
	}
	
	public static void printHeap() {
		for (int i = 0; i < A.length; i++) {
			System.out.print(" "+ A[i]);
		}
System.out.println();
	}

}


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

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

const int mod = 1e9 + 7;

void f(int& x){
    x += 2 * mod;
    if (x >= mod)
        x %= mod;
}

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

    string k;
    cin >> k;

    int d;
    cin >> d;

    int n = k.length();

    vector<vi> dp(d, vi(2, 0));
    //dp[i][j] - broj nacina da napravimo sumu i ako jesmo/nismo (j=0v1) uzeli manju cifru do sad

    dp[0][0] = 1;
    for (int i = 0; i < n; ++i){
        vector<vi> new_dp(d, vi(2, 0));
        for (int suma = 0; suma < d; ++suma){
            for (int j = 0; j < 2; ++j){
                for (int b = 0; b < 10; ++b){
                    if (b > k[i] - '0' && !j) break;
                    new_dp[(suma + b) % d][j || (b < k[i] - '0')] += dp[suma][j];
                    f(new_dp[(suma + b) % d][j || (b < k[i] - '0')]);
                }
            }
        }
        dp = new_dp;
    }

    int sol = (dp[0][0] + dp[0][1]) % mod;
    --sol;
    if (sol == -1)
        sol = mod - 1;
    cout << sol << '\n';
}

Measured memory_bytes: 384
package main

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

func main() {
	sc := newScanner()
	var x = sc.readInt64()
	var ans int64
	ans += (x / 500) * 1000
	x = x % 500
	ans += (x / 5) * 5
	fmt.Println(ans)

}

//////////////////
//////////////////
//////////////////

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T> inline T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m,ans=0;cin>>n>>m;
  V<ll> v(n),sum(n+1,0);
  rep(i,0,n)cin>>v[i];
  sort(all(v));

  repr(i,0,n)sum[i]=sum[i+1]+v[i];

  ll ng=2*mpow(10ll,5ll)+10,ok=0,mid;
  while(abs(ok-ng)>1){
    ll num=0;
    mid=(ok+ng)/2;

    rep(i,0,n){
      ll ue=n,st=-1,mi;
      while(abs(ue-st)>1){
        mi=(ue+st)/2;
        if(v[mi]+v[i]>=mid)ue=mi;
        else st=mi;
      }
      num+=n-ue;
    }

    if(m<=num)ok=mid;
    else ng=mid;
  }


  ll num=0;
  rep(i,0,n){
    ll ue=n,st=-1,mi;
    while(abs(ue-st)>1){
      mi=(ue+st)/2;
      if(v[mi]+v[i]>ok)ue=mi;
      else st=mi;
    }
    ans+=sum[ue]+(n-ue)*v[i];
    num+=n-ue;
    //cerr<<ans<<" "<<num<<ENDL;
  }
  ans+=(m-num)*ok;

  cout<<ans<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  ll n;
  cin>>n;
  vector<ll>d(n);
  rep(i,n){
    cin>>d[i];
  if((i>0&&d[i]==0)||d[0]!=0){
    cout<<0;
    return 0;
  }
  }
  vector<ll>s(n);
  rep(i,n){
   s[d[i]]++;
  }
  ll ans=1,mod=998244353;
  for(int i=1;i<n;i++){
    for(int j=0;j<s[i];j++)ans=ans*1LL*s[i-1]%mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
_ = input()
T,A = map(int, input().strip().split(' '))
H = list(map(int, input().strip().split(' ')))
min_idx, min_diff = None, float('inf')
for i in range(len(H)):
  tmp = abs(A-(T-H[i]*0.006))
  if tmp < min_diff:
    min_diff = tmp
    min_idx = i
print(min_idx+1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final int N=sc.nextInt();
    char[] s=sc.next().toCharArray();
    int sum=N;
    for(int i=0;i<N-1;i++){
      if(s[i]==s[i+1]){
        sum--;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 25284
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	tmp, _ := reader.ReadString('\n')
	tmp = strings.Trim(tmp, "\n")

	n, _ := strconv.Atoi(tmp)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		tmp, _ = reader.ReadString('\n')
		tmp = strings.Trim(tmp, "\n")

		tmpi, _ := strconv.Atoi(tmp)
		a[i] = tmpi
	}

	org := make([]int, n)
	for i := 0; i < n; i++ {
		org[i] = a[i]
	}
	sort.Ints(a)

	for i := 0; i < n; i++ {
		if org[i] >= a[n-1] {
			fmt.Println(a[n-2])
		} else {
			fmt.Println(a[n-1])
		}
	}

}


Measured memory_bytes: 8064
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        Long X = sc.nextLong();
        Long Y = sc.nextLong();

        for(int i=1; i<=1000000000; i++){
            if(X*2>Y){
                System.out.println(i);
                break;
            }
            X *= 2;
        }
    }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
int main() {
	int	n,i,c,cnt,j,d[10];
	while (~fscanf(stdin, "%d", &n), n != 0) {
		memset(d, 0, sizeof(d));
		cnt = 0;
		while (n--) {
			fscanf(stdin, "%d", &c);
			d[c]++;
		}
		for (i = 0; i < 10; i++, putchar('\n')) {
			for (j = 0; j < d[i]; j++) putchar('*');
			if (d[i] == 0) putchar('-');
		}
	}
	return 0;
}

Measured memory_bytes: 576
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		String step = sc.next();
		boolean flag = true;
		for(int i = 0; i < step.length(); i++){
			if(i % 2 == 0 && step.charAt(i) == 'L'){
				flag = false;
				break;
			}
			else if(i % 2 == 1 && step.charAt(i) == 'R'){
				flag = false;
				break;
			}
		}
		
		System.out.println((flag)?"Yes":"No");
	}
}

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

# nがmより大きければ交換 (n <= mにする)
if n > m:
    n, m = m, n

if n >= 2:
    print((n-2)*(m-2))
elif n == 1 and m >= 2:
    print(m-2)
elif n == 1 and m == 1:
    print(1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    bool flag = false;
    FOR(i, 1, 10) {
        FOR(j, 1, 10) {
            if (i * j == n)
                flag = true;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    solve();
    return 0;
}


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

using namespace std;

class node
{
public:
  int v;
  node *left,*right;

  node(int _v=0)
  {
      v=_v,left=right=NULL;
  }
};

node *root=NULL;

void ins(int a)
{
    node *tmp=new node(a);

    node *x=root,*y=NULL;

    while(x)
    {
        y=x;

        if(a<x->v)
        {
            x=x->left;
        }else
        {
            x=x->right;
        }
    }

    if(!y)
    {
        root=tmp;
    }else if(a<y->v)
    {
        y->left=tmp;
    }else
    {
        y->right=tmp;
    }
}

void in(node *r)
{
    if(!r)  return;

    in(r->left);
    printf(" %d",r->v);
    in(r->right);
}

void pre(node *r)
{
    if(!r)  return ;


    printf(" %d",r->v);
    pre(r->left);
    pre(r->right);
}

void print()
{
    in(root);
    printf("\n");
    pre(root);
    printf("\n");
}

bool fnd(node *r,int a)
{
    if(!r) return false;

    if(r->v==a) return true;

    if(r->v<a) return fnd(r->right,a);
    else    return fnd(r->left,a);
}


int main()
{
    int n;

    cin>>n;

    string s;
    int a;

    while(n--)
    {
        cin>>s;

        if(s=="insert")
        {
            cin>>a;
            ins(a);
        }else if(s=="find")
        {
            cin>>a;
            if(fnd(root,a))
            {
                cout<<"yes"<<endl;
            }else
            {
                cout<<"no"<<endl;
            }
        }else
        {
            print();
        }
    }



    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int>h(n);
  rep(i,n) cin>>h.at(i);
  int count=0;
  int ma = h.at(0);
  rep(i,n){
    if(ma<=h.at(i)) count++;
    ma = max(ma,h.at(i));
  }
  cout << count << endl;
}


Measured memory_bytes: 256
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
f = min([a[i+1]-a[i] for i in range(n)])
ans = f
for i in range(n):
    if (a[i+1] - a[i])%f:
        ans = min(ans,(a[i+1] - a[i])%f)
print(ans)

Measured memory_bytes: 14224
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

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

    string S;
    cin >> S;
    int N = S.size();

    int i = 0;
    string res = "YES";
    while (i < N) {
        if (S.substr(i, 11) == "dreameraser") {
            i += 11;
        } else if (S.substr(i, 10) == "dreamerase") {
            i += 10;
        } else if (S.substr(i, 7) == "dreamer") {
            i += 7;
        } else if (S.substr(i, 5) == "dream") {
            i += 5;
        } else if (S.substr(i, 6) == "eraser") {
            i += 6;
        } else if (S.substr(i, 5) == "erase") {
            i += 5;
        } else {
            res = "NO";
            break;
        }
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

//約数列挙
template <class T>
vector<T> divisor(T x){
	vector<T> res;
	for(T i=1;i*i<=x;i++){
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i){
				res.push_back(x/i);
			}
		}
	}
	return res;
}

//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vector<ll> ret=divisor(m);
	ll ans=1;
	for(auto x:ret){
		ll y=m/x;
		if(y>=n){
			chmax(ans,x);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
// }}}


signed main()
{
    int N, L;
    vector<int> a;

    cin >> N >> L;
    a.resize(N);
    for (int i = 0; i < N; ++i) {
        a[i] = L + i;
    }
    sort(ALL(a), [](auto a, auto b) { return abs(a) < abs(b); });

    int sum = 0;
    for (int i = 1; i < N; ++i) {
        sum += a[i];
    }
    cout << (sum) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int a;
  cin >> a;
  cout << a*800 - 200 * (a/15) <<endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	cin>>s;
	t = "";
	ll cou = 0;

	for(ll i=0;i<n;i++) {
		if(s[i]=='(') cou++;
		else cou--;
		t += s[i];
		if(cou == -1) {
			cou = 0;
			t = '('+t;
		}
	}

	while(cou > 0) {
		t += ')';
		cou --;
	}
	cout<<t;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	int res = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			res += S[i][j] != '#';
		}
	}
	int si = 0, sj = 0;
	queue<P> q;
	vector<vector<int>> d(H, vector<int>(W, -1));
	q.emplace(si, sj);
	d[si][sj] = 1;
	while (!q.empty()) {
		P p = q.front(); q.pop();
		for (int i = 0; i < 4; i++) {
			int tx = p.first + dx[i], ty = p.second + dy[i];
			if (0 <= tx && tx < H && 0 <= ty && ty < W && S[tx][ty] == '.' && d[tx][ty] == -1) {
				d[tx][ty] = d[p.first][p.second] + 1;
				q.emplace(tx, ty);
			}
		}
	}
	cout << (d[H - 1][W - 1] == -1 ? -1 : res - d[H - 1][W - 1]) << endl;
	return 0;
}


Measured memory_bytes: 256
/*|In The Name of Allah|*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pair<int,int> > vii;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> pii;
#define el	'\n'
#define lp(i,n) for(int i = 0;i < int(n);i++)
#define rlp(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rng(i,a,b) for(int i = int(a);i <= int(b);i++)
#define mp(x,y)  	make_pair((x),(y))
#define pb(x)    	push_back((x))
#define all(v)  	((v).begin()),((v).end())
#define sz(x)  		((int) (x).size())
#define bits(a) 	__builtin_popcountll(a)
#define fr first
#define sc second
#define pii pair<int, int>
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define SS stringstream
#define ll long long
#define clr(x, y) memset(x, y, sizeof(x))
#define foreach(it,x) for(__typeof__((x).begin()) it = (x).begin(); it != (x).end(); ++it)
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
ll gcd(ll a, ll b){if (a == 0)return b;return gcd(b % a, a);}



void MisSiOn_ImPosSiBlE(){
//freopen("portals.in", "r", stdin);
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

}


int const N = 5e6 + 9, mod = 1e9+7 , oo = 0x3f3f3f3f;
//------------------------------------------------------------------------------------




int arr[N];
int main()
{
    MisSiOn_ImPosSiBlE();


    int n=3;
    lp(i,n)cin>>arr[i];
    sort(arr,arr+n);
    cout<< 0.5*arr[1]*arr[0];















/*
*/
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}

void solve()
{

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




signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}





Measured memory_bytes: 3700
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int N = sc.nextInt();
    Set<Integer> p = new HashSet<Integer>();
    for (int i =0; i<N; i++) {
      p.add(sc.nextInt());
    }
    int i =1, ans =0;
    if (N ==0) {
      ans =X;
    } else if (!p.contains(X)){
      ans =X;
    } else {
      while (true) {
        if (!p.contains(X-i)) {
          ans = X -i;
          break;
        }
        if (!p.contains(X+i)) {
          ans = X +i;
          break;
        }
        i++;
      }
    }
   System.out.println(ans);
  }
}

Measured memory_bytes: 27244
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a*b%2==0){
		cout<<"Even"<<endl;
	}
	else if(a*b%2!=0){
		cout<<"Odd"<<endl;
	}
}

Measured memory_bytes: 256