akhauriyash/Code-Regression huggingface dataset:
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define en "\n"
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*

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

/*void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 10000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*i ; j <= 10000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}  */



// *#########################################################################################*

int main()
{
      fast
 
    
      ll n;
      cin>>n;
      
      ll i=0;
     ll p=100;
      while(p<n)
      {
            
      ll te=p;
      ll z=te/100;
      p+=z;
      i++;
            
            
            
            
      }
      

o(i)





re}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static long[] ReadLongArray()
    {
        return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }

    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Bisect
{
    /* BisectRight(a, x) returns the index where to insert x in a sorted list a.
     *
     * The return value i is such that for all 0 < j < i, a[j] <= x and
     * for all j > i, a[j] > x.
     */
    public static int BisectRight<T>(T[] a, T x) where T : IComparable
    {
        int lo = 0, hi = a.Length;
        while (lo < hi)
        {
            int mid = (lo + hi) / 2;
            if (x.CompareTo(a[mid]) < 0) { hi = mid; }
            else { lo = mid + 1; }
        }
        return lo;
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], k = tmp[1];

        var x = ReadLongArray();
        int idx = Bisect.BisectRight(x, 0);

        long ans = 10000000000;

        for (int i = 0; i < idx; i++)
        {
            int num1 = idx - i;
            if (num1 >= k)
            {
                ans = Math.Min(ans, -x[i]);
            }
            else
            {
                int nrest = k - num1;
                int j = nrest + idx - 1;
                if (j < n)
                {
                    ans = Math.Min(ans, -x[i] * 2 + x[j]);
                }
            }
        }

        for (int i = idx; i < n; i++)
        {
            int num1 = i - idx + 1;
            if (num1 >= k)
            {
                ans = Math.Min(ans, x[i]);
            }
            else
            {
                int nrest = k - num1;
                int j = idx - nrest;
                if (j >= 0)
                {
                    ans = Math.Min(ans, x[i] * 2 - x[j]);
                }
            }
        }

        WriteLine(ans);
    }
}


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

int main() {
  int n;cin>>n;
  int x=0,maxi=0;
  string s;cin>>s;
  rep(i,n) {
    char c=s[i];
    if (c=='I') x++;
    else x--;
    maxi = max(x, maxi);
  }
  cout << maxi;
}


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

int main() {
  int group[12] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0}, x, y;
  cin >> x >> y;
  x--;
  y--;
  if (group[x] == group[y])
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555555555555555555555555555555555455555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int ts[100100], xs[100100], ys[100100];

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

    int N;
    std::cin >> N;

    for(int i=1;i<=N;++i){
        std::cin >> ts[i] >> xs[i] >> ys[i];
    }

    for(int i=0;i+1<=N;++i){
        int dist = abs(xs[i] - xs[i+1]) +  abs(ys[i] - ys[i+1]), dt = ts[i+1] - ts[i];
        if(dt >= dist && (dt - dist) % 2 == 0){

        }else{
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;
}


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

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

#define fr first
#define sc second

int main(){
	static ll n;
	static ll d[100010];
	scanf("%lld",&n);
	for(int i = 1 ; i <= n ; i ++){
		scanf("%lld",&d[i]);
	}
	
	vector<P> vec;
	for(int i = 1 ; i <= n ; i ++){
		vec.push_back(P(d[i],i));
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	
	static ll cnt[100010];
	static ll dp[100010];
	for(int i = 1 ; i <= n ; i ++){
		cnt[i] = 1;
		dp[i] = 0;
	}
	
	map<ll,ll> id;
	for(int i = 1 ; i <= n ; i ++){
		id[d[i]] = i;
	}
	
	vector<P> ans;
	for(int i = 1 ; i <= n ; i ++){
		P p = vec[i-1];
		//cout << p.fr << " " << p.sc << endl;
		if(cnt[p.sc]*2 >= n)continue;
		ll nx = d[p.sc]-(n-cnt[p.sc])+cnt[p.sc];
		if(id.find(nx) == id.end()){
			puts("-1");
			return 0;
		}
		else {
			ans.push_back(P(p.sc,id[nx]));
			cnt[id[nx]] += cnt[p.sc];
			dp[id[nx]] += dp[p.sc];
			dp[id[nx]] += cnt[p.sc];
		}
	}
	if(n%2 == 0){
		if(ans.size() != n-1){
			if(vec[n-2].fr != vec[n-1].fr){
				puts("-1");
				return 0;
			}
			ans.push_back(P(vec[n-2].sc,vec[n-1].sc));
			if(vec[n-1].fr != dp[vec[n-1].sc]+dp[vec[n-2].sc]+n/2){
				puts("-1");
				return 0;
			}
		}
		else {
			if(vec[n-1].fr != dp[vec[n-1].sc]){
				puts("-1");
				return 0;
			}
		}
	}
	else {
		if(vec[n-1].fr != dp[vec[n-1].sc]){
			puts("-1");
			return 0;
		}
	}
	
	/*for(int i = 1 ; i <= n ; i ++){
		if(dp[i] != d[i]){
			puts("-1");
			return 0;
		}
	}*/
	
	if(ans.size() < n-1){
		puts("-1");
		return 0;
	}
	for(int i = 0 ; i < ans.size() ; i ++){
		printf("%d %d\n",ans[i].fr,ans[i].sc);
	}
}


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

int main() {
  
  int a;
  int b;
  
  cin >> a >> b;
  
  if ( ( a * b ) % 2 == 0 ) {
    
    cout << "Even" << endl;
  }
  
  else {
    
    cout << "Odd" << endl;
  }

}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
  int n,i=0;
  bool flag=0;
  char s;
  cin>>n;
  while(i<n){
    cin>>s;
    if(s=='Y'){
      flag=1;
      break;
    }
    i++;
  }
  if(flag)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String,Integer>map=new TreeMap<>();
		String s=sc.next();
		int n=sc.nextInt();
		map.put(s, 0);
		for(int m=1;m<=n;m++) {
			for(int i=0;i+m<s.length()+1;i++) {
				map.put(s.substring(i,i+m),0);
			}
		}
		int count=0;
		for(String key:map.keySet()) {
				count++;
				if(count==n) {
					System.out.println(key);
				break;
				}
			}
		}
	}


