akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    int n; cin >> n;
    int searched = 1;
    REP(i, n){
        int a; cin >> a;
        if(a == searched) ++searched;
    }
    cout << (searched == 1 ? -1 : n - searched + 1) << "\n";
    return 0;
}


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

int main() {
	int N, M; 
  	int A[40][40]; // i人目の回答A[i]のA[i][0]は配列A[i]の長さ（A[i][1]~A[i][A[0]]）
    cin >> N >> M;
  	for (int i = 0; i < N; ++i) {
      cin >> A[i][0];
      for (int j = 1; j <= A[i][0]; ++j) {
        cin >> A[i][j];
      }
    }
    
  	int B[A[0][0]+1]; // count
  	for (int i = 0; i <= A[0][0]; ++i) {
  		B[i] = 0;
    }
  	for (int i = 1; i < N; ++i) {
      for (int j = 1; j <= A[i][0]; ++j) {
        //cout << A[i][j];
        for (int k = 1; k <= A[0][0]; ++k) {
          if(A[0][k]==A[i][j]){
            B[k] += 1;
          }
        }
      }
      //cout << endl;
    }
  	
    int count = 0;
  	for (int i = 1; i <= A[0][0]; ++i) {
      if(B[i]==N-1){
        count += 1;
      }
    }
    cout << count << endl;
}

Measured memory_bytes: 384
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

N = gete(int)
a1, a2, i1 = 0, -1, -1

for i in range(N):
    ai = gete(int)
    if ai >= a1:
        a1, a2 = ai, a1
        i1 = i
    elif ai >= a2:
        a2 = ai

if a1 == a2:
    print(*[a1] * N, sep="\n")
else:
    print(*[a2 if i == i1 else a1 for i in range(N)], sep="\n")


Measured memory_bytes: 7804
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int, int> P;
typedef vector<vector<int>> mat;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int W, H, N;
  cin >> W >> H >> N;
  int maxx = W, maxy = H;
  int minx = 0, miny = 0;

  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      minx = max(minx, x);
    } else if (a == 2) {
      maxx = min(maxx, x);
    } else if (a == 3) {
      miny = max(miny, y);
    } else {
      maxy = min(maxy, y);
    }
  }

  int ans = (maxx - minx) * (maxy - miny);
  if (maxx - minx < 0 || maxy - miny < 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int i,j,cnt;
  ll k;
  string s;
  cin>>s;
  cin>>k;
  for(i=0;i<s.size();i++){
    if(s[i]!='1'){
      cnt=s[i];
      break;
    }
  }
  if(k>=i+1)cout<<s[i];
  else cout<<1;
}

