akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

vector<int> G[700];
vector<int> rG[700];

int main(){
    int N, M;
    double dp[700];
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int s, t;   cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        rG[t].push_back(s);
    }

    dp[N-1] = 1;
    for(int i = N-2; i >= 0; i--){
        double num = G[i].size();
        double su = 0.0;
        for(auto v: G[i]){
            su += dp[v];
        }
        dp[i] = su / num + 1;
    }

    double prob[700];
    prob[0] = 1.0;
    for(int i = 1; i < N; i++){
        double x = 0.0;
        for(auto v: rG[i]){
            x += prob[v] / ((double)(G[v].size()));
        }
        prob[i] = x;
    }

    double res = 0.0;
    for(int i = 0; i < N-1; i++){
        if(G[i].size() <= 1){
            continue;
        }
        for(auto v: G[i]){
            double newE = (dp[i] - 1 - dp[v] / ((double) G[i].size())) * G[i].size() / (G[i].size() - 1) + 1.0;
            res = max(res, (dp[i] - newE) * prob[i]);
        }
    }

    printf("%.10f\n", dp[0] - res - 1.0);


    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

int main(){
ll n,k;cin>>n>>k;
vl a(n);rep(i,n)cin>>a[i];
ll ans=0;

sort(a.begin(),a.end());
rep(i,k)ans+=a[i];
cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

// dp[i][t]:i番目までを考えたとき，時間t以内に完食できる最大満足度
int dp[3001][3001];

int main()
{
	int N, T; cin >> N >> T;
	vector<pair<int, int>> plates(N);
	for (int i = 0; i < N; ++i) cin >> plates[i].first >> plates[i].second;
	sort(plates.begin(), plates.end());
	int ans = 0;
	for (int i = 1; i <= N; ++i)
	{
		int ti = plates[i - 1].first;
		int vi = plates[i - 1].second;
		for (int t = 0; t < T; ++t)
		{
			// 通常のdp更新：t以内に完食できる場合は食べるか食べないかの最大値を選択
			// 完食できない場合は食べない
			if (t >= ti)
			{
				dp[i][t] = max(dp[i - 1][t], dp[i - 1][t - ti] + vi);
			}
			else
			{
				dp[i][t] = dp[i - 1][t];
			}
			// 完食できるできないに関わらず，１つ食べることができる
			ans = max(ans, dp[i - 1][t] + vi);
		}
	}
	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

ll m[500][500];
ll q[100000][2];

int main(){
    ll N,M,Q;
    cin >> N >> M >> Q;
    int l,r;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            m[i][j] = 0;
        }
    }
    for(int i=0;i<M;i++){
        cin >> l >> r;
        m[l-1][r-1]++;        
    }
    for(int i=0;i<Q;i++){
        cin >> l >> r;
        q[i][0] = l-1;
        q[i][1] = r-1;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i == 0 && j==0) continue;
            if(i == 0){
                m[i][j] += m[i][j-1];
                continue;
            }
            if(j == 0){
                m[i][j] += m[i-1][j];
                continue;
            }
            m[i][j] += m[i-1][j] + m[i][j-1] - m[i-1][j-1];
        }
    }
    for(int i=0;i<Q;i++){
        if(q[i][0] == 0){
            cout << m[q[i][1]][q[i][1]] << endl;
            continue;
        }
        l = q[i][0];
        r = q[i][1];
        cout << m[r][r] - m[r][l-1] - m[l-1][r] + m[l-1][l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 4480
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



int isGoal(int hnow, int wnow, int H, int W) {
	int ans = intmax;
	ans = min(ans, hnow);
	ans = min(ans, wnow);
	ans = min(ans, H - hnow - 1);
	ans = min(ans, W - wnow - 1);
	return ans;
}

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

	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>>A(H, vector<int>(W, 0));
	int sh, sw;
	rep(i, H) {
		string s;
		cin >> s;
		rep(j, W) {
			A[i][j] = (s[j] == '#' ? 1 : 0);
			if (s[j] == 'S') {
				sh = i;
				sw = j;
			}
		}
	}
	const int D[5] = { 0,1,0,-1,0 };

	vector<vector<int>>searched(H, vector<int>(W, 0));
	queue<array<int, 3>>bfs;
	bfs.push({ sh,sw,0 });
	int ans = intmax;
	while (!bfs.empty()) {
		auto x = bfs.front(); bfs.pop();
		int hpos = x[0];
		int wpos = x[1];
		ans = min(ans, isGoal(hpos, wpos, H, W));
		if (ans == 0) {
			cout << 1 << endl;
			return 0;
		}
		if (searched[hpos][wpos]++)continue;
		if (K <= x[2])continue;
		rep(d, 4) {
			int hnew = hpos + D[d];
			int wnew = wpos + D[d + 1];
			if (A[hnew][wnew])continue;
			bfs.push({ hnew,wnew,x[2] + 1 });
		}
	}
	cout << (2 + ((ans - 1) / K)) << endl;



	return 0;
}

Measured memory_bytes: 10368
// https://atcoder.jp/contests/keyence2020/tasks/keyence2020_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, K, S;
  cin >> N >> K >> S;

  VL res(N);

  rep(i, K) res[i] = S;
  repf(i, K, N) res[i] = S == 1e9 ? 1e9 - 1 : 1e9;

  print_ints(res);
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 2944
from collections import deque

n, m = map(int,input().split())
g = [[] for _ in range(n+1)]
for i in range(m):
  a, b = map(int,input().split())
  g[a].append(b)
  g[b].append(a)
  
yet = [-1 for _ in range(n+1)]
yet[0] = 0
yet[1] = 1

d = deque([1])

while d:
  v = d.popleft()
  for i in g[v]:
    if yet[i] == -1:
      yet[i] = v
      d.append(i)
      
ans = yet[2:]
print("Yes")
print(*ans, sep="\n")

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

int N;

struct state{
  int pl,c1,c2,id;
  bool r;
  state(int c1,int c2,int id,bool r):c1(c1),c2(c2),id(id),r(r) {
    if( c2 >= 0 ) pl = -1;
    else pl = 0;
  }
  bool operator<(const state& st) const {
    if( pl == st.pl ){
      if( pl == -1 )
        return c1 < st.c1;
      else
        return c1+c2 > st.c1+st.c2;
    } else
      return pl < st.pl;    
  }
};

vector<state> S;

void counter(const string& s,int &c1,int &c2){//c1???????????????,c2?????????
  c1=0; c2=0;  
  for(int i=0;i<(int)s.size();i++){
    if( s[i] == '(' ) c2++;
    else c2--;
    c1 = min(c1,c2);
  }
  c1*=-1;
}

bool solve(){
  int Ls=0,Rs=0;
  bool used[111]={};
  sort(S.begin(),S.end());
  for(int i=0;i<(int)S.size();i++){
    if( used[S[i].id] ) continue;
    if( S[i].r ) { //rev[R]
      if( Rs<S[i].c1 ) return false;
      Rs+=S[i].c2;
    } else { //[L]
      if( Ls<S[i].c1 ) return false;
      Ls+=S[i].c2;
    }
    used[S[i].id]=true;
  }
  
  return Ls==Rs;
}

void reverse_s(string& s){
  reverse(s.begin(),s.end());
  for(int i=0;i<(int)s.size();i++)
    if( s[i] == '(' ) s[i] = ')';
    else s[i] = '(';  
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    string s; cin >> s;
    int c1,c2; counter(s,c1,c2);
    S.push_back( state( c1, c2, i, false ) );
    reverse_s(s); counter(s,c1,c2);
    S.push_back( state( c1, c2, i, true ) );
  }
  cout << ( solve()?"Yes":"No" ) << endl;
}