Measured memory_bytes: 25596
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;

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


stack<pair<int,int>> s;

void dfs(int pos, vector<vector<int>>& G, vector<int>& a, vector<int>& dp, vector<int>& ans, vector<bool>& is_visited){
    is_visited[pos] = true;
    int insert_pos = distance(dp.begin(), lower_bound(dp.begin(), dp.end(), a[pos]));
    int old = dp[insert_pos];
    dp[insert_pos] = a[pos];
    ans[pos] = distance(dp.begin(), lower_bound(dp.begin(), dp.end(), 1e+9));
    for(auto e: G[pos]){
        if(is_visited[e]) continue;
        dfs(e, G, a, dp, ans, is_visited);
    }
    dp[insert_pos] = old;
}


int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    vector<vector<int>> G(N);
    REP(i, N-1){
        int u, v;
        cin >> u >> v;
        --u, --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<int> ans(N), dp(N, 1e+9);
    vector<bool> is_visited(N, false);
    dfs(0, G, a, dp, ans, is_visited);
    REP(i, N) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 33796
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)

Measured memory_bytes: 311760
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    double p = 0;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        p += 1.0 / a[i];
    }
    printf("%.10f\n", 1 / p);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    string s;
    cin>>s;
    if(s.size() == 2 ) {
        if(s[0] == s[1]) {
            cout<<1<<' '<<2;
            return ;
        }
    }
    for(int i = 2; i < s.size(); i ++) {
        if(s[i] == s[i - 2] or s[i] == s[i - 1] or s[i - 1] == s[i - 2]) {
            cout<<i - 1<<' '<<i + 1;
            return ;
        }
    }
    cout<<-1<<' '<<-1;
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=12;
int k[N],p[N],on[N];
vector<int>a[N];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d",&k[i]);
		a[i].resize(k[i]);
		for(int j=0;j<k[i];j++)
		{
			scanf("%d",&a[i][j]);
			a[i][j]--;
		}
	}
	for(int i=0;i<m;i++)
		scanf("%d",&p[i]);
	int ans=0;
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
				on[j]=1;
			else
				on[j]=0;
		}
		int flag=1;
		for(int j=0;j<m;j++)
		{
			int sum=0;
			for(int s=0;s<k[j];s++)
				sum+=on[a[j][s]];
			if(sum%2!=p[j])
				flag=0;
		}
		ans+=flag;
	}
	printf("%d\n",ans);
	return 0;
}


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

