akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 1;
    int n = 0;
    ans = a * n - n + 1;
    while (ans < b)
    {
        n++;
        ans = a * n - n + 1;
    }

    cout << n << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

const int MXN = 1010;

ll s[MXN];

bool flag[MXN * MXN];
ll sc[MXN * MXN];

int main ()
{
	int n, k;
	scanf("%d%d", &n, &k);
	s[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &s[i]);
		s[i] = s[i - 1] + s[i];
	}
	int cnt = 0;
	for (int l = 0; l < n; l++)
	{
		for (int r = l + 1; r <= n; r++)
		{
			sc[cnt++] = s[r] - s[l];
		}
	}
	// cout << "cnt = " << cnt << endl;
	memset(flag, 1, sizeof(flag));
	ll ans = 0;
	for (int i = 50; i >= 0; i--)
	{
		int tmp = 0;
		for (int j = 0; j < cnt; j++)
		{
			if (flag[j] && (sc[j] >> i & 1) == 1)
			{
				tmp++;
			}
		}
		if (tmp >= k)
		{
			for (int j = 0; j < cnt; j++)
			{
				if ((sc[j] >> i & 1) == 0)
				{
					flag[j] = 0;
				}
			}
			ans = ans | (1ll << (ll)i);
		}
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 7168
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	H := scanInt()
	W := scanInt()
	h := scanInt()
	w := scanInt()

	fmt.Fprintln(wr, (H-h)*(W-w))
}


Measured memory_bytes: 640
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = [A, B, C, D, E]
a.sort(key=lambda x : (x-1) % 10)

ans = a[0]
for i in a[1:]:
    t = i % 10
    if t == 0:
        ans += i
    else:
        ans += 10 - t + i

print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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; }

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    string s;
    cin>>s;
    rep(i,s.length()){
        if(s[i]==','){
            s[i]=' ';
        }
    }
    cout<<s<<endl;
    return  0;
}


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