Measured memory_bytes: 256
#include<iostream>
int main()
{
	int N;
	int A[100];
	int ans = 1;
	int anss = 1;
	int a = 0;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::cin >> A[i];
		if (A[i] == 1) {
			a += 1;
		}
	}
	for (int i = 1; i < N; i++) {
		if (A[i] == 1 && A[i - 1] == 1) {
			ans += 1;
			if (ans > anss) {
				anss = ans;
			}
		}
		else {
			ans = 1;
		}
	}
	if (a == 0) {
		anss = 1;
	}
	else {
		anss += 1;
	}
	std::cout << anss << std::endl;
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main() {
	double n,m,s;
	while(cin>>n>>m>>s,n){
		int ans=0;
		n+=100;
		m+=100;
		for(int i=1;i<s;i++){
			for(int j=1,x,y;j<s;j++){
				x=i*n/100;
				y=j*n/100;
				if(x+y==s){
					x=i*m/100;
					y=j*m/100;
					ans=max(ans,x+y);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1220
N = int(input())
ABCs = [tuple(map(int, input().split())) for _ in range(N)]

dp = [[0] * (3) for _ in range(N+1)]
for i, (A, B, C) in enumerate(ABCs, 1):
    dp[i][0] = max(dp[i-1][1] + B, dp[i-1][2] + C)
    dp[i][1] = max(dp[i-1][0] + A, dp[i-1][2] + C)
    dp[i][2] = max(dp[i-1][0] + A, dp[i-1][1] + B)

print(max(dp[N]))


Measured memory_bytes: 40224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string n;
    cin >> n;
    string ans = "No";
    if((n.substr(0,1)==n.substr(1,1)&&n.substr(1,1)==n.substr(2,1))||(n.substr(1,1)==n.substr(2,1)&&n.substr(2,1)==n.substr(3,1))){
        ans =" Yes";
    }
    cout << ans << endl;
}


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

#ifdef _DEBUG
#define debug(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[110][100010];

int main(int argc, char* argv[]) {
  INFILE;

  ll n, k;
  cin >> n >> k;

  vector<ll> candies(n);
  scan(candies);

  REP(i, 0, n + 1) {
    REP(j, 0, k + 1) {
      if (j == 0) {
        dp[i][j] = 1;
        continue;
      }

      if (i == 0) {
        dp[i][j] = 0;
        continue;
      }

      int index = j - candies[i - 1] - 1;
      ll v = index < 0 ? 0 : dp[i - 1][index];
      ll result = (dp[i - 1][j] + dp[i][j - 1] - v) % LL7_MOD;

      dp[i][j] = result < 0 ? result + LL7_MOD : result;
    }
  }

  cout << dp[n][k] << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

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

int main()
{
    int n;
    cin>>n;
    vector<int> x(n+1);
    vector<ll> y(n);
    for(int i=0;i<=n;i++){
        cin>>x[i];
    }
    sort(all(x));
    for(int i=0;i<n;i++){
        y[i]=x[i+1]-x[i];
    }
    int ans=y[0];
    for(int i=0;i<n;i++){
        ans=gcd(ans,y[i]);
    }
    cout<<ans<<endl;

}


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

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

    for (ll i = 0; i < K; ++i) {
        cout << S << " ";
    }
    for (ll i = K; i < N; ++i) {
        cout << ((S == 1'000'000'000) ? 1 : 1'000'000'000) << " ";
    }
    cout << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
using namespace std;
int main(){
  int n, m, i, j, cnt=0;
  scanf("%d %d", &n, &m);
  int arr[m]={0};
  for (i=0; i<n; i++) {
    int k, l;
    scanf("%d", &k);
    for (j=0; j<k; j++) {
      scanf("%d", &l);
      arr[l-1]+=1;
    }
  }
  for (i=0; i<m; i++) {
    if (arr[i] >=n) cnt++;
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main()
{
    int n,d;
    scanf("%d %d",&n,&d);
    int possible_answer=n*(n-1)/2;
    int x[1000]={0};
    int arr_ind;
    for (int i=1;i<=n;i++)
    {
        arr_ind=i*10;
        for (int j=0;j<d;j++)
        {
            scanf("%d",&x[arr_ind]);
            arr_ind++;
        }
    }
 /*/for(int i=0;i<1000;i++)
    {
        if (x[i])
            printf("%d\t%d\n",i,x[i]);
    }/*/
    int answer=0;
    double t3,s5;
    int t1=0,t2=0,sum=0,s1=0,s2=0,s3=10;
    for (int i=1;i<n;i++)
    {
        arr_ind=i*10;
        s3=10;
        for (int j=i;j<n;j++)
        {
            sum=0;
            t2=0;t1=0;
            for (int k=arr_ind,k1=0;k1<d;k++,k1++)
            {
                t2=x[k]-x[k+s3];//printf("t2-%d\n",t2);
                t3=pow(t2,2);//printf("t2=%d\tt3=%lf\n",t2,t3);
                t1=t3;
                sum+=t1;
            }
            s3+=10;
            s1= sqrt(sum);
            s5=pow(s1,2);
            s2=s5;//printf("sum=%d\ts1=%d\ts2=%d\n",sum,s1,s2);
            if (sum==s2)
                answer++;

        }
    }
    printf("%d",answer);
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int M=50000000;
		while(in.hasNext())
		{
			int n=in.nextInt(), m=in.nextInt(),K=in.nextInt();
			double minmax=0;
			int cost[][]=new int[n+1][n+1];
			for(int i=0;i<=n;i++)
				Arrays.fill(cost[i], M);
			for(int i=0;i<=n;i++)
				cost[i][i]=0;
			String cap[]=new String[m];
			for(int i=0;i<m;i++)
			{
				int a=in.nextInt(),b=in.nextInt(),l=in.nextInt();
				cap[i]=a+" "+b+" "+l;
				cost[a][b]=l;
				cost[b][a]=l;
			}
			int fmo=in.nextInt();
			int startmo=fmo;
			if(K>1)
				for(int i=1;i<K;i++)
				{
					int nexmo=in.nextInt();
					cost[fmo][nexmo]=0;
					cost[nexmo][fmo]=0;
					fmo=nexmo;
				}
			int leng[]=new int[n+1];// minimum distance
			int v[] = new int[n+1];// decision flag

			int p=0;
			int start =startmo;
			for(int k=1;k<=n;k++)
			{
				leng[k]=M;
				v[k]=0;
			}
			leng[start]=0;
			for(int j=1;j<=n;j++)
			{
				int min=M;//最小の節点を探す
				for(int k=1;k<=n;k++)
				{
					if(v[k]==0&&leng[k]<min)
					{
						p=k;
						min=leng[k];
					}
				}
				v[p]=1;//確定フラグ
				for(int k=1;k<=n;k++) //pを経由してkに至長さがそれまでの最短経路より小さければ更新
					leng[k]=Math.min(leng[p]+cost[p][k], leng[k]);
			}
			for(int i=0;i<m;i++)
			{
				String ss[]=cap[i].split(" ");
				int a=Integer.valueOf(ss[0]);
				int b=Integer.valueOf(ss[1]);
				int cos=Integer.valueOf(ss[2]);
				double d=(leng[a]+leng[b]+cos)/2.0;
				minmax=Math.max(minmax, d);
			}
			System.out.println(Math.round(minmax));
		}
	}
}

Measured memory_bytes: 58000
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000

struct card
{
  char suit[2];
  int num;
  int order; // 順序
};

int partition(struct card *,int,int);
void quicksort(struct card *,int,int);

int main()
{
  struct card C[MAX];
  int n;
  int i;
  int flag=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s%d", C[i].suit, &C[i].num);
      C[i].order=i+1;
    }

  quicksort(C,0,n - 1);

  for(i=0;i<n;i++)
    {
      if(C[i].order>C[i+1].order && C[i].num==C[i+1].num)
	{
	  flag++;
	  break;
	}
    }

  if(flag==0) printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++) printf("%s %d\n",C[i].suit, C[i].num);

  return 0;
}

int partition(struct card *C, int p, int r)
{
  int i, j, a;
  struct card x;

  a=C[r].num;
  i=p-1;

  for(j=p;j<r;j++)
    {
      if(C[j].num<=a)
	{
	  i++;
	  x=C[i];
	  C[i]=C[j];
	  C[j]=x;
	}
    }

  x=C[i+1];
  C[i+1]=C[r];
  C[r]=x;

  return i+1;
}

void quicksort(struct card *C, int p, int r)
{
  int q;
  if(p<r)
    {
      q = partition(C,p,r);
      quicksort(C,p,q-1);
      quicksort(C,q+1,r);
    }
}



Measured memory_bytes: 2888
# include <iostream>
# include <algorithm>
# include <vector>
# include <functional>
# include <string>
using namespace std;

int main() {
	int N, num=2;

	cin >> N;

	for (int i = 0;num<=N; ++i) {
		num *= 2;
	}

	cout << num/2 << endl;

	return 0;
}

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

int max(int x, int y){
	if (x>=y){
		return x;
	}else {
		return y;
	}
}

int min(int x, int y){
	if (x<=y){
		return x;
	}else {
		return y;
	}
}

int gcd(int x,int y){
	int amari=max(x,y)%min(x,y);
	if (amari==0){
		return min(x,y);
	}else {
		return gcd(amari,min(x,y));
	}
}

int main(){
	int x,y,z;
	cin >> x>> y;
	z=gcd(x,y);
	cout << z << endl;
	return 0;
}

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

int main()
{
    ll h;

    cin >> h;

    ll ans = 1, sum = 0;

    while(h != 0){
        sum++;
        h /= 2;
        ans *= 2;
    }

    cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MOD = 1000000007;
int pw(int x, int n) { int ret = 1; while (true) { if (n & 1) ret = (ll)ret*x%MOD; if ((n >>= 1) == 0) return ret; x = (ll)x*x%MOD; } }

int want;
bool atleast(int cnt, int len) {
	if (len > 9) return true;
	int num = 9; REP(i, len - 1) num *= 10; return num >= cnt;
}
bool atleast2(int cnt, int len1, int len2) {
	if (len1 > 9 || len2 > 9) return true;
	int num1 = 9; REP(i, len1 - 1) num1 *= 10;
	int num2 = 9; REP(i, len2 - 1) num2 *= 10;
	return num1+num2 >= cnt;
}

int calcone(int len) {
	int cnt = want / len;
	if (!atleast(cnt, len)) return 0;
	int num = (ll)9 * pw(10, len - 1) % MOD;
	return (num + MOD - cnt + 1) % MOD;
}
int solveone() {
	int ret = 0;
	for (int x = 1; x*x <= want; ++x) if (want%x == 0) {
		ret = (ret + calcone(x)) % MOD;
		if (x != want / x) ret = (ret + calcone(want / x)) % MOD;
	}
	return ret;
}

int solvetwo() {
	// some of length x, some of length x+1 -> want/cnt-1<x<want/cnt
	int ret = 0;
	for (int cnt = 2; cnt <= want; ++cnt) {
		if (want%cnt == 0) continue;
		int x = want / cnt, nb = want%cnt, na = cnt - nb;
		if (!atleast2(cnt, x, x + 1)) break;
		if (!atleast(na, x) || !atleast(nb, x + 1)) continue;
		//printf("cnt=%d x=%d na=%d nb=%d\n", cnt, x, na, nb);
		++ret;
	}
	return ret;
}

int solvemulti() {
	int ret = 0;
	FORE(slen, 2, 8) {
		int alen = slen - 1, anum = 9 * pw(10, alen - 1);
		ll have = (ll)9 * pw(10, slen - 1)*slen;
		FORE(blen, slen + 1, 9) {
			if (have > want) break;
			int bnum = 9 * pw(10, blen - 1);
			int rem = want - have;
			int acnt = 1; rem -= alen;
			int g = gcd(alen, blen);
			if (rem >= 0 && rem%g == 0) {
				while (rem%blen != 0) ++acnt, rem -= alen;
				if (acnt <= anum&&rem >= 0) {
					int bcnt = rem / blen;
					if (bcnt > bnum) { int x = (bcnt - bnum + alen / g - 1) / (alen / g); bcnt -= x*(alen / g); acnt += x*(blen / g); }
					if (acnt <= anum&&bcnt >= 1) {
						int x = (anum - acnt) / (blen / g), y = (bcnt - 1) / (alen / g);
						ret = (ret + min(x + 1, y + 1)) % MOD;
						//printf("alen=%d blen=%d -> %d\n", alen, blen, min(x + 1, y + 1));
					}
				}
			}
			have += (ll)bnum*blen;
		}
	}
	return ret;
}

void run() {
	scanf("%d", &want);
	int ret = ((ll)solveone() + solvetwo() + solvemulti()) % MOD;
	printf("%d\n", ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,k,x,y;
    int sum=0;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);

    if(n>=k){
        for(int i=0;i<k;i++){
            sum+=x;
        }
        for(int i=0;i<n-k;i++){
            sum+=y;
        }
    }
    
    if(n<k){
        for(int i=0;i<n;i++){
            sum+=x;
        }
    }
    printf("%d",sum);

    return 0;
}

Measured memory_bytes: 128
h,w = [int(x) for x in input().split()]
a = []
for _ in range(h):
    tmp = list(input())
    if set(tmp) != set("."):
        a.append(tmp)

for i in range(w):
    save = False
    for y in range(len(a)):
        if a[y][i] == '#':
            save = True
            break
    if not save:
        for y in range(len(a)):
            a[y][i] = '0'

for x in a:
    print(*[z for z in x if z != '0'],sep="")

Measured memory_bytes: 4596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int ans=0;
  string S,T;
  cin>>S>>T;
  REP(i,3){
    if(S.at(i)==T.at(i)) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
n = int(input())
ls = list(map(int,input().split()))
ans = 1
if 0 in ls:
    print(0)
else:
    for i in range(n):
        ans *= ls[i]
        if ans > 10 ** 18:
            print(-1)
            break
    if ans <= 10 ** 18:
        print(ans)


Measured memory_bytes: 21472
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF (2e9)
#define EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a; cin >> b;
    cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
typedef complex<double> P;
typedef pair<P,int> PP;
namespace std {bool operator < (const P& a, const P& b) {return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);}}
double toDo(double agl){return agl*180.0/M_PI;}
double D(P a, P b) {
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}
P calc(P a, P b, P c) {
  double r=toDo(atan2(c.imag()-b.imag(),c.real()-b.real()));
  double r2=toDo(atan2(b.imag()-a.imag(),b.real()-a.real()));
  double r3=r-r2;
  if(r3<=0) r3+=360;
  return P(-r3,D(b,c));
}
int main() {
  int n;
  while(cin >> n && n) {
    P p=P(0,-1),q=P(0,0);
    P a[n];
    for(int i=0; i<n; i++) {
      double x,y;
      cin >> x >> y;
      a[i]=P(x,y);
    }
    bool u[n];
    memset(u,0,sizeof(u));
    double ans=0;
    for(int i=0; i<n; i++) {
      vector<PP> v;
      for(int j=0; j<n; j++) {
        if(u[j]) continue;
        P r=calc(p,q,a[j]);
        v.push_back(PP(r,j));
      }
      sort(v.begin(),v.end());
      ans+=v[0].first.imag();
      u[v[0].second]=1;
      swap(p,q);
      q=a[v[0].second];
    }
    printf("%.1f\n",ans);
  }
  return 0;
}


Measured memory_bytes: 3512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef pair<int,int> P;

int N;

int main() {
  while (scanf("%d", &N), N) {
    vector<P> v;
    int weight, bridge;
    rep(i,N) {
      scanf("%d%d",&weight, &bridge);
      v.push_back(P(bridge, weight));
    }
    sort(v.begin(), v.end());
    int cur = 0, ok = 1;
    rep(i,N) {
      cur += v[i].second;
      if (cur > v[i].first) ok = 0;
    }
    printf("%s\n", (ok) ? "Yes" : "No");
  }
  return 0;
}

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

#define MAX_N 50

int main() {
	int n, r;
	int card[MAX_N];
	int buffer[MAX_N];
	int i, j;

	while(scanf("%d %d", &n, &r) == 2 && n) {
		for(i = 0; i < n; ++i) {
			card[i] = n - i;
		}

		for(i = 0; i < r; ++i) {
			int p, c;
			scanf("%d %d", &p, &c);
			--p;

			memcpy(buffer + c, card, sizeof(int) * p);
			memcpy(buffer, card + p, sizeof(int) * c);
			memcpy(card, buffer, sizeof(int) * (p + c));
		}

		printf("%d\n", card[0]);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define mo 1000000007
using namespace std;
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll int n;
     cin>>n;
     ll int arr[n],sum{0};
     map<ll int,ll int>mp;
     for(int i=0;i<n;i++){
         cin>>arr[i];
         sum+=arr[i];
         mp[arr[i]]++;
     }
     ll int q;
     cin>>q;
     ll int a[q][2];
     for(int i=0;i<q;i++)
     {
         for(int j=0;j<2;j++)
             cin>>a[i][j];
     }
     for(int i=0;i<q;i++){
         ll int x=mp[a[i][0]];
         sum-=x*a[i][0];
         sum+=x*a[i][1];
         if(mp.find(a[i][1])!=mp.end())
            mp[a[i][1]]+=x;
         else
             mp[a[i][1]]=x;
         mp[a[i][0]]=0;
         cout<<sum<<endl;
     }
 return 0;    
}

Measured memory_bytes: 11760
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        Double ans = 0.0;
        for (int i = 0; i < n; i++) {
            Double x = sc.nextDouble();
            String u = sc.next();
//
//            System.out.println(x);
//            System.out.println(u);

            if (u.equals("JPY")) ans += x;
            else ans += x * 380000.0;
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( long long i = (b); i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll N, M;
ll ans = 1;


int main(void) {
    scanf("%lld %lld", &N, &M);
    if (M > N) swap(N, M);

    per(i, 1, N) ans = (ans * i) % MOD;
    per(i, 1, M) ans = (ans * i) % MOD;

    if (N == M) ans = (ans * 2) % MOD;
    else if (N > M+1) {
        ans = 0;
    }
  
    printf("%lld\n", ans % MOD);

	return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * R move will never pass beyond a L in its right. Similarly, L move
 * will never pass beyond a R in its left. So after long enough, Rs and
 * Ls will merge together to become (R+L)/2 and R+L-(R+L)/2. We just
 * need to decide which one got the bigger value.
 */

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    while (cin >> s) {
        const int n = s.size();
        int i = 0; VI ans(n);
        while (i < n) {
            int j = i;
            while (j < n && s[j] == 'R')
                j++;
            int k = j;
            while (k < n && s[k] == 'L')
                k++;
            const int x = j-i;
            const int y = k-j;
            const int a = (x+y)/2;
            const int b = x+y-a; /* b always >= a */
            if (x > y) {
                if (x&1)
                    ans[j-1] = b, ans[j] = a;
                else
                    ans[j-1] = a, ans[j] = b;
            }
            else {
                if (y&1)
                    ans[j-1] = a, ans[j] = b;
                else
                    ans[j-1] = b, ans[j] = a;
            }
            i = k;
        }
        FOR(i,0,n)
            cout << ans[i] << ' ';
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1104
H,W,D=map(int,input().split())
MAP=[list(map(int,input().split())) for i in range(H)]
Q=int(input())
data=dict()
from collections import defaultdict
cost=defaultdict(int)
for i in range(H):
    for j in range(W):
        data[MAP[i][j]]=(i,j)
for i in range(1,D+1):
    bef=i
    now=i
    c=0
    cost[i]=0
    while now+D<=H*W:
        bef,now=now,now+D
        c+=abs(data[now][0]-data[bef][0])+abs(data[now][1]-data[bef][1])
        cost[now]=c
def solve():
    L,R=map(int,input().split())
    return cost[R]-cost[L]
for q in range(Q):
    print(solve())

Measured memory_bytes: 37104
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	rep(i, N)cin >> H[i];

	H[0]--;
	rep(i, N - 1) {
		if (H[i] < H[i + 1])H[i + 1]--;
		else if (H[i] > H[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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



int main()
{

    //ios_base::sync_with_stdio(false);

   long long int a,b,c,n;
   cin>>n;
   a=n/500;
   n=n-(a*500);
   b=n/5;
   a=a*1000;
   a+=(b*5);
   cout<<a<<"\n";
    return 0;
}


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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<ll> v;
    rep(i, N){
        int a; cin >> a;
        auto it = upper_bound(all(v), -a);
        if(it == v.end()){
            v.push_back(-a);
        }else{
            *it = -a;
        }
    }
    cout << v.size() << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 8356
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	string s;
	cin>>s;
	int n;
	n=s.length()-1;
	cout<<s[0]<<n-1<<s[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#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>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
const int P=1000000007;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
  ll a,b,n;
  cin>>a>>b>>n;
  ll ans;
  if(n>=b-1){
    ans=(a*(b-1))/b;
  }else{
    ans=(a*n)/b;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 3872
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for(int i = 0; i < n; i++) cin >> h[i];
	vector<bool> ans(n, true);
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		if(h[u] >= h[v]) {
			ans[v] = false;
		}
		if(h[v] >= h[u]) {
			ans[u] = false;
		}
	}
	int a = 0;
	for(int i = 0; i < n; i++) a += ans[i];
	cout << a;
	
	return 0;
}


Measured memory_bytes: 3732
n = input()
s1= input()
s2= input()
s3= input()
ss1 = list(map(lambda x:int(x), s1.split()))
ss2 = list(map(lambda x:int(x), s2.split()))
ss3 = list(map(lambda x:int(x), s3.split()))

sum = 0
p = 21
for i in range(len(ss1)):
    sum += ss2[ss1[i]-1] + (ss3[p-1] if (p == (ss1[i]-1)) else 0)
    p = ss1[i]
print(sum)


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

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

    set<int> s;
    for(int i=0; i<n; i++){
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int d, num, sum = 0;

  while (scanf("%d", &d) != EOF) {

    int roop = 600 / d;
    int height[roop + 1];

    for (num = 1; num <= roop; num++) {
      height[num] = (600 - (num * d)) * (600 - (num * d));
    }

    for (num = 1; num <= roop; num++) {
      sum += d * height[num];
    }

    printf("%d\n", sum);
    sum = 0;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){
	ll T = 1;
	//cin >> T;
	while (T--){
	 int a; int b; int c; int d; int e; int x = 0;
	 cin >> a >> b >> c >> d >> e;
	 if (a == 0) {
		 x = 1;
	 }
	 if (b == 0) {
		 x = 2;
	 }
	 if (c == 0) {
		 x = 3;
	 }
	 if (d == 0) {
		 x = 4;
	 }
	 if (e == 0) {
		 x = 5;
	 }
	 cout << x << endl;
	}
}
	


Measured memory_bytes: 3560
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int n, k;
	cin >> n >> k;
	int ans = n - k + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  ll n, a;
  cin >> n >> a;
  ll ans = n;
  int s = 1000002;
  rrep(i,60) {
    ll x = 0;
    while (1) {
      x = s;
      rep(j,i) x *= s;
      if (x <= n) break;
      --s;
    }
    ll now = s*(i+1) + a*i;
    while (x < n) {
      x = x/s*(s+1);
      now++;
    }
    mins(ans, now);
  }
  cout << ans << endl;
  return 0;
}







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


int main(){
  int N,m,sum=1,P,i;
  cin >> N >> m;
  
  for(i=0;i<N-1;i++){
    cin >> P;
    if(m>P){
      sum++;
      m = min(m,P);
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

//最大公約数
	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	//素数判定
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}
	
	int check(int N, int a, int b) {
		int A,B,i;
		if (a > b) {
			A = a;
			B = b;
		}
		else {
			A = b;
			B = a;
		}
		for (i = N / b; i > 0; i--) {
			if ((N - b * i) % a == 0) {
				return i;
			}
		}
		return 0;
	}
	//コンビネーション(n,r)
	ull combination(int n, int r) {
		if (r * 2 > n) r = n - r;
		ull dividend = 1;
		ull divisor = 1;
		for (int i = 1; i <= r; ++i) {
			dividend *= (n - i + 1);
			divisor *= i;
		}
		return dividend / divisor;
	}

	struct UnionFind {
		vector<pair<int,int>> par; // par[i].first:iの親の番号　(例) par[3].second = 2 : 3の親が2 par[i].second:木の大きさ

		UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
			for (int i = 0; i < N; i++) {
				par[i] = make_pair(i, 1);
			}
		}

		int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
			if (par[x].first == x) return x;
			return par[x].first = root(par[x].first);
		}

		void unite(int x, int y) { // xとyの木を併合.yが根になる
			int rx = root(x); //xの根をrx
			int ry = root(y); //yの根をry
			if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
			par[ry].second = par[ry].second + par[rx].second;
			par[rx].first = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		}

		bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
			int rx = root(x);
			int ry = root(y);
			return rx == ry;
		}

		int size(int x) {//xが含まれる木の大きさを返す
			return par[root(x)].second;
		}
	};
	
int main() {
	ull N, M, i, a, b, count = 0;
	cin >> N >> M;
	vector<pair<int, int>> bridge(100000);
	vector<ull> ans(100000);
	UnionFind tree(N);
	REP(i, M) {
		cin >> a >> b;
		bridge[i] = make_pair(a-1, b-1);
	}
	ull sum;
	ans[M - 1] = N * (N - 1) / 2;
	for (i = M - 1; i > 0; i--) {
		if (tree.same(bridge[i].first, bridge[i].second)) {
			ans[i - 1] = ans[i];
			continue;
		}
		sum = tree.size(bridge[i].first) *  tree.size(bridge[i].second);
		tree.unite(bridge[i].first, bridge[i].second);
		ans[i-1] = ans[i] - sum;
	}
	REP(i, M)
		cout << (ull)ans[i] << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i=0; i<N; ++i) cin >> a[i];

    ll all = 0;
    for (int i=0; i<N; ++i) all ^= a[i];
    if (all == 0) {
        cout << 0 << '\n';
        return;
    }

    ll r = 0;
    for (int i=2; i<N; ++i) r ^= a[i];
    ll sum = a[0] + a[1];
    if (sum < r) {
        cout << -1 << '\n';
        return;
    }
    ll aa = sum - r;
    if (aa & (1LL)) {
        cout << -1 << '\n';
        return;
    }

    aa >>= 1;
    for (int i=0; i<51; ++i) {
        if ((r & (1LL<<i)) && (aa & (1LL<<i))) {
            cout << -1 << '\n';
            return;
        }
    }
    ll to = 0;
    for (int i=50; i>=0; --i) if (aa & (1LL<<i)) to += (1LL<<i);
    for (int i=50; i>=0; --i) {
        if ((r & (1LL<<i))) {
            if (to + (1LL<<i) <= a[0]) {
                to += (1LL<<i);
            }
        }
    }
    if (to == 0 || a[0] < to) {
        cout << -1 << '\n';
        return;
    }
    cout << a[0] - to << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

int main() {
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){cout<<"OK"<<endl;
               exit(0);
              }
  }
    cout<<"NG"<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    ll ans = 0LL;
    rep(i, N) {
        ll temp;
        cin >> temp;
        if(temp >= K) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int h,w;
    cin >> h >> w;
    char x[h+2][w+2] = {};
    int count[h+2][w+2] = {};
    for(int i = 1; i < h+1; i++){
        for(int j = 1; j < w+1; j++){
            cin >> x[i][j];
        }
    }
    for(int i = 1; i < h+1; i++){
        for(int j = 1; j < w+1; j++){
            if(x[i][j] == '#'){
                count[i][j] += 100;
                count[i-1][j-1] += 1;
                count[i-1][j] += 1;
                count[i-1][j+1] += 1;
                count[i][j-1] += 1;
                count[i][j+1] += 1;
                count[i+1][j-1] += 1;
                count[i+1][j] += 1;
                count[i+1][j+1] += 1;
            }
        }
    }
    for(int i = 1; i < h+1; i++){
        for(int j = 1; j < w+1; j++){
            if(count[i][j] >= 100){
                cout << '#';
            }else{
                cout << count[i][j];
            }
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256