int mod = 998244353;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> L(K), R(K);
    rep(i, K) {
        cin >> L[i] >> R[i];
        ++R[i];
    }

    vector<ll> sum(N + 5, 0);
    sum[1] = 1;
    sum[2] = -1;
    for (int i = 1; i <= N; ++i) {
        sum[i] = (sum[i] + sum[i - 1]) % mod;
        if (sum[i] < 0) sum[i] += mod;

        rep(j, K) {
            if (i + L[j] <= N + 1)
                sum[i + L[j]] = (sum[i + L[j]] + sum[i]) % mod;
            if (i + R[j] <= N + 1)
                sum[i + R[j]] = (sum[i + R[j]] - sum[i]) % mod;
        }
    }

    cout << sum[N] << endl;
}

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int min = kb.nextInt();
		int count = 1;
		for (int i = 0; i < n - 1; i++) {
			int j = kb.nextInt();
			int b = j;
			if (b > min) {
			} else {
				count += 1;
				min = b;
			}
		}
		System.out.println(count);
		kb.close();
	}

}


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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
ll d[N];
ll p[N];
ll f[N];

int main () {               
    cin >> n >> k;
    for (int i = 1; i <= n; i ++) {
    	cin >> p[i];
    	p[i] += p[i - 1];
    }
    d[0] = 0;
    f[n + 1] = 0;
    ll ans = 0;

    for (int i = 1; i <= n; i ++) {
    	d[i] = max(d[i - 1], d[i - 1] - p[i - 1] + p[i]);
    }
    for (int i = n; i >= 1; i --) {
    	f[i] = max(f[i + 1], f[i + 1] - p[i - 1] + p[i]);
    }

    for (int i = 1; i + k - 1 <= n; i ++) {
    	ans = max(ans, max(0ll, p[i + k - 1] - p[i - 1]) + d[i - 1] + f[i + k]);
    }
    ans = max(ans, p[n]);
    
    cout << ans;
    return Accepted;
}

// Coded By OB

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,K;
int A[20000];

int dp[20001];

signed main(){
    cin>>N>>M>>K;
    rep(i,N)cin>>A[i];

    for(int i=1;i<=N;i++){
        int mi=1001001001,ma=0;
        dp[i]=1001001001001001001ll;
        for(int j=1;j<=M&&i-j>=0;j++){
            chmax(ma,A[i-j]);
            chmin(mi,A[i-j]);
            chmin(dp[i],dp[i-j]+K+j*(ma-mi));
        }
    }

    cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 3380
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]


int main(){
  ll n, m;
  ll s, i;
  ll t, u;
  
  scanf("%lld%lld", &n, &m);

  if(n % 2 == 1){
    for (i = 1; i <= m; i++)
    {
        printf("%lld %lld\n", i, n + 1 - i);
    }
  }
  else
  {
      s = n/2;
      t = s+1;
      u = n-1;
    for (i = 1; (s-i)>=1 && i <= m ; i++)
    {
        printf("%lld %lld\n", i, s);
        s-=1;
    }
    for (; i <= m; i++)
    {
        printf("%lld %lld\n", u, t);
        u--;t++;
    }
    
  }
  
  
  return 0;
}

Measured memory_bytes: 1732
data = int(input())

cnt = 0
for lop in range(1,data+1,2):
    buf = lop
    cnt2 = 0
    for lop2 in range(1,lop+1):
        if buf%lop2 == 0:
            cnt2 = cnt2 +1
        elif buf == 1:
            break
    if cnt2 == 8:
        cnt = cnt + 1
            
print(cnt)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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 n; cin >> n;
    vector<int> a(n);
    int m = 0;
    REP(i,n) {
        cin >> a[i];
        chmax(m,a[i]);
    }
    sort(ALL(a));
    pair<int,int> ans = {0,0};
    ans.first = m;
    int diff = INT_MAX;
    REP(i,n-1) {
        int tmp = abs(2*a[i] - m);
        if(diff>tmp) {
            diff = tmp;
            ans.second = a[i];
        }
    }
    cout << ans.first << ' ' << ans.second << endl;
    return 0;
}


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