using ll = long long;
int main()
{
    ll l, r;
    cin >> l >> r;
        if (l / 2019 != r / 2019 )
    {
        cout << 0 << endl;
        return 0;
    }
    l %= 2019;
    r %= 2019;
    ll ans = 2020;
    for (int i = l; i <= r; i++)
    {
        for (int j = i + 1; j <= r; j++)
        {
            int now = (i * j) % 2019;
            if (i == j)
                continue;
            if (now <= ans)
                ans = now;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def sieve(n):
    res = list(range(n+10)) # nが小さい時よう
    res[0] = -1
    res[1] = -1
    i = 2
    while i*i<n:
        if res[i]<i:
            i += 1
            continue
        j = i*i
        while j<n:
            if res[j]==j:
                res[j] = i
            j += i
        i += 1
    return res

s = sieve(10**5+10)
acc = [0]*(10**5+10)
for i in range(2,10**5+9):
    if i%2==1 and s[i]==i and s[(i+1)//2]==(i+1)//2:
        acc[i+1] = acc[i]+1
    else:
        acc[i+1] = acc[i]

q = int(input())
res = [0]*q
for i in range(q):
    l,r = map(int, input().split())
    res[i] = acc[r+1]-acc[l]

for r in res:
    print(r)


Measured memory_bytes: 9696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
ll dp[2][2001];
int A[2000];

int main() {
	cin >> N;
	map<int, vector<int>> mm;
	REP(i, N) {
		scanf("%d", A + i);
		mm[A[i]].emplace_back(i);
	}
	
	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	
	int cnt = 0;
	for (auto it = mm.rbegin(); it != mm.rend(); ++it) {
		int a = it->fi;
		vector<int> elem = it->se;

		memset(dp[1], -1, sizeof(dp[1]));
		REP(i, cnt + 1) {
			// 左に i 個, 右に cnt - i 個確定
			if (dp[0][i] == -1) continue;
			
			// [0-左, 1-右][j] := j 個詰めたときの係数の総和
			vector<vector<ll>> dp2(2, vector<ll>(elem.size() + 1));
			
			reverse(ALL(elem));
			REP(j, elem.size()) {
				// j を左に入れる, j 個は左に確定している
				int idx = i + j;
				dp2[0][j + 1] = dp2[0][j] + abs(idx - elem[j]);
			}
			
			reverse(ALL(elem));
			REP(j, elem.size()) {
				// j を右に入れる, j 個は右に確定している
				int idx = N - 1 - (cnt - i + j);
				dp2[1][j + 1] = dp2[1][j] + abs(idx - elem[j]);
			}
			
			REP(j, elem.size() + 1) {
				// elem から j 個左に寄せる, elem.size() - j 個右に寄せる
				chmax(dp[1][i + j], dp[0][i] + (ll)a * (dp2[0][j] + dp2[1][elem.size() - j]));
			}
		}
		
		cnt += elem.size();
		memcpy(dp[0], dp[1], sizeof(dp[0]));
	}
	
	ll ans = 0;
	REP(i, N + 1) chmax(ans, dp[0][i]);
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

int main() {
  int n;
  cin >> n;
  ll ans = 1, MAX = pow(10, 18);
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  
  REP(i, n) {
    if (a[i] <= MAX / ans) {
      ans *= a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4036
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using namespace std;

int main()
{
    uint64_t N;
    cin >> N;
    uint64_t pl = 1;
    int i = 1;
    for (;; ++i)
    {
        uint64_t l = 1;
        for (int j = 1; j < i; ++j)
        {
            l += pow(26, j);
        }
        if (l > N)
            break;
        pl = l;
    }
    string s;
    N -= pl;
    while (N > 0)
    {
        char x = 'a' + (char)(N % 26);
        s.insert(s.begin(), x);
        N /= 26;
    }
    while (s.size() < i - 1)
        s.insert(s.begin(), 'a');
    cout << s;
    return 0;
}

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

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

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

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    sort(a.begin(),a.end());
    int ok = 0,ng = 1e9;
    while (ng-ok > 1) {
        int mid = (ok+ng)/2;
        ll cnt = 0;
        for (int i = 0;i < n;++i) cnt += a.end()-lower_bound(a.begin(),a.end(),mid-a[i]);
        (cnt >= m ? ok : ng) = mid;
    }
    ll ans = 0,cnt = 0;
    vector<ll> sums(n+1,0);
    for (int i = 0;i < n;++i) sums[i+1] = sums[i]+a[i];
    for (int i = 0;i < n;++i) {
        int j = upper_bound(a.begin(),a.end(),ok-a[i])-a.begin();
        ans += (n-j)*a[i]+sums[n]-sums[j];
        cnt += n-j;
    }
    ans += (m-cnt)*ok;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cassert>
#include <vector>
using namespace std;
typedef long long ll;

const ll inf = 1e18;

struct SegmentTree {
private:
    int n;
    vector<ll> node; 
public:
    SegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, inf);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, ll val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }
 
    ll getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return inf;
        if(a <= l && r <= b) return node[k];
        ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int N;
ll T,E;

ll res(vector<ll>& X){
    vector<ll> dp(N+1,inf);
    dp[0] = 0;
    for(int i=1;i<=N;i++){
        dp[i] = dp[i-1]+X[i]-X[i-1]+T;
        for(int j=1;j<=i-1;j++){
            dp[i] = min(dp[i],dp[j-1]+X[j]-X[j-1]+3*(X[i]-X[j])+max(T-2*(X[i]-X[j]),0LL));
        }
    }
    return dp[N]+(E-X[N]);
}

int main(){
    cin >> N >> E >> T;
    vector<ll> X(N+2,0),dp(N+2,0);
    for(int i=1;i<=N;i++){
        cin >> X[i];
        dp[i] = inf;
    }
    SegmentTree seg1(vector<ll>(N+2,inf)),seg2(vector<ll>(N+2,inf));
    X[N+1] = E;
    dp[0] = X[1];
    seg1.update(0,dp[0]-X[1]);
    seg2.update(0,dp[0]-3*X[1]);
    for(int i=1;i<=N;i++){
        dp[i] = dp[i-1]+X[i+1]-X[i]+T;
        int id = lower_bound(X.begin(),X.end(),X[i]-T/2)-X.begin();
        //cerr << i << " " << id << " " << seg1.getmin(id,i) << " " << seg2.getmin(0,id) << endl;
        dp[i] = min(dp[i],seg1.getmin(max(id-1,0),i)+T+X[i+1]);
        if(id>0) dp[i] = min(dp[i],seg2.getmin(0,id-1)+2*X[i]+X[i+1]);
        seg1.update(i,dp[i]-X[i+1]);
        seg2.update(i,dp[i]-3*X[i+1]);
    }
//    for(int i=0;i<=N;i++) cerr << dp[i] << (i!=N? " ":"\n");
    cout << dp[N] << endl;
    //cerr << res(X) << endl;
}


Measured memory_bytes: 8688
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#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=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int hash_min[256] = {};
    fill(hash_min, hash_min + 256, 50);
    REP(i, n){
        string s;
        cin >> s;
        int hash_buf[256] = {};
        REP(j, s.size()){
            hash_buf[(int)s[j]]++;
        }
        FOR(j, 'a', 'z'){
            hash_min[j] = min(hash_min[j], hash_buf[j]);
        }
    }

    string ans;
    FOR(j, 'a', 'z'){
        ans += string(hash_min[j], (char)j);
    }
    cout << ans << "\n";
    return 0;
}


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


int main() 
{
  int a;
  string s;
  cin>>a>>s;
  int len = s.size();
  if(len<=a)
  {
    cout<<s<<endl;
  }
  else
  {
    for(int i=a;i<len;i++)
    {
      s.pop_back();
    }
    cout<<s<<"..."<<endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fly ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define ll long long
const ll mxm = 100010;
using namespace std;

ll n,k;
ll dp[mxm];
ll ara[mxm];

ll fnc(ll i){
  if(i == n-1){
    return 0;
  }
  if(i >= n){
    return 9999999999;
  }
  if(dp[i] != -1)return dp[i];
  ll res = 9999999999;
  for(ll j = 1;j<=k;j++){
    res = min(res,abs(ara[i]-ara[i+j])+fnc(i+j));
  }
  dp[i] = res;
  return dp[i];
}

int main(int argc, char const *argv[]) {
  fly;
  cin >> n >> k;
  for(ll i = 0;i<n;i++){
    cin >> ara[i];
  }
  memset(dp,-1,sizeof(dp));
  cout << fnc(0) << endl;

  return 0;
}


Measured memory_bytes: 12980
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int n, m; 
	cin >> n >> m;
	vector<int> mati(n+1 , 0);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		mati[a]++;
		mati[b]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << mati[i] << endl;
	}

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;
int n,m;
int valid(int i, int j, int k, int l){
	if(i+k<0) return 0;
	if(i+k>=n) return 0;
	if(j+l<0) return 0;
	if(j+l>=m) return 0;
	if(i+k==i && j+l==j) return 0;
	if(i+k==i && (j+l==j || j+l==j-1 || j+l== j+1)) return 1;
	if(j+l==j && (i+k==i || i+k==i-1 || i+k==i+1)) return 1;
	return 2;
}

void solve(){
	cin>>n>>m;
	int r1,c1,r2,c2;
	cin>>r1>>c1>>r2>>c2;
	r1--;
	r2--;
	c1--;
	c2--;
	string s[n];
	rep(i,0,n) cin>>s[i];
	vii adj[n*m+1];
	rep(i,0,n){
		rep(j,0,m){
			if(s[i][j]=='.'){
				for(int k=-2;k<3;k++){
					for(int l = -2;l<3;l++){
						int o= valid(i,j,k,l);
						if(o==2){
							if(s[i+k][j+l]=='.'){
								adj[i*m+j].pb({(i+k)*m+(j+l),1});
							}
						}
						else if(o==1){
							if(s[i+k][j+l]=='.'){
								adj[i*m+j].pb({(i+k)*m+(j+l),0});
							}
						}
					}
				}
			}
		}
	}
	int dis[n*m+1];
	memset(dis,-1,sizeof(dis));
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
	q.push({0,r1*m+c1});
	while(!q.empty()){
		int cur = q.top().se;
		//cout<<cur<<endl;
		int d = q.top().fi;
		q.pop();
		if(dis[cur] == -1) dis[cur] = d;
		else continue;
		if(cur==r2*m+c2) break;
		for(auto i: adj[cur]){
			if(dis[i.fi]==-1){
				q.push({d+i.second, i.fi});
			}
		}
	}
	cout<<dis[r2*m+c2]<<endl;
}

int main(){
	io;
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}

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

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

    vector<int> v(n);
    
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int maxv = -2000000000;
    int minv = v[0];
    for(int i = 1; i < n; i++){
        maxv = max(maxv, v[i] - minv);
        minv = min(minv, v[i]);
    }
    cout << maxv << endl;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

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

int main() {
    int n; //??????????????°
    int W; //???????????¶???????????????
    int v[101]; //???????????? (?????°)
    int w[101]; //??????(??????)?????? (?????°)
    int dp[101][10001]; //dp[?????°+1][??????(??????)+1]????????????

    cin >> n >> W;
    rep(i,0,n) cin >> v[i] >> w[i];
    rep(i,0,W+1) dp[0][i] = 0;

    rep(i,0,n) {
        rep(j,0,W+1) {
            if(j < w[i]) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
    }

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

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

using ll = long long;
ll n;
ll f(ll i) {
  ll now = n;
  while (now >= i) {
    if (now % i == 0) now /= i;
    else now %= i;
  }
  return now;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> n;
  
  if (n == 2) {
    cout << 1 << '\n';
    return 0;
  }
  
  set<ll> x;
  
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      x.insert(i);
      x.insert(n / i);
    }
  }
  x.insert(n);
  
  n--;
  set<ll> y;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      y.insert(i);
      y.insert(n / i);
    }
  }
  y.insert(n);
  
  n++;
  set<ll> s;
  for (auto i = x.begin(); i != x.end(); i++) {
    if (f(*i) == 1) s.insert(*i);
  }
  
  cout << s.size() + y.size() << '\n';
}

Measured memory_bytes: 512
N = int(input())
H = list(map(int, input().split())) + [0]
az = [0]*(N+1)
ans = 0
while H != az:
    c = 0
    in_itv = False
    for i in range(N+1):
        if H[i] == 0:
            if in_itv:
                c += 1
                in_itv = False
            continue
        in_itv = True
        H[i] -= 1
    ans += c
print(ans)

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

#define ran 202202

int n;
string s[ran];

void upd(int &ma, vector<string> &ma_s, int cnt, string s) {
	if(cnt<ma) return;
	if(cnt>ma) {
		ma = cnt;
		ma_s.clear();
		ma_s.push_back(s);
	} else {
		ma_s.push_back(s);
	}
}

int main() {
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>s[i];
	}
	sort(s, s+n);
	
	int ma = 0;
	vector<string> ma_s;
	ma_s.clear();
	
	int cnt = 1;
	for(int i=1;i<n;i++)
		if(s[i] == s[i-1]) cnt++;
		else {
			upd(ma, ma_s, cnt, s[i-1]);
			cnt = 1;
		}
	upd(ma, ma_s, cnt, s[n-1]);
	
	for(int i=0;i<(int)ma_s.size();i++)
		cout<<ma_s[i]<<endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    vector<pair<string,int> > v;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        string s;
        int k;
        cin >> s >> k;
        v.push_back(make_pair(s, -k * 1000 - i - 1));
    }
    sort (v.begin(),v.end());
    for (int i = 0; i < n; i++){
        cout << - (v[i].second % 1000) << endl;
    }
    return 0;
}


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

int main()
{
    ll n,a,b;cin>>n>>a>>b;
    if(n%(a+b)<a){
        cout << n/(a+b)*a+n%(a+b) << endl;
    }
    else{
        cout << n/(a+b)*a+a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    int x[m];
    for(int i = 0;i < m;i++)
    {
        cin >> x[i];
    }
    sort(x,x + m);
    vector<int> v;
    for(int i = 0;i < m - 1;i++)
    {
        v.push_back(x[i + 1] - x[i]);
    }
    sort(v.begin(),v.end(),greater<int>());
    long long int ans = 0;
    for(int i = n - 1;i < v.size();i++)
    {
        ans += v.at(i);
    }
    cout << ans;

    return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// どういうDPか
// dp[i][j] := (i, j)から(H, W)までの経路数

// 計算方法
// dp[H-1][W-1] = 1
// dp[i][j] = dp[i+1][j] + dp[i][j+1]
// 右へ行く・下へ行くの2通り

// どういう順番
// H, Wに近い順からやっていく
ll dp[1010][1010];
string field[1010];
const ll mod = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    rep(i, H) cin >> field[i];

    dp[H-1][W-1] = 1;
    for (int y=H-1; y>=0; --y) {
        for (int x=W-1; x>=0; --x) {
            if (y == H-1 and x == W-1) continue;
            if (field[y+1][x] != '#') dp[y][x] += dp[y+1][x];
            if (field[y][x+1] != '#') dp[y][x] += dp[y][x+1];
            //dp[y][x] = dp[y+1][x] + dp[y][x+1];
            dp[y][x] %= mod;
        }
    }
    cout << dp[0][0] % mod << endl;
}


Measured memory_bytes: 9216
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final long X = sc.nextLong();
			final long Y = sc.nextLong();
			
			long count = 0;
			for(long x = X; x <= Y; x += x){ count++; }
			
			System.out.println(count);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b << ' '<<2 * (a + b) << endl;
}


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

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

    int res = int(B/A);
    if(res > C) res = C;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#
import sys
import math
import numpy as np
import itertools

# いくつか入力
x1, y1, x2, y2 = (int(i) for i in input().split())  

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy

print(x3,y3,x4,y4)



Measured memory_bytes: 22020
/*************************************************
       Author       :   NIYOUDUOGAO
       Last modified:   2018-08-01 09:00
       Email        :   pjm000@163.com
       Filename     :   t2.cpp
 *************************************************/
#include <bits/stdc++.h>
#define mset(a, x) memset(a, x, sizeof(a))
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
int a[N];
int vis[N];
ll fac[N], inv[N], f[N];
void init() {
	fac[0] = fac[1] = inv[0] = inv[1] = f[0] = f[1] = 1;
    for(int i = 2; i <= 100004; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = (mod - mod / i) * inv[mod % i] % mod;
        f[i] = f[i - 1] * inv[i] % mod;
    }
}
ll C(ll n, ll m) {
    return fac[n] * f[n - m] % mod * f[m] % mod;
}
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    init();
    int n;
    cin >> n;
    int Index1, Index2;
    for (int i = 1; i <= n + 1; i++) {
        cin >> a[i];
        if (vis[a[i]]) {
            Index1 = vis[a[i]] - 1;
            Index2 = i;
        }
        vis[a[i]] = i;
    }
    ll t1, t2;
    for (int i = 1; i <= n + 1; i++) {
        t1= C(n + 1, i) % mod;
        if (n + 1 - Index2 + Index1 >= i - 1) {
            t2 = C(n + 1 - Index2 + Index1, i - 1) % mod;
        } else {
            t2 = 0;
        }
        cout << (t1 - t2 + mod) % mod << "\n";
    }
    return 0;
}


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

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

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


    map<int, int> b;
    for( int i = 0; i < N; ++i ){
        if( b.find(a[i]+1) == b.end() ) b[a[i]+1] = 1;
        else b[a[i]+1] += 1;
        if( b.find(a[i]-1) == b.end() ) b[a[i]-1] = 1;
        else b[a[i]-1] += 1;
        if( b.find(a[i]) == b.end() ) b[a[i]] = 1;
        else b[a[i]] += 1;
    }

    int ans = 1;
    for( int i = 0; i < N; ++i )
        ans = ans < b[i] ? b[i] : ans;


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5376
n=int(input())
a=list(map(int,input().split()))
mina=min(a)
maxa=max(a)
powa= maxa if abs(mina)<abs(maxa) else mina
powa_i=a.index(powa)
ansl=[]
if powa<0:
  for i in range(n):
    if a[i]>=0:
      ansl.append(f"{powa_i+1} {i+1}")
  ansl.append(f"{powa_i+1} {n}")
  for i in reversed(range(1,n)):
    ansl.append(f"{i+1} {i}")
else:
  for i in range(n):
    if a[i]<=0:
      ansl.append(f"{powa_i+1} {i+1}")
  ansl.append(f"{powa_i+1} {1}")
  for i in range(1,n):
    ansl.append(f"{i} {i+1}")
print(len(ansl))
print("\n".join(ansl))
  

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  if(a < 9 && b < 9)
    out("Yay!");
  else
    out(":(");
  memi;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b; cin >> a >> b;
    int n;
    if(b/10){
        if(b/100) n = 1000*a + b;
        else n = 100*a + b;
    }
    else n = 10*a + b;

    for(int i=1; i*i<=n; i++){
        if(i*i == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int x, h, m, s;

  scanf("%d %d %d", &x,&h,&m);
if(x>h){
s=x;
x=h;
h=s;
}
if(x>m){
s=x;
x=m;
m=s;
}
if(h>m){
s=h;
h=m;
m=s;
}
printf("%d %d %d\n",x,h,m);
 
 
  return 0;
}


Measured memory_bytes: 2700
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while( cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil)break;
    if(isf++ > 0)printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next =x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i'){insert(key); np++; size++;}
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F')deleteFirst();
        else if(com[6] == 'L')deleteLast();
      }else{
        deleteKey(key); nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}

Measured memory_bytes: 32216
#include<cstdio>
using namespace std;
int main(){
  int n,p[20001],a;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    p[a]=i;
  }
  for(int i=1;i<=n;i++)
    printf("%d ",n*i);
  printf("\n");
  for(int i=1;i<=n;i++)
    printf("%d ",n*(n+1-i)+p[i]);
  printf("\n");
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

from math import sqrt


N, D = map(int, input().split())
XY = [tuple(map(int, input().split())) for _ in range(N)]

cnt = 0
for x, y in XY:
    d = sqrt(x * x + y * y)
    if d <= D:
        cnt += 1

print(cnt)


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

int main() {
  int A,B;
  cin >> A >> B;
  int max =0;
  for(int i =0;i<2;i++){
   if(A > B){
     max += A;
     A --;
   }else{
     max += B;
     B --;
   }
  }
  cout << max << endl;
}

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

class Main
{
	public static void main (String[] args) throws IOException
	{
		String A,B;
		int a,b,s,l;
		
		Scanner in = new Scanner(System.in);
		
		A = in.next();
		B = in.next();
		
		a = Integer.parseInt(A);
		b = Integer.parseInt(B);

		s = a * b;
		l = 2 * (a + b);
		
		System.out.println(s + " " + l);
	}
}

Measured memory_bytes: 17316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int MOD = (int)1e9 + 7;
int add(int x, int y)
{
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}

const int N = 21;
const int M = (1 << 19) + 5;
int n, m;
int a[N][N];
int dp[2][M];
int lowerBit[M];

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    for (int mask = 1; mask < M; mask++) {
        int k = 0;
        while(((mask >> k) & 1) == 0) k++;
        lowerBit[mask] = 1 << k;
    }

    int w;
    scanf("%d%d%d", &n, &m, &w);
    n--;
    for (int i = 0; i < m; i++)
        for (int j = 0; j < n; j++)
            a[i][j] = -1;
    while(w--) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        x--;
        y--;
        a[x][y] = z;
    }

    dp[0][0] = 1;

    for (int id = 0; id < m; id++)
        for (int k = 0; k < n; k++) {
            for (int mask = 0; mask < (1 << n); mask++)
                dp[1][mask] = 0;
            for (int mask = 0; mask < (1 << n); mask++) {
                if (dp[0][mask] == 0) continue;
                if (a[id][k] != 1 && ((mask >> k) & 1) == 0) {
                    dp[1][mask] = add(dp[1][mask], dp[0][mask]);
                }
                if (a[id][k] != 0) {
                    int nmask = mask ^ lowerBit[mask & ((1 << n) - (1 << k))] ^ (1 << k);
                    dp[1][nmask] = add(dp[1][nmask], dp[0][mask]);
                }
            }
            for (int mask = 0; mask < (1 << n); mask++)
                dp[0][mask] = dp[1][mask];
        }

    int ans = 0;
    for (int mask = 0; mask < (1 << n); mask++)
        ans = add(ans, dp[0][mask]);
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main() {
    int A[200];
    int N = 0, i, count = 0, flag = 1;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    while (1) {
        for (i = 0; i < N; i++) {
            if (A[i] % 2 != 0) {
                flag = 0;
                break;
            }
            A[i] = A[i] / 2;
        }
        if (flag == 0) {
            break;
        } else {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ld long double
#define pb push_back
#define N 10000007
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	ll x,n,i;
	cin>>x>>n;
	int a[n];
	map<int,int>mp;
	for(i=0;i<n;i++){
	cin>>a[i];
	mp[a[i]]++;
	}
	ll ans=x,ans2=0;
	for(i=0;i<=105;i++){
		if(mp[i]==0){
			if(abs(x-i)<ans){
				ans=abs(x-i);
				ans2=i;
			}
		}
	}
	cout<<ans2;
}


Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    string S;
    cin >> S;
    ll N = S.length();
    ll a = 0;
    ll b = 0;
    ll c = 0;
    rep(i,N){
        if(S[i]=='a') a++;
        else if(S[i]=='b') b++;
        else c++;
    }
    string out = "YES";
    if(N==1) out = "YES";
    else if(N==2&&(a>1||b>1||c>1)) out = "NO";
    else{
        ll n = N/3;
        if(N%3!=0) n++;
        if(a>n||b>n||c>n) out = "NO";
    }
    cout << out << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}
const ll MAX = MOD;

void solve(){
  ll a,b,c,d; cin>>a>>b>>c>>d;
  ll ans = a*c;
  chmax(ans,a*c);
  chmax(ans,a*d);
  chmax(ans,b*c);
  chmax(ans,b*d);
  cout << ans << "\n";
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    double r;
    cin >> r;
    double S = M_PI * r * r; //Sは面積
    double C = M_PI * 2 * r; //Cは円周
    cout << fixed << setprecision(6) << S << " " << C << endl;
}


Measured memory_bytes: 3288
#include<stdio.h>
int main()
{
    int A,B,C,D,E=0;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    while(A>0 && C>0)
    {
        if(E%2 == 0)
        {
            C=C-B;
            E++;
        }
        else
        {
            A=A-D;
            E++;
        }
    }
    if(A<=0)  printf("No\n");
    else printf("Yes\n");
}


Measured memory_bytes: 1620
#include <stdio.h>
#include <iostream>
using namespace std;
 
int main(int argc, char *argv[])
{
  int a=0, b=0;
  scanf("%d %d", &a, &b);
  if(a<b)
    cout << "a < b" << '\n';
  else if(a==b)
    cout << "a == b" << '\n';
  else
    cout << "a > b" << '\n';
 
  return 0;
}

Measured memory_bytes: 1172
from bisect import bisect_left,bisect
import sys

n,h=map(int,input().split())
#ab=[[0]*2 for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(n):
#    ab[i]=map(int,input().split())
    a[i],b[i]=map(int,input().split())
 
amax=max(a)    
b.sort()
ii=bisect(b,amax)
b=b[ii:]
b.reverse()

icnt=0
for bi in b:
    icnt+=1
    h=h-bi
    if h<=0:
        print(icnt)
        sys.exit()

di=(h-1)//amax+1
print(icnt+di)
        

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    if(n == k){
        cout << 0 << endl;
        return 0;
    }else if(n < k){
        cout << min(n,abs(k-n)) << endl;
        return 0;
    }else{
        ll tmp = n%k;
        cout << min(tmp,abs(k-tmp)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

static const int32_t limit{ 30000 };

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

	int32_t p_i;
	vector<int32_t> a(n, 0), b(n, 0);
	for (auto i = 1; i <= n; ++i) {
		cin >> p_i;
		a[i - 1] += limit * i;
		b[i - 1] += limit * (n - i) ;
		b[p_i - 1] += i;
	}

	for (auto itr = a.cbegin(); itr != a.cend(); ++itr) cout << *itr << ' ';
	cout << '\n';
	for (auto itr = b.cbegin(); itr != b.cend(); ++itr) cout << *itr << ' ';
	cout << '\n';
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair
#define vd vector<double>
#define vdd vector<vd>

int main() {
  int t, x;
  cin >> t >> x;
  cout << t / (double) x << endl;
}


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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  int n1 = a1.size();
  int n2 = a2.size();
  if (n1 != n2) {
    return n1 - n2;
  }
  for (int i=0; i<n1; i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

vector<vector<int>> all_comb(int n, int k) {
  vector<vector<int>> combs(nCr(n, k), vector<int>(k));
  for(int i=0; i<k; i++) {
    combs[0][i] = i;
    combs[1][i] = i;
  }
  
  for(long i=1; i<nCr(n, k); i++) {
    int p = 1;
    while(combs[i][k - p] == n - p) {
      p++;
      if(p > k) {
        break;
      }
    }
    combs[i][k - p]++;
    int q = combs[i][k - p];
    for(int j=1; j<p; j++) {
      combs[i][k - p + j] = q + j;
    }

    if(i < nCr(n, k) - 1) {
      for(int j=0; j<k; j++) {
        combs[i + 1][j] = combs[i][j];
      }
    }
  }

  return combs;
}

template <typename TYPE> void co(TYPE a) {
  cout << a << endl;
}

template <typename TYPE> void co_2(TYPE a, TYPE b) {
  cout << a << ' ' << b << endl;
}

template <typename TYPE> void co_l(vector<TYPE> as) {
  int n = as.size();
  for(int i=0; i<n; i++) {
    cout << as[i] << endl;
  }
}

template <typename TYPE> void co_s(vector<TYPE> as) {
  int n = as.size();
  for(int i=0; i<n; i++) {
    if(i > 0) {
      cout << ' ';
    }
    cout << as[i];
  }
  cout << endl;
}

int main() {
  std::cout << std::setprecision(9);
  long a, b, n;
  cin >> a >> b >> n;

  if(b > n) {
    cout << (a * n) / b << endl;
  }
  else {
    cout << (a * (b - 1)) / b << endl;
  }
}

Measured memory_bytes: 3600