Measured memory_bytes: 1216
a, b= map(int, input().split())
list=[]
list2=[]
sum=0
for n in range(a):
    list.append(n+b)
for n in range(a):
    list2.append(n+b)

if list.count(0)==1:
    for w in list:
        sum += w
    print(sum)
else:
    if list[len(list)-1] > 0:
        for w in list:
            sum += w
        print(sum-list[0])
    else:
        for w in list:
            sum += w
        print(sum-list[len(list)-1])


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 1000000007;

LL N,M,K,C;
LL a,b,c,d;
string s;
int main(){
    cin>>s; 
    for(int i=1;i<s.length();i++){
        if((s.length()-i)%2==0){
            string s1=s.substr(0,(s.length()-i)/2);
            string s2=s.substr((s.length()-i)/2,(s.length()-i)/2);
            //cout<<s1<<endl;
            if(s1==s2){
                cout<<s.length()-i<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	string s,t;
	cin>>s>>t;
	if(s==t.substr(0,ll(s.length()))&&ll(t.length())==ll(s.length())+1)
	cout<<"Yes";
	else
	cout<<"No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
    int m, d;
    cin >> m >> d;
    int ans=0;
    for(int i=2; i<=m; i++){

        for(int j=20; j<=d; j++){
            int d1 = j%10;
            int d2 = j/10;
            if(d1<=1) continue;
            if(d1*d2==i){
                ans++;
            }
        }

    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>

using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
const string FILENAME = "input";
const int Mod = 1000000007;
const int MAXN = 100228;



int mul(int a, int b) {
	return (1LL * a * b) % Mod;
}


int sum(int a, int b) {
	return (a + b) % Mod;
}


int powm(int a, int b) {
	int res = 1;
	while (b > 0) {
		if (b & 1) {
			res = mul(res, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int n;
int st[MAXN];
int fact[MAXN];


int cnk(int a, int b) {
	return mul(fact[a], mul(powm(fact[b], Mod - 2), powm(fact[a - b], Mod - 2)));
}


int pref[MAXN];
map<char, int> cnt;

int  main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
   // read(FILENAME);
	cin >> n;
   	string s;
   	cin >> s;
   	for (int i = 0; i < n; i++) {
   		cnt[s[i]]++;
   	}
   	int res = 1;
   	for (auto x: cnt) {
   		res = mul(res, x.second + 1);
   	}
   	res--;
   	if (res < 0) {
   		res += Mod;
   	}
   	cout << res << '\n';
 	return 0; 
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int ans = 0;
void nanagoogo(ll x, int n) {
	vector<bool> flag(10, false);
	string s = to_string(x);
	for (int i = 0; i < s.size(); i++) flag[s[i] - '0'] = true;
	if (flag[3] && flag[5] && flag[7]) ans++;
	if (x * 10 + 3 <= n) nanagoogo(x * 10 + 3, n);
	if (x * 10 + 5 <= n) nanagoogo(x * 10 + 5, n);
	if (x * 10 + 7 <= n) nanagoogo(x * 10 + 7, n);
}
int main() {
	int n;
	cin >> n;
	nanagoogo(0, n);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
int main () {
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    bool can = false;
    for (int i = a; i <= b; i++){
        if (i%k == 0){
            can = true;
        }
    }
    if (can){
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
 
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mii map<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FORD(i,a,n) for(int i=n-1;i>=0;i--)
using namespace std;
 
 
int32_t main(){

    
    int n,k,a[100001];
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[n+1]={};
    for(int i=0;i<n;i++)
        dp[i]=1000000000;
    dp[0]=0;
   dp[1]=abs(a[1]-a[0]);
    
    for(int i=1;i<n;i++)
    {
        int x=1000000000;
        for(int j=1;j<=k&&j<=i;j++)
        {
            x=(dp[i-j]+abs(a[i]-a[i-j]));
           // cout<<x<<" ";
            dp[i]=min(x,dp[i]);
        }
        //cout<<endl;
    }
    //cout<<endl;
  //  for(int i=0;i<n;i++)
        cout<<dp[n-1];

 
    return 0;
 
}


Measured memory_bytes: 1792
base = input().split()
n = int(base[0])
k = int(base[1])
ans = 0
x = []
for i in range(n+1):
    x.append(i)
y = x.copy()
y.sort(reverse = True)
for a in range(k,n+2):
    z = (n+1-a)*a
    ans += (z+1)%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 18476
import sys
import math
import bisect
 
 
sys.setrecursionlimit(1000000000)
def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())
 
def finput():
    return float(input())
 
def tinput():
    return input().split()
 
def rinput():
    return map(int, tinput())
 
def rlinput():
    return list(rinput())
 
def modst(a, s):
    res = 1
    while s:
        if s % 2:
            res *= a
        a *= a
        s //= 2
    return res

 
def main():
    n = iinput()
    for i in range(1, 10):
        for o in range(1, 10):
            if o * i == n:
                print("Yes")
                return 0
    print("No")
main()

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VI card(n + 2, 0);
    REP(i, m) {
        int l, r;
        cin >> l >> r;
        card[l] += 1;
        card[r + 1] += -1;
    }
    FOR(i, 1, n + 1) {
        card[i] += card[i - 1];
    }

    int ans = 0;
    REP(i, n + 1)if(card[i] == m) ans++;
    cout << ans << ln;
}


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

bool isOK(int n) {
    if (n % 2 == 0) return false;
    int result = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            result++;
            if (i != n / i) result++;
        }
    }
    return (result == 8);
}
int main(void) {
    int N;cin>>N;
    int result = 0;
    for (int i = 1; i <= N; i++) {
        if (isOK(i)) result++;
    }
    cout << result << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off (4*n)


using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 1000005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

vector <int> g[maxn] , cost[maxn] ;
int n ;

int Find( int cn ,int b, int e, int idx )
{
    if(b==e) return cn ;
    int lc = 2*cn , rc = 2*cn+1 , m = (b+e)/2 ;

    if( idx <= m ) return Find( lc , b,m , idx ) ;
    return Find( rc , m+1 , e , idx ) ;
}

void build( int cn , int b, int e )
{
    if( b==e ) return ;
    int lc = 2*cn , rc = 2*cn+1 , m = (b+e)/2 ;

    g[cn].pb( lc ) ; cost[cn].pb( 0 ) ;  g[lc+off].pb(cn+off) ; cost[lc+off].pb(0) ;
    g[cn].pb( rc ) ; cost[cn].pb( 0 ) ;  g[rc+off].pb(cn+off) ; cost[rc+off].pb(0) ;
    build(lc,b,m) ;    build(rc,m+1,e) ;
}

void addEdge( int cn , int b, int e, int l , int r, int c, int from )
{
    if( e<l || b>r ) return ;
    if( l<=b && e<=r )
    {
        g[from].pb( cn ) ; g[cn+off].pb(from) ;
        cost[from].pb(c) ; cost[cn+off].pb(c) ;
        return ;
    }
    int lc = 2*cn , rc = 2*cn+1 , m = (b+e)/2 ;
    addEdge( lc , b , m , l , r , c , from ) ;
    addEdge( rc , m+1 ,e , l , r , c , from ) ;
}

i64 dis[maxn] ;

int main()
{
    int m ;

    scanf("%d %d",&n,&m) ;

    build(1,1,n) ;

    for(int i=1 ; i<=n ; i++)
    {
        g[ 8*n+i ].pb( Find( 1 , 1 , n , i ) + off ) ;
        cost[ 8*n+i ].pb( 0 ) ;

        g[ Find( 1 , 1 , n , i ) ].pb( 8*n+i ) ;
        cost[ Find( 1 , 1 , n , i ) ].pb( 0 ) ;
    }

    for(int i=1 ; i<=m ; i++)
    {
        int l , r  , c ;

        scanf("%d %d %d",&l,&r,&c) ;

        addEdge( 1 , 1 , n , l , r , c , 9*n+i ) ;
    }

    int N = 9*n+m ;

    for(int i=1 ; i<=N ; i++) dis[i] = INF ;

    priority_queue < pair<i64,int> > pq ;
    dis[ 8*n+1 ] =  0 ;
    pq.push( mp(0,8*n+1 ) ) ;

//    cout<<Find(1,1,n,1)<<endl ;

    while( !pq.empty() )
    {
        pair<i64,int>  p = pq.top() ;
        pq.pop() ;

        int u = p.yy ; i64 d = -p.xx ;

    //    printf("--%d %lld\n",u,d) ;

        if( dis[u]!=d ) continue ;

        for(int i=0 ; i<g[u].size() ; i++)
        {
            int v = g[u][i] ;

            if( dis[v] > dis[u] + cost[u][i] )
            {
                dis[v] = dis[u] + cost[u][i] ;
                pq.push( mp( -dis[v] , v ) ) ;
            }
        }
    }

    if( dis[9*n]==INF ) printf("-1\n") ;
    else printf("%lld\n" , dis[9*n]/2 ) ;

    return 0 ;
}


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

bool check(const std::string& ss)
{
    if (ss.length() >= 10) return false;

    std::string s = ss;

    std::sort(std::begin(s), std::end(s));
    s.erase(std::unique(std::begin(s), std::end(s)), std::end(s));

    return (s == "357");
}

void rec(const std::string& ss, const std::string& n, std::vector<std::string>& c)
{
    if (ss.length() >= 10) return;

    std::string s = ss + n;
    c.push_back(s);

    rec(s, "3", c);
    rec(s, "5", c);
    rec(s, "7", c);
}

int main()
{
    long long N;
    std::cin >> N;

    std::vector<std::string> c;

    rec("", "3", c);
    rec("", "5", c);
    rec("", "7", c);

    std::vector<long long> ll;
    long long i = 0;
    for (auto & s : c) {
        if (check(s)) {
            ll.push_back(std::stoll(s));
        }
    }

    std::sort(std::begin(ll), std::end(ll));

    i = 0;
    for (; i < ll.size(); i++) {
        if (ll[i] > N) break;
    }

    std::cout << i << std::endl;

    return 0;
}

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

long long dp[101][100010];

int main(){

  int n,w;
  cin >> n >> w;
  int c[n][2];
  
  for(int i=0;i<n;i++){
    cin >> c[i][0] >> c[i][1];
  }
  
  for (int i = 0; i <= w; ++i) dp[0][i] = 0;
  
  for(int i=0;i<n;i++){
    for(int q=0;q<=w;q++){
      if(q>=c[i][0]){dp[i+1][q] = max(dp[i][q-c[i][0]]+c[i][1],dp[i][q]);}else
      {dp[i+1][q]=dp[i][q];}
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 79104
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;

using mint = atcoder::modint998244353;
const mint inv9 = mint(1)/9;

struct S{
    mint x, w;
    S(mint x=0, mint w=1):x(x),w(w){}
};

S op(S a, S b){
    return S{a.x*b.w +b.x, a.w*b.w};
}

S e(){
    return S{0, 1};
}

S mapping(int f, S a){
    if(f == 0)return a;
    return S{(a.w-1)*inv9*f, a.w};
}

int composition(int f, int g){
    if(f)return f;
    return g;
}

int id(){return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    
    int n,q;cin >> n >> q;
    vector<S> a(n);
    fr(i,n)a[i] = S{1, 1};

    atcoder::lazy_segtree<S, op, e, int, mapping, composition, id> t(n);

    fr(i,n)t.set(i, {1, 10});
    fr(i,q){
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        t.apply(l, r, d);
        S ans = t.prod(0, n);
        cout << ans.x.val() << endl;
    }
    return 0;
}

Measured memory_bytes: 11420
num_str = input().split()

num = [0, 0, 0]

for i in range(3):
  num[i] = int(num_str[i])

count_rb = int(num[0] / (num[1] + num[2]))
amari = int(num[0] % (num[1] + num[2]))

# print(count_rb , amari)

if amari >= num[1]:
  print(count_rb * num[1] + num[1])
else:
  print(count_rb * num[1] + amari)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    for(ll i=-2000;i<=2000;i++) {
        for(ll j=-2000;j<=2000;j++) {
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if (a-b==x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

using ll = long long;
const int MOD = 1e9 + 7;

void setIO(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main() {
	setIO();
	int A, B; cin >> A >> B;
	cout << A * B << "\n";
}


Measured memory_bytes: 3652
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def all_group_size(self):
        return [len(self.members(r)) for r in self.roots()]
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m = map(int,input().split())
tree = UnionFind(n)
ans = 1
for _ in range(m):
    i,j = map(int, input().split())
    tree.union(i-1,j-1)
    ans = max(ans,tree.size(i-1))
print(ans)

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

using namespace std;

typedef long long ll;

ll ans[200005];

int main()
{
	int n, k;
	cin >> n >> k;
	ll sum = 0;
	for(int i=0;i<k;i++)
	{
		int x;
		cin >> x;
		sum += x;
	}
	if(sum >= n)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 

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

int main(){
  ll n,x,a[110];
  cin>>n>>x;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  ll ans=0;
  for(int i=0;i<n;i++){
    if(i!=n-1){
      if(a[i]<=x){
        ans++;
        x-=a[i];
      }else break;
    }else if(a[i]==x)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1145141919810ll
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(15)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

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

  int N, M, P, A, B, C; cin >> N >> M >> P;
  vector<edge> G;
  int d[2500]; fill(d, d+N, INF); d[0] = 0;
  REP(i, M){
    cin >> A >> B >> C;
    A--; B--; C-=P;
    G.push_back({A, B, -C});
  }

  bool close = 0;
  REP(cnt, N*2){
    REP(i, M){
      edge e = G[i];
      int tmp = d[N-1];
      if(d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        if(cnt >= N-1 and d[N-1] < tmp){
          close = 1; break;
        }
      }
    }
  }

  if(close){
    cout << -1 << endl;
  } else {
    cout << max(0ll, -d[N-1]) << endl;
  }
}


Measured memory_bytes: 576
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >>n >>k;
	cout <<floor(log2(n) / log2(k)) + 1;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
void chmin(ll &x, ll y) {x = min(x, y); }
void chmax(ll &x, ll y) {x = max(x, y); }

void solve(long long N, std::vector<long long> h){
    vll dp(N, INF);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(ll i = 2; i < N; i++){
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout<< dp[N-1]<<endl;
}

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


Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    
    if(a > x){
      System.out.println("NO");
      return;
    }
    
    if(x - a <= b){
      System.out.println("YES");
      return;
    }
    System.out.println("NO");
      return;
   }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()
#define cerr if(0)cerr

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

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

int bfs(int h, int w,
    const vector<string> &field,
    int sy,int sx) {
    vector<vector<int> > step(h,vector<int>(w,-1));
    queue<ii_t> que;
    que.push(ii_t(sy,sx));
    step[sy][sx]=0;
    int answer = 0;
    while(!que.empty()){
        ii_t cur = que.front(); que.pop();
        int cy = cur.first;
        int cx = cur.second;
        for (int k=0;k<4;k++) {
            int ny = cy + dy[k];
            int nx = cx + dx[k];
            if (0 <= ny && ny < h && 
                    0 <= nx && nx < w &&
                    field[ny][nx] == '.' &&
                    step[ny][nx] < 0) {
                step[ny][nx] = step[cy][cx] + 1;
            cerr << "ny=" << ny << " nx=" << nx << " " << step[ny][nx] << endl;
                answer = max(answer, step[ny][nx]);
                que.push(ii_t(ny,nx));
            }
        }
    }
    return answer;
}

int main() {
    int n,h,w;
    cin >> h >> w;
    vector<string> field(h);
    for (int i=0;i<h;i++)
        cin >> field[i];

    int answer = 0;
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
        if (field[i][j]=='.') {
            cerr << "i=" << i << " j=" << j << endl;
            answer = max(answer,
                    bfs(h,w,field,i,j));
        }

    
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int T[100010];
int main()
{
	int N, C, K;
	cin >> N >> C >> K;
	for (int i = 0; i < N; i++) cin >> T[i];
	sort(T, T + N);
	int ans = 0;
	int time = 0;
	int cnt = 0;
	int i = 0;
	while (true) {
		time = T[i] + K;
		cnt = 1;
		i++;
		while (T[i] <= time && cnt < C) {
			cnt++;
			i++;
			if (i >= N) break;
		}
		ans++;
		if (i >= N) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static String S;
	boolean flg = false;

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		long N = sc.nextLong();
		long[] H = new long[(int) N];
		for (long i = 0; i < N; i++) {
			H[(int) i] = sc.nextLong();
		}
		long back = H[0];
		back--;
		for (long i = 1; i < N; i++) {
			if (back < H[(int) i]) {
				H[(int) i] -= 1;
				back = H[(int) i];
			} else if (back > H[(int) i]) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24016
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> pii;

int dp[4001][4001];

void solve(string s, string t) {
	memset(dp, 0, sizeof(dp));
	int maxi = 0;
	rep(i, s.length()) {
		rep(j, t.length()) {
			if( s[i] == t[j] ) {
				dp[i+1][j+1] = dp[i][j] + 1;
				maxi = max(maxi, dp[i+1][j+1]);
			} else {
				dp[i+1][j+1] = 0;
			}
		}
	}
	cout << maxi << endl;
}

int main() {
	string s, t;
	while(cin >> s >> t) {
		solve(s,t);
	}
	return 0;
}

Measured memory_bytes: 63760
def initSquaresArray():
    arr = []
    n = 1
    while True:
        if n * n >= 32768:
            break
        arr.append(n * n)
        n += 1
    return arr

def get2Squares(num):
    global squares
    global memo2

    if num in memo2:
        return memo2[num]

    squareSums = set()
    for square in squares:
        if square >= num:
            break
        if num - square in squares:
            squareSums.add( (min(square, num - square), max(square, num - square)) )
    
    memo2[num] = squareSums
    return memo2[num]

def get3Squares(num):
    global squares
    global memo3

    if num in memo3:
        return memo3[num]

    squareSums = set()
    for square in squares:
        if square >= num:
            break
        other = get2Squares(num - square)
        for o in other:
            a = square
            b = o[0]
            c = o[1]
            tpl = tuple(sorted([ a, b, c ]))
            squareSums.add(tpl)

    memo3[num] = squareSums
    return memo3[num]

def get4Squares(num):
    global squares
    global memo4

    if num in memo4:
        return memo4[num]

    squareSums = set()
    for square in squares:
        if square >= num:
            break
        other = get3Squares(num - square)
        for o in other:
            a = square
            b = o[0]
            c = o[1]
            d = o[2]
            tpl = tuple(sorted([ a, b, c, d ]))
            squareSums.add(tpl)

    memo4[num] = squareSums
    return memo4[num]

if __name__ == '__main__':
    memo2 = {}
    memo3 = {}
    memo4 = {}
    squares = initSquaresArray()
    
    while True:
        num = int(input())
        if num == 0:
            break

        s2 = get2Squares(num)
        s3 = get3Squares(num)
        s4 = get4Squares(num)

        count = 1 if num in squares else 0
        count += len(s2)
        count += len(s3)
        count += len(s4)

        print(count)


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

void    primes(long N, vector<long> &p) {
        long i=2;
        while (N !=1) {
                if (0 == N % i) {
                        N /= i;
                        p.at(i)++;
                } else i++;
        }
        return;
}

long    comb(long N, long P) {
        long S=1;
        for (long i=1; i<=P; i++) {
                S *= N;
                S /= i;
                N--;
        }
        return S;
}
/*
long    perm(long N, long P) {
        long S=1;
        for (long i=1; i<=P; i++) {
                S *= N;
                N--;
        }
        return S;
}
*/
long    NofP(long N, vector<long> &p) {
        N--;
        long S=0;
        for (long i=0; i<p.size(); i++) {
                if (p.at(i) >= N) S++;
        }
        return S;
}

int     main() {
        long    N=100;
        cin >>N;
        vector<long> p(N+1, 0);
        for (long i=2; i<=N; i++) {
                primes(i, p);
        }
        long S=0;
        S += comb(NofP(75, p), 1);
        S += comb(NofP(25, p), 1) * comb(NofP(3, p)-1, 1);
        S += comb(NofP(15, p), 1) * comb(NofP(5, p)-1, 1);
        S += comb(NofP(5, p), 2) * comb(NofP(3, p)-2, 1);
        cout <<S <<endl;
        return 0;
}

Measured memory_bytes: 256
D,G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]

min_count = 10 ** 100

for i in range(2 ** D):
    point,cnt = 0, 0
    for j in range(D):
        if i >> j & 1:
            point += pc[j][0] * 100 * (j + 1) + pc[j][1]
            cnt += pc[j][0]
    if point >= G:
        min_count = min(min_count, cnt)
    else:
        for j in range(D-1, -1, -1):
            if i >> j & 1:
                continue
            else:
                for _ in range(pc[j][0]):
                    point += (j+1) * 100
                    cnt += 1
                    if point >= G:
                        break
            if point >= G:
                break
    min_count = min(min_count, cnt)
print(min_count)

Measured memory_bytes: 3064
n = int(input())
if n%4 == 0 or n%7 == 0:
  print('Yes')
elif (n%4)%7 == 0 or (n%7)%4 == 0:
  print('Yes')
else:
  a = n // 4
  msg = 'No'
  for i in range(a):
    m = n - 4*i
    if m%7 == 0:
      msg = 'Yes'
      break
  print(msg)

Measured memory_bytes: 3064
#include<iostream>
#define INF 200001
int main(){
  int u,k,C,V,A[1000][1000],D[1000][1000],n;
  std::cin >> n;
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j] = INF;
  for(int i=0;i<n;i++){  
    std::cin >> u >> k;
    for(int j=0;j<k;j++){
      std::cin >> V >> C;
      D[u][V] = C;
    }  
  }
  for(int i=0;i<n;i++)D[i][i] = 0;
  for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j]= std::min(D[i][j],D[i][k] + D[k][j]);
  for(int i=0;i<n;i++)std::cout << i << " " << D[0][i] << std::endl;
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,k;
  cin >> n >> k;
  vector<int> d(n);
  RIP(i,k){
    int a;
    cin >> a;
    RIP(j, a){
      int aa;
      cin >> aa;
      d[aa-1] = 1;
    }
  }

  int ans=0;
  RIP(i,n){
    if(d[i] != 1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split(' ');
        var A = int.Parse(s[0]);
        var B = int.Parse(s[1]);
        var C = int.Parse(s[2]) * 2;
        var X = int.Parse(s[3]);
        var Y = int.Parse(s[4]);

        var N = Math.Max(X, Y);
        var min = int.MaxValue;

        for (int i = 0; i <= N; i++)
        {
            min = Math.Min(min,
                A * Math.Max(0, X - i) + B * Math.Max(0, Y - i) + C * i);
        }

        Console.WriteLine(min);
    }
}


Measured memory_bytes: 11092
package main

import "fmt"

func main() {
    var h, m, s int
    var syo int

    fmt.Scanf("%d", &syo)

    // 秒を求める
    s = syo % 60
    syo = syo / 60

    // 分を求める
    m = syo % 60

    // 時を求める
    h = syo / 60

    fmt.Printf("%d:%d:%d\n", h, m, s)
}


Measured memory_bytes: 1132
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x, y = LI()
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if x in a and y in a:
        print("Yes")
        return
    if x in b and y in b:
        print("Yes")
        return
    if x in c and y in c:
        print("Yes")
        return
    print("No")
    return

#B
def B():
    h, w = LI()
    print("#" * (w + 2))
    for _ in range(h):
        a = ["#"]
        for s in S():
            a.append(s)
        a.append("#")
        print("".join(a))
    print("#" * (w + 2))
    return

#C
def C():
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38896