akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    string s;
    cin >> s;
    vector<int> v(26, 0);
    for (auto ss : s) {
        v[ss - 'a'] = 1;
    }
    for (int i = 0; i < 26; i++) {
        if (v[i] == 0) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}




Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dp[210];

int main(){
    int n, m;
    int h, r;
    while(cin>>n && n){
        vector<pii> v;
        rep(i, n) {
            cin>>h>>r;
            v.pb(mp(h, r));
        }
        cin>>m;
        rep(i, m){
            cin>>h>>r;
            v.pb(mp(h, r));
        }
        sort(all(v));

        int ans = 0;
        for(int i = 0; i < 210; i++) dp[i]=1;
        for(int i = 1; i < n + m; i++){
            for(int j = 0; j < i; j++){
                if(v[j].fi < v[i].fi && v[j].se < v[i].se){
                    dp[i]=max(dp[j]+1, dp[i]);
                }
            }
            ans = max(ans, dp[i]);
        }
        cout<<ans<<endl;
    }  
}

Measured memory_bytes: 1204
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readLong()
    val mod = 1000000007
    var primeFactorMap = mutableMapOf<Long, Long>()
    for (i in 1..n) {
        val tmp = primeFactor(i)
        for (e in tmp) {
            primeFactorMap.merge(e.key, e.value) { old, new -> old + new }
        }
    }

    var ans = 1L
    for (e in primeFactorMap) {
        ans = (ans * (e.value + 1) % mod) % mod
    }
    out.println(ans)
}

/**
O(n^(1/2)) // n * n <= Long.MAX_VALUE n <= 10^8 or more
if n == 1, return emptyMap
 */
fun primeFactor(n: Long): Map<Long, Long> {
    val factorMap = mutableMapOf<Long, Long>()
    var target = n
    var i = 2L
    while (i * i <= target) {
        while (target % i == 0L) {
            factorMap[i] = factorMap.getOrElse(i) { 0L } + 1L
            target /= i
        }
        i++
    }

    if (target != 1L) { factorMap[target] = 1 }
    return factorMap
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 34576
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll N, M; cin >> N >> M;
  
  vector <ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  vector <ll> sum(N); sum[0] = A[0];
  for (int i = 1; i < N; i++) sum[i] = sum[i - 1] + A[i];

  ll L = 0, R = A[N - 1] * A[N - 1] + 2;

  while (R - L > 1){
    ll now = (L + R) / 2;
    ll cnt = 0;
    for (int i = 0; i < N; i++){
      if (A[i] + A[N - 1] < now) continue;
      
      if (A[i] + A[0] >= now){
        cnt += N; continue;
      }

      ll l = 0, r = N;
      while (r - l > 1){
        ll n = (l + r) / 2;
        if (A[i] + A[n] < now) l = n;
        else r = n;
      }
      cnt += N - r;
    }
    
    if (cnt >= M) L = now;
    else R = now;
  }

  ll ans = 0, cnt = 0;
  for (int i = 0; i < N; i++){
    if (A[i] + A[N - 1] < L){
      continue;
    }
    if (A[i] + A[0] >= L){
      ans += A[i] * N + sum[N - 1];
      cnt += N;
      continue;
    }

    ll l = 0, r = N;
    while (r - l > 1){
      ll now = (l + r) / 2;
      if (A[i] + A[now] < L) l = now;
      else r = now;
    }
    ans += A[i] * (N - r) + sum[N - 1] - sum[l];
    cnt += N - r;
  }
  
  ans += L * (M - cnt);
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;
#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int main ()
{
  long long N,M,K,b,time,timeb,anum,bnum,res;
  vector<long long> A,B;


  cin >> N >> M >> K;

  REPI(N)
  {
    cin >> b;
    A.push_back (b);
  }

  REPI(M)
  {
    cin >> b;
    B.push_back (b);
  }
  
  time = 0;
  anum = 0;
  while(1)
  {
    if (anum == N || time + A[anum] > K)
      break;
    
    time += A[anum];
    anum++;
  }
  res = anum;

  bnum = 0;
  while (1)
  {
    
    while (bnum != M && time + B[bnum] <= K)
    {
      time += B[bnum];
      bnum++; 
    }

    res = max(res, anum+bnum);
    
    anum--;
    if (anum < 0)
      break;    
    
    time -= A[anum];    
  }

  cout << res << endl;

  return 0; 
}

Measured memory_bytes: 7988
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
    p_max = max(p[i-1], p[i], p[i+1])
    p_min = min(p[i-1], p[i], p[i+1])
    if p_max != p[i] and p_min != p[i]:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>

using namespace std;

//start of 0uts1de's library

int cin_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}


