akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	ll n;
	cin >> n;
	//~ ll res = 1;
	//~ while (n >= 2) {
		//~ res *= n;
		//~ n -= 2;
	//~ }
	//~ cout << res << endl;

	if (n%2) {
		cout << 0 << '\n';
		return 0;
	}

	n/=2;

	ll res = 0;
	while (n > 0) {
		res += n / 5;
		n /= 5;
	}
	cout << res << '\n';
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()

n = len(s)
ans1 = [i % 2 for i in range(n)]
ans2 = [i % 2 for i in range(1,n+1)]
#print(ans1)
#print(ans2)
count1 = 0
count2 = 0
for i in range(n):
    if int(s[i]) != ans1[i]:
        count1 += 1
    if int(s[i]) != ans2[i]:
        count2 += 1
print(min(count1, count2))


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, D;
    cin >> n >> D;
    int ans = 0;
    rep(i, n){
        double x, y;
        cin >> x >> y;
        double d = sqrt(x*x + y*y);
        if(d - 1e-15 <= D){
            ans++;
        }
    }
    cout << ans << endl;
}

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

bool isPrime( int x ){
 if( x==2 ){
  return true;
 }

 if( x<2 || x%2==0 ){
  return false;
 }

 int i=3;
 while( i <= sqrt(x) ){
  if( x%i==0 ){
   return false;
  }
  i += 2;
 }

 return true;
}

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

 int list;
 int numbers=0;
 for( int i=0; i<n; i++ ){
  cin >> list;
  if(isPrime(list)){
   numbers++;
  }
 }

 cout << numbers << endl;

 return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

const LL inf = 1e15+10;
const LL maxn = 1e5+10;
LL n,w;
LL dp[105][maxn+5];
LL val[105];
LL wet[105];


