akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
	ll s;cin>>s;
    ll m[1000001];rep(i,0,1000001)m[i]=0;
    for(ll i=1;;i++){
        if(m[s] == 1){
            cout<<i<<ednl;
            return 0;
        }else{
          	m[s] = 1;
            if(s%2==0){
                s/=2;
            }else{
                s=3*s+1;
            }
        }
    }
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b, c;

int main()
{
    cin >> a >> b >> c;
    vi v{a, b, c};
    sort(all(v));

    int ans = 0;

    // situation 1
    ans += v[2] - v[1];
    v[0] += (v[2] - v[1]); v[1] = v[2];

    if(v[0] == v[1]){
        cout << ans << endl;
        return 0;
    }

    // situation 2
    int dif = v[1] - v[0];
    if(dif % 2 == 0){ ans += dif / 2; }
    else{ ans += (dif / 2 + 1) + 1; }
    cout << ans << endl;
    return 0;
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
//const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll N, X; cin >> N >> X;
    ll res = N; // 最初の 2 本の合計の長さ

    // 最初の 2 本の平行四辺形
    ll a = max(N - X, X);
    ll b = min(N - X, X); 

    // Euclid の互除法を非再帰で回してみる
    while (b) {
        ll q = a / b;
        ll r = a % b;

        res += (b * 2) * q; // 答えを加算
        if (r == 0) res -= b; // 最後だけ「対角線」のみになるので
        a = b, b = r; // 次の平行四辺形は (b, r)
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 5e3+5;

int BIT[MAXN];
void updBIT(int p, int val){
    p++;
    for(; p < MAXN; p += p&-p) BIT[p] += val;
}
int sumBIT(int p){
    p++;
    int ret = 0;
    for(; p; p -= p&-p) ret += BIT[p];
    return ret;
}

int dp[MAXN][MAXN];
int pos[2][MAXN];
int n;

int f(int w, int b){
    if(dp[w][b] != -1) return dp[w][b];
    if(w == n && b == n) return 0;
    int ret = INF;
    if(w < n){
        updBIT(pos[0][w], -1);
        ret = min(ret, sumBIT(pos[0][w]) + f(w+1, b));
        updBIT(pos[0][w], 1);
    }
    if(b < n){
        updBIT(pos[1][b], -1);
        ret = min(ret, sumBIT(pos[1][b]) + f(w, b+1));
        updBIT(pos[1][b], 1);
    }

    return dp[w][b] = ret;
}

char tmp[5];

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

    ms(dp, -1);
    ri(n);
    FOR(i,0,2*n){
        int x;
        scanf("%s", tmp);
        ri(x); x--;
        pos[tmp[0] == 'B'][x] = i;
        updBIT(i, 1);
    }

    printf("%d\n", f(0,0));

    return 0;
}


Measured memory_bytes: 98432
N = int(input())

AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[1])
time = 0
flag = True

for i in range(N):
    time += AB[i][0]
    
    if (time > AB[i][1]):
        flag = False
        break

if (flag):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 53600
#include <iostream>
#include <cstring>
#include <algorithm>
 
using namespace std;
 
constexpr int MAX = 4001;
  
int dp[MAX][MAX];
  