int cout_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}


int max_int_arr(std::vector<int>& arr){    //data mode
    int maxVal = INT_MIN;       //min of int
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
        }
    }
    return maxVal;
}

int max_int_arr(std::vector<int>& arr, int mode){    //overload index mode
    int maxVal = INT_MIN;       //min of int
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
            maxIndex = i;
        }
    }
    return maxIndex;
}

double max_double_arr(std::vector<double>& arr){    //data mode
    double maxVal = -DBL_MAX;       //min of double
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
        }
    }
    return maxVal;
}

int max_double_arr(std::vector<double>& arr, int mode){    //overload index mode
    double maxVal = -DBL_MAX;       //min of double
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
            maxIndex = i;
        }
    }
    return maxIndex;
}

//end of 0uts1de's library

int main(){
    int n, k;
    cin >> n >> k;
    if ((n+1)/2 >= k){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = input()

n = len(s)
ok = False
ans = 9
if n == 1:
    print(s)
    exit()

for i in range(n-1):
    if ok:
        ans += 9
        continue
    if s[i+1] == '9':
        ans += ord(s[i]) - ord('0')
        continue
    x = ord(s[i]) - ord('0')
    ans += x-1
    ok = True

print(ans)


Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){FIN;
	ll l; cin>>l;
	long double lad=1.*l/3;
	cout<<fixed<<setprecision(12)<<lad*lad*lad;
	
	return 0;
}

Measured memory_bytes: 256
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):*a,c=I();R+=[(a,c)];Y+=c,;X+=a
for i in r(m):a,*b=I();H+=[(a,b)];X+=a,;Y+=b
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)+1
h,s,K=g(X);w,t,L=g(Y);j=lambda:[[0]*-~K for i in r(L+1)];V=j();U=j();v=j()
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]-=1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]-=1
for i in r(L):
 for j in r(K):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if 1-v[d][c]and(U[(f>0)+y][x]|e==0)|(V[y][(e>0)+x]|f==0):q+=[(c,d)];v[d][c]=1
print([a,'INF'][a>F])

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

int main() {
int N;
int ans = 0;
cin >> N;
vector<int>takoyakies(N);
for(int i = 0; i < N; i++){
    cin >> takoyakies.at(i);
}

for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
        ans += takoyakies.at(i) * takoyakies.at(j);
    }
 }
cout << ans << endl;

}

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

main() {
    string S; cin >> S;
    string A;
    rep(i,S.size()){
        if(S[i]=='0')
        A.push_back('0');
        else if(S[i]=='1')
        A.push_back('1');
        else if(A.size()>0) 
        A.pop_back();
    }
    cout << A << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n , m;
  scanf("%d %d",&n ,&m);

  int h[n+2];
  for(int i = 1;i <= n;i ++){
    scanf("%d",&h[i]);
  }

  int check[100002] = {0};
  int a[m] , b[m];
  for(int i = 0;i < m;i ++){
    scanf("%d %d",&a[i] ,&b[i]);
    if(h[a[i]] > h[b[i]]){
      check[b[i]] = 1;
    }
    else if(h[a[i]] < h[b[i]]){
      check[a[i]] = 1;
    }
    else{
      check[a[i]] = 1;
      check[b[i]] = 1;
    }
  }
  
  int ans = 0;
  for(int i = 1;i <= n;i ++){
  	if(check[i] == 0){
      ans ++;
    }
  }

  printf("%d\n",ans);

  return 0;

}

Measured memory_bytes: 3264
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		String s = sc.next();
		
		int pass = 0;
		int oversea_pass = 0;
		
		for(int i=0; i<s.length(); i++) {
			char ch = s.charAt(i);
			if(ch == 'c') {
				System.out.println("No");
				continue;
			}
			if(ch == 'a') {
				if(pass < a + b) {
					System.out.println("Yes");
					pass++;
				}
				else
					System.out.println("No");
				continue;
			}
			if(ch == 'b') {
				if(pass >= a + b) 
					System.out.println("No");
				else {
					if(oversea_pass < b) {
						System.out.println("Yes");
						pass++;
						oversea_pass++;
					}
					else
						System.out.println("No");
				}
			}
		}
		
	}

}