int32_t main()
{

    // reading input
    cin >> n >> w;
    for(int i = 1;i<=n;i++){
        cin >> wet[i] >> val[i];
    }



    // filling with infinity
    for(int i = 0;i<=n;i++){
        for(int j = 1;j<=maxn;j++){
            dp[i][j] = inf;
        }
    }



    // updating dp
    for(int i = 1;i<=n;i++){
        for(int j = 0;j<=maxn;j++){
            if(val[i] > j){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = min(dp[i-1][j-val[i]]+wet[i],dp[i-1][j]);
            }
        }
    }


    // output
    LL ans = 0;

    for(int i = 0;i<=maxn;i++){
        if(dp[n][i] <= w && i > ans){
            ans = i;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 82496
n = int(input())
X, Y = [0]*n, [0]*n
for i in range(n):
    X[i], Y[i] = map(int, input().split())

r = 0
for i in range(n-1):
    for j in range(i+1, n):
        r += ((X[i]-X[j])**2+(Y[i]-Y[j])**2)**0.5
print((n-1)*r/(n*(n-1)//2))

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val H = readLine()!!.split(" ").map(String::toInt)

    var max = 0
    var streak = 0

    for (i in 1 until H.size) {
        if (H[i - 1] >= H[i]) {
            streak++
        } else {
            streak = 0
        }

        max = Math.max(streak, max)

    }
    println(max)
}


Measured memory_bytes: 59660
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() { 
  ll n;
  cin >> n;
  ll ans = 0;
  for(auto p : divisor(n)){
    if(p==1) continue;
    if(n/(p-1) == n%(p-1)) ans+=p-1;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    string s; cin >> s;
    bool ans = ((s[0]==s[1]) && (s[0]==s[2]) && (s[2]==s[1]));
    cout << ((ans) ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 922337203685477580
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
string s,t;
ll h,w;
ll dp[1005][1005];
ll vis[1005][1005];
int main()
{
	boost
	cin>>h>>w;
	ll i,j;
	for(i=1; i<=h; i++)
	{
		for(j=1; j<=w; j++)
		{
			char ch;
			cin>>ch;
			if(ch=='.')
				vis[i][j]=0;
			else
				vis[i][j]=1;
		}
	}
	for(i=1; i<=h; i++)
	{
		for(j=1; j<=w; j++)
		{
			if(i==1 && j==1)
				dp[i][j]=1;
			else if(vis[i][j]==0)
				dp[i][j]=((dp[i-1][j]%mod)+(dp[i][j-1]%mod))%mod;
		}
	}
	cout<<dp[h][w]<<endl;
	return 0;
}

Measured memory_bytes: 16000
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int sum = 0;
            int n = Integer.parseInt(in.next());
            int s[] = new int[n];
            for (int i = 0; i < n; i++) {
                s[i] = Integer.parseInt(in.next());
                sum += s[i];
            }

            Arrays.sort(s);
            for (int i = 0; i < n; i++) {
                if (sum % 10 == 0) {
                    if (s[i] % 10 != 0) sum -= s[i];
                } else {
                    out.println(sum);
                    return;
                }
                if (i == n - 1) out.println(0);
            }

        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()

using ll = long long;

int main () {
  int a, b, x;
  cin >> x >> a >> b;
  
  if (x >= b-a ) {
    if (a-b >= 0)
      cout << "delicious" << endl;
    else 
      cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 3124
(defn t4
  [n]
  (if (= "22" n)
    "Christmas Eve Eve Eve"
    "")
)


(defn t3
  [n]
  (if (= "23" n)
    "Christmas Eve Eve"
    (t4 n))
)


(defn t2
  [n]
  (if (= "24" n)
    "Christmas Eve"
    (t3 n))
)

(defn t
  [n]
  (if (= "25" n)
    "Christmas"
    (t2 n))
)






(def line (read-line))
(print (str "" (t line)))

Measured memory_bytes: 62656
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}
//printf("%.10f\n", n);

char test[1234][1234], red[1234][1234], blue[1234][1234];
signed main() {
	ll n, m; cin >> n >> m;
	rep(h, n) {
		rep(i, m) {
			cin >> test[h][i];
			red[h][i] = test[h][i];
			blue[h][i] = test[h][i];
		}
	}
	for (int h = 1; h < n - 1; h++) {
		if (h % 2 == 1) {
			rep(i, m - 1) {
				blue[h][i] = '#';
			}
			red[h][m - 1] = '#';
		}
		else {
			blue[h][0] = '#';
			for (int i = 1; i < m; i++) {
				red[h][i] = '#';
			}
		}
	}
	rep(h, n) {
		rep(i, m) {
			cout << red[h][i];
		}
		cout << endl;
	}
	cout << endl;
	rep(h, n) {
		rep(i, m) {
			cout << blue[h][i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 5464
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w, h; cin >> w >> h;
  vector<ll> P(w); rep(i, w) cin >> P[i];
  vector<ll> Q(h); rep(i, h) cin >> Q[i];
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
  rep(i, w) q.push({P[i], 0});
  rep(i, h) q.push({Q[i], 1});
  ll ans = 0;
  int cntW = w+1, cntH = h+1;
  while(!q.empty()) {
    auto cur = q.top(); q.pop();
    if(cur.second == 0) {
      ans += cur.first * cntH;
      cntW--;
    } else {
      ans += cur.first * cntW;
      cntH--;
    }
  }
  cout << ans << endk;
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	if (n == 3) cout << "2 3 25\n";
	else if (n % 2) {
		int arr[] = {12, 2, 10, 3, 9, 4, 8, 6};
		for (int i = 0; i < n; i++) {
			cout << arr[i % 8] + 12 * (i / 8) << " ";
		}
		cout << endl;
	} else {
		int arr[] = {2, 10, 3, 9, 4, 8, 6, 12};
		for (int i = 0; i < n; i++) {
			cout << arr[i % 8] + 12 * (i / 8) << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
using Graph = vector<vector<int>>;
int main() {
  int A,P;
  cin >> A >> P;
  cout << (A*3+P)/2 << endl;
  return 0;
}

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

constexpr int inf = 1e9;

bool dfs(vector<vector<int>> const& g, vector<int>& col, int v, int& sz1, int& sz2, int c) {
    if(col[v] != -1 && c != col[v]) return false;
    if(col[v] != -1) return true;
    col[v] = c;
    sz1 += c; sz2 += !c;
    bool res = true;
    for(int i = 0; i < (int)g.size(); ++i) {
        if(g[v][i] == 0 || i == v) continue;
        res &= dfs(g, col, i, sz1, sz2, !c);
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n, vector<int>(n, 1));
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        g[a - 1][b - 1] = g[b - 1][a - 1] = 0;
    }

    vector<int> sz1, sz2, col(n, -1);
    for(int i = 0; i < n; ++i) {
        if(col[i] != -1) continue;
        int s1 = 0, s2 = 0;
        if(!dfs(g, col, i, s1, s2, 0)) {
            cout << -1 << endl;
            return 0;
        }
        sz1.push_back(s1), sz2.push_back(s2);
    }
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, -inf));
    dp[0][0] = 0;
    const int sz = sz1.size();
    for(int i = 0; i < sz; ++i) {
        vector<vector<int>> nxt(n + 1, vector<int>(n + 1, -inf));
        for(int j = 0; j <= n; ++j) {
            for(int k = 0; k <= n; ++k) {
                if(dp[j][k] == -inf) continue;
                nxt[j + sz1[i]][k + sz2[i]] = max(nxt[j + sz1[i]][k + sz2[i]], dp[j][k] + sz1[i] * k + sz2[i] * j + sz1[i] * sz2[i]);
                nxt[j + sz2[i]][k + sz1[i]] = max(nxt[j + sz2[i]][k + sz1[i]], dp[j][k] + sz2[i] * k + sz1[i] * j + sz1[i] * sz2[i]);
            }
        }
        dp = move(nxt);
    }

    int ans = 0;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= n; ++j) {
            ans = max(ans, dp[i][j]);
        }
    }
    ans -= n * (n - 1) / 2 - m;
    ans = m - ans;

    cout << ans << endl;
}


Measured memory_bytes: 6144
def read_input():
    n = int(input())
    alist = list(map(int, input().split()))
    blist = list(map(int, input().split()))
    clist = list(map(int, input().split()))

    return n, alist, blist, clist


def submit():
    n, alist, blist, clist = read_input()

    alist.sort(reverse=True)
    blist.sort(reverse=True)
    clist.sort(reverse=True)

    b_a_n = [0] * n
    i = j = 0

    while j < n:
        while i < n and alist[i] >= blist[j]:
            i += 1
        b_a_n[j] = n - i
        j += 1

    b_a_sum = b_a_n.copy()
    for i in range(2, n + 1):
        b_a_sum[n - i] = b_a_sum[n - i + 1] + b_a_n[n - i]

    count = 0
    i = j = 0
    while i < n:
        while blist[j] >= clist[i]:
            j += 1
            if j == n:
                print(count)
                return
        count += b_a_sum[j]
        i += 1

    print(count)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 24380
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int n; readV(n);
  int k; readV(k);

  auto r = 10^^9;
  foreach (i; 0..1<<n) {
    auto d = 1;
    foreach (j; 0..n)
      if (i.bitTest(j)) d *= 2;
      else              d += k;
    r = min(r, d);
  }

  writeln(r);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 256
function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  const K = parseInt(args[1], 10);
  const X = parseInt(args[2], 10);
  const Y = parseInt(args[3], 10);
  let ans;
  
  if (N < K) {
    ans = N * X;
  } else {
    ans = ((N - K) * Y)  + K * X;
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29660
import math
N, K = map(int, input().split())
p = 0
if N >= K:
    p += N - K + 1
    for r in range(1, K):
        p += (1 / 2) ** math.ceil(math.log2(K / r))
else:
    for r in range(1, N + 1):
        p += (1 / 2) ** math.ceil(math.log2(K / r))
print(p / N)

Measured memory_bytes: 9444
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#define maxn 200005
#define lson (now<<1)
#define rson ((now<<1)|1)
#define mid ((nl+nr)>>1)
using namespace std;
typedef long long ll;
const ll mod=998244353;
int n,q;
ll dat[maxn<<2];
ll lazy[maxn<<2];
ll mypow[maxn];
ll bit[10][maxn];
void pushup(int now)
{
	dat[now]=(dat[lson]+dat[rson])%mod;
}
void build(int nl,int nr,int now)
{
	if(nl==nr)
	{
		dat[now]=(mypow[n-nr]*bit[1][1])%mod;
		return;
	}
	build(nl,mid,lson);
	build(mid+1,nr,rson);
	pushup(now);
}
void pushdown(int nl,int nr,int now)
{
	if(lazy[now])
	{
		dat[lson]=(mypow[n-mid]*bit[lazy[now]][mid-nl+1])%mod;
		dat[rson]=(mypow[n-nr]*bit[lazy[now]][nr-mid])%mod;
		lazy[lson]=lazy[now];
		lazy[rson]=lazy[now];
		lazy[now]=0;
	}
}
void add(int ql,int qr,int val,int nl,int nr,int now)
{
	if(ql<=nl && nr<=qr)
	{
		dat[now]=(mypow[n-nr]*bit[val][nr-nl+1])%mod;
		lazy[now]=val;
		return;
	}
	pushdown(nl,nr,now);
	if(ql<=mid)
		add(ql,qr,val,nl,mid,lson);
	if(mid<qr)
		add(ql,qr,val,mid+1,nr,rson);
	pushup(now);
}
int main()
{
	for(int i=1;i<=9;i++)
		bit[i][1]=i;
	
	for(int i=1;i<=9;i++)
		for(int j=2;j<=200000;j++)
			bit[i][j]=(bit[i][j-1]*10+i)%mod;
	
	mypow[0]=1;mypow[1]=10;
	for(int i=2;i<=200000;i++)
		mypow[i]=(mypow[i-1]*10)%mod;
	scanf("%d%d",&n,&q);
	build(1,n,1);
	
	while(q--)
	{
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		add(l,r,d,1,n,1);
		printf("%lld\n",dat[1]);
	}
}


Measured memory_bytes: 27656
x,y = (int(x) for x in input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if (x in a and y in a) or (x in b and y in b) or (x in a and y in b):
    print('Yes')
else:
    print('No')

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
 int n,k; cin >> n >> k;
 int h,count = 0;
  REP(i,n){
	cin >> h;
    if(h >= k) ++count;
  }
  cout << count;
}

Measured memory_bytes: 256
import math

N,M=map(int,input().split(" "))
A=[int(_) for _ in input().split(" ")]

s = math.ceil(sum(A) / (4*M))

#print(s)
count = 0

for i in range(N):
  if A[i] >= s:
    count += 1

if M <= count:
  ans="Yes"
else:
  ans="No"
  
print(ans)

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

using namespace std;

typedef pair<long long int, vector<long long int>> PLVL;


class combination{
public:

//Nの最大値がわかれば代入する
	combination(long long int combinationThreshold = 1e7){
		( *this ).combinationThreshold = combinationThreshold + 2;
	}

	//a^p % mod
	long long int powmod(long long int A, long long int P, long long int M = LLONG_MAX){
		long long int ans = 1;
		long long int mul = A;
		for( ; P > 0; P >>= 1, mul = ( mul*mul ) % M ){
			if( ( P & 1 ) == 1 ) ans = ( ans*mul ) % M;
		}
		return ans;
	}

	//nCk mod m
	long long int cb(long long int N, long long int K, long long int M = LLONG_MAX){
		if( N < combinationThreshold ){// 事前計算O(N)、答えるのはO(1)
			if( inv.size() == 0 ){
				inv = vector<long long int>(combinationThreshold);
				inv[1] = 1;
				for( long long int i = 2; i < combinationThreshold; i++ ){
					inv[i] = M - ( M / i )*inv[M%i] % M;
				}
				fact = vector<long long int>(combinationThreshold);
				fact[0] = 1;
				revFact = vector<long long int>
					(combinationThreshold);
				revFact[0] = 1;
				for( long long int i = 1; i < combinationThreshold; i++ ){
					fact[i] = ( fact[i - 1] * i ) % M;
					revFact[i] = ( revFact[i - 1] * inv[i] ) % M;
				}
			}
			return ( ( ( fact[N] * revFact[K] ) % M )*revFact[N - K] ) % M;
		} else{
			return cbOnce(N, K, M);
		}
	}

	//一回だけなら最速 O(K + log(M))
	long long int cbOnce(long long int N, long long int K, long long int M = LLONG_MAX){
		if( K > N / 2 ) return cbOnce(N, N - K, M);
		long long int ans = 1;
		long long int div = 1;
		for( long long int i = 0; i < K; i++ ){
			ans *= N - i;
			ans %= M;
			div *= i + 1;
			div %= M;
		}
		ans *= powmod(div, M - 2, M);
		return ans % M;
	}

private:
	vector<vector<long long int>>C;//3000以下の答え
	vector<long long int>fact;//階乗
	vector<long long int>revFact;//階乗の逆元
	vector<long long int>inv;//mod pでの逆元

	long long int combinationThreshold;//Nの最大値がわかれば入れる。
};

int main(){
	long long int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	long long int m = min(X, Y);
	long long int ans = C * 2 * m + ( X - m )*A + ( Y - m )*B;

	long long int ma = max(X, Y);
	ans = min(ans, ma*C * 2);

	cout << min(ans, A * X + B * Y) << endl;

}


Measured memory_bytes: 256
N, W = map(int, input().split())
wt, vt = [], []
for _ in range(N):
    w, v = map(int, input().split())
    wt.append(w)
    vt.append(v)

dp = [[float('inf')] * (10 ** 5 + 5) for _ in range(N + 5)]
dp[0][0] = 0
for i in range(N):
    for j in range(10 ** 5 + 1):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        if 0 <= j - vt[i]:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - vt[i]] + wt[i])
# print(dp)
ans = 0
for i in range(N + 1):
    for j in range(10 ** 5 + 1):
        if dp[i][j] <= W:
            ans = max(ans, j)
print(ans)

Measured memory_bytes: 313320
#include<stdio.h>

int main(){
  int n, i, j, cnt, t;

  while(scanf("%d", &n), n){
    cnt=0;
    for(i=1; i<n; i++){
      t=0;
      for(j=i; j<n; j++){
	t+=j;
	if(t==n){
	  cnt++;
	  break;
	}else if(t>n){
	  break;
	}
      }
    }
    printf("%d\n", cnt);

  }

  return 0;
}

Measured memory_bytes: 600
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<vector>
using namespace std;

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

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

	int two = 0, four = 0, no = 0;
	REP(i, n){
		long long t; cin >> t;
		if(t % 4 == 0) four++;
		else if(t % 2 == 0) two++;
		else no++;
	}

	if(four + 1 < no){
		cout << "No" << endl;
		return 0;
	}else if(four + 1 == no && two % 2 == 1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m, a[100][100], b[100], c[100] = {0};
	int i, j;
	
	scanf("%d %d", &n, &m);
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
	}
	
	for (i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    int res = 0;
    int ma = 0;
    rep(i, n)
    {
        if (ma <= h[i])
        {
            res++;
            ma = h[i];
        }
    }

    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>

int main()
{
    int N;
    scanf("%d", &N);
    int *array = new int[N];
    for (int i = 0; i < N; i++)
        scanf("%d", &array[i]);

    for (int k = 0; k < N - 1; k++)
        printf("%d ", array[k]);
    printf("%d\n", array[N - 1]);

    for (int i = 1; i < N; i++)
    {
        int v = array[i];
        int j = i - 1;
        while (j >= 0 && array[j] > v)
        {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = v;

        for (int k = 0; k < N - 1; k++)
        {
            printf("%d ", array[k]);
        }
        printf("%d\n", array[N - 1]);
    }
}


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

const int N = 51;
const ll mod = 1000000007;

int n;

ll tmp[N][N];
void mul(ll b[N][N], ll a[N][N])
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            tmp[i][j] = 0;
            for (int k = 0; k < n; k++)
                tmp[i][j] = (tmp[i][j] + b[i][k] * a[k][j]) % mod;
        }
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            b[i][j] = tmp[i][j];
}


void pw(ll b[N][N], ll a[N][N], ll k)
{
    ll bit = 1;
    while (2*bit <= k) bit *= 2;
    while (bit)
    {
        mul(b, b);
        if (k&bit) mul(b, a);
        bit /= 2;
    }
}

ll a[N][N];
ll b[N][N];
int main()
{
    ll k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
        b[i][i] = 1;
    }

    pw(b, a, k);
    ll ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = (ans + b[i][j]) % mod;


    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

ll splithh(int h,int w){
    ll s1,s2,s3;
    ll result = 10000000000;
    for(ll i=1; i<h-1; i++){
        s1 = (ll)i*w;
        h--;
        s2 = (ll)(h/2)*w;
        s3 = (ll)(h-h/2)*w;
        result = min(result,max({s1,s2,s3})-min({s1,s2,s3}));
    }
    return result;
}
ll splithv(int h, int w){
    ll s1,s2,s3;
    ll result = 10000000000;
    for(ll i=1; i<h; i++){
        s1 = (ll)i*w;
        h--;
        s2 = (ll)(w/2)*h;
        s3 = (ll)(w-w/2)*h;
        result = min(result,max({s1,s2,s3})-min({s1,s2,s3}));
    }
    return result;
}

int main(){
    int h,w;
    cin >> h >> w;
    int ans = 0;
    OUT(min({splithh(h,w), splithh(w,h), splithv(h,w), splithv(w,h)}));
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int  main()
{
	int a,b,sum;
	cin>>a>>b;
	sum=a+b;
	if(sum%3==0)cout<<"Possible";
	else if(a%3==0)cout<<"Possible";
	else if(b%3==0)cout<<"Possible";
	else cout<<"Impossible";
} 



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int sum=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int l=0;l<10;l++){
						if(i+j+k+l==n)sum++;
					}
				}
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod=998244353;
const ll INF= 1LL << 60;


vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; 

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); 
    }
}

int main(){
	int n,m; cin >> n >> m;
	Graph G(n+1);
	seen.assign(n+1, false);
	int ans=0;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
	for (int i=1;i<n+1;i++){
		if (seen[i]) continue;
		dfs(G,i);
		ans++;
	}
	cout << ans-1 << "\n";
}

Measured memory_bytes: 9596
#include <iostream>

int main(){
   int N, M;
   std::string S, T;
   std::cin >> N >> M;
   if(N>M) std::cin >> S >> T;
   else std::cin >> T >> S;

   int min = N < M ? N : M;
   int max = N < M ? M : N;
   long long L = max;
   while(true){
      if(L%min!=0){
	 L += max;
	 continue;
      }
      int prev = 0;
      for(int i=0; i<min; ++i){
	 int index1 = L/min * i + 1;
	 for(int j=prev; j<max; ++j){
	    int index2 = L/max * j + 1;
	    if(index1==index2 && T[i] != S[j]){
	       std::cout << -1 << std::endl;
	       return 0;
	    }else if(index1<=index2){
	       prev = j - 1;
	       break;
	    }
	 }
      }
      break;
   }

   std::cout << L << std::endl;
   return 0;
}


Measured memory_bytes: 512
a = int(input())

def func_1(x):
    return x//2

def func_2(x):
    return 3*x+1

dp = [0] * 1000000

c = 1
dp[a] = 1
while True:
    c += 1
    if a % 2 == 0:
        a = func_1(a)
    else:
        a = func_2(a)

    if dp[a] > 0:
        print(c)
        break
    else:
        dp[a] = 1


Measured memory_bytes: 46064
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int a,b; cin>>a>>b;
  int x,y;
  y = (2*a - b) / (-2);
  x = a - y;
  if (((2*a - b) % (-2)) == 0){
    if (((2*a - b) / (-2)) >= 0 && (x >= 0)) {
      cout << "Yes" << endl;

    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}


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

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;
long long h[100010];
long long dp[100010];

int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }

  for (int i = 0; i < N; i++) {
    dp[i] = INF;
  }
  
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      if (i - j < 0) break;
      chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }

  printf("%lld", dp[N - 1]);
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n, z, w, a[2000], i;

	scanf("%d %d %d", &n, &z, &w);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
    if(abs(a[n - 1] - w) > abs(a[n - 1] - a[n - 2]))
        printf("%d\n", abs(a[n - 1] - w));
    else
         printf("%d\n", abs(a[n - 1] - a[n - 2]));
    
    return 0;
}



Measured memory_bytes: 128
M(int*a){return*1[&a]-*a;}L(t){return t/100*60+t%100;}n,p,q,e[999],m,k,s,t,i,x;main(){for(;scanf("%d%d%d",&n,&p,&q)*n;printf("%d\n",n&&q-p>x?q-p:x)){p=L(p);q=L(q);m=x=0;for(i=n;i--;)for(scanf("%d",&k);k--;e[m++]=L(s)*2+1,e[m++]=L(t)*2)scanf("%d%d",&s,&t);for(qsort(e,m,4,M);m--&&(t=e[m]/2)<=q;)e[m]%2?!--n&&t-p>x?x=t-p:0:!n++?p=e[m]/2:0;}}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

ll dp[101][10001];

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

    // input
    ll N, C; // C : capacity
    cin >> N >> C;

    vector<ll> V(N);
    vector<ll> W(N);
    FOR(i, 0, N){
        cin >> V[i]; 
        cin >> W[i];
    }

    // i番目以降を見て
    // jキャパシティに入る最大の価値
    for(int i=N-1; i>=0; i--){
        FOR(j, 0, C+1){
            if(W[i]>j){
                // 入らない
                dp[i][j] = dp[i+1][j];
            }
            else{
                ll v0 = dp[i+1][j];
                ll v1 = dp[i+1][j-W[i]] + V[i];
                dp[i][j] = max(v0, v1);
            }
        }
    }
    p(dp[0][C]);


    
    return 0;
}


Measured memory_bytes: 10988
import math
import pprint
import fractions
import collections
import itertools
from decimal import *
from collections import deque
from bisect import *
H,W,K=map(int,input().split())
table=[list(input()) for _ in range(H)]
yoko=[]                                     #横列の塗る(1)/ぬらない(0)
tate=[]                                     #縦列の塗る(1)/ぬらない(0)
ans=0
for i in range(pow(2,H)):
    yoko=[0]*H
    for j in range(H):
        if i>>j&1:
            yoko[j]=1
    for j in range(pow(2,W)):
        tate=[0]*W
        for k in range(W):
            if j >> k & 1:
                tate[k] = 1
        cnt=0
        for i in range(H):
            for j in range(W):
                if (yoko[i]==0)and(tate[j]==0)and(table[i][j]=="#"):
                    cnt=cnt+1
        if cnt==K:
            ans=ans+1
print(ans)






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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol n, m; cin >> n >> m;
    //lol k; cin >> k;
    REP(i, m)
    {
        int a;
        cin >> a;
        n -= a;
    }
    if(n < 0)
        cout << -1 << endl;
    else
    {
        cout << n << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3572
//https://atcoder.jp/contests/abc177/tasks/abc177_b
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s, t;
    cin>>s>>t;

    int lenS=s.length();
    int lenT=t.length();
    int ans=1e4;
    for (int i=0; i+lenT<=lenS; i++) {
        int change=0;
        for (int j=0; j<lenT; j++) {
            if (s[i+j]!=t[j]) {
                change++;
            }
        }
        ans = min(ans, change);
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3564
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val list =
      for{
        in <- Source.stdin.getLines.toList
      } yield in

    list.map(_.split(" ").map(_.toInt).toList).init.foreach{ list =>
      val height = list.head
      val width = list.last

      println("#" * width)
      (2 to height-1).foreach{ i =>
        println(s"#${"." * (width - 2)}#")
      }
      println("#" * width)
      println
    }
  }
}

Measured memory_bytes: 45940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){

  ll X,K,D;
  cin >> X >> K >> D;
  if(X<0)
  X = -X;
  ll ans = X;
  if(X/D < K){
    K -= X/D;
    ans = X - D*(X/D);
  }
  else{
    cout << X-D*K << endl;
    return 0;
  }

  if(K%2==0){
    cout << ans << endl;
  }
  else{
    cout << D-ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string s;
int a,p=753,i,x=9999;
int absx(int a){
	if(a<0)a*=-1;
	return a;
}
int minx(int a,int b){
	if(a<b)return a;
	return b;
}
int main(){
	cin>>s;
	for(i=0;i<s.length();i++){
		s[i]-=48;
	}
	for(i=2;i<s.length();i++){
		a=s[i-2]*100+s[i-1]*10+s[i];
		x=minx(x,absx(a-p));
	}
	cout<<x<<endl;
	return 0;
}

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

using namespace std;

int main()
{
//    vector <> vec;
//    vec.clear;
    int t,a,b;
    cin>>t;
    a=t*t;
    b=a*t;
    cout<< b+a+t <<endl;
//    while (t--){}
//    for(int i=0;i<n;i++){}
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;

void solve(){
	ll n, x, m;
	cin>>n>>x>>m;
	ll cur = x;
	ll r = 1;
	vector<ll> v;
	v.pb(0ll);
	map<ll, ll> s;
	while(true){
		if(s.find(cur%m)!=s.end()) break;
		v.pb(cur);
		s[cur] = r++;
		cur = (cur*cur)%m;
	}
	ll l = s[cur];
	for(int i=1;i<v.size();i++){
		v[i] += v[i-1];
	}
	if(n<v.size()){
		cout<<v[n]<<endl;
	}
	else{
		ll ans = v[l-1];
		n-=(l-1);
		ll sz = v.size();
		ans += (v[sz-1]-v[l-1])*(n/(sz-l));
		ans += v[l -1 + n%(sz-l)] - v[l-1];
		cout<<ans<<endl;
	}
}

int main(){
	io;
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 6708
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut h: Vec<u64> = (0..n).map(|_| read()).collect();
    let mut ans = true;

    for i in 0..h.len() - 1 {
        if h[i] > h[i + 1] {
            if h[i] == h[i + 1] + 1 {
                h[i + 1] += 1;
            } else {
                ans = false;
                break;
            }
        }
    }

    println!("{}", if ans { ("Yes") } else { ("No") });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second

class DSU
{
  public:
	vector<int> f;
	vector<int> cnt;
	DSU(int sz)
	{
		f = vector<int>(sz);
		cnt = vector<int>(sz, 1);
		forn(i, sz) f[i] = i;
	}
	int get(int x)
	{
		return f[x] == x ? x : (f[x] = get(f[x]));
	}
	void merge(int x, int y)
	{
		x = get(x);
		y = get(y);
		if (x != y)
			f[x] = y, cnt[x] += cnt[y], cnt[y] = cnt[x];
	}
	bool same(int x, int y)
	{
		return get(x) == get(y);
	}
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	DSU dsu(n);
	vector<pair<int, int>> e;
	vector<ll> ans;
	forn(i, m)
	{
		int u, v;
		cin >> u >> v;
		u--, v--;
		e.push_back({u, v});
	}
	forr(i, m - 1, 0)
	{
		int x = e[i].fi, y = e[i].se;
		if (dsu.same(x, y))
			ans.push_back(0);
		else
			ans.push_back((ll)dsu.cnt[dsu.get(x)] * (ll)dsu.cnt[dsu.get(y)]);
		dsu.merge(x, y);
	}
	forr(i, m - 1, 0)
	{
		static ll sum = 0;
		sum += ans[i];
		cout << sum << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int n;cin>>n;
    string s;cin>>s;
    REP(i,s.size()){
        s[i]+=n;
        if(s[i]>'Z')s[i]-=26;
    }cout<<s<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define frep(i,m,n) for(int (i)=(m); (i)<(int)(n); (i)++)
#define rrep(i,n) for(int (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(int (i)=(n)-1; (i)>(int)(m)-1; (i)--)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
const int INF = 1001001001;
const int MOD = 1000000007;

// A:array of pair, N:size of array
void sort_second(vector<pair<ll, ll>> &A, int N);
// a^n
ll a_n(ll a, ll n);
// make vector of (n!)%MOD, (n!)^(-1)%MOD to calculate nCk
void nCk(vector<ll> &n, vector<ll> &ninv);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    int n;
    cin >> n;
    const int N = n;
    vector<int> p(N), q(N), permutation(N);
    rep(i, N) cin >> p[i];
    rep(i, N) cin >> q[i];
    rep(i, N) permutation[i] = i+1;
    
    int flag, pcount = 0, qcount = 0;
    do {
        flag = 1;
        rep(i, N) {
            if(p[i] != permutation[i]) flag = 0;
        }
        if(flag == 1) break;
        pcount++;
    } while(next_permutation(all(permutation)));

    rep(i, N) permutation[i] = i+1;
    do {
        flag = 1;
        rep(i, N) {
            if(q[i] != permutation[i]) flag = 0;
        }
        if(flag == 1) break;
        qcount++;
    } while(next_permutation(all(permutation)));

    cout << abs(pcount-qcount) << endl;

    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD ;
}

/* calculate a^n with no recursive process (%MOD)
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    int num = 1;
    vector<ll> memory(100);
    memory.at(0) = a;

    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
        memory.at(num) = ret;
        num++;
    }
    if(count == n) return ret;
    else {
        bitset<100> bit = bitset<100>(n-count);
        rep(i, 100) {
            if(bit.test(i)) ret = (ret * memory.at(i)) % MOD;
        }
        return ret;
    }    
}
*/

void nCk(vector<ll> &n, vector<ll> &ninv) {
    n[0] = 1;
    for(int i = 1; i < n.size(); i++) n[i] = (n[i-1] * i) % MOD;
    ninv[n.size()-1] = inv(n[n.size()-1]);
    for(int i = n.size() - 2; i > -1; i--) ninv[i] = (ninv[i+1] * (i+1)) % MOD;
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	ll ans = 0;

	ans += min(k, a);
	k -= a;
	if (k <= 0) {
		cout << ans << endl;
		return 0;
	}

	k -= b;
	if (k <= 0) {
		cout << ans << endl;
		return 0;
	}

	ans -= min(k, c);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
N, A, B, C, D = map(int, input().split())
S = '.'+input()

def dp(s,g):
  if s==g or s==g-1 or s==g-2:
    return 1
  if S[s+1]=='.' and S[s+2]=='.':
    return DP[s+1]|DP[s+2]
  if S[s+1]=='#' and S[s+2]=='.':
    return DP[s+2]
  if S[s+1]=='.' and S[s+2]=='#':
    return DP[s+1]
  if S[s+1]=='#' and S[s+2]=='#':
    return 0
DP=[0]*(N+1)
for i in range(C,A-1,-1):
  DP[i] = dp(i,C)
ansA = DP[A]
for i in range(D,B-1,-1):
  DP[i] = dp(i,D)
ansB = DP[B]
#print(ansA,ansB)
if C<D:
  ans = ansA & ansB
else:
  ans = ansA & ansB & ('...' in S[B-1:D+2])

Ans = ['No','Yes']
print(Ans[ans])

Measured memory_bytes: 4980