akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << a << endl;}
template<class T> void writes(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
void write(double a){cout << fixed << setprecision(12) << a << endl;}
void write(long double a){cout << fixed << setprecision(12) << a << endl;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
	int n,l;
    string a[100];
    cin>>n>>l;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    string res="";
    rep(i,n)res+=a[i];
    write(res);
    return 0;
}

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    S = []
    for _ in range(n):
        S.append(input_int())
    ans = sum(S)
    S.sort()
    if ans % 10 != 0:
        print(ans)
        return
    else:
        for s in S:
            if s % 10 != 0:
                print(ans - s)
                return
    print(0)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61768
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    int m;
    cin>>n>>m;
    vector<int> v(n,0);
    rep(i,n) cin>>v[i];
    int sum=0;
    rep(i,n) sum+=v[i];
    int cnt=0;
    for(int i=0;i<n;i++){
        if(v[i]*(4*m)>=sum){
            cnt++;
        }
    }
    if(cnt>=m){
                cout<<"Yes"<<endl;
                return 0;
            }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
class a
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        for(int i = 0; i < n; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }
        int max0 = 0;
        int point0 = 0;
        for(int i = 0; i < n; i++)
        {
            if (a[i] > max0)
            {
                max0 = a[i];
                point0= i;
            }
        }
        int max1 = 0;
        int point1 = 0;
        for (int i = 0; i < n; i++)
        {
            if (i!=point0&&a[i] > max1)
            {
                max1 = a[i];
                point1 = i;
            }
        }
        for (int i = 0; i < n; i++)
        {
            if (i != point0)
            {
                Console.WriteLine(max0);
            }
            else
            {
                Console.WriteLine(max1);
            }
        }



    }
}