Measured memory_bytes: 23200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    for (int i = 0;; i++) {
        if (i * i > n) {
            int j = i - 1;
            cout << j * j << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7


import heapq
def prim_heap(n, edges):  # n: 最大の頂点番号+1, edges[頂点番号]=[[重み, 行き先],[重み, 行き先],...]. 無向グラフの場合は相方向有向グラフの表記にしておく。
    seen = [False] * n #True:不使用
    edgelist = []  # heapq
    for e in edges[0]:  # 頂点 0 から伸びる辺をすべて heapq に入れる。
        heapq.heappush(edgelist,(e, 0))  # 一応、どこから来たかの情報を持っておく。
    seen[0] = True  # 頂点 0 は見たと記録する。
    res_edges = []  # 辺を記録するためのリスト。
    res = 0  # 最小全域木の辺の重みの合計。
    while len(edgelist) != 0:
        minedge, start = heapq.heappop(edgelist)  # edgelist から最小の辺を1つ取り出す。
        if seen[minedge[1]]:  # その辺の行き先がすでに見た先だったら棄却して次へ。
            continue
        v = minedge[1]  # 行き先を v とする。
        seen[v] = True  # 頂点 v は見たと記録する。
        for e in edges[v]:  # 頂点 v から伸びる辺すべてについて、もしその行き先を見ていなかったら heapq に追加する。
            if not seen[e[1]]:
                heapq.heappush(edgelist,(e, v))
        res_edges.append((start, v, minedge[0]))  # Edge: (from, to, weight)
        res += minedge[0]  # いま使った辺の重みを結果に加える。
    # print(res_edges)  # 最小全域木の辺を print する。
    # return res_edges  # 最小全域木の辺を返す。
    return res  # 最小全域木の全体の重みを返す。



def main(): 
    N = II()
    pos_li = []
    for i in range(N):
        x,y = LI()
        pos_li.append((x,y,i))
    edges = [[] for _ in range(N)]
    # # すべての頂点を結ぶグラフを作ってその最小全域木を取ると、時間が足りない（二重ループが O(10^10)）。
    # for i in range(N):
    #     for j in range(N):
    #         weight = min(abs(pos_li[i][0] - pos_li[j][0]), abs(pos_li[i][1] - pos_li[j][1]))
    #         edges[i].append([weight, j])
    #         edges[j].append([weight, i])
    # # なので、座標でソートして、最も近い4点のみへ辺を伸ばす。
    pos_li.sort(key=lambda x: x[0])
    for k in range(N-1):
        x1, y1, p1 = pos_li[k]
        x2, y2, p2 = pos_li[k+1]
        weight = abs(x1-x2)
        edges[p1].append([weight, p2])
        edges[p2].append([weight, p1])

    pos_li.sort(key=lambda x: x[1])
    for k in range(N-1):
        x1, y1, p1 = pos_li[k]
        x2, y2, p2 = pos_li[k+1]
        weight = abs(y1-y2)
        edges[p1].append([weight, p2])
        edges[p2].append([weight, p1])

    # print(edges)
    print(prim_heap(N, edges))

main()

Measured memory_bytes: 94560
import heapq as hq

n = int(input())

list_A = []
list_B = []
h = []
for i in range(n):
    a, b = map(int, input().split())
    hq.heappush(h, [b, a])

time = 0
for _ in range(n):
    b, a = hq.heappop(h)
    time += a
    if b < time:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 34816
#include <stdio.h>
int main(void)
{
    int a, b, c;
    int i, count = 0;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    for(i = 1; i <= c; i++){
        if((c % i) == 0){
            if(i >= a && i <= b)
                count += 1;
        }
    }
    printf("%d\n", count);

    return 0;
}


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

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

    int p[5000];
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    int min_sum=20000;

    for(int I=0;I<=p[0];I++){
        int q[5000];
        for(int i=0;i<N;i++){
        q[i]=p[i];
        }
        int sum=I;
        q[0] -=I;

        for(int i=0;i<=N-2;i++){
            if(q[i]<=0)
            continue;

            sum +=q[i]*2;
            q[i+1] -=q[i];
        }
        if(q[N-1]>0){
            sum += q[N-1];
        }
        min_sum= min(min_sum,sum);
    }
    cout <<min_sum<<endl;

    return 0;

}


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

signed main(){
  
  string s;
  cin>>s;
  
  int cnt = 0;
  
  for(int i=0;i<s.size();i++){
    
    if( s[i] == '*' ) break;
    
    if( s[i] == '(' ) cnt++;
    
    if( s[i] == ')' ) cnt--;
    
  }
  
  cout<<cnt<<endl;  
  
  return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N, A; cin >> N >> A;
	LL ans = N*N- A;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int N;
  scanf("%d",&N);
  int x,y;
  int count;
  int money;

  x = 800 * N;
  count = N / 15;
  y = count*200;

  money = x - y;
  printf("%d\n",money);
  return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

table=[0,2,5,5,4,5,6,3,7,6]

n,mmm = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]


bar = list(set([table[i] for i in a]))
bar.sort()
minbar=min(bar)

maxnum = ['0']*10
for i in bar:
    mbmax = max([j for j in a if table[j] == i])
    maxnum[i]=str(mbmax)
#print(maxnum,bar)
ans = ['0']*(100)
for i in range(8):
    if i in bar:
        ans[i]=maxnum[i]
#print(ans)
for i in range(90):
    if ans[i] == '0':
        continue
    for j in bar:
        if maxnum[j] > ans[i][0]:
            tmp = maxnum[j]+ans[i]
        else:
            tmp = ans[i]+maxnum[j]
            ans[i+j] = str(max(int(ans[i+j]),int(tmp)))
#print(ans)
if n < 90:
    print(ans[n])
else:
    mn = maxnum[minbar]
    ans2=0
    for i in range(90):
        if n>=i and (n-i)%minbar == 0:
            q=(n-i)//minbar
            if ans[i]=='0' : continue
            X = ''.join([j for j in ans[i] if j > mn])
            Y = ''.join([j for j in ans[i] if j <= mn])
            tmp = int(X+str(mn)*q+Y)
#            print(tmp,X,Y,ans[i],i)
            ans2 = str(max(int(ans2),tmp))
    print(ans2)
    

        
    
    
    
    


    
    

        


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall

	ins(a);
	if(a == "hi" or a == "hihi" or a == "hihihi" or a =="hihihihi" or a == "hihihihihi"){
		out("Yes");
		return 0;
	}
	out("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll INF = 1e15, k, a[100010], dp[100010];

ll solve(ll pos){
  if(pos < 0) return INF;
  if(!pos) return 0;
  ll &r = dp[pos];
  if(r >= 0) return r;
  r = INF;
  fore(i,1,k+1){
    if(pos-i >= 0) r = min(r, abs(a[pos]-a[pos-i])+solve(pos-i));
    else break;
  }
  return r;
}

int main(){FIN;
  memset(dp,-1,sizeof(dp));
  int n; cin >> n >> k;
  fore(i,0,n) cin >> a[i];
  cout << solve(n-1) << "\n";
}

Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            var k = RInt;

            var has = new HashSet<string>();
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 1; j < Min(s.Length + 1 - i, k + 1); j++)
                {
                    has.Add(s.Substring(i, j));
                }
            }
            var lis = has.ToList();
            lis.Sort();

            WriteLine(lis[k - 1]);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int main() {
 int W,H;
  while(1){
    cin>>W>>H;
    if(W==0&&H==0){
      break;
    }
    for(int a=0;a<H;a++){
      cout<<"#";
    }
    cout<<endl;
    

      for(int a=0;a<W-2;a++){
        cout<<"#";
        if(W>=3&&H>=3){
        for(int b=0;b<H-2;b++){
          cout<<".";
        }}
        if(H!=1)
        cout<<"#";
        cout<<endl;
      }

    for(int a=0;a<H;a++){
      cout<<"#";
    }
    cout<<endl<<endl;
  }
}


