akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class TaskD {
public:
    void solve(istream& in, ostream& out) {
        long long N, A, B;
        in >> N >> A >> B;
        vector<int> h(N);
        for (int i = 0; i < N; ++i) {
            in >> h[i];
        }
    
        long long low = 1, high = 1000 * 1000 * 1000, ans = high;
        while (low <= high) {
            long long mid = (low + high) / 2;
            long long cur = 0;
            for (int i = 0; i < N; ++i) {
                long long rem = h[i] - mid * B;
                if (rem > 0) {
                    cur += (rem + (A - B) - 1) / (A - B);
                }
            }
            if (cur > mid) {
                low = mid + 1;
            } else {
                high = mid - 1;
                ans = mid;
            }
        }
        out << ans << "\n";
    }
};


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

	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 55;
const int MCNT = 125005;
const int INF = 1e9 + 10;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
long long limit, sum[MAXN];
long long dp[MAXN][MCNT];
int n, d, fa[MAXN], size[MAXN], pos[MAXN];
bool cmp(int x, int y) {
	return sum[x] * size[y] < sum[y] * size[x];
}
int main() {
	read(n), read(limit), read(d);
	for (int i = 1; i <= n; i++) {
		read(sum[i]);
		if (i != 1) read(fa[i]);
	}
	int cnt = 0;
	for (int i = n; i >= 1; i--) {
		sum[fa[i]] += sum[i];
		size[fa[i]] += ++size[i];
		cnt += size[i] * n;
		pos[i] = i;
	}
	sort(pos + 1, pos + n + 1, cmp);
	for (int i = 1; i <= cnt; i++)
		dp[0][i] = INF;
	int tmp = min(n, d);
	for (int i = 1; i <= n; i++) {
		memcpy(dp[i], dp[i - 1], sizeof(dp[i]));
		for (int j = 0; j <= cnt; j++)
		for (int k = 1; k <= tmp && j - k * size[i] >= 0; k++)
			chkmin(dp[i][j], dp[i - 1][j - k * size[i]] + k * sum[i]);
	}
	int ans = 0;
	for (int i = 0; i <= cnt; i++) {
		if (dp[n][i] > limit) continue;
		int tans = i, lft = limit - dp[n][i];
		for (int j = 1; j <= n; j++) {
			int tmp = pos[j], used = min(1ll * max(d - n, 0), lft / sum[tmp]);
			if (tmp == 1) used = lft / sum[tmp];
			lft -= sum[tmp] * used;
			tans += size[tmp] * used;
		}
		chkmax(ans, tans);
	}
	writeln(ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N, X, T; cin >> N >> X >> T;
	int ans = (N + X - 1) / X * T;
	cout << ans << endl; 
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

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

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    if (A == B && B != C) {
      cout << "Yes" << endl;
    } else if(B == C && C != A) {
      cout << "Yes" << endl;
    } else if (C == A && A != B) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

const int MAXN = 100001;

using namespace std;

int n;
int a[MAXN], b[MAXN];

void calcm(int a[], int *m1, int *m2, int *v1, int *v2) {
	*m1 = 0;
	*m2 = 0;
	for(int i = 0; i < MAXN; i++) {
		if(a[i] > *m1) {
			*m2 = *m1;
			*v2 = *v1;
			*m1 = a[i];
			*v1 = i;
		} else {
			if(a[i] > *m2) {
				*m2 = a[i];
				*v2 = i;
			}
		}
	}
}

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

	for(int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if(i & 1) {
			a[x]++;
		} else {
			b[x]++;
		}
	}
	int max3, max4, v3, v4;
	int max1, max2, v1, v2;

	calcm(a, &max1, &max2, &v1, &v2);
	calcm(b, &max3, &max4, &v3, &v4);

	if(v1 != v3) {
		printf("%d\n", n - max1 - max3);
	} else {
		printf("%d\n", min(n - max1 - max4, n - max2 - max3));
	}

	return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define R(i,n) for(int i = 0; i < (n); i++)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class T> ostream &operator<<(ostream& os, set<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int m;
const int MAX = 311;
void add(int &a,int b){
  a += b;
  if(a >= m)
    a-=m;
}
int dwu[MAX][MAX];
bool cz[MAX][MAX];
int dp[MAX][MAX];
int licz2(int k,int n);
int licz(int k,int n){
  if(n == 1){
    return 1;
  }
  if(k == 0){
    return 0;
  }
  int &res = dp[k][n];
  if(cz[k][n])return res;
  cz[k][n] = 1;
  R(i,n)if(i){
    debug(n-2,i-1);
    debug(licz2(k, i), licz(k, n - i), dwu[n-2][i-1]);
    add(res, licz2(k, i) * licz(k, n - i) % m * dwu[n-2][i-1] % m);
  }
  debug(k,n,res);
  return res;
}

bool cz2[MAX][MAX];
int dp2[MAX][MAX];
int licz2(int k,int n){
  int &res = dp2[k][n];
  if(cz2[k][n])return res;
  cz2[k][n] = 1;
  R(i,k){
    add(res,licz(i, n));
  }
  debug("2",k,n,res);
  return res;  
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n,k;
  cin >> n >> k >> m;
  R(i,MAX)R(j,i+1){
    if(j == 0){
      dwu[i][j] = 1;
    }else{
      dwu[i][j] = dwu[i-1][j];
      add(dwu[i][j], dwu[i-1][j-1]);
    }
  }
  cout << licz(k,n+1) << endl;/*
  vector<int> dp(n);
  dp[0] = 1;
  for(int i = 1; i <= k; i++){
    vector<int> dp2(n);
    vector<int> ak(n);
    dp[0] = 1;
    R(k,n+1){
      R(ii,n){
        add(dp2[ii],ak[ii]);
      }
      vector<int> pom(n);
      R(j,n){
        add(pom[j])
      }
    }
  }*/
}




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

int main() {
  string S;
  cin >> S;
  if(S=="SUN") cout << '7' << endl;
  else if(S=="MON") cout << '6' << endl;
  else if(S=="TUE") cout << '5' << endl;
  else if(S=="WED") cout << '4' << endl;
  else if(S=="THU") cout << '3' << endl;
  else if(S=="FRI") cout << '2' << endl;
  else if(S=="SAT") cout << '1' << endl;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
ans=0
1.upto(N) do|a|
    ans+=(N-1)/a
end
puts ans

Measured memory_bytes: 14308
n, m = [int(x) for x in input().split(' ')]
conditions = []


for i in range(m):
    s, c = [int(x) for x in input().split(' ')]
    conditions.append([s,c])

def solve(n, m, conditions):
    start = 10**(n-1)
    end = 10**n
    if start == 1:
        start = 0

    for i in range(start, end, 1):
        current = str(i)
        valid = True
        for j in range(m):
            condition = conditions[j]
            if current[condition[0] - 1] != str(condition[1]):
                valid = False
        
        if valid == True:
            print(current)
            return
    
    print(-1)

solve(n, m, conditions)



Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int fun(int [],int ,int );
int cmp(const void *,const void *);
int cmp(const void *a,const void *b)
{
    return *(int *)b-*(int *)a;
}
int fun(int a[],int n,int k)
{
    int i,sum=0;
    qsort(a,n,sizeof(a[i]),cmp);
    for(i=0;i<k;i++)
    {
        sum=sum+a[i];
    }
    return sum;
}
int main()
{
    int a[50];
    int n,k,i;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    printf("%d\n",fun(a,n,k));
    return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() 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 main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	var V, C []int
	for i := 0; i < N; i++ {
		V = append(V, nextInt())
	}
	for i := 0; i < N; i++ {
		C = append(C, nextInt())
	}

	res := 0
	for i := 0; i < N; i++ {
		if C[i] < V[i] {
			res += V[i] - C[i]
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
taro = 0
hana = 0
n = int(input())
for _ in range(n):
    taro_s, hana_s = map(str, input().split())
    if taro_s > hana_s:
        taro += 3
    elif hana_s > taro_s:
        hana += 3
    else:
        taro += 1
        hana += 1
print(taro, hana)



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

const int MAXN = 200005, mod = 1e9+7;

struct node {
	int to, next, dis;
} edge[MAXN*4], e[MAXN*20];
int head[MAXN], h[MAXN*5], top = 0, tot = 0;
int rd[MAXN*5], cd[MAXN*5];
inline void push(int i, int j, int d)
{ edge[++top] = (node) {j, head[i], d}, head[i] = top; }
inline void push2(int i, int j)
{
	e[++tot] = (node) {j, h[i], 0}, h[i] = tot;
	e[++tot] = (node) {i, h[j], 1}, h[j] = tot;
	rd[j]++, cd[i]++;
}

int n, m, s, t;
long long dis[2][MAXN];

priority_queue<pair<long long,int>, vector<pair<long long, int> >, greater<pair<long long,int> > > que;

int vis[MAXN];

void dijkstra(int S, long long dis[])
{
	memset(vis, 0, sizeof vis);
	dis[S] = 0, que.push(make_pair(0, S));
	while (!que.empty()) {
		int nd = que.top().second; que.pop();
		if (vis[nd]) continue;
		vis[nd] = 1;
		for (int i = head[nd]; i; i = edge[i].next) {
			int to = edge[i].to;
			if (dis[to] > dis[nd] + edge[i].dis) {
				dis[to] = dis[nd]+edge[i].dis;
				que.push(make_pair(dis[to], to));
			}
		}
	}
}

int tot_pt;
int mark[MAXN*5];

int stk[MAXN*5], stk_top = 0;
int f[MAXN*5], g[MAXN*5];

void solve()
{
	for (int i = 1; i <= n; i++) {
		if (dis[0][i] == dis[1][i] && dis[0][i]+dis[1][i] == dis[0][t]) mark[i] = 1;
		for (int j = head[i]; j; j = edge[j].next) {
			int to = edge[j].to;
			if (dis[0][to] != dis[0][i]+edge[j].dis) continue;
			if (dis[0][to]+dis[1][to] != dis[0][t] || dis[0][i]+dis[1][i] != dis[0][t] || dis[0][i]+dis[1][to]+edge[j].dis != dis[0][t]) continue;
			long long cur = dis[1][to]+edge[j].dis-dis[0][i];
			if (cur > 0 && cur < 2*edge[j].dis) {
				int nd = ++tot_pt;
				push2(i, nd), push2(nd, to), mark[nd] = 1;
			} else push2(i, to);
		}
	}
	for (int i = 1; i <= tot_pt; i++)
		if (rd[i] == 0) stk[++stk_top] = i;
	f[s] = 1;
	while (stk_top) {
		int nd = stk[stk_top--];
		for (int i = h[nd]; i; i = e[i].next) {
			if (e[i].dis == 0) {
				int to = e[i].to;
				(f[to] += f[nd]) %= mod;
				if ((--rd[to]) == 0) stk[++stk_top] = to;
			}
		}
	}
	for (int i = 1; i <= tot_pt; i++)
		if (cd[i] == 0) stk[++stk_top] = i;
	g[t] = 1;
	while (stk_top) {
		int nd = stk[stk_top--];
		for (int i = h[nd]; i; i = e[i].next) {
			if (e[i].dis == 1) {
				int to = e[i].to;
				(g[to] += g[nd]) %= mod;
				if ((--cd[to]) == 0) stk[++stk_top] = to;
			}
		}
	}
	int ans = (long long)f[t]*g[s]%mod;
	for (int i = 1; i <= tot_pt; i++)
		if (mark[i])
			(ans += mod-(long long)f[i]*g[i]%mod*f[i]%mod*g[i]%mod) %= mod;
	cout << ans << endl;
}

int main()
{
	scanf("%d%d%d%d", &n, &m, &s, &t), tot_pt = n;
	for (int i = 1; i <= m; i++) {
		int u, v, d; scanf("%d%d%d", &u, &v, &d);
		push(u, v, d), push(v, u, d);
	}
	memset(dis, 127/3, sizeof dis);
	dijkstra(s, dis[0]);
	dijkstra(t, dis[1]);
	solve();
	return 0;
}


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

int main(){
  int64_t A, B, C, K; cin >> A >> B >> C >> K;
  
  int64_t ans = 0;
  for(int i = 0; i < K; i++){
    if(A != 0){
      ans++;
      A--;
      continue;
    }else if(B != 0){
      B--;
      continue;
    }else{
      ans--;
    }
  }
  
  cout << ans << endl;
}

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

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

  vector<int> P(N);
  vector<int> Q(N);
  vector<int> array(N);
  for (int i = 0; i < N; i++)
  {
    cin >> P.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> Q.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    array.at(i) = i + 1;
  }
  int p_i = 0;
  int q_i = 0;
  int i = 0;
  do
  {
    if (P == array)
    {
      p_i = i;
    }
    if (Q == array)
    {
      q_i = i;
    }
    i++;
  }
  while (next_permutation(array.begin(), array.end()));
  cout << abs(p_i - q_i) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	  public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    double m = n;
	    if(m % 2 ==0) {
	      System.out.println(0.5);
	    } else {
	      System.out.println((m+1)/(2*m));
	    }
	  }
	}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int N, S, T;
    cin >> N >> S >> T;
    if (N + S >= T) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

int main(void){
  solve();
  return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    double r;
    cin >> r;
    cout << setprecision(10) << 2 * r * M_PI << endl;
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int dp[300];
P ma[300];

int main(){
	int n, m;
	while(cin >> n && n){
		memset(dp, 0, sizeof(dp));
		rep(i, n) cin>> ma[i].first >> ma[i].second;
		cin >> m;
		rep(i, m) cin >> ma[n+i].first >> ma[n+i].second;
		sort(ma, ma + n + m);
		int res = 0;
		rep(i, n + m){
			int best = 0;
			rep(j, i){
				if(ma[i].first > ma[j].first && ma[i].second > ma[j].second) best = max(best, dp[j]);
			}
			dp[i] = best + 1;
			res = max(res, dp[i]);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 0
A,B,C,X,Y = gets.chomp.split.map(&:to_i)

ans = 10**10

if X >= Y
  0.upto(X) do |a|
    nokori_x = X-a
    c = nokori_x * 2
    b = Y - (c * 0.5).floor
    b = 0 if b<0

    ans = [ans, a*A+b*B+c*C].min
  end
else
  0.upto(Y) do |b|
    nokori_y = Y-b
    c = nokori_y * 2
    a = X - (c * 0.5).floor
    a = 0 if a<0

    ans = [ans, a*A+b*B+c*C].min
  end
end

p ans


Measured memory_bytes: 14292
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <deque>
using namespace std;

long bigger(long a, long b){
    if(a >= b){
      return a;
    }else{
      return b;
    }
}

int main() {
    //input
    long k,a,b;cin >> k >> a >> b;
   
    //compute
    long ans;
    ans = 1 + k + bigger(0 , bigger(0 , (1+ k -a)/2) * (b - a - 2));

    //output
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount



int a, b, c, d;



int32_t main(){
INIT
for(int i=1; i<=5; i++){
    cin>>a;
    if(a==0){
        cout<<i; return 0;
    }
}


return 0;
}



Measured memory_bytes: 3604
N = int(input())
T = list(map(int, input().split()))
M = int(input())
px = []
sumT = sum(T)
for _ in range(M):
    px.append(list(map(int, input().split())))

for x in px:
    sub = x[1] - T[x[0] - 1]
    newSum = sumT + sub
    print(newSum)


Measured memory_bytes: 3060
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll r = n / (a + b);
	ll m = n % (a + b);
	cout << r * a + (m < a ? m : a) << endl;
	return 0;
}


Measured memory_bytes: 256
ww = list(input())
w = sorted(ww)
if len(w) % 2 == 1:
         print("No")
         exit()
for i in range(len(w)-1):
         if w[i] != w[i+1] and i % 2 == 0:
                  print("No")
                  exit()
print("Yes")


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

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

  ll N; cin >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  ll ok = false;
  for (ll i = 0; i < N - 2; i++) {
    if (A[i] == B[i] && A[i + 1] == B[i + 1] && A[i + 2] == B[i + 2]) ok = true;
  }
  if (ok) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n,now,ans;
char ch;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>ch;
        if(ch=='I')now++;
        else
        now--;
        ans=max(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                   \
  ifstream in("atcoder-problems/keyence2019_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  cin >> S;
  int N = S.size();

  string O = "keyence";
  bool ok = false;
  rep(i, O.size() + 1) {
    string l = O.substr(0, i);
    string r = O.substr(i, O.size() - i);

    string sl = S.substr(0, i);
    string sr = S.substr(S.size() - O.size() + i, O.size() - i);

    if ((sl == l) && (r == sr)) {
      ok = true;
      break;
    }
  }

  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]),i,a[]=new int[n],ans=1;
        s=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        a[i]=Integer.parseInt(s[i]);
        int l=1,r=1000000000,mid;
        while(l<=r)
        {
            mid=(l+r)/2;
            long cn=cuts(a,mid);
            if(cn>k) l=mid+1;
            else {ans=mid; r=mid-1;}
        }
        System.out.print(ans);
    }

    static long cuts(int a[],int k)
    {
        int i; long c=0;
        for(i=0;i<a.length;i++)
        c+=(a[i]-1)/k;
        return c;
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int m = 0;
    bool ok = true;
    rep(i, n) {
        string s;
        cin >> s;
        if (s == "A") {
            m++;
        } else {
            m--;
        }
        if (m < 0) ok = false;
    }
    if (m > 0) ok = false;
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int n;
	string s;
	int cnt = 0;
	int max = 0;

	cin >> n >> s;
	
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			cnt++;
		}
		else if (s[i] == 'D') {
			cnt--;
		}

		if (max < cnt) {
			max = cnt;
		}
	}

	cout << max << endl;
	return 0;
	
	
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    char a,b;
    ll i,j,x,y,z;
    cin>>x>>a>>y>>b>>z;
    if(x<=2019 && y<=4 && z>=1 && z<=30 )cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
return 0;
}


Measured memory_bytes: 4992
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>

#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"

namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;

using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  Real a, b, c;
  cin >> a >> b >> c;

  YesorNo(sqrt(a)+sqrt(b) < sqrt(c));
  return 0;
}

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

    // 出力
    //std::cout << "SAMPLE\n";
    //std::cout << n << "\n";

int n;
int m;

int main() {

    // 入力
    cin >> n;
    cin >> m;

    std::array<int,2> route[m];
    for(int i=0; i<m; i++){
        cin >> route[i][0];
        cin >> route[i][1];
    }

    std::sort(&route[0], &route[m], [](auto& x, auto& y){return x[0] < y[0];});

    long double room_info[n];//最後の部屋までの通路の数
    int room_num = route[m-1][0]; // 初期化
    room_info[n-1]=0; // 初期化

    int count = 0;
    long double total = 0;
    int next = 0;
    long double max = 0;
    
    long double step[n];

    for(int j=n; j>0; j--){// 部屋N~1まで

        for(int i=m-1; i>-1; i--){

            int s = route[i][0];// 部屋s
            int t = route[i][1];// 部屋t

            if(s==j){
                if(room_info[t-1]+1 > max){
                    max = room_info[t-1]+1;
                }
            }
            
            total += room_info[t-1]+1;
            count++;

            if(i>0){
                next = route[i-1][0];
            }
            if((s!=next)||i==0){

                if((count>1)&&j==s){
                    total-=max;
                    count--;
                }
                room_info[s-1]=(total)/count;
                total = 0;
                count = 0;
                max = 0;
            }
        }
        step[j-1] = room_info[0];
    }
    sort(step, step+n);
    //std::cout <<  step[0] << "\n";
    cout << fixed << setprecision(10) << step[0] << endl;
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);

  sort(all(A));
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=A.at(i);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
   int H,W; cin >> H >> W;
   vector<vector<int>> a(H,vector<int>(W));
   rep(i,H)rep(j,W){
       cin >> a[i][j];
   }

   vector<int> ans;
   int cnt = 0;
   rep(i,H){
       if(i % 2 == 0){
           rep(j,W){
               if(j == W-1){
				   if(i != H-1){
						if(a[i][j] % 2 == 1){
							ans.push_back(i+1);
							ans.push_back(j+1);
							ans.push_back(i+2);
							ans.push_back(j+1);
							a[i+1][j]++;
							cnt++;
						}
				   }
               }
               else{
                   if(a[i][j] % 2 == 1){
                       ans.push_back(i+1);
                       ans.push_back(j+1);
                       ans.push_back(i+1);
                       ans.push_back(j+2);
                       a[i][j+1]++;
                       cnt++;
                   }
               }
           }
       }
       else{
           for(int j = W-1; j >= 0; j--){
               if(j == 0){
				   if(i != H-1){
						if(a[i][j] % 2 == 1){
							ans.push_back(i+1);
							ans.push_back(j+1);
							ans.push_back(i+2);
							ans.push_back(j+1);
							a[i+1][j]++;
							cnt++;
						}
				   }
               }
               else{
                   if(a[i][j] % 2 == 1){
                       ans.push_back(i+1);
                       ans.push_back(j+1);
                       ans.push_back(i+1);
                       ans.push_back(j);
                       a[i][j-1]++;
                       cnt++;
                    }
               }
           }
       }
   }

   cout << cnt << endl;

   rep(i,ans.size()){
       if(i % 4 != 3) cout << ans[i] << " ";
       else cout << ans[i] << endl;
   }
}
   

Measured memory_bytes: 5232
from itertools import permutations

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

per_loop = map(list, (permutations(range(1, n+1))))
cnt = 0
x = []
for t in per_loop:
    if t == p or t == q:
        x.append(cnt)
    cnt += 1
if len(x) == 2: 
    print(abs(x[0]-x[1]))
else:
    print(0)

Measured memory_bytes: 73448
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

// how many humans?
static sl N;
// how many colors?
const static sl M = 3;
// what is the number of same color persons?
static vector<sl> Ai;

// O(MN)
void solve(void) {
  // color combination count
  // all product of `C` is solution
  // C := (c_i)_{i = 0, ..., N - 1}
  vector<sl> C(N);
  // (d_{ij})_{j = 0, ..., M - 1} = D_i\in\mathbb{Z}^M
  // D := (D_i)_{i = 0, ..., N - 1}
  vector<vector<sl>> D(N, vector<sl>(M, 0));
  // q: \mathbb{Z}\times\mathbb{Z}\to\mathbb{Z}^*
  // q(i; v) := \Set{j \mid d_{ij}\in D_i, d_{ij} = v}
  // O(M)
  auto q = [&](sl i, sl v) {
    vector<sl> res;
    FOR0(j, M) {
      if (D[i][j] == v) {
        res.push_back(j);
      }
    }
    return res;
  };
  // If A_0 \ne 0, we can't find any combination
  if (Ai[0] == 0) {
    C[0] = M;
    D[0][0] = 1;
  }
  // O(MN)
  FORi(i, 1, N) {
    // i-th person had seen `Ai[i]` same-color persons
    auto X = q(i - 1, Ai[i]);
    // |X| is combination count
    C[i] = X.size();
    // we choose one `j` and increment D_{ij}
    // we can choose any `X[i]`
    // use `X[0]` in this code for check simplicity
    D[i] = D[i - 1];
    if (X.size() > 0) {
      D[i][X[0]]++;
    }
  }
  // each C_i are independent
  // so all product of that equals to the solution
  // O(N)
  ul ret = 1;
  FOR0(i, N) {
    ret *= C[i];
    ret %= 1000000007;
  }
  cout << ret << endl;
}

int main(void) {
  cin >> N;
  Ai.resize(N);
  FOR0(i, N) {
    cin >> Ai[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 7296
while True:
  H,W=map(int, input().split())
  if H == 0 and W == 0:
      break  
  for i in range(H):
        for j in range(W):
          if  (i + j) % 2 == 0 :
            print("#", end="")
          else                                            :
            print(".", end="")
        print()
  print()


Measured memory_bytes: 7004
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int h=gi();
        int w=gi();
        String[] A=new String[h];
        boolean[] r=new boolean[w];
        for (int i=0; i<w; i++) {
        	r[i]=false;
        }
        for (int i=0; i<h; i++) {
        	A[i]=gs();
        	for (int j=0; j<w; j++) {
        		if (A[i].charAt(j) == '#') {
        			r[j]=true;
        		}
        	}
        }
        
        for (int i=0; i<h; i++) {
        	if (A[i].contains("#")) {
        		StringBuilder sb = new StringBuilder();
        		for (int j=0; j<w; j++) {
            		if (r[j]) {
            			sb.append(A[i].charAt(j));
            		}
            	}
        		System.out.println(sb.toString());
        	}
        }

        //System.out.println(y);
//        if (a>0) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 37028
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<vector<int> > Graph;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l),S.substr(l, r)
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//'0'+cnt 数字cntからcharへの変換

int main(){

    int h,w;
    cin >> h >> w;
    vs s;
    rep(i,h){
        string masu;
        cin >> masu;
        s.push_back(masu);
    }
    int dx[] = {-1,-1,-1,0,0,1,1,1};
    int dy[] = {1,0,-1,1,-1,-1,0,1};


    vs ans(h);
    int cnt;
    rep(i,h)rep(j,w){
        if(s.at(i).at(j) == '#'){
            ans.at(i).push_back('#');
            continue;
        }
        cnt = 0;
        rep(k,8){
            int X,Y;
            X = i+dx[k];
            Y = j+dy[k];
            if(X>-1&&X<h&&Y>-1&&Y<w){
                if(s.at(X).at(Y) == '#') cnt++;
            }
        }
        ans.at(i).push_back('0'+cnt);
    }
    rep(i,h) cout << ans.at(i) << endl;
    return 0;
}


Measured memory_bytes: 256
def removewhite(l):
  return [item for item in l if all([c=="." for c in item])==False]

import numpy as np
[H,W]=list(map(int,input().split()))
a=[list(input()) for _ in range(H)]

a=np.array(removewhite(np.array(removewhite(a)).T.tolist()
                      )
          ).T.tolist()
[print("".join(l)) for l in a]



Measured memory_bytes: 12648
#define rep(i,n) for (int i=0;i<n;i++)
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const long long INF = 1LL<<60;

int main(){
  int H,W,m=0;
  cin >> H >> W;
  
  vector<vector<char>> a(H,vector<char>(W));
  
  rep(i,H){
    rep(j,W)
      cin >> a.at(i).at(j);
  }
  
 vector<vector<int>> dp(H,vector<int>(W,0));
  dp.at(0).at(0)=1;
  
  rep(i,H){
    rep(j,W){
      
      if(i>0 && a.at(i).at(j)=='.')
        dp.at(i).at(j)=(dp.at(i).at(j)+dp.at(i-1).at(j))%1000000007;
      if(j>0 && a.at(i).at(j)=='.')
        dp.at(i).at(j)=(dp.at(i).at(j)+dp.at(i).at(j-1))%1000000007;
      
       // cout << i << j << dp.at(i).at(j)<< endl;
        
    }
  }
  /* for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (i+1 < H && a[i+1][j] == '.') {
              dp.at(i+1).at(j)+=dp.at(i).at(j);
              cout << i << j << dp.at(i).at(j)<< endl;
            }
            if (j+1 < W && a[i][j+1] == '.') {
              dp[i][j+1]+=dp.at(i).at(j);
         	  cout << i << j << dp.at(i).at(j)<< endl;
            }
        }
    }*/
   // cout << dp[H-1][W-1] << endl;
  
  
  cout << dp.at(H-1).at(W-1) << endl;
  
}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


// ------------debug用------------
#define FALSE cout<<"false"<<endl;
#define TRUE cout<<"true"<<endl;
// ------------debug用------------


// ------------計算用------------
#define ALL(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)
// ------------計算用------------


// ------------出力用------------
#define PRINT(x) cout<<x<<endl;
// ------------出力用------------


using namespace std;
typedef long long ll;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int> > jobs(N);
  
  FOR(N)cin>>jobs[i].second>>jobs[i].first;
  sort(ALL(jobs));
  ll tmp = 0;
  FOR(N){
    tmp += jobs[i].second;
    if(tmp > jobs[i].first){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// const int MOD = 1E9 + 9;
// const int INF = 1<<29; 

int main(){
    int64_t ans = 0;
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i, N) cin >> s[i];
    map<string, int> cnt;
    rep(i, N){
        sort(s[i].begin(), s[i].end()); 
        cnt[s[i]]++;
        // cout << s[i] << ' ' << cnt[s[i]] << endl;
    }
    for(int i = 0; i < N; i++){
        // cout << cnt[s[i]] << endl;
        ans += cnt[s[i]] - 1;
    }
    // nC2にするために2で割っている。すでに上で(N-1)をN回足し合わせている。
    // nC2 = N*(N-1)/2
    cout << ans / 2 << endl;
}


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

int main() {
    string S;
    cin >> S;
    int count = 0;
    int answer = 0;
    for(char c : S) {
        if(c=='R') count++;
        else count = 0;
        answer = max(count, answer);
    }
    cout << answer << endl;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
  
public class Main {
	LinkedList<Integer> list = new LinkedList<>();
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
    
    public void exec() throws IOException {
    	SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
    	int n = in.readInt();
    	
    	for(int i=0; i<n; i++) {
    		String[] cmd = in.br.readLine().split(" ");
    		if(cmd[0].equals("insert")){
    			list.addFirst(new Integer(cmd[1]));
    		} else if(cmd[0].equals("delete")){
    			list.remove(new Integer(cmd[1]));
    		} else if(cmd[0].equals("deleteFirst")){
    			list.removeFirst();
    		} else {
    			list.removeLast();
    		}
    	}
    	boolean first = true;
    	for(Integer i : list) {
    		if(first) {
    			first = false;
    		} else {
    			out.print(" ");
    		}
    		out.print(i);
    	}
    	out.println("");
    	out.flush();
    }
}

class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public String[] readStrArray(String delim) throws NumberFormatException, IOException{
    	return br.readLine().split(delim);
    }
    
    public int readInt() throws NumberFormatException, IOException{
    	return Integer.parseInt(br.readLine());
    }
    
    public int[] readIntArray(int[] a) throws NumberFormatException, IOException{
        int i=0;
        while(i<a.length) {
            for(String s: br.readLine().split(" ")){
            	if(i<a.length) {
                    a[i++] = Integer.parseInt(s);
            	}
            }
        }
        return a;
    }

    
}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n),dp(n+1,INT_MAX>>1);
    for (int i = 0;i < n;++i) cin >> h[i];
    dp[0] = 0;
    for (int i = 1;i < n;++i) {
        for (int j = max(0,i-k);j < i;++j) dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    //p_ary(dp,0,n,i);
    cout << dp[n-1] << endl;
    return 0;
}

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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<vector<int>> A(N, vector<int>(M)); vector<int> B(M);

    for (int i = 0; i < M; i++) {
        cin >> B.at(i);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A.at(i).at(j);
        }
    }

    int cnt = 0, sum = 0;
    for (int i = 0; i < N; i++) {
        sum = 0;
        for (int j = 0; j < M; j++) {
            sum += A.at(i).at(j) * B.at(j);
        }
        if (0 < sum + C) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3620