int main()
{
    long long N, K, sum = 0;
    cin >> N >> K;
    vector<long long> h(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> h.at(i);
        
    }
    sort(h.begin(), h.end());
    /*for (int i = 0; i < N;i++){
        cout << h.at(i) << endl;
    }*/
    if(K>=N){
        cout << 0 << endl;
        return 0;
    }
    for (long long i = 0; i < N - K;i++){
        sum += h.at(i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<vector<int>> v(3,vector<int>(3,0));
    vector<vector<int>> c(3,vector<int>(3,0));
    REP(i,3)REP(j,3) {
        cin >> v[i][j];
    }
    int N; cin >> N;
    REP(i,N) {
        int b;
        cin >> b;
        REP(j,3) REP(k,3) {
            if(v[j][k] == b) c[j][k] = 1;
        }
    }
    bool flg = false;
    REP(i,3) {
        bool tmp = true;
        REP(j,3) if(c[i][j] == 0) tmp = false;
        if(tmp) flg = true;
    }
    REP(j,3) {
        bool tmp = true;
        REP(i,3) if(c[i][j] == 0) tmp = false;
        if(tmp) flg = true;
    }
    bool tmp1 = true;
    REP(i,3) {
        if(c[i][i] == 0) tmp1 = false;
    }
    if(tmp1) flg = true;
    tmp1 = true;
    REP(i,3) {
        if(c[i][2-i] == 0) tmp1 = false;
    }
    if(tmp1) flg = true;
    cout << (flg ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
map$
$`{$1}=$$1{$`}=$'*<>=~/ (.*) /,2..<>;@s=<>=~$"*$';map$d[$_]//=$d[$u]+$$u{$s[@s]=$_},keys%{$u=$_}for@s;//,print$d[$`]+$d[$'],$/for<>

Measured memory_bytes: 112512
# ARC090C - Candies (ABC087C)
def main():
    n = int(input())
    arr = [list(map(int, input().rstrip().split())) for _ in range(2)]
    ans = 0
    for i in range(n):
        ans = max(ans, sum(arr[0][: i + 1]) + sum(arr[1][i:]))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    scanf("%d", &N);
    int SUM[N];
    int TAK, AOK;
    long long answer=0, sumAOK=0;
    int i;

    
    for(i=0; i<N; i++){
        scanf("%d %d", &TAK, &AOK);
        SUM[i] = TAK + AOK;
        sumAOK += AOK;
    }
    sort(SUM, SUM+N, greater<int>());
    for(i=0; i<N; i++){
        if(i%2==0){
            answer += SUM[i];
        }
    }
    answer -= sumAOK;
    printf("%lld", answer);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int n, k;
    scanf("%d%d", &n, &k);

    vector<pair<int,int> > z;
    int i;
    for(i=0; i<n; i++) {
        int t,d;
        scanf("%d%d", &t, &d);
        z.push_back(make_pair(d,t));
    }
    sort(z.rbegin(),z.rend());

    set<int> kind;
    vector<int> rm;
    ll val=0;
    for(i=0; i<k; i++) {
        val += z[i].first;
        if(!kind.insert(z[i].second).second) {
            rm.push_back(z[i].first);
        }
    }
    reverse(rm.begin(), rm.end());

    int siz=(int)kind.size();
    ll ans = val + (ll)siz*siz;
    
    int cnt=0;
    if(!rm.empty()) {
        for(i=k; i<n; i++) {
            if(kind.insert(z[i].second).second) {
                val = val + z[i].first - rm[cnt];
                siz=(int)kind.size();
                ans = MAX(ans, val+(ll)siz*siz);
                cnt++;
                if(cnt==(int)rm.size()) {
                    break;
                }
            }
        }
    }
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll c;
    cin >> n >> c;
    vector<ll> x(n + 1, 0);
    vector<ll> v(n + 1, 0);
    ll vallsum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> v[i];
        vallsum += v[i];
    }

    ll vrsum = 0, vlsum = 0, dpr = 0, ans = 0;
    vector<ll> dpl(n + 1, 0);
    for (int i = n - 1; i >= 1; i--) {
        vlsum += v[i + 1];
        dpl[i] = max(dpl[i + 1], vlsum - (c - x[i + 1]) * 2);
    }

    for (int i = 1; i <= n; i++) {
        vlsum = vallsum - vrsum;
        vrsum += v[i];

        ans = max({ans, vrsum - x[i] + dpl[i], vlsum - (c - x[i]) + dpr});
        dpr = max(dpr, vrsum - x[i] * 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
n = int(input())
d = {}
for i in range(n):
    x = input()
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

max_count = max(d.values())
ans = [s for s, count in d.items() if count == max_count]

for s in sorted(ans):
    print(s)


Measured memory_bytes: 33112
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>

using namespace std;


int n, x;
int l[100];
int ans=1;

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

  for(int i=0;i<n;i++) {
    cin >> l[i];
  }

  int d=0;

  for(int i=0;i<n;i++){
    d += l[i];
    if (d <= x) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<bool> flag(N + 1, true);
    vector<ll> dp(N + 1, 0);
    for (int i = 0; i < M; i++)
    {
        int index;
        cin >> index;
        flag[index] = false;
    }
    dp[0] = 1;
    if (flag[1])
    {
        dp[1] = dp[0];
    }
    else
    {
        dp[1] = 0;
    }
    for (int i = 2; i <= N; i++)
    {
        if (flag[i])
        {
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
        }
        else
        {
            dp[i] = 0;
        }
    }
    cout << dp[N] % 1000000007 << endl;

    return 0;
}

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

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

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  int N,a;
  int four=0,two=0;
  
  cin >> N;

  REPI(N)
  {
    cin >> a;
    if (a % 4 == 0)
      four++;
    else if (a % 2 == 0)
      two++;
  }

  if (four*2+ 1 >= N || four*2 + two >= N)
    cout << "Yes" << endl;    
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3540
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

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

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int main(){
  int A,B,C;cin>>A>>B>>C;
  int M=max({A,B,C});
  int res=3*M-A-B-C;
  if(res&1) res+=3;
  res/=2;
  cout<<res<<endl;
  return 0;
}





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

char c[50][50];
int R,C,M;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

vector< pair<int,int> > bfs(int x1,int y1,int x2,int y2){
	queue< pair<int,int> > Q;
	pair<int,int> prev[50][50];
	for(int i = 0 ; i < 50 ; i++)
		for(int j = 0 ; j < 50 ; j++)
			prev[i][j] = {-1,-1};
	prev[y1][x1] = {x1,y1};
	Q.push({x1,y1});
	while( Q.size() ){
		auto q = Q.front(); Q.pop();
		for(int i = 0 ; i < 4 ; i++){
			int tx = q.first + dx[i];
			int ty = q.second + dy[i];
		
			if( tx >= 0 && tx < C && ty >= 0 && ty < R && c[ty][tx] != '#' && prev[ty][tx] == make_pair(-1,-1) ){
				prev[ty][tx] = q; 
				Q.push({tx,ty});
			}
		}
	}
	
	vector< pair<int,int> > route;
	pair<int,int> now = {x2,y2};
	while( prev[now.second][now.first] != now ){
		route.push_back(now);
		now = prev[now.second][now.first];
	}
//	cout << "(" << x1 << " " << y1 << ")-(" << x2 << " " << y2 << ")" << route.size() << endl;
	reverse(route.begin(),route.end());
	return route;
}

int cost[3][51][51];

vector<int> timing[51][51];

int main(){
	cin >> R >> C >> M;
	for(int i = 0 ; i < R ; i++){
		for(int j = 0 ; j < C ; j++){
			cin >> c[i][j];
		}
	}
	for(int k = 0 ; k < 3 ; k++){
		for(int i = 0 ; i < R ; i++){
			for(int j = 0 ; j < C ; j++){
				cin >> cost[k][i][j];
			}
		}
	}
	int px,py;
	vector< pair<int,int> > all;
	for(int i = 0 ; i < M ; i++){
		int y,x;
		cin >> y >> x;
		if(i){
			auto v = bfs(px,py,x,y);
			all.insert(all.end(),v.begin(),v.end());
		}else{
			all.push_back({x,y});
		}
		px = x;
		py = y;
	}
	for(int i = 0 ; i < all.size() ; i++){
		timing[all[i].second][all[i].first].push_back(i);
	}
	long long sum = 0;
	for(int i = 0 ; i < R ; i++){
		for(int j = 0 ; j < C ; j++){
			int sw = 0;
			int ans = 0;
			for(int k = 0 ; k < timing[i][j].size() ; k++){
				if( sw == 0 ){
					ans += cost[1][i][j]; // on
					sw ^= 1;
				}
				if(k+1 < timing[i][j].size() ){
					int l = timing[i][j][k+1] - timing[i][j][k];
					int always = l * cost[0][i][j];
					if( cost[2][i][j]+cost[1][i][j] < always ){
						ans += cost[2][i][j];
						sw ^= 1;
					}else{
						ans += always;
					}
				}else{
					ans += cost[2][i][j];
					sw ^= 1;
				}
			}
			sum += ans;
		}
	}
	cout << sum << endl;
	
}

Measured memory_bytes: 16420
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <math.h>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;

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

	int n,x;
	vector<int> a;
	cin>>n;
	rep(i,0,n){
		cin>>x;
		a.PB(x);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());

	int sum=0;
	rep(i,0,n){
		if(i%2)sum-=a[i];
		else sum+=a[i];
	}
	cout << sum<<endl;

	
	return 0;
}


Measured memory_bytes: 256
M=1000003
o=->a,n{n<1?1:(n%2>0?a:1)*o[a,n/2]**2%M}
f=f=1,*(1..M).map{|i|f=f*i%M}
gets
$<.map{|s|x,d,n=s.split.map &:to_i
p d<1?o[x,n]:M-n<(t=x*o[d,M-2]%M)?0:f[t+n-1]*o[f[t-1],M-2]*o[d,n]%M}

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

int main(){
    int N;  cin >> N;
    map<int, int> mp;
    for(int i=0; i<N; i++){
        int a;  cin >> a;
        mp[a]++;
        if(mp[a] != 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N; scanf("%d", &N);
    set<long long> S;
    vector<long long> v;
    for(int i=0; i<N; i++) {
        long long A; scanf("%lld", &A);
        if(S.count(A)) {
            v.push_back(A);
            S.erase(A);
        }
        else {
            S.insert(A);
        }
    }
    
    if(v.size() < 2) {
        printf("0\n");
    }
    else {
        sort(v.rbegin(), v.rend());
        long long ans = v[0] * v[1];
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4864
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

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

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int main(){
  ll n, sum = 0, cnt = 1;
  fastScan(n);
  while(n >= 1){
    n /= 2;
    sum += cnt;
    cnt *= 2ll;
  }
  printf("%lld\n", sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <pll> v;
ll dp[102][100005];

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m=0,j,k,x,y,a,b,w;
	string s;
	
	cin >> n >> w;
	v.pb(mp(0,0));
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		v.pb(mp(x,y));
	}
	for(i=1;i<=n;i++)
		for(j=0;j<=w;j++)
		{
			if(j<v[i].first)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],v[i].second+dp[i-1][j-v[i].first]);
		}
	for(i=0;i<=w;i++)
		m=max(m,dp[n][i]);
	cout << m;
	return 0;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define RELEASE

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define ALL(v) v.begin(), v.end()

int main(){
    int X;
    cin>>X;
    if(X==2){
        cout<<2;
        return 0;
    }
    std::vector<int> p={2};
    int num=2;
    while(true){
        bool pf=1;
        REP(i,p.size()){
            if(num%p[i-1]==0)pf=0;
        }
        if(pf){
            p.push_back(num);
            if(num>=X)break;
        }
            
        
        num++;
    }
    
    cout<<num;
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

//check modulo
int main(){
	IOS;
	cout.precision(30) ;
	string s ; cin >> s;
	int n = s.size() ;
	string l ="",r="";for(int i = 0 ; i < n ; i++){l += "L" ; r +="R" ;}
	if(s == l || s == r){
		for(int i = 0 ; i < n ; i++) cout << 1 << " " ;
		cout << endl ;
		return 0 ;
	}
	vector<int> c1(n) ;
	vector<int> c2(n) ;
	int lastL = n - 1 , lastR = 0 ;
	
	for(int i = n - 1 ; i >= 0 ; i--){
		if(s[i] == 'R') c1[i] = lastL ;
		else lastL = i ;
		//cout << lastL << " " << c1[i] << endl ;
	}
	for(int i = 0  ; i < n ; i++){
		if(s[i] == 'L') c2[i] = lastR ;
		else lastR = i ;
	}
	vi ans(n , 0) ;
	for(int i = 0 ; i < n ; i++){
		if(s[i] == 'R'){
			if((c1[i] - i) % 2 == 0) ans[c1[i]]++ ;
			else ans[c1[i] - 1]++ ;
		}
		else{
			if((c2[i] - i) % 2 == 0) ans[c2[i]]++ ;
			else ans[c2[i] + 1]++ ;
		}
	}
	for(int i = 0 ; i < n ; i++) cout << ans[i] << " " ;
	cout << endl ;
	return 0;
}


Measured memory_bytes: 2000
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int q = sc.nextInt();

    int p[] = new int[n];
    for (int i = 0; i < q; i++) {
      int ans = sc.nextInt();
      p[ans - 1] = p[ans - 1] + 1;
    }

    for (int i = 0; i < n; i++) {
      if ((p[i] + k - q) > 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}


Measured memory_bytes: 57016
A, B, C, K = map(int,input().split())
a = 0
if K == A:
    print(A)
elif K < A:
    print(K)
else:
    a += A
    K -= A
    if K > B:
        K -= B
        if K > C or K == C:
            a -= C
            print(a)
        else:
            a -= K
            print(a)
    else:
        print(a)

Measured memory_bytes: 9200
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <iterator>      // std::next prev
#include <utility>      // std::pair, std::make_pair

using namespace std;

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

	int a,b;
	cin>>a>>b;
	int sn = b+2;
	for(int i = 0 ; i < sn ; i++)
	{
		cout<<'#';
	}
	cout<<'\n';
	
	for(int i = 0 ; i < a ; i++)
	{
		cout<<'#';
		for(int j = 0 ; j < b ; j++)
		{
			char t;
			cin>>t;
			cout<<t;
		}
		cout<<"#\n";
	}
	
	for(int i = 0 ; i < sn ; i++)
	{
		cout<<'#';
	}
	cout<<'\n';
	
	return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

  constexpr auto M = 1000000007L;
  bitset<64> bs(n);
  int64_t dp[64][3][2][2] = {};
  dp[63][0][0][0] = 1;
  for (auto i : irange(0L, 63L) | reversed) {
    if (bs[i]) {
      dp[i][0][1][1] = dp[i + 1][0][0][0] + dp[i + 1][0][1][1];

      dp[i][1][0][1] = dp[i + 1][0][0][0] + dp[i + 1][0][1][1] +
                       dp[i + 1][1][0][0] + dp[i + 1][1][0][1] +
                       dp[i + 1][1][1][0] + dp[i + 1][1][1][1];
      dp[i][1][1][1] = dp[i + 1][1][0][0] + dp[i + 1][1][1][1];

      dp[i][2][0][0] = dp[i + 1][0][0][0] + dp[i + 1][0][1][1] +
                       dp[i + 1][1][0][0] + dp[i + 1][1][0][1] +
                       dp[i + 1][1][1][0] + dp[i + 1][1][1][1] +
                       dp[i + 1][2][0][0] + dp[i + 1][2][0][1] +
                       dp[i + 1][2][1][0] + dp[i + 1][2][1][1];
      dp[i][2][0][1] = dp[i + 1][2][0][0] + dp[i + 1][2][0][1] +
                       dp[i + 1][2][1][0] + dp[i + 1][2][1][1];
      dp[i][2][1][0] = dp[i + 1][1][0][1] + dp[i + 1][1][1][0] +
                       dp[i + 1][2][0][1] + dp[i + 1][2][1][0];
      dp[i][2][1][1] = dp[i + 1][2][0][0] + dp[i + 1][2][1][1];
    } else {
      dp[i][0][0][0] = dp[i + 1][0][0][0] + dp[i + 1][0][1][1];

      dp[i][1][0][0] = dp[i + 1][1][0][0] + dp[i + 1][1][0][1] +
                       dp[i + 1][1][1][0] + dp[i + 1][1][1][1];
      dp[i][1][1][0] = dp[i + 1][1][0][1] + dp[i + 1][1][1][0];

      dp[i][2][0][0] = dp[i + 1][2][0][0] + dp[i + 1][2][0][1] +
                       dp[i + 1][2][1][0] + dp[i + 1][2][1][1];
      dp[i][2][0][1] = dp[i + 1][2][0][0] + dp[i + 1][2][0][1] +
                       dp[i + 1][2][1][0] + dp[i + 1][2][1][1];
      dp[i][2][1][0] = dp[i + 1][2][0][1] + dp[i + 1][2][1][0];
      dp[i][2][1][1] = dp[i + 1][2][0][0] + dp[i + 1][2][1][1];
    }

    for (auto j : irange(0L, 3L)) {
      for (auto k : irange(0L, 2L)) {
        for (auto l : irange(0L, 2L)) {
          dp[i][j][k][l] %= M;
        }
      }
    }
  }

  cout << (dp[0][0][0][0] + dp[0][0][1][1] + dp[0][1][0][0] + dp[0][1][1][1] +
           dp[0][2][0][0] + dp[0][2][1][1]) %
              M
       << endl;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

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

    int N;
    std::cin >> N;
    map<string, int> S;
    REP(i, N) {
        string s;
        std::cin >> s;
        auto itr = S.find(s);
        if(itr != S.end()) {
            itr->second++;
        }
        else {
            S.insert(make_pair(s, 1));
        }
    }

    int M;
    std::cin >> M;
    map<string, int> T;
    REP(i, M) {
        string t;
        std::cin >> t;
        auto itr = T.find(t);
        if(itr != T.end()) {
            itr->second++;
        }
        else {
            T.insert(make_pair(t, 1));
        }
    }

    auto ans = 0;
    for(const auto& s : S) {
        auto itr = T.find(s.first);
        if(itr != T.end()) {
            ans = max(ans, s.second - itr->second);
        }
        else {
            ans = max(ans, s.second);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
  
int main() {
  int n,m;
  while(cin >> n && n) {
    int h[n];
    for(int i=0; i<n; i++) cin >> h[i];
    cin >> m;
    vector<P> a,b;
    string name,t;
    for(int i=0; i<m; i++) {
      P c;
      cin >> name >> c.first >> t >> c.second;
      if(t=="All") a.push_back(c);
      else b.push_back(c);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int da[100001],db[100001];
    fill(da,da+100001,1<<29);
    fill(db,db+100001,1<<29);
    da[0]=db[0]=0;
    for(int i=0; i<a.size(); i++) {
      for(int j=0; j<100001; j++) da[min(100000,j+a[i].second)]=min(da[min(100000,j+a[i].second)],da[j]+a[i].first);
    }
    for(int i=0; i<b.size(); i++) {
      for(int j=0; j<100001; j++) db[min(100000,j+b[i].second)]=min(db[min(100000,j+b[i].second)],db[j]+b[i].first);
    }
    for(int i=99999; i>=0; i--) {
      da[i]=min(da[i],da[i+1]);
      db[i]=min(db[i],db[i+1]);
    }
    int ans=1<<29;
    for(int i=0; i<=100000; i++) {
      int d=da[i];
      if(d==1<<29) continue;
      bool f=1;
      for(int j=0; j<n; j++) {
        int x=max(0,h[j]-i);
    if(db[x]>=1<<29) f=0;
        d+=db[x];
      }
      if(f) ans=min(ans,d);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2000
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	_, m := nextInt(), nextInt()
	ac := make(map[int]bool)
	pn := make(map[int]int)
	ps := 0
	for i := 0; i < m; i++ {
		p, s := nextInt(), nextString()
		if !ac[p] && s == "AC" {
			ac[p] = true
			ps += pn[p]
		} else if !ac[p] && s == "WA" {
			pn[p]++
		}
	}
	fmt.Printf("%d %d\n", len(ac), ps)
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

std::vector<ll> Eratosthenes( const ll N )
{
    std::vector<ll> P(N+1,2);
    P[1] = 1;
    for( ll i = 2; i <= N; i++ ){
      for( ll j = 2; i*j <= N; j++){
        P[i*j]++;
      }
    }
    return P;
}
int main(){
  int N; cin >> N;
  ll retval = 0;
  auto v= Eratosthenes(N);
  rep(i,N+1) {
    if (i==0) continue;
    retval += i*v[i];
  }
  cout << retval << endl;
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 81384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

ll cul_f(ll b, ll n)
{
    if (n < b)
        return n;
    return cul_f(b, n / b) + n % b;
}

int main()
{
    ll n, s;
    cin >> n >> s;

    if (n == s)
    {
        cout << n + 1 << endl;
        return 0;
    }

    for (ll i = 2; i * i <= n; ++i)
    {
        if (s == cul_f(i, n))
        {
            cout << i << endl;
            return 0;
        }
    }

    for (ll i = ll(sqrt(n)); i >= 1; --i)
    {

        ll b = (n - s) / i + 1;
        if (b >= 2 && cul_f(b, n) == s)
        {
            cout << b << endl;
            return 0;
        }
    }

    // repx(i, 1, sqrt(n))
    // {
    //     if ((n - s) % i != 0)
    //         continue;
    //     ll b = ll((n - s) / i) + 1;
    //     if (s == cul_f(b, n))
    //     {
    //         cout << b << endl;
    //         return 0;
    //     }
    // }

    cout << "-1" << endl;
    return 0;
}


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

int main(int argc, char const *argv[])
{
	string s,t;
	cin>>s>>t;
	int memo[30],f=1;
	for (int i = 0; i < 30; ++i)
	{
		memo[i]=-1;
	}
	for (int i = 0; i < s.size(); ++i)
	{
		if (memo[s[i]-'a']==-1)
		{
			memo[s[i]-'a']=t[i]-'a';
		}
		else if (memo[s[i]-'a']!=t[i]-'a')
		{
			f=0;
			break;
		}
	}
	for (int i = 0; i < 30; ++i)
	{
		for (int j = i+1; j < 30; ++j)
		{
			if (memo[i]>=0&&memo[j]>=0&&memo[i]==memo[j])
			{
				f=0;
			}
		}
	}
	if (f)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 776