int main()
{
    string s1, s2;
  
    while (cin >> s1 >> s2) {
        memset(dp, 0, sizeof(dp));
  
        int n = s1.size(), m = s2.size();
        int ans = 0; 
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (s1[i] == s2[j]) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                }
                ans = max(ans, dp[i + 1][j + 1]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 65640
#include<stdio.h>

int main(){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int d = 1;
    if(a != b){
        d++;
    }
    if(a != c && b != c){
        d++;
    }
    printf("%d\n", d);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int N, sum, cnt;
  while(cin >> N, N){
    cnt = 0;
    for(int i = 1 ; i < N ; i++){
      sum = 0;
      for(int j = i ; j < N ; j++){
	sum += j;
	
	if(sum > N) break;
	else if(sum == N){
	  cnt++;
	  break;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

int main() {
    int N;
    cin >> N;

    string s;
    cin >> s;

    map<char,int> mp;
    REP(i,N) mp[s[i]]++;
    
    ll ans=1;
    for(auto m:mp) mulM(ans,m.second+1);

    pl(ans-1)

    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 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 PI=acos(-1);
const double EPS=1e-10;

struct state{
	char c;
	int a;
};

//ARC 097 E Sorted and Sorted
/*
dp[i][j]:左からi個黒、j個白が埋まってるとした時の最小回数とすれば良い
dp[i+1][j]を考えるときに、i+1が書かれた黒ボールを(i+j+1)番目におけば良い
そのための操作回数は初期状態でi+1が書かれた黒ボールよりも左にある、
i+2以上の黒ボールの数とj+1以上の白ボールの数の合計値になる
これを前計算
*/
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<state> g(2*n);
	rep(i,2*n){
		cin>>g[i].c>>g[i].a;
		g[i].a--;
	}
	vector<vector<int>> dp(n+1,vector<int>(n+1,INF));
	vector<vector<int>> black(n+1,vector<int>(n+1,0));
	vector<vector<int>> white(n+1,vector<int>(n+1,0));
	vector<vector<int>> sumb(n+1,vector<int>(2*n+1,0));
	vector<vector<int>> sumw(n+1,vector<int>(2*n+1,0));
	rep(i,n){//位置xまでにある黒i以上の個数を求める(白も同様)
		rep(x,2*n){
			char color=g[x].c;
			int num=g[x].a;
			sumb[i][x+1]=sumb[i][x];
			sumw[i][x+1]=sumw[i][x];
			if(color=='B'){
				if(num>=i) sumb[i][x+1]++;
			}else{
				if(num>=i) sumw[i][x+1]++;
			}
		}
	}
	rep(x,2*n){//black[i][j]:黒iの位置xより左にある黒i以上,白j以上のボールの個数
		char color=g[x].c;
		int num=g[x].a;
		rep(j,n+1){
			if(color=='B'){
				black[num][j]=sumb[num][x]+sumw[j][x];
			}else{
				white[num][j]=sumw[num][x]+sumb[j][x];
			}
		}
	}
	dp[0][0]=0;
	rep(i,n+1)rep(j,n+1){
		if(i+1<=n) chmin(dp[i+1][j],dp[i][j]+black[i][j]);
		if(j+1<=n) chmin(dp[i][j+1],dp[i][j]+white[j][i]);
	}
	cout<<dp[n][n]<<endl;
}

Measured memory_bytes: 110208
#include<cstdio>
#include<algorithm>
#include<cstring>
#define lson o<<1
#define rson o<<1|1
#define mid (l+r)/2
using namespace std;
int n,p[200005],maxx[200005],v[200005],x[800005][2],f[800005][2],sum[200005];
void pushup(int o)
{
	x[o][0]=max(x[lson][0],x[rson][0]);
	x[o][1]=max(x[lson][1],x[rson][1]);
}
void update(int o,int l,int r,int p,int v0,int v1)
{
	if(l==r)
	{
		x[o][1]=v1;
		x[o][0]=v0;
		return;
	}
	if(p<=mid)update(lson,l,mid,p,v0,v1);
	else update(rson,mid+1,r,p,v0,v1);
	pushup(o);
}
pair<int,int>query(int o,int l,int r,int from,int to)
{
	if(l>=from&&r<=to)return make_pair(x[o][0],x[o][1]);
	pair<int,int>ans=make_pair(0,0),res;
	if(from<=mid)
	{
		res=query(lson,l,mid,from,to);
		if(res.first>ans.first)ans.first=res.first;
		if(res.second>ans.second)ans.second=res.second;
	}
	if(to>mid)
	{
		res=query(rson,mid+1,r,from,to);
		if(res.first>ans.first)ans.first=res.first;
		if(res.second>ans.second)ans.second=res.second;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		maxx[i]=max(maxx[i-1],p[i]);
		if(maxx[i]==p[i])v[i]=2;
		else v[i]=1;
	}
	for(int i=n;i>=1;i--)
	{
		pair<int,int>res=query(1,1,n,p[i],n);
		if(v[i]&1)
		{
			f[i][0]=res.second+v[i];
			f[i][1]=res.first+v[i];
		}
		else
		{
			f[i][0]=res.first+v[i];
			f[i][1]=res.second+v[i];
		}
		if(f[i][0]&1)f[i][0]=0;
		if(f[i][1]%2==0)f[i][1]=0;
		update(1,1,n,p[i],f[i][0],f[i][1]);
		if(maxx[i]==p[i])sum[i]=sum[i+1]+1;
		else sum[i]=sum[i+1];
	}
	int v1=0,v2=0,m1=0,m2=0;
	for(int i=1;i<=n;i++)
	{
		int vv1=v1+(p[i]>m1);
		int mm1=max(m1,p[i]);
		update(1,1,n,p[i],0,0);
		int g=vv1+sum[i+1]-v2,val;
		pair<int,int>res;
		if(g>=0)
		{
			res=query(1,1,n,min(m2+1,n),n);
			if(g&1)val=res.second;
			else val=res.first;
			if(val>=g)
			{
				printf("0");
				if(p[i]>m1)v1++,m1=p[i];
				continue;
			}
		}
		g=v2+sum[i+1]-vv1;
		if(g>=0)
		{
			res=query(1,1,n,min(mm1+1,n),n);
			if(g&1)val=res.second;
			else val=res.first;
			if(val>=g)
			{
				printf("0");
				if(p[i]>m1)v1++,m1=p[i];
				continue;
			}
		}
		if(i==1)
		{
			printf("-1\n");
			return 0;
		}
		printf("1");
		if(p[i]>m2)v2++,m2=p[i];
	}
	printf("\n");
	return 0;
}

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

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

	int cards[13][4] = { 0 };
	int i,j;
	char mark;
	int number;
	for (i = 0; i < n; i++) {
		cin >> mark >> number;
		switch (mark) {
		case 'S':
			cards[number-1][0] = 1;
			break;
		case 'H':
			cards[number-1][1] = 1;
			break;
		case 'C':
			cards[number-1][2] = 1;
			break;
		case 'D':
			cards[number-1][3] = 1;
			break;
		}
	}

	for (j = 0; j < 4; j++) {
		for (i = 0; i < 13; i++) {
			if (cards[i][j] == 0) {
				switch (j) {
				case 0:
					cout << "S " << i + 1 << endl;
					break;
				case 1:
					cout << "H " << i + 1 << endl;
					break;
				case 2:
					cout << "C " << i + 1 << endl;
					break;
				case 3:
					cout << "D " << i + 1 << endl;
					break;
				}
			}

		}
	}
	return 0;
}


Measured memory_bytes: 3092
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll A[1<<20];
ll maxanswer = 0;

int main() {
    int k,n;
    cin>>n>>k;
    rep(i, n) cin>>A[i];

    ll lsum = 0;
    ll msum = 0;
    ll rsum = 0;

    rep(i, n) {
        if(i < k) msum += A[i];
        else if(A[i] > 0) rsum += A[i];
    }

    maxanswer = max(max(lsum+rsum, lsum+rsum+msum), maxanswer);

    for(int i = 1;i+k-1 < n;i++) {
        msum = msum + A[i+k-1] - A[i-1];
        if(A[i-1] > 0) lsum += A[i-1];
        if(A[i+k-1] > 0) rsum -= A[i+k-1];
        maxanswer = max(max(lsum+rsum, lsum+rsum+msum), maxanswer);
    }

    cout<<maxanswer;
    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

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

using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k,i = 0;
  string s;
  cin  >> s >> k;
  ll suf = 0;
  ll mem = 0;
  while(i < k){
    if(suf == s.size()){
      mem = k - i; 
      break;
    }
    if(s[suf] != 'a'){
    if(k - i < 'z' - s[suf] + 1){
      ++suf;
    }
    else{
      i += 'z' - s[suf] + 1;
      s[suf] = 'a';
      ++suf;
    }
    }
    else ++suf;
  }
  mem %= 26;
  while(mem ){
    --mem;
    s.back()++;
    if(s.back() == '{') s.back() = 'a';
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 592
# 嘘解法を書いてしまったので、再提出。

# 最後に選ぶ料理は、食べる料理の中で時間が最もかかるものを食べるとして良い。
# 先に a で昇順ソートしておき、最後に選ぶ料理を i とした時に、
# それよりも時間のかからない料理だけを使って、t-1までに食べ切れるものの中で最も高い満足度を得るという方針。
# 前計算はナップサックDPで。

n, t = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()

a = []
b = []
for ai, bi in ab:
    a.append(ai)
    b.append(bi)

dp = [[0 for j in range(t+1)] for i in range(n+1)]

for i in range(n):
    for j in range(t):
        if j + a[i] <= t-1:
            if dp[i+1][j + a[i]] < dp[i][j] + b[i]:
                dp[i+1][j + a[i]] = dp[i][j] + b[i]
        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j]

ans = 0

for i in range(n):
    ans = max(ans, dp[i][t-1] + b[i])

print(ans)






Measured memory_bytes: 124376
import java.util.*;

public class Main{
    public static void main(String[] args){
        int h;
        int w;
        int i = 0;
        int j = 0;
        String n = System.getProperty("line.separator");
        Scanner scanner = new Scanner(System.in);
        while(true){
            h = scanner.nextInt();
            w = scanner.nextInt();
            if(h == 0 && w == 0) break;
            else{
                while(i < h){
                    while(j < w){
                        System.out.print("#");
                        j++;
                    }
                    j = 0;
                    System.out.print(n);
                    i++;
                }
                i = 0;
                System.out.print(n);
            }
        }
    }
}


Measured memory_bytes: 37540
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto e: v) os << e << ",";
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

string s;
int l[100010], r[100010];

void solve()
{
    int n = s.size();
    l[n-1] = n-1;
    r[0] = 0;
    FOR (i, 1, n)
        r[i] = (s[i] == 'R' ? i : r[i-1]);
    REPR (i, n-2)
        l[i] = (s[i] == 'L' ? i : l[i+1]);

    vector<int> ans(n);
    REP (i, n) {
        if (s[i] == 'L') {
            int d = r[i] - i;
            ans[r[i] + (d % 2 == 0 ? 0 : 1)]++;
        } else {
            int d = l[i] - i;
            ans[l[i] - (d % 2 == 0 ? 0 : 1)]++;
        }
    }
    REP (i, n-1) cout << ans[i] << " ";
    cout << ans[n-1] << endl;

}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 1872
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.close();
		
		for (int i = 0 ; i <= N / 4 ; i++) {
			for (int j = 0 ; j <= N / 7 ; j++) {
				int ans = i * 4 + j * 7;
				if (ans == N) {
					System.out.print("Yes"); 
					return;
				} else if (ans > N) {
					break;
				}
			}
		}
		System.out.print("No"); 
	}
}


Measured memory_bytes: 23892
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
    return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
    a+=b;
    if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
    a-=b;
    if(a<0){
        a+=mod;
    }
    return a;
}
 
int powz(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1){
            res=mul(res,a);
        }
        b/=2;
        a=mul(a,a);
    }
    return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
    input>>x.F>>x.S;
    return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
    for(auto& i:x)
        input>>i;
    return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
    for(auto& i:x)
        output<<i<<' ';
    return output;
}
 
const int N=200005;

int cnt[N];
bool pos[N];

void solve(){
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>>a(m);
	cin>>a;
	pos[0]=true;
	for(int i=0;i<n;i++){
		cnt[i]=1;
	}
	for(int i=0;i<m;i++){
		int x=a[i].F,y=a[i].S;
		x--;y--;
		cnt[x]--;
		cnt[y]++;
		pos[y]|=pos[x];
		if(cnt[x]==0){
			pos[x]=false;
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(cnt[i]&&pos[i]){
			ans++;
		}
	}
	cout<<ans;
}
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int tc=1;
    //~cin>>tc;
    for(int _=0;_<tc;_++){
        //~ cout<<"Case #"<<_+1<<": ";
        solve();
        if(_!=tc-1)
        cout<<"\n";
    }
}


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

int main() {
	string N;
	cin >> N;
	if((N.at(1) == N.at(0) && N.at(1) == N.at(2)) || (N.at(2) == N.at(1) && N.at(2) == N.at(3))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define llt long long int
#define M 1000000007
#define yesno(f) if(f){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define forr(j,n,k) for(int i=j;i<=n;i=i+k)
#define fori() for(int i=0;i<n;i++)
#define ford() for(int i=n-1;i>=0;i--)
#define MAX INT_MAX
#define MIN INT_MIN
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int main() {
    fastIO;
    int t=1;
    //cin>>t;
    while(--t>=0)
    {
      llt n,x,a,b,c;
      cin>>n;
      llt arr[n];
      fori(){
          cin>>arr[i];
      }
     int maxa=arr[0]; 
     llt sum=0;
      
      fori(){
          if(arr[i]>maxa)
          maxa=arr[i];
          else{
              sum=sum+(maxa-arr[i]);
          }
      }
      cout<<sum<<endl;
      
    }
      
	return 0;
}

Measured memory_bytes: 5212
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <set>
using namespace std;
int main() {
  int n; cin>>n;
  int x[n],y[n];
  for(int i=0;i<n;i++) {cin>>x[i];y[i]=x[i];}
  sort(x,x+n);
  for(int i=0;i<n;i++){
    if(y[i]<=x[n/2-1]) cout<<x[n/2]<<endl;
    else cout<<x[n/2-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<fstream>
#include<string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

string in;
int changed = 0;

#define fin cin

void change(string _to)
{
	string::size_type pos = in.find(_to[1]);
	while(pos != string::npos)
	{
		changed++;
		pos = in.find(_to[1], pos + 1);
	}
	string from = "ABC";
	//string::size_type 
	pos = in.find(from);
	while(pos != string::npos){
    	in.replace(pos, from.size(), _to);
    	pos = in.find(from, pos + _to.size());
		changed--;
	}
}

int main()
{
	//std::ifstream fin("in.txt");

	fin >> in;
	if(in.size() < 3)
	{
		cout << "No" << endl;
		return 0;
	}
	//cout << in << endl;

	while(in.size() >= 3)
	{

		//A?????????
		if( in[0] == 'A' &&
			in[1] == 'B' &&
			in[2] == 'C')
		{
				change(" A ");
		}

		//C?????????
		else if( in[in.size() - 3] == 'A' &&
 				 in[in.size() - 2] == 'B' &&
				 in[in.size() - 1] == 'C')
		{
			change(" C ");
		}

		//B?????????
		else if(in.find("ABC") != string::npos)
		{
			change(" B ");
		}
		else
		{
			break;
		}
//		cout << in << endl;
		for(size_t c = in.find_first_of(" "); c != string::npos; c = in.find_first_of(" "))
		{
	    	in.erase(c,1);
		}
//		cout << in << endl;
		if(changed != 0)break;
	}
	cout << ((in == "A") ? "Yes" : "No") << endl;


	return 0;
}

Measured memory_bytes: 3184
import sys
n, y = map(int, input().split())

for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - i - j
        price = (i * 10**4) + (j * 5 * 10**3) + (k * 10**3)
        if price == y:
            print(i, j, k)
            sys.exit()
        elif y < price:
            break

print(-1, -1, -1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<ll, ll>;
const int INF = 1001001001;

struct UnionFind{
  vector<int> par;
  UnionFind(int n) : par(n, -1){}
  int root(int x){ return (par[x] < 0) ? x : par[x] = root(par[x]); }
  int size(int x){ return -par[root(x)]; }
  bool issame(int x, int y){ return root(x) == root(y); }
  void marge(int x, int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(x > y) swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }
};

int main(void){
  ll n;
  cin >> n;
  map<P, ll> xmp, ymp;
  vector<P> xp(n), yp(n);
  vector<tuple<ll, ll, ll>> c;
  UnionFind uf(n);
  REP(i, n){
    ll x, y;
    cin >> x >> y;
    xp[i] = P(x, y);
    yp[i] = P(y, x);
    xmp[xp[i]] = i;
    ymp[yp[i]] = i;
  }
  sort(ALL(xp));
  sort(ALL(yp));
  auto cost = [](P a, P b){
    ll c = abs(a.first - b.first);
    ll d = abs(a.second - b.second);
    return min(c, d);
  };
  REP(i, n-1){
    ll p = xmp[xp[i]];
    ll q = xmp[xp[i+1]];
    c.emplace_back(cost(xp[i], xp[i+1]), p, q);
    p = ymp[yp[i]];
    q = ymp[yp[i+1]];
    c.emplace_back(cost(yp[i], yp[i+1]), p, q);
  }
  sort(ALL(c));
  ll ans = 0;
  ll m = c.size();
  for(ll i = 0; i < m && uf.size(0) != n; i++){
    ll d, p, q;
    tie(d, p, q) = c[i];
    if(uf.issame(p, q)) continue;
    uf.marge(p, q);
    ans += d;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 24432
n = gets.to_i
ans = []
(1..n-1).each do |a|
  b = n - a
  sum_a = a.to_s.chars.map(&:to_i).inject(:+)
  sum_b = b.to_s.chars.map(&:to_i).inject(:+)

  ans << (sum_a + sum_b)
end
puts ans.min

Measured memory_bytes: 2684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int ans = 0;

		for (int i = 0; i < N; i++) {
			double let = Math.sqrt(Math.pow(sc.nextInt(), 2) + Math.pow(sc.nextInt(), 2));
			if (let <= D ) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 60388
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
    if a[i]+a[i-1]>x:
        if x-a[i-1]>0:
            ans+=a[i]+a[i-1]-x
            a[i]+=x-a[i-1]-a[i]
        else:
            ans+=a[i]+a[i-1]-x
            a[i]=0
print(ans)

Measured memory_bytes: 14132
#include<iostream>
#include<map>
#include<string>
#include<utility>
#include<vector>
#include<cctype>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b; i>=a; i--)
#define all(a)  a.begin(), a.end()
#define MAX 10
typedef long long ll;
using namespace std;

char ToUpper(char cX) { return toupper(cX); }

int main(void){
  string a, b, c; cin >> a >> b >> c;
  string s;
  s.push_back(a[0]);
  s.push_back(b[0]);
  s.push_back(c[0]);
  transform(s.begin(), s.end(), s.begin(), ToUpper);
  cout << s.c_str() << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
if N==3:
    print(2,5,63)
    exit()
r=[]
s=14999
for i in range((N-2)//2*2):
    r.append(s*2)
    s-=1 if (s-1)%3 else 2
    if s<1:
        break
s=9999
for i in range((N-len(r))//2*2):
    r.append(s*3)
    s-=2
    if s<1:
        break
s=5000
for i in range(len(r),N):
    r.append(s*6)
    s-=1
print(*r)

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
int main(){
    long x,y;
    long a; cin >> a;
   for(int i=sqrt(a);i>=1;i--){
       if(a%i == 0){
           x = i,y = a/i;
           break;
       }
   }
   cout << x+y-2 << endl;
}


Measured memory_bytes: 3672
#ifdef ONLINE_JUDGE
  #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#endif

#include "bits/stdc++.h"
using namespace std;
#define int long long

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

signed main() {
  #ifndef ONLINE_JUDGE
    ifstream cin("in");
  #endif
  ios_base::sync_with_stdio(0); cin.tie(0); // harris leung ioi gold calling it 18.09

  const int mod = 1e9 + 7;
  int a, b; cin >> a >> b;
  int grid[a][b]; for (int i = 0; i < a; i ++) for (int j = 0; j < b; j ++) {char x; cin >> x; grid[i][j] = x == '.';}
  int dp[a][b]; memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i < a; i ++) {
    for (int j = 0; j < b; j ++) {
      if (grid[i][j] == 0) continue;
      if (i > 0) dp[i][j] += dp[i - 1][j];
      if (j > 0) dp[i][j] += dp[i][j - 1];
      dp[i][j] %= mod;
    }
  }
  cout << dp[a - 1][b - 1] << endl;
}

Measured memory_bytes: 19264
#[allow(unused_macros)]
macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            let mut next = || { iter.next().unwrap() };
            input_inner!{next, $($r)*}
        };
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };

        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };

        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };

        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };

        ($next:expr, bytes) => {
            read_value!($next, String).into_bytes()
        };

        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };

        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }

fn main() {
    input! {
            length: i32,
            heights: [i32; length],
        }

    let mut answer = 0;
    let mut current = 0;

    for idx in 1..length {
        let ans = &mut answer;
        let cur = &mut current;
        let hei = &heights;

        if hei[(idx-1) as usize] >= hei[idx as usize] { *cur += 1 } else { *cur = 0 }
        if *ans < *cur { *ans = *cur }
    }

    println!("{}", answer);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 998244353;
int N, S;
vector<int> v;

int cache[3001][3001];

//f(pos, j)=k 인 pos <= j < N의 개수
int solve(int pos, int k) {
	if (k == 0) return N - pos + 1;
	if (pos == N) return 0;

	int& ret = cache[pos][k];
	if (ret != -1) return ret;

	ret = solve(pos + 1, k) % MOD;
	if (k - v[pos] >= 0) ret = (ret + solve(pos + 1, k - v[pos])) % MOD;
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N >> S;
	v.resize(N);
	for (int i = 0; i < N; i++) cin >> v[i];

	int ans = 0;
	memset(cache, -1, sizeof(cache));
	for (int i = 0; i < N; i++)
		ans = (ans + solve(i, S)) % MOD;

	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 35584
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        n: usize,
        info: [((i64, i64), i64); n]
    }

    if info.iter().filter(|t| t.1 > 0).count() == 1 {
        let a: Vec<&((i64, i64), i64)> = info.iter().filter(|t| t.1 > 0).collect();
        println!("{} {} {}", (a[0].0).0, (a[0].0).1, a[0].1);
        std::process::exit(0)
    }

    for i in 0..101 {
        for j in 0..101 {
            let h: Vec<i64> = info.iter().filter(|t| t.1 > 0).map(|t| (i - (t.0).0).abs() + (j - (t.0).1).abs() + t.1).collect();
            if h.iter().all(|x| *x == h[0]) { println!("{} {} {}", i, j, h[0]); break; }
        }
    }
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<string> SS(N);
    rep(i, N) cin >> SS[i];

    map<char, int> cnt;
    rep(i, 26) cnt['a'+i] = 100;

    for (auto s : SS) {
        map<char, int> tmp_cnt;
        rep(i, 26) tmp_cnt['a'+i] = 0;

        for (auto c : s) tmp_cnt[c]++;
        for (auto t : tmp_cnt) {
            cnt[t.first] = min(cnt[t.first], t.second);
        }
    }

    string ans;
    for (auto t : cnt) {
        ans += string(t.second, t.first);
    }
    sort(ALL(ans));
    cout << ans << endl;
}



Measured memory_bytes: 256
l,r = map(int,input().split())

if r-l >= 2019:
    ans = 0
else:
    ans = 2018
    for i in range(r-l):
        for j in range(i+1,r-l+1):
            mod = ((l+i)*(l+j))%2019
            if ans > mod:
                ans = mod

print(ans)

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

int main() {
  int h,w;
  cin>>h>>w;
  for(int i=0; i<w+2; i++)
    cout<<'#';
  cout<<endl;
  for(int j=0; j<h; j++){
    string s;
    cin>>s;
    cout<<'#'<<s<<'#'<<endl;
  }
  for(int k=0; k<w+2; k++)
    cout<<'#';
}

Measured memory_bytes: 256
import itertools


N = int(input())
L = [int(''.join(l)) for i in range(3, 10) for l in list(itertools.product(['3', '5', '7'], repeat=i)) if '3' in l and '5' in l and '7' in l]
L = [l for l in L if l <= N]

print(len(L))


Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,cnt,bnt;
int main(){
	cin>>a;
	int arr[a+5];
	for (int i = 1; i <=a; ++i){
		cin>>arr[i];
		cnt+=arr[i];
	}
	cin>>b;
	for (int i = 0; i < b ; ++i){
		cin>>c>>d;
		if(arr[c]>=d) cnt-=(arr[c]-d);
		else cnt+=(d-arr[c]);
		cout<<cnt<<'\n';
		cnt+=(arr[c]-d);
	}
}

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

int main()
{
  int n,x;
  cin>>n>>x;
  vector<int> a(n);
  for(auto &i:a)
     cin>>i;
  long long int ans=0;
  for(int i=0;i<n-1;i++)
    if(a[i]+a[i+1]>x)
      {
        long long sub = a[i+1]+a[i]-x;
        ans += sub;
        a[i+1]=max(a[i+1]-sub,0ll);
      }
  if(a[n-1]>x)
    ans += a[n-1]-x;
  cout<<ans<<"\n";
  return 0;
}


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

int main(){
	int n;vector<int> v;
	scanf("%d",&n);int i;int j;
	rep(i,0,n){
		scanf("%d",&j);
		v.push_back(j);
	}
	sort(v.begin(),v.end());
	printf("%d\n",v.back()-v.front());
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

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

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

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

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<998244353>;

mint dp[3333][3333];
signed main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	dp[A][B]=1;

	for(int i=A;i<=C;i++){
		for(int j=B;j<=D;j++){
			dp[i][j]+=dp[i-1][j]*j;
			dp[i][j]+=dp[i][j-1]*i;
			dp[i][j]-=dp[i-1][j-1]*(i-1)*(j-1);
		}
	}
	cout<<dp[C][D]<<endl;
	return 0;
}


Measured memory_bytes: 47044
<?php
list($n) = ints();
list($c) = strs();
$cntr = 0;
for ($i = 0; $i < $n; ++$i)
    if ($c[$i] === 'R') ++$cntr;
$cnt = 0;
for ($i = 0; $i < $cntr; ++$i)
    if ($c[$i] === 'W') ++$cnt;
echo $cnt;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define yes cout<<"YES"<<nl
#define no  cout<<"NO"<<nl
#define nl  '\n'
#define tr ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define tst int t;cin>>t;while(t--)
#define     Max             1000000000000000014
#define     Min             -1000000000000000014
#define     PI              3.1415926535897
#define     Fr               first
#define     Se               second
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     space            ' '
#define COUT(v) for(auto it:v)cout<<it<<space;cout<<nl;
/*error cheaking method starts from here */
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
/*error cheaking method ebds here */

#define vi    vector<int>
#define    vl    vector<ll>
#define    si    set<int>
#define    sl    set<ll>
#define    msi    multiset<int>
#define    msl    multiset<ll>
#define    pii    pair<int,int>
#define    pil    pair<int,ll>
#define    pli    pair<ll,int>
#define    pll    pair<ll,ll>
#define    mp    make_pair
#define    pb    push_back
int main()
{
    string s,t;
    cin>>s>>t;
    int i,j,l=t.size(),mn=10000000;
    for(i=0;i<=s.size()-l;i++)
    {
        string u=s.substr(i,l);//cout<<u<<endl;
        int c=0;
        for(j=0;j<l;j++)
        {
            if(u[j]!=t[j])
                c++;
        }
        if(c<mn)
            mn=c;
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))

b = [0] * n

for i in range(n, 0, -1):
    if sum(b[i-1::i]) % 2 == a[i-1]:
        continue
    else:
        b[i-1] = 1

c = []
for i in range(n):
    if b[i] == 1:
        c.append(i+1)
print(sum(b))
if len(c) > 0:
    print(*c)


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

void init()
{

}

int main()
{
	int H,W,K;
	cin >> H >> W >> K;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> c[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << H); ++i)
	{
		for (int j = 0; j < (1 << W); ++j)
		{
			rep(k,H)
			{
				rep(l,W)
				{
					temp[k][l] = c[k][l];
				}
			}
			rep(k,H)
			{
				if (1 & (i >> k))
				{
					//cout << k << " ";
					rep(l,W)
					{
						temp[k][l] = 'x';
					}
				}
			}
			//cout << "/";
			rep(k,W)
			{
				if (1 & (j >> k))
				{
					//cout << k << " ";
					rep(l,H)
					{
						temp[l][k] = 'x';
					}
				}
			}
			//cout << endl;
			int cnt = 0;
			rep(k,H)
			{
				rep(l,W)
				{
					//cout << temp[k][l];
					if (temp[k][l] == '#') cnt++;
				}
				//cout << endl;
			}
			if (cnt == K)
			{
				ans++;
				//cout << "o";
			}
			//cout << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

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

signed main() 
{
    int h,w,d;
    cin >> h >> w >> d;
    ll dp[90001];
    int px[90001],py[90001];
    rep(i,0,h) rep(j,0,w)
    {
        int tmp; cin >> tmp;
        px[tmp]=j,py[tmp]=i;
    }
    int q; cin >> q;
    for(ll i=d+1;i<=h*w;i++)
    {
        dp[i]=dp[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d]);
    }
    rep(i,0,q)
    {
        int l,r;
        cin >> l >> r;
        cout << dp[r]-dp[l] << endl;
    }
}

Measured memory_bytes: 2560
S = input()
n = len(S) + 1
A = []
mini = 0

for i in range(n-1):
  if i==0:
    if S[i]=="<":
      A.append([1,0])
    else:
      A.append([0,1])
  else:
    if S[i]=="<" and S[i-1]==">":
      A.append([1,0])
    elif S[i]=="<":
      A[-1][0] += 1
    else:
      A[-1][1] += 1

summ = 0
for x in A:
  ma = max(x)
  mi = min(x)
  summ += (ma+1)*ma//2
  summ += (mi-1)*mi//2
print(summ)

Measured memory_bytes: 16284
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  int X;
  X=S.size();
  if(S.at(X-1)=='s'){
    cout<<S+"es"<<endl;
  }else if(S.at(X-1)!='s'){
    cout<<S+"s"<<endl;
  }
}


Measured memory_bytes: 3556