Measured memory_bytes: 18608
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	int n;
	while (cin >> n) {
		int MIN = 1000, MAX = -1000;
		int in[200];
		for (int i = 0; i < n; ++i) {
			cin >> in[i];
			MIN = MIN < in[i] ? MIN : in[i];
			MAX = MAX > in[i] ? MAX : in[i];
		}
		long long  ans = 1e9;
		for (int i = MIN; i <= MAX; ++i) {
			long long sum = 0;
			for (int j = 0; j < n; ++j) {
				sum += (in[j] - i) * (in[j] - i);
			}
			ans = ans < sum ? ans : sum;
		}
		cout << ans << endl;
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,C;
int D[40][40];
int bef[510][510];
void solve() {
    int i,j,k,l,r,x,y; string s;
    bool exit = false;
    cin>>N>>C;
    FOR(i,C){
        FOR(j,C){
            cin>>D[i][j];
        }
    }  
    FOR(i,N){
        FOR(j,N){
            cin>>bef[i][j];
            bef[i][j] -= 1;
        }
    }
    int color0,color1,color2,aft;
    ll ret = LLONG_MAX;
    ll cost0[C],cost1[C],cost2[C];
    FOR(aft,C){
        ll _cost0=0,_cost1=0,_cost2=0;
        FOR(i,N){
            FOR(j,N){
                if((i+j)%3==0){
                    _cost0 += D[bef[i][j]][aft];
                }else if((i+j)%3==1){
                    _cost1 += D[bef[i][j]][aft];
                }else{
                    _cost2 += D[bef[i][j]][aft];
                }
            }
        }
        cost0[aft] = _cost0;
        cost1[aft] = _cost1;
        cost2[aft] = _cost2;
    }
    FOR(color0,C){
        FOR(color1,C){
            if(color1==color0) continue;
            FOR(color2,C){
                if(color2==color0 || color2==color1) continue;
                ll cand = cost0[color0]+cost1[color1]+cost2[color2];
                if(ret>cand){
                    ret = cand;
                }
            }
        }
    }
    cout<<ret<<endl;
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll H,W;cin>>H>>W;
  if(H%3==0 || W%3==0) cout<<0<<endl;
  else{
    ll tmp=1e18;
    rep(i,W){
      ll block1,block2,block3;
      block1=i*H;
      block2=(W-i)*((H+1)/2);
      block3=(W-i)*(H/2);
      tmp = min(tmp,max(block1,max(block2,block3))-min(block1,min(block2,block3)));
    }
    rep(i,W){
      ll block1,block2,block3;
      block1=i*H;
      block2=((W-i+1)/2)*H;
      block3=((W-i)/2)*H;
      tmp = min(tmp,max(block1,max(block2,block3))-min(block1,min(block2,block3)));
    }
    rep(j,H){
      ll block1,block2,block3;
      block1=j*W;
      block2=(H-j)*((W+1)/2);
      block3=(H-j)*(W/2);
      tmp = min(tmp,max(block1,max(block2,block3))-min(block1,min(block2,block3)));
    }
    rep(j,W){
      ll block1,block2,block3;
      block1=j*W;
      block2=((H-j+1)/2)*W;
      block3=((H-j)/2)*W;
      tmp = min(tmp,max(block1,max(block2,block3))-min(block1,min(block2,block3)));
    }
    cout << tmp << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << 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;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

ll gcd(ll a, ll b) {
  return (b == 0ll ? a : gcd(b, a % b));
}

void dfs(const string &s, int pos, ll &ans, vector<ll> vec) {
  if (pos >= s.size()) {
    ans += accumulate(all(vec), 0ll);
    return;
  }
  ll d = (ll)(s[pos] - '0');
  if (!vec.empty()) {
    auto v = vec;
    ll a = v.back();
    v.pop_back();
    v.push_back(a * 10ll + d);
    dfs(s, pos + 1, ans, v);
  }
  vec.push_back(d);
  dfs(s, pos + 1, ans, vec);
}

void solve() {
  string s;
  cin >> s;
  ll ans = 0ll;
  vector<ll> work;
  dfs(s, 0, ans, work);
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> l(n);
		REP(i, n) cin >> l[i];
		sort(ALL(l));
		LL ans = 0;
		REP(i, n) REP(j, i) {
			auto lite = upper_bound(l.begin(), l.begin() + j, l[i] - l[j]);
			auto rite = lower_bound(l.begin(), l.begin() + j, l[i] + l[j]);
			ans += rite - lite;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

string s; 
int n, c, d;
map<P,bool> memo;

bool dfs(int now, int g) {
    if (now == g) return true;
    if (now > g) return false;
    bool res = false;
    if (s[now+1] != '#' && dfs(now+1,g)) res = true;
    if (s[now+2] != '#' && dfs(now+2,g)) res = true;
    return res;
}

int main() {
    int a, b; 
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;
    if (c < d) {
        if (dfs(a,c) && dfs(b,d)) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        for (int i = b; i <= d; i++) {
            if (s[i-1] == '#' || s[i] == '#' || s[i+1] == '#') continue;
            if (dfs(a,i-1) && dfs(b,i) && dfs(a+1,c) && dfs(b,d)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265

#define MAX 100001

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

    int n , k;
    cin >> n >> k;
    int v;
    int pos;
    for (int i = 0; i < n; i++) {
        cin >> v;
        if (v == 1) {
            pos = i + 1;
        }
    }
    k--;
    int ans = INT_MAX;
    int reml = 0 , remr = 0;
    for (int i = 0; i <= k; i++) {
        remr = n - (pos + i);
        reml = (pos - (k + 1 - i));
        //cout << remr << " " << reml << endl;
        ans = min(ans , (remr >= 0 ? remr / k + (remr % k > 0) : 1) + 1 + (reml >= 0 ? reml / k + (reml % k > 0) : 1));
        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;
map<pair<ll, ll>, ll> m;
vector<ll> x(50);
ll n, a;
ll ret(ll i, ll su) {
	i++;
	if (i == n) {
		if (su == 0)return 1;
		else return 0;
	}
	ll res = 0;
	if (m.find({ i,su }) == m.end()) m[{i, su}] = ret(i, su);
	res += m[{i, su}];
	su += x[i];
	if (m.find({ i,su }) == m.end()) m[{i, su}] = ret(i, su);
	res += m[{i, su}];
	return res;
}


int main() {
	cin >> n >> a;
	rep(i, n) {
		ll buf; cin >> buf;
		x[i] = buf - a;
	}
	ll ans = ret(-1, 0)-1;
	cout << ans << endl;
}

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

int main() {
  string S,T;
  cin>>S>>T;
  int N=S.size(),M=T.size(),Z=0;
  for(int i=N-M;i>=0;i--){
    int A=0;
    for(int j=0;j<M;j++){
      if(!(S.at(i+j)=='?'||S.at(i+j)==T.at(j))){
        A++;
        break;
      }
    }
    if(A==0){
      Z++;
      for(int j=0;j<M;j++){
      S.at(i+j)=T.at(j);
      }
      break;
    }
  }
  if(Z==0){
    cout<<"UNRESTORABLE"<<endl;
  }
  else{
    for(int i=0;i<N;i++){
      if(S.at(i)=='?'){
        S.at(i)='a';
      }
    }
    cout<<S<<endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  string s,t;
  cin>>s>>t;
  ll n=s.length();
  string ss=t.substr(0,n);
  if(ss==s)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
    cin >> s;
    if(s[0]=='7' || s[1] == '7' || s[2] == '7'){
      cout << "Yes" << endl;
    }
	else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int a, b, c, x;
	int ans = 0;
	cin >> a >> b >> c >> x;
	for(int i = 0;i <= a;i++){
		for(int j = 0;j <= b;j++){
			int last = x - 500*i - 100*j;
			if(last < 0) continue;
			if(last <= 50*c) ans++;
		}
	}

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        int l = 0, r = N-1;
        ll val = 0;
        vector<bool> visited(N);
        while (r > i and !visited[l] and !visited[r] and l != r) {
            visited[l] = visited[r] = 1;
            val += A[l] + A[r];
            chmax(ans,val);
            l += i;
            r -= i;
        }
    }

    cout << ans << ln;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int a[] =new int[n];
    int b[] =new int[n-1];
    int count = 0;
    
    //入力値を配列に格納
    for(int i = 0; i < n-1; ++i){
      b[i] = sc.nextInt();
    }
    
    a[0] = b[0];
    a[n-1] = b[n-2];
    
    for(int i = 1; i < n-1; ++i){
      a[i] = Math.min(b[i-1],b[i]);
    }
    
    
    for(int i = 0; i < n; ++i){
      count += a[i];
    }

    System.out.println(count);
  }
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
ll A,B,N, x;

void solve(){
    if(A == 1 || B==1){
        cout << 0 << endl;
        return;
    } 

    if(N < B){
        x = N;
        cout << floor((A*x)/B) << endl;
    } else{
        cout << floor((A*(B-1))/B) << endl;
    }
}

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

    solve();
}


Measured memory_bytes: 3716
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x;
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MD = 1e9+7;
//......Variables........
ll a,b,c,x,y,z,re;
//......Funcs............

//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>a>>b>>c;
    if(a==b&&b==c&&a%2==0)
    {
        cout<<-1;
        return 0;
    }
    while(a%2==0&&b%2==0&&c%2==0)
    {
        re++;
        x=a;
        y=b;
        z=c;
        a=z/2+y/2;
        b=x/2+z/2;
        c=x/2+y/2;
    }
    cout<<re;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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

int main() {
  ll N;
  cin>>N;
  ll a[N];


  FOR(i,0,N-1){
    cin>>a[i];
  }

  sort(a,a+N);

  ll max1=-1;
  ll max2=-1;

  for(ll i=N-1;i>=1;i--){
    if(a[i]==a[i-1]){
//cout<<"hit"<<i<<endl;
      if(max1==-1){
        max1=a[i];
        i--;
      }else if(max2==-1){
        max2=a[i];
        i--;

        cout<<max1*max2<<endl;
        return 0;
      }
    }
  }

cout<<"0"<<endl;
return 0;

}
 


Measured memory_bytes: 1024
a=''
while True:
    try:
        a+=input().lower()
    except EOFError:
        break
    a=list(a)
for i in range(ord('a'),ord('z')+1):
    print(chr(i),end='')
    print(' : ',end='')
    k=0
    for j in range((len(a))):
        if a[j]==chr(i):
            k+=1
    print(k)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int h,w;
string st[21];
int l[21][21];
int xx[4]={1,-1,0,0};
int yy[4]={0,0,-1,1};
int bfs(pair<int,int> a,pair <int,int> b){
	// cout << a.f << " " << a.s << " ;  " << b.f << " " << b.s << endl;

	memset(l,-1,sizeof l);
	if(a==b)return 0;
	queue <pair <int,int> > q;
	q.push(a);
	l[a.f][a.s]=0;
	while(!q.empty()){
		if(q.front()==b)
			return l[b.f][b.s];
		int x=(q.front()).f,y=(q.front()).s;
		q.pop();
		for(int i=0;i<4;i++){
			int nx=x+xx[i],ny=y+yy[i];
			if(nx>=0 and nx<h and ny>=0 and ny<w and st[nx][ny]=='.' and l[nx][ny]==-1){
				q.push({nx,ny});
				l[nx][ny]=l[x][y]+1;
				// cout << nx << " " << ny << " f " << l[nx][ny] << endl;
			}
		}
	}
	return 0;
}
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin >> h >> w;
	for(int i=0;i<h;i++)
		cin >> st[i];
	int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(st[i][j]=='#')continue;
			for(int x=0;x<h;x++){
				for(int y=0;y<w;y++){
					if(st[x][y]=='#')continue;
					ans=max(ans,bfs({i,j},{x,y}));
				}
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int fact(int n){
    if(n==0){
        return 1;
    }
    else{
        return n*fact(n-1);
    }
}
int main(){
    int n;
    cin>>n;
    vector<double> x(n),y(n);
    vector<int> v(n);
    rep(i,n){
        cin >> x[i]>>y[i];
        v[i]=i;
    }
    double sum=0;
    sort(v.begin(), v.end());
    do {
        for(int i=0;i<n-1;i++){
        sum += sqrt(pow(x[v[i+1]]-x[v[i]],2)+pow(y[v[i+1]]-y[v[i]],2));
        }
    } while (next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10);
    cout << sum/fact(n) <<endl;

}

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

struct Edge {
	int to;
	int64_t dist{1};

	// int64_t cost;
	// int from;
	// int rev_i;
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

std::tuple<int, int, decltype(Edge::dist)> calcTreeDiameter(const std::vector<std::vector<Edge>>& edges)
{
	using Dist = decltype(Edge::dist);
	using pid = std::pair<int, Dist>;

	pid one_side{0, 0};
	std::stack<pid> dfs;
	dfs.push(one_side);
	std::vector<bool> visited(edges.size());

	while (!dfs.empty())
	{
		auto now{dfs.top()};
		dfs.pop();
		visited[now.first] = true;
		if (now.second > one_side.second)
			one_side = now;
		for (auto& e: edges[now.first])
			if (!visited[e.to])
				dfs.push({e.to, now.second + e.dist});
	}
	pid another_side{one_side.first, 0};
	dfs.push(another_side);
	std::fill(visited.begin(), visited.end(), false);
	while (!dfs.empty())
	{
		auto now{dfs.top()};
		dfs.pop();
		visited[now.first] = true;
		if (now.second > another_side.second)
			another_side = now;
		for (auto& e: edges[now.first])
			if (!visited[e.to])
				dfs.push({e.to, now.second + e.dist});
	}
	return std::make_tuple(one_side.first, another_side.first, another_side.second);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
	using ve = std::vector<Edge>;
	using vve = std::vector<ve>;

	int n;
	scanf("%d", &n);
	vve graph(n);
	for (int i{}; i < n - 1; i++)
	{
		int s, t, w;
		scanf("%d%d%d", &s, &t, &w);
		graph[s].push_back({t, w});
		graph[t].push_back({s, w});
	}
	printf("%lld\n", std::get<2>(calcTreeDiameter(graph)));
	return 0;
}


Measured memory_bytes: 10716
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}

int main() {
	int n;
	cin >> n;
	hei(string) s(n);
	rep(i, 0, n) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	int ans = 1;
	rep(i, 0, n - 1) {
		if (s[i] != s[i + 1])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9520
/***************************************************
	> File Name: Unkown_Error.cpp
	> Author: Zcorpio
	> Mail: 1113043195@qq.com 
	> Created Time: [Data_Deleted]
***************************************************/
#include<bits/stdc++.h>
#define int long long
#define rint register int
#define mst(a,b) memset(a,b,sizeof(a))
#define go(u) for(int i=head[u],v=to[i];i;v=to[i=nxt[i]])
#define F(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
#define R(i,a,b) for(register int i=(a),i##_end=(b);i>=i##_end;--i)
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
//const int mod=1e9+7;
//const int mod=998244353;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
/*
template<typename T> inline T max(T a,T b){return a>b?a:b;}
template<typename T> inline T min(T a,T b){return a<b?a:b;}
template<typename T> inline T abs(T a){return a>0?a:-a;}
template<typename T> inline bool chkmin(T &a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool chkmax(T &a,T b){return a>b?a=b,1:0;}
template<typename T> inline T gcd(T a,T b){T t;if(a<b)
{while(a){t=a;a=b%a;b=t;}return b;}else{while(b){t=b;b=a%b;a=t;}return a;}}
template<typename T> inline T sqr(T x){return x*x;}
inline void write(T k,char ch=0)
{
	if(k<0)k=-k,putchar('-');
	if(k>=10)write(k/10);
	putchar(k%10+'0');
	if(ch)putchar(ch);
}
inline void add(int u,int v)
{
	cnt++;
	nxt[cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
*/
inline int read()
{
	int x=0;
	bool f=0;
	char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') f=1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return f?-x:x;
}
const int maxn=1e6+3;
int a[maxn],f[maxn],n;
ll maxa=-1,maxf=-1,k;
bool chk(ll x)
{
	ll tmp=k;
	F(i,1,n)
	{
		ll qw=x/f[n-i+1];
		if(a[i]>qw) tmp-=(a[i]-qw);
	}
	if(tmp<0) return false;
	else return true;
}
signed main()
{
	//File("");
	n=read(),k=read();
	F(i,1,n) a[i]=read();
	F(i,1,n) f[i]=read();
	sort(a+1,a+n+1);
	sort(f+1,f+n+1);
	ll l=0,r=(ll)a[n]*f[n],ans=0;
	while(l<r)
	{
		ll mid=(l+r)>>1;
		if(chk(mid))
			r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 6016
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h, a;
  cin >> h >> a;
  if (h % a)
    cout << h / a + 1 << endl;
  else
    cout << h / a << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    for a in A:
        if a==3:
            try:
                A.remove(2)
            except:
                pass
        elif a==5:
            try:
                A.remove(2)
            except:
                pass
            try:
                A.remove(3)
            except:
                pass
        elif a==9:
            try:
                A.remove(6)
            except:
                pass
    d={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
    l=[d[x] for x in A]
    dp=[[0]*(N+1) for _ in range(len(l)+1)]
    prev_w=[[0]*(N+1) for _ in range(len(l)+1)]
    real_w=[[0]*(N+1) for _ in range(len(l)+1)]
    for num in range(len(l)):
        for w in range(N+1):
            if w>=l[num]:
                if dp[num+1][w]<dp[num+1][w-l[num]]+1 and real_w[num+1][w-l[num]]+l[num]==w:
                    dp[num+1][w]=dp[num+1][w-l[num]]+1
                    prev_w[num+1][w]=w-l[num]
                    real_w[num+1][w]=w
            if dp[num+1][w]<dp[num][w]:
                dp[num+1][w]=dp[num][w]
                prev_w[num+1][w]=w
                real_w[num+1][w]=w
    l2=[]
    cur_w=N
    for num in range(len(l)-1,-1,-1):
        while True:
            if prev_w[num+1][cur_w]==cur_w-l[num]:
                l2.append(str(A[num]))
                cur_w=prev_w[num+1][cur_w]
            else:
                cur_w=prev_w[num+1][cur_w]
                break
    print(''.join(l2))

if __name__ == '__main__':
    main()


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

int main(){
	
	int t = 1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		string s;
		map<string, int> m;
		for(int i = 0; i < n; ++i){
			cin >> s;
			if(m.find(s) != m.end()) m[s]++;
			else{
				m.insert(pair<string, int>(s, 1));
			}
		}
		//cout << m["buffalo"];
		int mx = 0;
		for(auto it = m.begin(); it!= m.end(); ++it){
			if(it->second > mx) mx = it->second;
		}
		for(auto it = m.begin(); it!= m.end(); ++it){
			if(it->second == mx) cout << it->first << '\n';
		}
		
	}
	return 0;
}

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

int main(void){
  int n,a,max;
  unsigned long long ans=0;

  std::cin >> n >> max;

  for(int i=1;i<n;i++){
    std::cin >> a;
    if(max>a){ ans += max-a; }
    else max=a;
  }
  
  std::cout << ans;
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
using namespace std;

int n,m,len; char s[1000009];
int main(){
	scanf("%d%s%d",&n,s+1,&m);
	while (m--){
		scanf("%d",&len);
		int i; ll now=0,ans=0,sd=0,sm=0;
		for (i=1; i<=n; i++){
			if (i>len){
				if (s[i-len]=='D'){ sd--; now-=sm; }
				if (s[i-len]=='M') sm--;
			}
			if (s[i]=='D') sd++; else
			if (s[i]=='M'){ sm++; now+=sd; }
			else if (s[i]=='C') ans+=now;
		}
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 1408
N=int(input())
S=[]
T=[]
for _ in range(N):
    s,t=input().split()
    S.append(s)
    T.append(int(t))
X=input()

ans=0
sleep=False
for s,t in zip(S,T):
    ans+=t if sleep else 0
    if s==X:
        sleep=True
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin >>s;
  ll ss=s.size(),ans=0,ans1=0;
  for(ll i=0;i<ss;i++){
    if(i%2==0){
      if(s[i]!='0') ans++;
    }
    else{
      if(s[i]!='1') ans++;
    }
  }
  for(ll i=0;i<ss;i++){
    if(i%2==0){
      if(s[i]!='1') ans1++;
    }
    else{
      if(s[i]!='0') ans1++;
    }
  }
  cout <<min(ans,ans1)<<endl;
}


Measured memory_bytes: 512
// In the name of Allah
// #Isart

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 1e5 + 10;
ll a[MAXN], dp[MAXN], ps[MAXN];
int r[MAXN];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n, s = 1;
	cin >> n;
	
	for(int i = 0; i < n; i ++){
		char ch = '+';
		if(i) cin >> ch;
		if(ch == '+') s = 1;
		else s = -1;
		cin >> a[i];
		a[i] *= s;
	}	
	for(int i = n - 1; i > -1; i --)
		ps[i] = ps[i + 1] + abs(a[i]);

	for(int i = n - 1; i > -1; i --){
		if(a[i] > 0 and a[i + 1] <= 0) r[i] = i;
		else r[i] = r[i + 1];
	}

	for(int i = n - 1; i > -1 ; i --){
		if(a[i] >= 0) dp[i] = dp[i + 1] + a[i];
		else if(a[i] < 0 and a[i + 1] < 0)
			dp[i] = a[i] + ps[i + 1];
		else if(a[i] < 0 and a[i + 1] > 0)
			dp[i] = max(a[i] + dp[i + 1], 2 * ps[r[i] + 1] - ps[i]);
		
	}
	cout << dp[0] << endl;

//	system("pause");
	return 0;	
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    ll a=sqrt(n), b;
    while(true){
        if(n % a == 0){
            b = n / a;
            break;
        }
        else a--;
    }

    out(a+b-2);
}

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

const int mn=2006,mod=1e9+7;
int fac[mn],inv[mn];

int poww(int a,int b)
{
	LL ans=1,tp=a;
	while(b) {
		if(b&1) ans=ans*tp%mod;
		tp=tp*tp%mod;
		b>>=1;
	}
	return ans;
}

int calc(int n,int m)
{
	if(m>n) return 0;
	return (1ll*fac[n]*inv[m]%mod)*inv[n-m]%mod;
}

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	fac[0]=inv[0]=1;
	for(int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=poww(fac[n],mod-2);
	for(int i=n-1;i>=1;--i) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for(int i=1;i<=k;++i) {
		LL ans=1ll*calc(k-1,i-1)*calc(n-k+1,i)%mod;
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] str = s.split("");
        int max = 0;
        int count = 0;
        for (int i = 0; i < str.length; i++) {
            if ("A".equals(str[i]) || "C".equals(str[i])
                    || "G".equals(str[i]) || "T".equals(str[i])) {
                count++;
            } else {
                count = 0;
            }
            if (count > max) {
                max = count;
            }
        }
        System.out.println(max);
    }

}


Measured memory_bytes: 22736
#include <iostream>
#include <string>
#include <numeric>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);

	for (int i = 0; i < M; ++i) {
		cin >> L[i] >> R[i];
	}
  int Rmin = *min_element(R.begin(), R.end());
  int Lmax = *max_element(L.begin(), L.end());
  if(Rmin>=Lmax){
    cout<<Rmin-Lmax+1<<endl;
  }
  else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a*b)%2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 22612
#include <iostream>

using namespace std;

int main(){
	int K = 0;
  	int N = 0;
  	int max = 200000;
  	int a[max] = {};
    cin >> K >> N;
  	int i = 0;
  	while(cin >> a[i]) {
    	i++;
    }
  	int max_dist = K - a[N-1]+a[0];
    for (int i = 0; i < N-1; i++) {
    	if (max_dist < (a[i+1]-a[i])) {
        	max_dist = (a[i+1]-a[i]);
        }
    }
  	cout << K-max_dist << endl;
	return 0;
  
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
#define all(x) x.begin(),x.end()
typedef pair<int,int>pii;

int p[2][200001];
int r[2][200001];
int uni(int j,int i){
	return p[j][i]=p[j][i]&&p[j][i]!=i?uni(j,p[j][i]):i;
}

int N,KL[2];
pair<pii,int>s[200001];
int ans[2000001];

main(){
	cin>>N>>KL[0]>>KL[1];
	for(int j=0;j<2;++j){
		for(int i=0;i<KL[j];++i){
			int a,b;
			scanf("%d%d",&a,&b);
			a=uni(j,a);
			b=uni(j,b);
			if(a!=b){
				if(r[j][a]<r[j][b]){
					p[j][a]=b;
				}else{
					p[j][b]=a;
					if(r[j][a]==r[j][b]){
						++r[j][a];
					}
				}
			}
		}
	}
	for(int i=1;i<=N;++i){
		s[i]={{uni(0,i),uni(1,i)},i};
	}
	sort(s+1,s+1+N);
	for(int i=1;i<=N;){
		int j=i+1,c=1;
		for(;j<=N&&s[i].first==s[j].first;++j){
			++c;
		}
		for(;i<j;++i){
			ans[s[i].second]=c;
		}
	}
	for(int i=1;i<=N;++i){
		printf("%d%s",ans[i],i==N?"\n":" ");
	}
}


Measured memory_bytes: 8704
# Problem B - 81

# input
N = int(input())

# initialization
num_list = []
for i in range(1, 10):
    for j in range(1, 10):
        num_list.append(i * j)
num_list = list(set(num_list))

# output
if N in num_list:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


int a[3001],dp[3001][3001][2],n;

int recur(int i,int j,int x)
{
  if(i==j)
  {
    return (x%2?-1:1) * a[i];
  }
  if(dp[i][j][x]!=-1) return dp[i][j][x];
  
  if(!x)
  {
    dp[i][j][x] =  max(a[i]+recur(i+1,j,(x+1)%2),a[j]+recur(i,j-1,(x+1)%2));
  }else
  {
    dp[i][j][x] =  min(recur(i+1,j,(x+1)%2)-a[i],recur(i,j-1,(x+1)%2)-a[j]);
  }

  return dp[i][j][x];
}


void solve()
{
   
   cin >> n;

   forf(i,0,3001)
   {
    forf(j,0,3001) dp[i][j][0] = dp[i][j][1] = -1;
   }

   forf(i,1,n+1) cin >> a[i];
   
   cout<<recur(1,n,0);

}


int32_t main()
{
  pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 144520
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

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

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li];
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d",&n);
	FOR{
		scanf("%d",&a[i]);
	}
	dp[1]=0;
	dp[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	printf("%d\n",dp[n]);
	return 0;
}



Measured memory_bytes: 4564
MOD = 998244353

n = int(input())
d_lst = list(map(int, input().split()))
if d_lst[0] != 0:
    print(0)
    exit()

max_d = max(d_lst)
lst = [0 for _ in range(max_d + 1)]
for d in d_lst:
    lst[d] += 1
if lst[0] != 1:
    print(0)
    exit()
ans = 1
for i in range(max_d):
    ans *= pow(lst[i], lst[i + 1], MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 20516