akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#if 1
    #define u8 unsigned char
    #define u16 unsigned short
    #define u32 unsigned int
    #define u64 unsigned long
    #define s8 char
    #define s16 short
    #define s32 int
    #define s64 long
    #define f32 float
    #define f64 double
    #define forin(_x,_y) for(auto& _x: _y)
    #define iter(_i,_c) for(size_t _i=0; _i<_c; ++_i)
    #define rangeloop(_i,_begin,_end) for(size_t _i=_begin; _i<_end; ++_i)

    using namespace std;

    char ctoi(char a){return a-'0';}

    template<class T> T max(const vector<T> &x){return *std::max_element(x.begin(), x.end());}
    template<class T> T min(const vector<T> &x){return *std::min_element(x.begin(), x.end());}
    template<class T> size_t argmax(const vector<T> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T> size_t argmin(const vector<T> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T> T sum(const vector<T> &x){ return std::accumulate(x.begin(), x.end());}
    template <class T> void sort(vector<T> &x){sort(x.begin(), x.end());}
    template <class T, class Compare> void sort(vector<T> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T> void len(const vector<T> &x){return x.size();}
    template<class T> ostream& operator<<(ostream& os, const vector<T> &x){os<<'[';forin(y,x)os<<y<<" ";os<<']'; return os;}

    template<class T, size_t SIZE> T max(const array<T,SIZE> &x){return *std::max_element(x.begin(), x.end());}
    template<class T, size_t SIZE> T min(const array<T,SIZE> &x){return *std::min_element(x.begin(), x.end());}
    template<class T, size_t SIZE> size_t argmax(const array<T,SIZE> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T, size_t SIZE> size_t argmin(const array<T,SIZE> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T, size_t SIZE> T sum(const array<T,SIZE> &x){ return std::accumulate(x.begin(), x.end());}
    template<class T, size_t SIZE> void sort(array<T,SIZE> &x){sort(x.begin(), x.end());}
    template<class T, size_t SIZE, class Compare> void sort(array<T,SIZE> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T, size_t SIZE> ostream& operator<<(ostream& os, const array<T,SIZE> &x){os<<'[';forin(y,x)os<<y<<" ";os<<']'; return os;}
#endif

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

    char C;
    cin>>C;
    cout<<char(C+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main(){
    int n, m ;
    cin >> n >> m ;
    vector<int> num (n, 1) ;
    vector<bool> cn (n, false) ;
    cn[0] = true ; 
    int ans = 0 ;
    rep(i, m){
        int x, y ;
        cin >> x >> y ; 
        x-- ; 
        y-- ; 
        if(num[x] == 1 && cn[x]){
            cn[x] = false ; 
            num[x]-- ; 
            cn[y] = true ;
            num[y]++ ; 
            continue ; 
        }
        if(!cn[x]){
            num[x]-- ;
            num[y]++ ;
            continue ; 
        }
        if(num[x] > 1 && cn[x]){
            cn[y] = true ;
            num[x]-- ;
            num[y]++ ;
            continue ; 
        }
    }
    rep(i, n){
        if(cn[i]) {
            ans++ ; 
        }
    }
    cout << ans << endl ; 
}


Measured memory_bytes: 3792
#include<iostream>
#include<utility>
#include<queue>
#include<functional>
#include<algorithm>
using namespace std;

struct edge{
	int to,cost;
};

int n,d[100001];
const int inf=1<<30;
vector<edge> g[100001];

void dijkstra(void){
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
	fill(d+1,d+n+1,inf);
	d[1]=0;
	q.push(pair<int,int> (0,1));
	while(!q.empty()){
		pair<int,int> p=q.top();
		q.pop();
		int v=p.second;
		if(d[v]<p.first){
			continue;
		}
		for(int i=0;i<g[v].size();++i){
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				q.push(pair<int,int> (d[e.to],e.to));
			}
		}
	}
}

int main(){
	int m,c;
	long long int x,S=0;
	cin>>n>>m>>c;
	for(int i=0;i<m;++i){
		int j,k,l;
		cin>>j>>k>>l;
		g[j].push_back((edge){k,l});
		g[k].push_back((edge){j,l});
		S+=l;
	}
	dijkstra();
	vector<pair<int,int> > v;
	for(int i=1;i<=n;++i){
		v.push_back(pair<int,int> (d[i],i));
	}
	sort(v.begin(),v.end());
	x=S;
	long long int dS=0;
	for(int i=1;i<n;++i){
		int a=v[i].second;
		for(int j=0;j<g[a].size();++j){
			int b=g[a][j].to;
			if(d[b]<d[a]){
				S-=g[a][j].cost;
			}else if(d[b]==d[a]){
				dS+=g[a][j].cost;
			}
		}
		if(i==n-1||d[a]<v[i+1].first){
			S-=(dS/2);
			dS=0;
			x=min(x,S+(long long int)c*d[a]);
		}
	}
	cout<<x<<endl;
}

Measured memory_bytes: 11544
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


signed main(){

	int N;
	cin >> N;
	vector<set<int>> g;
	g.assign(N+1, set<int>());

	if (N % 2 == 1){
		// Nから全点へ
		for (int i = 1; i <= N - 1; i++){
			g[N].insert(i);
			g[i].insert(N);
//			cerr << N <<" " << i << endl;
		}
		// nからはN-n以外へつなぐ
		for (int n = 1; n <= N; n++){
			for (int i = n+1; i <= N; i++){
				if (i != N - n){
					g[n].insert(i);
					g[i].insert(n);
//					cerr << n << " " << i << endl;
				}
			}
		}
/*		// check
		cerr << endl;
		for (int i = 1; i <= N; i++){
			int sum = 0;
			for (int v : g[i]) sum += v;
			cerr << i << " " << sum << endl;
		}*/
	}
	else{
		// Nから1以外の全点へ
		for (int i = 2; i <= N - 1; i++){
			g[N].insert(i);
			g[i].insert(N);
//			cerr << N << " " << i << endl;
		}
		// nからはN+1-n以外へつなぐ
		for (int n = 1; n <= N; n++){
			for (int i = n + 1; i <= N; i++){
				if (i != N+1 - n){
					g[n].insert(i);
					g[i].insert(n);
//					cerr << n << " " << i << endl;
				}
			}
		}
/*		// check
		cerr << endl;
		for (int i = 1; i <= N; i++){
			int sum = 0;
			for (int v : g[i]) sum += v;
			cerr << i << " " << sum << endl;
		}*/
	}

	int cnt = 0;
	for (int i = 1; i <= N; i++){
		for (int j : g[i]){
			cnt++;
		}
	}
	cout << cnt / 2 << endl;
	for (int i = 1; i <= N; i++){
		for (int j : g[i]){
			if (i < j){
				cout << i << " " << j << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>

using namespace std;

int main(){
	string S;

	cin >> S;

	int upper = stoi(S.substr(0, 2));
	int lower = stoi(S.substr(2, 2));

	if((1 <= upper && upper <= 12) && (1 <= lower && lower <= 12))
		cout << "AMBIGUOUS" << endl;
	else if((1 <= upper && upper <= 12))
		cout << "MMYY" << endl;
	else if((1 <= lower && lower <= 12))
		cout << "YYMM" << endl;
	else
		cout << "NA" << endl;

}

Measured memory_bytes: 256
#abc114-C:dfs

n=int(input())

def dfs(s):
    #s>nになったら数えない
    if int(s)>n:
        return 0

    #7,5,3がすべて入ってたら1,それ以外は0を返す変数を考える
    cnt=1 if all(s.count(c)>0 for c in '753') else 0

    for c in '753':
        cnt+=dfs(s+c)

    return cnt

print(dfs('0'))

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

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


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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

typedef long long ll;


int main() {
    string s;
    cin >> s;
    int count = 0;
    int max_count = 0;
    REP(i, s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') count++;
        else {
            chmax(max_count,count);
            count = 0;
        }
    }

    cout << max(count, max_count) << endl;

    return 0;
}


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int ans=1<<30;
	FOR(i, 1, n/2+1){
		int a=i, b=n-i, tmp=0;
		while(a>0){
			tmp+=a%10;
			a/=10;
		}
		while(b>0){
			tmp+=b%10;
			b/=10;
		}
		ans=min(ans, tmp);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.lang.Math;
    import java.util.Scanner;
    import java.util.Arrays;
    import java.util.Collections;
    import java.util.stream.*;

    class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int A = sc.nextInt();  // white, '.', false
            int B = sc.nextInt();  // black, '#', true
            boolean map[] = new boolean[99*49];

            Arrays.fill(map, false);

            for (int i = 99*25; i < 99*49; i++) {
                map[i] = true;
            }

            for (int i = 0; i < A - 1; i++) {
                map[i*2] = true;
            }

            for (int i = 0; i < B - 1; i++) {
                map[99*49 - i*2 - 1] = false;
            }

            String whiteLine = "...................................................................................................";
            String blackLine = "###################################################################################################";

            System.out.println("98 99");
            for (int i = 0; i < 49; i++) {
                for (int j = 0; j < 99; j++) {
                    System.out.print(map[i*99 + j] ? "." : "#");
                }
                System.out.println("");
                if (i < 25) {
                    System.out.println(blackLine);
                }
                else {
                    System.out.println(whiteLine);
                }
            }
        }
    }


Measured memory_bytes: 24404
///
// File:  2014.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 19 01:33:04 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

enum color_t {
  NONE = 0,
  WHITE = 0x01,
  BLACK = 0x02,
  BLACK_AND_WHITE = 0x03,
};

color_t dfs(vector<string> &arr, vector<vector<bool>> &visited, int32_t i, int32_t j)
{
  visited[i][j] = true;
  if (arr[i][j] == 'W') {
    return WHITE;
  } else if (arr[i][j] == 'B') {
    return BLACK;
  } else {
    color_t u = NONE, d = NONE, r = NONE, l = NONE;
    if (i > 0 && !visited[i - 1][j]) {
      d = dfs(arr, visited, i - 1, j);
    }
    if (i + 1 < arr.size() && !visited[i + 1][j]) {
      u = dfs(arr, visited, i + 1, j);
    }
    if (j + 1 < arr[0].size() && !visited[i][j + 1]) {
      r = dfs(arr, visited, i, j + 1);
    }
    if (j > 0 && !visited[i][j - 1]) {
      l = dfs(arr, visited, i, j - 1);
    }
    return (color_t)(u | d | r | l);
  }
}

int32_t main()
{
  while (true) {
    uint32_t w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) break;

    vector<string> arr;
    for (uint32_t _ = 0; _ < h; _++) {
      string str;
      cin >> str;
      arr.push_back(str);
    }

    vector<vector<color_t>> colors(h);
    vector<vector<bool>> visited(h);
    for (uint32_t i = 0; i < visited.size(); i++) {
      colors[i].resize(w, NONE);
      visited[i].resize(w);
    }
    for (uint32_t i = 0; i < h; i++) {
      for (uint32_t j = 0; j < w; j++) {
        for (auto iter = visited.begin(); iter < visited.end(); iter++) {
          for (auto it = iter->begin(); it < iter->end(); it++) {
            *it = false;
          }
        }
        colors[i][j] = dfs(arr, visited, i, j);
      }
    }

    uint32_t whites = 0, blacks = 0;
    for (uint32_t i = 0; i < h; i++) {
      for (uint32_t j = 0; j < w; j++) {
        if (arr[i][j] == '.') {
          if (colors[i][j] == WHITE) {
            whites++;
          } else if (colors[i][j] == BLACK) {
            blacks++;
          }
        }
      }
    }
    cout << blacks << " " << whites << endl;
  }

  return 0;
}

Measured memory_bytes: 3264
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val r = IntArray(200000)

    for (i in 0 until n) {
        r[i] = readLine()!!.toInt()
    }

    var maxv = -2000000000
    var minv = r[0]

    for (i in 1 until n) {
        maxv = Math.max(maxv, r[i] - minv)
        minv = Math.min(minv, r[i])
    }

    println(maxv)
}


Measured memory_bytes: 45604
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int n;
	int a[105];
	cin >> n;
	int i;
	int ans = 0;
	rep(i, n) cin >> a[i];
	rep(i, n) {
		int j;
		rep(j, n) {
			ans = max(ans, abs(a[i] - a[j]));
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  if (N == 1) cout << "Hello World" << endl;
  else {
    cout << (nextInt() + nextInt()) << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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


int main()
{
int n,m,i,j,k,l,r,a;

scanf("%d %d",&n,&m);
l = 0;
r = 100001;
for(i=0;i<m;i++)
{
    scanf("%d %d",&k,&j);
    if(k>l)
        l = k;
    if(j<r)
        r = j;
}

a = r-l+1;
if(a < 0)
 a = 0;
 
printf("%d",a);

return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int p1, p2, p3, j1, j2;
		
		p1 = sc.nextInt();
		p2 = sc.nextInt();
		p3 = sc.nextInt();
		j1 = sc.nextInt();
		j2 = sc.nextInt();
		
		System.out.println(Math.min(p1, Math.min(p2, p3)) + Math.min(j1, j2) - 50);
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>                                                                          
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  for(int i=0; i<N; i++){
    cin >> V.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> C.at(i);
  }
  int X=0;
  int Y=0;
  for(int i=0; i<N; i++){
    if(V.at(i)>C.at(i)){
      X+=V.at(i);
      Y+=C.at(i);
    }
  }
  cout << X-Y << endl;
}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
h = Hash.new(0)

gets.chomp.split.each do |a|
  h[a.to_i] += 1
end

m.times do
  b, c = gets.chomp.split.map(&:to_i)
  h[c] += b
end

sum = 0
h.sort_by{|num, count| -num}.each do |num, count|
  if count < n
    sum += count * num
    n -= count
  else
    sum += n * num
    break
  end
end

puts(sum)

Measured memory_bytes: 31096
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x) cerr << "  (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x) cerr << "  (L" << __LINE__ << ") " << #x << " = "; REP(q,(x).size()) cerr << (x)[q] << " "; cerr << endl;
template<typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& d) {return s << "(" << d.first << "," << d.second << ")";}


const int INF = 10e+9;
struct Edge {
  int to, dist, cost;
  Edge(int t, int d, int c) : to(t), dist(d), cost(c) {}
};

int solve(int N, int M, vector<int>& u, vector<int>& v, vector<int>& d, vector<int>& c) {
  vector<vector<Edge> > G(N);
  for (int i = 0; i < M; i++) {
    G[u[i]-1].push_back(Edge(v[i]-1, d[i], c[i]));
    G[v[i]-1].push_back(Edge(u[i]-1, d[i], c[i]));
  }

  vector<bool> used(N, false);
  priority_queue<pair<int, PII>, vector<pair<int, PII> >, greater<pair<int, PII> > > que;

  int total_cost = 0;

  que.push(make_pair(0, make_pair(0, 0)));
  while (!que.empty()) {
    int city = que.top().second.first;
    int cost = que.top().second.second;
    int dist = que.top().first;
    que.pop();

    if (!used[city]) {
      used[city] = true;
      total_cost += cost;

      for (int i = 0; i < G[city].size(); i++) {
        Edge& e = G[city][i];
        if (!used[e.to]) {
          que.push(make_pair(dist + e.dist, make_pair(e.to, e.cost)));
        }
      }
    }
  }
  return total_cost;
}

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

  while (true) {
    int N, M; cin >> N >> M;
    if (N == 0 && M == 0) break;

    vector<int> u(M), v(M), d(M), c(M);
    for (int i = 0; i < M; i++) cin >> u[i] >> v[i] >> d[i] >> c[i];

    int ans = solve(N, M, u, v, d, c);
    cout << ans << endl;
  }
}

Measured memory_bytes: 2408
#include <iostream>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

map<ll, ll> mp;

void decompositPrime(ll n) {
    ll a = 2;
    while(a * a <= n) {
        if(n % a == 0) {
            mp[a]++;
            n /= a;
        } else {
            a++;
        }
    }
    mp[n]++;
}


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

    decompositPrime(n);

    /*
    for(auto x : mp) {
        cout << x.first << ' ' << x.second << endl;
    }
     */
    
    if(n == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll cnt = 0;

    for(auto x : mp) {
        ll k = x.second;
        // cout << "k is " << k << endl; 
        for(ll i = 1; i <= k + 1; i++) {
            // cnt++;
            k = k - i;
            if(k >= 0) {
                cnt++;
                // cout << x.first << " de increment. k is " << k << endl;
            }
            else break;
        }
    }

    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

ll n;

int main()
{
    cin >> n;
    for (ll i=sqrt(n);i>0;i--)
    {
        if (n%i==0)
        {
            cout << (i-1)+(n/i-1) << endl;return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int i, j, k, c, n, x;
    for(; scanf("%d %d", &n, &x), n || x; printf("%d\n", c)) {
        for(i = n, c = 0; i > 2; i--) {
            for(j = ~-i; j > 1; j--) {
                for(k = ~-j; k > 0; k--) {
                    i + j + k - x || c++;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 600
N,x = map(int,input().split())
a = list(map(int, input().split()))
ans=0
wa=a[0]+a[1]
if wa>x:
    ans=wa-x
    if a[1]<ans:
        a[1]=0
    else:
        a[1]-=ans
for i in range(1,N-1):
    wa=a[i]+a[i+1]
    if wa>x:
        ans+=wa-x
        a[i+1]-=(wa-x)
print(ans)

Measured memory_bytes: 20008
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

	string str;
	cin >> str;

	LL x,y;

	cin >> x >> y;

	LL ofs = 8000;
	vector<LL> t;
	LL tmp = 0;
	for(int i = 0; i < str.size();i++){
		if(str[i] == 'F'){
			tmp++;
		}else{
			t.push_back(tmp);
			tmp = 0;
		}
	}
	if(tmp != 0){
		t.push_back(tmp);
	}
	vector<vector<bool>> dpx((t.size()+1)/2+2,vector<bool>(16001,false));
	dpx[0][ofs] = true;
	LL indx = 1;
	for(int i = 0; i < t.size(); i += 2){
		for(int j = 0; j < 16001; j++){
			if(dpx[indx-1][j]){
				if(i > 0 && j - t[i] >= 0){
					dpx[indx][j-t[i]] = true;
				}
				if(j + t[i] < 16001){
					dpx[indx][j+t[i]] = true;
				}
			}
		}
		indx++;
	}

	vector<vector<bool>> dpy((t.size()+1)/2+2,vector<bool>(16001,false));
	dpy[0][ofs] = true;
	LL indy = 1;
	for(int i = 1; i < t.size(); i += 2){
		for(int j = 0; j < 16001; j++){
			if(dpy[indy-1][j]){
				if(j - t[i] >= 0){
					dpy[indy][j-t[i]] = true;
				}
				if(j + t[i] < 16001){
					dpy[indy][j+t[i]] = true;
				}
			}
		}
		indy++;
	}

	if(dpx[indx-1][ofs+x] && dpy[indy-1][ofs+y]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


	
    
    return 0;
}

Measured memory_bytes: 16352
A,B,C=map(int,input().split())
s=set()
cnt=0
while (A,B,C) not in s:
    s.add((A,B,C))
    if A%2==1 or B%2==1 or C%2==1:
        print(cnt)
        exit()
    A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
    cnt+=1
print("-1")

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)2e5 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int n, m, k, a[N], b[N];
LL pa[N], pb[N];

void solve() {
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		pa[i] = a[i];
		if (i)
			pa[i] += pa[i - 1];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		pb[i] = b[i];
		if (i)
			pb[i] += pb[i - 1];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (pa[i] > k)
			break;
		int rest = k - pa[i];
		int pos = upper_bound(pb, pb + m, rest) - pb - 1;
		uax(ans, i + pos + 2);
	}
	for (int i = 0; i < m; i++) {
		if (pb[i] > k)
			break;
		int rest = k - pb[i];
		int pos = upper_bound(pa, pa + n, rest) - pa - 1;
		uax(ans, i + pos + 2);
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 8316
/*#include <iostream>
using namespace std;

//Compiler version g++ 6.3.0

int main()
{
    int tt;
    cin >> tt;
    while(tt--){
      int N;
      cin >> N;
      long long sq = N * N;
      int start = 1;
      
      if( N % 2 == 1){
        for(int i = 0; i < N; i++)
        {
          for(int j = 0; j < N; j++){
            cout << start << " ";
            start += 1;
          }
          cout << "\n";
        }
      }
      else{
        for(int i = 1; i <= N; i++){
          if(i % 2 == 1){
            for(int i = 1; i <= N; i++){
              cout << start << " ";
              start += 1;
            }
            cout << "\n";
          
        }
        else{
          for(int i = 1; i <= N/2; i++){
            cout << start + 1 << " " << start << " ";
            start += 2;
          }
          cout << "\n";
        }
      }
      }
      
    }
}*/
 #include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 vector<int> store(16);
 void helper(){
   int num = 2;
   store[0] = 2;
   for(int i = 1; i <= 15; i++){
     num *= 2;
     store[i] = num;
   }
 }
 int main(){
   
   helper();
   int n,k;
   cin >> n >> k;
   
  if(n == 1 && k == 1){
  cout << 1;
  return 0;  
  }
  
  auto it = lower_bound(store.begin(),store.end(),k);
  int hi = it - store.begin() + 1;
  int lo = 1;
  int as = hi;
  int mid;
//  cout << start << endl;
  double sum = 0.0;
  if(n <= k)
  for(int i = 1; i <= k-1;i++){
    if(i > n)break;
    
    while(lo <= hi){
       mid = hi - (hi - lo)/2;
      
      if(i * pow(2,mid) == k)break;
      
      if(i * pow(2,mid) < k){
        lo = mid + 1;
        continue;
      }
      if(i * pow(2,mid) > k){
        if(i * pow(2,mid - 1) < k)break;
        else hi = mid - 1;
      }
    }
    lo = 1;
    hi = as;
    
   // if( n > k - 1)break;
    sum += (double)pow(0.5,mid);
  //  cout << mid << endl;
    
    
  }
  if(n > k){
    
    for(int i = 1; i <= k - 1; i++){
     // if(i >= k - 1)break
    
      while(lo <= hi){
       mid = hi - (hi - lo)/2;
      
      if(i * pow(2,mid) == k)break;
      
      if(i * pow(2,mid) < k){
        lo = mid + 1;
        continue;
      }
      if(i * pow(2,mid) > k){
        if(i * pow(2,mid - 1) < k)break;
        else hi = mid - 1;
      }
    }
    lo = 1;
    hi = as;
    
   // if( n > k - 1)break;
    sum += (double)pow(0.5,mid);
  //  cout << mid << endl;
  
      
    }
    for (int i = k; i <= n; i++){
      sum += 1.0;
    }
  }
  
  double tmp = (double)1/n;
 // cout << tmp << endl;
 // cout << sum << endl;
  double res = (double) sum * tmp;
  cout  << setprecision(12) << res;
  
  
  return 0;
  
 
 
 
 }

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for (int &i : a) cin >> i;
  for (int &i : b) cin >> i;
  long long t = 0;
  for (int i = 0; i < m; i++) t += b[i];
  int j = m;
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    while (j > 0 && t > k) {
      j--;
      t -= b[j];
    }
    if (t > k) break;
    ans = max(ans, i + j);
    t += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4820
N = gets.to_i
a = []
for i in 0...N do
    a << gets.split
    for j in 0...3 do
        a[i][j] = a[i][j].to_i
    end
end

a.unshift([0,0,0])
msg = ""
for i in 0...N do
    noko_time = a[i+1][0] - a[i][0] - (a[i+1][1] - a[i][1]).abs
    if ((noko_time - (a[i+1][2] - a[i][2]).abs)%2 == 0) && (noko_time >= (a[i+1][2] - a[i][2]).abs) then
        msg = "Yes"
    else
        msg = "No"
        break
    end
end
print msg

Measured memory_bytes: 9724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  V<ll> v(7,0);
  rep(i,0,7)cin>>v[i];

  ll ans=0;
  ll a=v[0],b=v[3],c=v[4];
  
  ans=4*((a/2)+(b/2)+(c/2));

  if(a&&b&&c){
    a--;b--;c--;
    chmax(ans,6+ (4*((a/2)+(b/2)+(c/2))));
  }

  ans+=2*v[1];
  cout<<ans/2<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?  

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  int C = 10000, ans = 0;
  for(int i = 1; i < N; ++i){
    if(A[i-1] == A[i]){
      ++ans;
      A[i] = C;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  if(abs(b-a)<=d&&abs(c-b)<=d )cout<<"Yes"<<endl;
  else if(abs(c-a)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

return 0;}


Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())

if a*a*b==2*x:
    print(45)
    exit()

x/=a

if a*b>2*x:
    h=x*2/b
    #print("a b x h",a,b,x,h)
    print(math.degrees(math.atan(b/h)))
else:
    h=2*(a*b-x)/a
    #print("a b x h",a,b,x,h)
    print(math.degrees(math.atan(h/a)))




Measured memory_bytes: 3060
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    cin >> n >> k;
    if(k == 1)
    {
        cout << n << endl;
    }
    else
    {
        int chaeng = 0;
        while(n > 0)
        {
            chaeng++;
            n /= k;
        }
        cout << chaeng << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

int Solve() {
    ll n, m;
    cin >> n >> m;

    if (m == 1) return 0;

    vector<ll> x(m);
    for (int i = 0; i < m; ++i) cin >> x[i];
    sort(x.begin(), x.end());

    vector<ll> d(m - 1);
    for (int i = 1; i < m; ++i) d[i - 1] = x[i] - x[i - 1];
    sort(d.begin(), d.end(), greater<ll>());

    if (n == 1) return x[m - 1] - x[0];
    ll sum = 0;
    for (int i = n - 1; i < d.size(); ++i)
        sum += d[i];
    return sum;
}

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

    cout << Solve() << endl;

    return 0;
}


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

int main(){
  string S;
  cin >> S;

  int N = S.size();
  vector<int> ans(N,0);

  int now_R_cnt = 0;
  for(int i = 0;i < N - 1;i++){
    if(S[i] == 'R')now_R_cnt++;

    if(S[i] == 'R' && S[i+1] == 'L'){
      ans[i] += (now_R_cnt + 1)/2;
      ans[i+1] += now_R_cnt/2;
      i++;
      now_R_cnt = 0;
    }
  }

  int now_L_cnt = 0;
  for(int i = N-1;i > 0;i--){
    if(S[i] == 'L')now_L_cnt++;

    if(S[i] == 'L' && S[i-1] == 'R'){
      ans[i] += (now_L_cnt + 1)/2;
      ans[i-1] += now_L_cnt/2;
      i--;
      now_L_cnt = 0;
    }
  }

  for(int i = 0;i < N;i++)cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 1024
n=[int(input())]
flag=0
count=1
while flag==0:
  if n[count-1]%2==1:
    n.append(3*n[count-1]+1)
  else:
    n.append(int(n[count-1]/2))
  for i in range(count-1):
    if n[i]==n[count-1]:
      flag=1
      print(count)
  count+=1    

Measured memory_bytes: 3064
#include <stdio.h>

void bobble_sort(int n, int *list);

int main(void)
{
	int max = 0;
	int d[200] = {};
	int list[200] = {};
	int a;
	int i = 0;
	int j = 0;

	while (scanf("%d", &a) != EOF) {
		d[a]++;
		if (d[a] > max) max = d[a];
	}

	for (i = 0; i < 100; i++) {
		if (d[i] == max) {
			list[j] = i;
			j++;
		}
	}

	bobble_sort(j, list);

	for (i = 0; i < j; i++) {
		printf("%d\n", list[i]);
	}

	return (0);
}

void bobble_sort(int n, int *list) {
	int i, j, t;

	for (i = 0; i < n - 1; i++) {
		for (j = n - 1; j > i; j--) {
			if (list[j - 1] > list[j]) {
				t = list[j - 1];
				list[j - 1] = list[j];
				list[j] = t;
			}
		}
	}
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	multimap<string, int> M;
	int q;
	cin >> q;
	int query, x;
	string key;
	multimap<string, int>::iterator itr;
	string L, R;

	for (int i = 0; i < q; i++) {
		cin >> query >> key;
		if (query == 0) {
			cin >> x;
			M.insert(make_pair(key, x));
		}
		else if(query == 1){
			pair<multimap<string, int>::iterator, multimap<string, int>::iterator >
			its = M.equal_range(key);

			for (multimap<string, int>::iterator it = its.first; it != its.second; it++) {
				cout << it->second << endl;
			}
		}	
		else if(query == 2){
			M.erase(key);
		}
		else {
			L = key;
			cin >> R;
			
			for (auto it = M.lower_bound(L); it != M.upper_bound(R); it++)
				cout << it->first << " " << it->second << endl;
		}
	}
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<ll> L(N);
    REP(i,0,N) cin >> L[i];

    sort(ALL(L));

    ll cnt = 0;
    ll a, b, c;
    REP(i,0,N-2){
        a = L[i];
        REP(j,i+1,N-1){
            b = L[j];
            REP(k,j+1,N){
                c = L[k];
                if(a > c - b) ++cnt;
                else break;
            }
        }
    }

    _PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

int main(){

  int N,L;
  std::cin >> N >> L;
  std::string S[101];
  for (int i = 0;i < N;i++) std::cin >> S[i];

  std::sort(S,S+N);

  for (int i = 0;i < N; i++)
  std::cout << S[i];
  std::cout << '\n';
}


Measured memory_bytes: 256
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}

class IntArray2D(val size1: Int, val size2: Int) {
  private val innerArray = IntArray(size1 * size2)

  operator fun get(i1: Int, i2: Int): Int = innerArray[i2 + size2 * i1]

  operator fun set(i1: Int, i2: Int, v: Int) {
    innerArray[i2 + size2 * i1] = v
  }
}

data class Query(val v: Int, val d: Int, val c: Int)

fun main(args: Array<String>) {
  val (n, m) = fastReadInts(2)
  val mutableGraph = Array(n, { mutableListOf<Int>() })
  repeat(m) {
    val (rawV1, rawV2) = fastReadInts(2)
    val v1 = rawV1 - 1
    val v2 = rawV2 - 1
    mutableGraph[v1].add(v2)
    mutableGraph[v2].add(v1)
  }
  val graph = mutableGraph.map { it.toIntArray() }

  val q = readLine()!!.toInt()
  val queries = Array(q, {
    val (vRaw, d, c) = fastReadInts(3)
    val v = vRaw - 1
    Query(v, d, c)
  })
  queries.reverse()

  val dp = IntArray2D(n, 11)

  fun dfs(v: Int, d: Int, c: Int) {
    if (dp[v, d] > 0) return
    for (k in d downTo 0) {
      if (dp[v, k] > 0) break
      dp[v, k] = c
    }

    if (d == 0) return

    for (u in graph[v]) {
      dfs(u, d - 1, c)
    }
  }

  for (query in queries) {
    dfs(query.v, query.d, query.c)
  }

  val ansList = (0 until n).map { dp[it, 0] }
  println(ansList.joinToString("\n"))
}


Measured memory_bytes: 79700
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string str = Console.ReadLine();
		long ans = 0;
		var table = new Dictionary<string,long>();
		string a1;
		string a2;
		for(var i=0;i<Math.Pow(2,N);i++){
			a1 = "";
			a2 = "";
			for(var j=0;j<N;j++){
				if((i/(int)Math.Pow(2,j)) % 2 == 1){
					a2 = str.Substring(j,1) + a2;
				} else {
					a1 = a1 + str.Substring(j,1);
				}
			}
			if(table.ContainsKey(a1+" "+a2)){
				table[a1+" "+a2] += 1;
			} else {
				table[a1+" "+a2] = 1;
			}
		}
		for(var i=0;i<Math.Pow(2,N);i++){
			a1 = "";
			a2 = "";
			for(var j=0;j<N;j++){
				int t = 2*N-1-j;
				if((i/(int)Math.Pow(2,j)) % 2 == 1){
					a2 = a2 + str.Substring(t,1);
				} else {
					a1 = str.Substring(t,1) + a1;
				}
			}
			if(table.ContainsKey(a2+" "+a1)){
				ans += table[a2+" "+a1];
			}
		}
		Console.WriteLine(ans);
	}
}

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

int main()
{
    int A, B;
    cin >> A >> B;

    int ans;
    for (int i = 0; i < 1000; i++)
    {
        if (A * i - (i - 1) >= B)
        {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,st,num)for(int i=(st);i<(num);++i)
#define ll long long
using namespace std;

double cal(ll n) {
    int s = 0;
    ll a = n;
    while(n){
        s+=n%10;
        n/=10;
    }
    double ans =(double)a / s;
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    ll K, ans = 0;
    cin >> K;
    vector<ll> anss;
    for (ll i = 0; i <= 15; ++i)
	{
		for (ll j = 1; j <= 1000; ++j)
		{
			if (i == 0 && j == 1) continue;
			ll tmp = j * pow(10LL, i);
			--tmp;
			anss.push_back(tmp);
		}
	}
    sort(anss.begin(),anss.end());
    anss.erase(std::unique(anss.begin(), anss.end()), anss.end());
    REP(i,0,anss.size()) {
        REP(j,i+1,anss.size()){
            if(cal(anss[i]) > cal(anss[j])) {
                anss.erase(anss.begin() + i);
                --i;
                break;
            }
        }
    }
    REP(i,0,K){
        cout<<anss[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,x,a[100010],i;
  long ans=0;
  cin >> n >> x;
  for (i=0;i<n;i++) cin >> a[i];
  for (i=0;i<n-1;i++){
    if (a[i]+a[i+1]<=x) continue;
    ans+=a[i+1]+a[i]-x;
    if (a[i]>=x){
      a[i+1]=0;
      a[i]=x;
    }else a[i+1]=x-a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n, k;
llong a[200005];
llong f[200005];

bool check(llong k, llong t) {
    for (int i = 0; i < n; i++) {
        if (a[i] * f[i] > t) {
            k -= (a[i] * f[i] - t + f[i] - 1) / f[i];
        }
    }

    return k >= 0;
}

int main() {

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

    sort(a, a + n);
    sort(f, f + n, greater<>());

    llong valid = 1ll << 60ll;
    llong invalid = -1;

    while (valid - invalid > 1) {
        llong mid = (valid + invalid) / 2;

        if (check(k, mid)) {
            valid = mid;
        }
        else {
            invalid = mid;
        }
    }

    cout << valid << endl;

    return 0;
}


Measured memory_bytes: 3328
//#pragma GCC optimize(2)
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 1000
#define INF 0x3f3f3f3f
vector<int> G[MAXN+5];
void Addedge(int u,int v){
	G[u].push_back(v);
	return ;
}
int n,m,ans=INF,fa[MAXN+5],dep[MAXN+5];
void BFS(int S){
	queue<int> Q;
	memset(dep,0,sizeof(dep));
	memset(fa,-1,sizeof(fa));
	dep[S]=1,Q.push(S);
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		for(int i=0;i<int(G[u].size());i++){
			int v=G[u][i];
			if(dep[v]&&v!=S)
				continue;
			if(dep[v]){
				ans=min(ans,dep[u]);
				continue;
			}
			dep[v]=dep[u]+1,fa[v]=u;
			Q.push(v);
		}
	}
	return ;
}
void BFS1(int S){
	queue<int> Q;
	memset(dep,0,sizeof(dep));
	memset(fa,-1,sizeof(fa));
	dep[S]=1,Q.push(S);
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		for(int i=0;i<int(G[u].size());i++){
			int v=G[u][i];
			if(dep[v]&&v!=S)
				continue;
			if(dep[v]){
				if(ans==dep[u]){
					int tmp=u;
					do{
						printf("%d\n",tmp);
						tmp=fa[tmp];
					}while(tmp!=-1);
					exit(0);
				}
				continue;
			}
			dep[v]=dep[u]+1,fa[v]=u;
			Q.push(v);
		}
	}
	return ;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		int u=read(),v=read();
		Addedge(u,v);
	}
	for(int i=1;i<=n;i++)
		BFS(i);
	if(ans==INF){
		puts("-1");
		return 0;
	}
	printf("%d\n",ans);
	for(int i=1;i<=n;i++)
		BFS1(i);
	return 0;
}

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

int main(){
    int64_t h; cin >> h;
    int64_t n = 1;
    while(h > 0){
        h /= 2;
        n *= 2;
    }
    cout << n-1 << endl;
}

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

typedef long long ll;

ll N;
string X;
vector<ll> M;
vector<ll> W;
const ll MOD = 998244353;
string Y;
ll R;

ll count(ll m) {
  ll x = 0;
  for (ll i = 0; i < m; ++i) {
    (x = 2 * x + (X[i] - '0')) %= MOD;
  }
  Y = X;
  for (ll i = 0; i < N; ++i) {
    Y[i] = X[i % m];
    if ((i / m) % 2 == 1) Y[i] = Y[i] == '0' ? '1' : '0';
  }
  return Y <= X ? (x + 1) % MOD : x;
}
int main() {
  cin >> N >> X;
  for (ll d = 1; d <= N; d += 2)
    if (N % d == 0) M.push_back(N / d);
  W.resize(M.size());
  for (ll i = 0; i < M.size(); ++i) {
    W[i] = 2 * M[i] % MOD;
    for (ll j = 0; j < i; ++j) {
      if (M[j] % M[i] == 0) (W[i] += MOD - W[j]) %= MOD;
    }
    (R += W[i] * count(M[i]) % MOD) %= MOD;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef vector<int> vi;
typedef queue<int> qi;

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

    int n, m;
    cin >> n >> m;
    vi e[n];
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    int dis[n];
    fill(dis, dis+n, -1);
    dis[0] = 0;
    qi q;
    q.push(0);

    int p[n];

    while (!q.empty()) {
        int x = q.front();
        q.pop();

        for (int y : e[x]) {
            if (dis[y] == -1) {
                dis[y] = dis[x] + 1;
                p[y] = x;
                q.push(y);
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << p[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 10928
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

const int N_MAX = 1e5+5;

int n, a[N_MAX];

ll solve(bool parity) {
    ll cnt = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == parity && sum <= 0) {
            cnt += abs(sum) + 1;
            sum += abs(sum) + 1;
        } else if (i % 2 != parity && sum >= 0) {
            cnt += abs(sum) + 1;
            sum -= abs(sum) + 1;
        }
    }
    return cnt;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    cout << min(solve(0), solve(1)) << endl;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
	Scanner sc;
	int N;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		N = sc.nextInt();
		System.out.println(N*N*N);
	}

	public static void main(String[] args) {
		new Main().calc();
	}

}

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

using namespace std;

int W;

void output()
{

    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
}

int main()
{
    int H;
    string a, b;
    cin >> H >> W;

    output();

    cout << "" << endl;

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

    output();
}

Measured memory_bytes: 256