Measured memory_bytes: 3056
from itertools import product
def main(): 
    with open(0) as f:
        N = int(f.readline())
        A = [list(map(int, line.split())) for line in f.readlines()]

    possible = True
    ans = 0
    r = range(N)
    for i,j in product(r, r) :
        if j <= i: continue
        for k in r:
            if k == i or k == j:
                continue
            if A[i][j] < A[i][k] + A[k][j]:
                continue
            elif A[i][j] == A[i][k] + A[k][j]:
                break
            else:
                possible = False
            break
        else:
            ans += A[i][j]
    print(ans if possible else -1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 13652
from collections import deque
N, D, A = map(int, input().split())

ys = []
hs = []
for i in range(N):
    X, H = map(int, input().split())
    ys.append((X,-(-H//A)))

ys = sorted(ys, key=lambda x : x[0])
l = ys[0][0] + 2*D
li = dmg = r = 0
hs2 = [0]*N
for i, (y, h) in enumerate(ys):
    while l < y:
        dmg -= hs2[li]
        li += 1
        l = ys[li][0] + 2*D
    hs2[i] = max(0, h-dmg)
    dmg += hs2[i]
    r += hs2[i]
print(r)


Measured memory_bytes: 77528
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; ll ans = n*(n+1)/2;
  
  for(ll i=2; i <= n; i++){
    for(ll j=1; j <= n; j++){
      if(i*j <= n) ans += i*j;
      else break;
    }
  }
  
  cout << ans << endl;
  
  
}

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int comb(int n, int m) {
    int result = 1;
    for (int i = n; i > n-2; i--)
        result *= i;
    for (int i = m; i > 1; i--)
        result /= i;
    return result;
}

int main(void){
    int n;
    cin >> n;
    
    vector<vector<int>> count(10, vector<int>(10, 0));
    for (int i = 1; i <= n; i++) {
        if (i % 10 != 0)
            count[ctoi(to_string(i)[0])][i % 10]++;
    }
    
    int ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i == j) {
                ans += comb(count[i][j], 2) * 2 + count[i][j];
            }
            else {
                ans += count[i][j] * count[j][i];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N; long long C;
long long x[101010];
long long v[101010];
long long dpL[101010];
long long dpR[101010];
long long solve()
{
  memset(dpL, 0, sizeof dpL);
  
  long long sum = 0;
  for(int i=1; i<=N; ++i)
  {
    sum += v[i];
    dpL[i] = max(dpL[i-1], sum-2*x[i]);  
  }
  sum = 0;
  long long ans = 0;
  for(int i=N+1; i>=1; --i)
  {
    sum += v[i];
    ans = max(ans, dpL[i-1] + sum - (C-x[i]));
  }
  return ans;
}
int main()
{
  scanf("%d%lld", &N, &C);
  for(int i=1; i<=N; ++i)
    scanf("%lld%lld", x+i, v+i);
  x[N+1] = C; v[N+1] = 0;
  long long ans = solve();
  for(int i=1; i<=N; ++i) x[i] = C - x[i];
  reverse(x+1, x+N+1);
  reverse(v+1, v+N+1);
  ans = max(ans, solve());
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

int main(void){

	int ans[32]	= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K; cin >> K;
	cout << ans[K-1] << endl;


	return 0;

}


Measured memory_bytes: 256
import numpy as np
n = int(input())
rec = np.zeros((10, 10))

for i in range(1, n+1):
    rec[int(str(i)[0]), int(str(i)[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        t = rec[i, j] * rec[j, i]
        ans += rec[i, j] * rec[j, i]

print(int(ans))

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

int main() {
    int n, h, w;
    cin>>n>>h>>w;
    vector<pair<int, int>>window;
    bool dis[n*w];
    memset(dis, false, sizeof(dis));
    for(int i=0; i<n; i++){
        window.emplace_back((i+1-1)*w, (i+1)*w);
    }
    for(int i=0; i<n; i++){
        int slide;
        cin>>slide;
        if((i+1)%2==0){
            window[i].first-=slide;
            window[i].second-=slide;
        }else{
            window[i].first+=slide;
            window[i].second+=slide;
        }
    }
    for(int i=0; i<n; i++){
        for(int s=window[i].first; s<window[i].second; s++){
            dis[s]=true;
        }
    }
    int counter=0;
    for(int i=0; i<sizeof(dis)/sizeof(dis[0]); i++){
        if(!dis[i]) counter++;
    }
    cout<< counter*h << endl;
}



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = reader.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = reader.nextInt();
		}
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int tmp = 0;
			for (int j = 0; j <= i; j++) {
				tmp += A[j];
			}
			for (int j = i; j < N; j++) {
				tmp += B[j];
			}
			ans = Math.max(ans, tmp);
		}


		System.out.print(ans);
		reader.close();
	}
}





Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    int cnt1 = 0;
    int cnt2 = 0;
    rep(i, n) {
        if (i&1) {
            if (s[i] == '0') cnt1++;
            else cnt2++;
        } else {
            if (s[i] == '1') cnt1++;
            else cnt2++;
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

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

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;

const ll mod = 998244353;

string s;
ll K, dp[305][305][305]; // groups, moves, carry
ll N, sz[305];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s >> K;

	int gn = 1, gz = 0;
	N = s.size();
	K = min(K,N);
	reverse(s.begin(),s.end());

	for (int i = 0; i < s.size(); ++i){
		if (s[i] == '0'){
			sz[gn] = gz;
			gz = 0;
			gn++;
		}
		else gz++;
	}
	sz[gn] = gz;
	/*
	for (int i = 1; i <= gn; ++i){
		cout << sz[i] << ' ';
	}
	cout << '\n';
	*/
	dp[0][0][0] = 1;
	for (ll i = 1; i <= gn; ++i){
		for (ll k = 0; k <= K; ++k){
			for (ll c = 0; c <= k; ++c){
				for (ll l = 0; (c+l) <= k; ++l){
					dp[i][k][c] += dp[i-1][k][c+l];
					dp[i][k][c] %= mod;
				}
				for (ll l = 1; l <= min(min(sz[i],k),c); ++l){
					dp[i][k][c] += dp[i-1][k-l][c-l];
					dp[i][k][c] %= mod;
				}
				//cout << i << ' ' << k << ' ' << c << ' ' << dp[i][k][c] << '\n';
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= K; ++i){
		ans += dp[gn][i][0];
		ans %= mod;
	}
	cout << ans << '\n';
	
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int strnum(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    str s[51];
    rep(i,0,n){
        cin >> s[i];
    }
    int a,b,c,ans=INF,num=0;
    rep(i,0,n-2){
        a=0;
        //a=i;
        rep(u,0,i+1){
            rep(l,0,m){
                if(s[u][l]!='W')a++;
            }
        }
        rep(j,i+1,n-1){
            b=0;
            rep(u,i+1,j+1){
                rep(l,0,m){
                    if(s[u][l]!='B')b++;
                }
            }
            c=0;
            rep(k,j+1,n){
                rep(l,0,m){
                    if(s[k][l]!='R')c++;
                }
            }
            if(ans>(a+b+c)){
                //cout << a <<" "<< b <<" "<<c << endl;
               // cout << i <<j<<(n-j) << endl;
                ans = (a+b+c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int N = 1e2+2;
const int MAX = 1e5 + 3;

long long dp[N][MAX], w[N], c[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, W;
    cin >> n >> W;
    for (int i = 1; i <= n; ++i) {
        cin >> w[i] >> c[i];
    }        
    int ans = 0;
    for (int cost = 1; cost <= 1e5; cost++)
        for (int i = 0; i <= n; i++)
            dp[i][cost] = 1e9+5;
    for (int cost = 0; cost <= 1e5; cost++) {
        for (int i = 1; i <= n; i++) {
            dp[i][cost] = dp[i - 1][cost];
            if (cost - c[i] >= 0)
                dp[i][cost] = min(dp[i][cost], dp[i-1][cost - c[i]] + w[i]);    
        }    
        if (dp[n][cost] <= W)
            ans = cost;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
using namespace std;
int main(){
    long long a,b;
    cin >> a >> b;
    int n,m;
    n = a%4;
    m = (b+1)%4;
    long long c=0;
    for(int i=0; i<(4-n); i++){
        c = c ^ (a+i);
    }
    for(int i=0; i<m; i++){
        c = c ^ (b-i);
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
typedef struct p point;
ll MOD = (1e9)+7;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
ll dp[101010][3];
int input[101010][3];
int main(){
	fastIO();
	memset(dp,0,sizeof(dp));
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>input[i][0]>>input[i][1]>>input[i][2];
	}
	dp[0][0]=input[0][0];
	dp[0][1]=input[0][1];
	dp[0][2]=input[0][2];
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][2],dp[i-1][1])+input[i][0];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+input[i][2];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+input[i][1];
		//cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}
// - VERIFICAR LONG VS INT -


Measured memory_bytes: 3840
#include <stdio.h>
char s[9];
void sort(char *a)
{
  int i,j,t;
  for(i=0;i<8;i++){
    for(j=7;j>i;j--){
      if(a[i] > a[j]) {
	t = a[i];
	a[i] = a[j];
	a[j] = t;
      }
    }
  }
}
void rsort(char *a)
{
  int i,j,t;
  for(i=0;i<8;i++){
    for(j=7;j>i;j--){
      if(a[i] < a[j]) {
	t = a[i];
	a[i] = a[j];
	a[j] = t;
      }
    }
  }
}
int main()
{
  int n,l,h;
  scanf("%d",&n);
  while(n--){
    scanf("%s",s);
    sort(s);
    l = atol(s);
    rsort(s);
    h = atol(s);
    printf("%d\n",h-l);
  }
  return 0;
}

Measured memory_bytes: 0
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
char arr[500][500];
void Dufaux()
{
    ll n,m;
    string k="";
    cin>>n>>m;
    for(int i=0;i<m+2;i++){
        k+="#";
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    cout<<k<<endl;
    for(int i=0;i<n;i++){
        cout<<"#";
        for(int j=0;j<m;j++){
            cout<<arr[i][j];
        }
        cout<<"#"<<endl;
    }
    cout<<k<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






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

using namespace std;

const long long MOD = 1e9 + 7;



int main(void){
  long long N,K;
  long long min=0;
  long long max=0;
  long long sum=0;

  cin >> N >> K;

  for(int i=0;i<K;i++){
    min = min + i;
    max = max + N - i;
  }

  for(int i=K;i<=N;i++){
    sum = (sum + (max - min + 1))%MOD;
    min = min + i;
    max = max + N - i;
  }

  cout << sum%MOD + 1 << endl;

  return 0;
}


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

int main() {
  int n, x, t; cin >> n >> x >> t;
  int nx = n, cnt = 0;
  while(nx > 0) {
    nx -= x;
    cnt++;
  }
  cout << t * cnt << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

const int sz=256, MX=60000;
int q,t[MX],a[MX],b[MX],y[MX];
int vs[MX*2],init[MX*2],m;
int z[MX*2],mx[1000];
bool eq[1000],initialized[1000];

inline void takemax(int i,int j,int x){
	bool flag=eq[i/sz];
	while(i<j&&i%sz){
		if(eq[i/sz])rep(k,sz)z[i/sz*sz+k]=mx[i/sz];
		eq[i/sz]=0; z[i]=max(flag?mx[i/sz]:z[i],x);
		i++;
	}
	flag=eq[(j-1)/sz];
	while(i<j&&j%sz){
		if(eq[--j/sz])rep(k,sz)z[j/sz*sz+k]=mx[j/sz];
		eq[j/sz]=0; z[j]=max(flag?mx[j/sz]:z[j],x);
	}
	i/=sz; j/=sz;
	if(i&&!eq[i-1]){
		mx[i-1]=inf;
		rep(k,sz)mx[i-1]=min(mx[i-1],z[(i-1)*sz+k]);
	}
	if(!eq[j]){
		mx[j]=inf;
		rep(k,sz)mx[j]=min(mx[j],z[j*sz+k]);
	}
	while(i<j){
		if(eq[i]||mx[i]>=x)mx[i]=max(mx[i],x);
		else{
			mx[i]=inf;
			rep(k,sz)z[i*sz+k]=max(z[i*sz+k],x), mx[i]=min(mx[i],z[i*sz+k]);
		}
		i++;
	}
}
inline void set(int i,int j,int x,bool ini=0){
	bool flag=eq[i/sz];
	while(i<j&&i%sz){
		if(ini&&!initialized[i/sz]&&init[i]==-inf)init[i]=flag?mx[i/sz]:z[i];
		if(eq[i/sz])rep(k,sz)z[i/sz*sz+k]=mx[i/sz];
		eq[i/sz]=0; z[i++]=x;
	}
	flag=eq[(j-1)/sz];
	while(i<j&&j%sz){
		j--;
		if(ini&&!initialized[j/sz]&&init[j]==-inf)init[j]=flag?mx[j/sz]:z[j];
		if(eq[j/sz])rep(k,sz)z[j/sz*sz+k]=mx[j/sz];
		eq[j/sz]=0; z[j]=x;
	}
	i/=sz; j/=sz;
	if(i&&!eq[i-1]){
		mx[i-1]=inf;
		rep(k,sz)mx[i-1]=min(mx[i-1],z[(i-1)*sz+k]);
	}
	if(!eq[j]){
		mx[j]=inf;
		rep(k,sz)mx[j]=min(mx[j],z[j*sz+k]);
	}
	while(i<j){
		if(ini&&!initialized[i]){
			rep(k,sz)if(init[i*sz+k]==-inf)init[i*sz+k]=eq[i]?mx[i]:z[i*sz+k];
			initialized[i]=1;
		}
		eq[i]=1; mx[i++]=x;
	}
}
inline int get(int i,int j){
	int res=inf;
	while(i<j&&i%sz)res=min(res,eq[i/sz]?mx[i/sz]:z[i]), i++;
	while(i<j&&j%sz)res=min(res,eq[--j/sz]?mx[j/sz]:z[j]);
	i/=sz; j/=sz;
	while(i<j)res=min(res,mx[i++]);
	return res;
}

bool func(bool ck){
	rep(i,q){
		if(t[i]==0){
			if(!ck)takemax(a[i],b[i],y[i]);
 			else if(get(a[i],b[i])!=y[i]) return 0;
		}
		else set(a[i],b[i],y[i],!ck);
	}
	if(!ck)rep(i,m)if(init[i]==-inf)init[i]=eq[i/sz]?mx[i/sz]:z[i];
	return 1;
}

int main(){
	scanf("%d",&q);
	rep(i,q){
		scanf("%d%d%d%d",t+i,a+i,b+i,y+i);
		vs[2*i]=a[i]; vs[2*i+1]=++b[i];
	}
	sort(vs,vs+2*q);
	m=unique(vs,vs+2*q)-vs;
	rep(i,q){
		a[i]=lower_bound(vs,vs+m,a[i])-vs;
		b[i]=lower_bound(vs,vs+m,b[i])-vs;
	}
	
	rep(i,m)z[i]=init[i]=-inf;
	rep(i,(m+sz-1)/sz)mx[i]=-inf, eq[i]=1;
	func(0);
	rep(i,m)z[i]=init[i];
	rep(i,(m+sz-1)/sz){
		eq[i]=1; mx[i]=inf;
		rep(j,sz)if(i*sz+j<m){
			mx[i]=min(mx[i],z[i*sz+j]);
			if(z[i*sz]!=z[i*sz+j])eq[i]=0;
		}
	}
	puts(func(1)?"YES":"NO");
	
	return 0;
}

Measured memory_bytes: 2828
# 入力
N = int(input())

# N = 1 + 2 + ... + K で表せるならばYes
K = next(
    (
        k
        for k in range(1, N + 1)
        if k * (k + 1) // 2 == N
    ),
    0
)

# (1, 2, ..., K), (1, K + 1, ..., 2K - 1), (2, K + 1, 2K, ..., 3K - 3), ...
# を構築する
ans = (
    'Yes\n{}\n{}'.format(
        K + 1,
        '\n'.join(
            '{} {}'.format(
                K,
                ' '.join(
                    map(
                        str,
                        [
                            i + j * K - j * (j + 1) // 2
                            for j in range(i)
                        ] +
                        [
                            1 + j + i * (2 * K - (i - 1)) // 2
                            for j in range(K - i)
                        ]
                    )
                )
            )
            for i in range(K + 1)
        )
    ) if K else
    'No'
)

# 出力
print(ans)


Measured memory_bytes: 6484
n = int(input())
s = {}
ans = 0
for i in range(n):
    a = list(input())
    sorted_a = "".join(sorted(a))
    if sorted_a in s:
        s[sorted_a] += 1
    else:
        s[sorted_a] = 0
    ans += s[sorted_a]

print(ans)


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll N;
    cin >> N;
    vll h(N);
    rep(i, N){
        cin >> h[i];
    }
    bool p = true;
    --h[0];
    REP(i, 1, N){
        if(h[i]>h[i-1]){
            --h[i];
        }
        else if(h[i]<h[i-1]){
            p = false;
            break;
        }
    }
    if(p) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int nax =305;
double dp[nax][nax][nax];
double n;
int mp[4];
double probrec(int i, int j, int k){
  if (i==0 && j == 0 && k==0)
    return 0;
  if (i>n || j>mp[2]+mp[3] || k>mp[3])
    return 0;
  if (i<0 || j<0 || k<0)
    return 0;
  if( dp[i][j][k] != 0)
    return dp[i][j][k];

  dp[i][j][k] = (1+probrec(i-1, j, k)*(i)/n + probrec(i+1, j-1, k)*(j)/n + probrec(i, j+1, k-1)*(k)/n)/((i+j+k)/n);
  return dp[i][j][k];
}

int main()
{
    IOS
    cin >> n;
    REP(i,n)
    {
        int x;
        cin >> x;
        mp[x]++;
    }
    // cout << cnt[1] << "  "<<cnt[2] << " "<<cnt[3];
    cout << fixed << setprecision(10);
    cout << probrec(mp[1], mp[2], mp[3])<<"\n";
}

Measured memory_bytes: 219392