akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int h,w;
    cin >> h >> w;
    char C[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> C[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<w;k++){
                cout << C[i][k];
            }
            cout << endl;
        }
    }
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#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 (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int maxi = N - (K - 1);
    int mini = 1;
    if (K == 1) {
        cout << 0 << endl;
    } else {
        cout << (maxi - mini) << endl;
    }
    return 0;
}



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

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

    //long long all_sum = N*(N+1)/2;
    long long sum_3 = 0;
    long long sum_5 = 0;
    long long sum_15 = 0;
    int64_t sum = 0;

    for(int i = 1; i <= N; i++){
        if(i%3 == 0 && i%5 == 0){
            sum_15 += i;
            //cout << "15" << endl;
        }else if(i%3 == 0 && i%5 != 0){
            sum_3 += i;
            //cout << "3" << endl;
        }else if(i%5 == 0 && i%3 != 0){
            sum_5 += i;
            //cout << "5" << endl;
        }else{
            //cout << i << endl;
            sum += i;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
A = []
for _ in range(3):
    A.extend(map(int,input().split()))
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

# print(A,N,b)

for i in b:
    for j in range(len(A)):
        if i == A[j]:
            A[j] = -1

#print(A[0] == A[1] == A[2] == -1, A[0] == A[4] == A[8] == -1)
if A[0] == A[1] == A[2] == -1 or A[3] == A[4] == A[5] == -1 or A[6] == A[7] == A[8] == -1 or A[0] == A[3] == A[6] == -1 or A[1] == A[4] == A[7] == -1 or A[2] == A[5] == A[8] == -1 or A[0] == A[4] == A[8] == -1 or A[2] == A[4] == A[6] == -1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int a, b;
	cin >> a >> b;
	if (a % 3 && b % 3 && (a + b) % 3) {
		cout << "Impossible" << endl;
	}
	else cout<<"Possible"<<endl;
	return 0;

}




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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

int64 solve(const string& s, int64& p) {
  p++;
  if (isdigit(s[p])) {
    int64 res = 0;
    while (isdigit(s[p])) {
      res = (res * 10) + (s[p++] - '0');
    }
    p++;
    return (res+1)/2;
  }
  vector<int64> v;
  while (s[p] != ']') {
    v.push_back(solve(s, p));
  }
  sort(all(v));
  int64 res = 0;
  REP(i, v.size()/2+1) res += v[i];
  p++;
  return res;
}

int main(void) {
  int64 T;
  cin >> T;
  REP(_, T) {
    string s;
    cin >> s;
    int64 p = 0;
    cout << solve(s, p) << endl;
  }
}




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

int main()
{
	int N, X;
	cin >> N >> X;
	int res = 0;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		res = __gcd(abs(X - x), res);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
//g++ -std==c++14
int n;

int prime[1000000];
long long int number_sum[1000];
void eratosthenes(){
    for(int i = 0; i < 1000000; i++)    prime[i] = 1;
    prime[0] = prime[1] = 0;
    for(int i = 0; i * i <= 1000000; i++)
        if(prime[i])
            for(int j = i * 2; j < 1000000; j += i)
                prime[j] = 0;
}

int main(){
    cin >> n;
    eratosthenes();
    for(int i = n; i != 1; i--){
        for(int j = 2; j <= 1000; j++){
            int va = i;
            while(va % j == 0 && prime[j]){
                va = va / j;
                number_sum[j]++; 
            }
            //cout << j << " " << number_sum[j] << endl;
        }
    }
    long long int ans = 1;
    loop(i, 2, 1001){
        if(number_sum[i]){
            ans *= (number_sum[i] + 1);
            ans = ans % MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enque(P x){
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

P deque(){
    P x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int min(int a, int b){return a<b?a:b;}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for(i=1;i<=n;i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;tail = n+1;

    while(head != tail){
        u = deque();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t>0)enque(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}

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

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

  unordered_map<int, int> freq;
  int buf;
  for(int i=0; i<N; i++){
    cin >> buf;
    if(freq.count(buf)){ freq.at(buf)++; }
    else               { freq[buf]= 1; }
  }

  int ans= 0;
  for(auto [num, f]:freq){
    int cnt= (num > f) ? f
                       : f- num;
    ans+= cnt;
  }

  cout << ans << endl;
}

Measured memory_bytes: 7192
let n = read_int ()
let ss = Array.init n @@ fun _ -> read_line ()
let cs = Array.make 128 0
let _ = Array.(Char.(for i = code 'a' to code 'z' do let m = ref max_int in
  iter (fun s -> let a = ref 0 in String.iter (fun c -> if code c = i then incr a) s; m := min !m !a) ss; cs.(i) <- !m done;
  iteri (fun i c -> if c > 0 then print_string @@ String.make c @@ chr i) cs)); print_newline ()

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

char C[4] = {'p', 'b', 'q', 'd'};

int main()
{
    string S;
    cin >> S;
    string ans = "Yes";
    REP(i, S.length())
    {
        char a = S[i];
        char b = S[S.length() - 1 - i];
        bool e = false;
        REP(j, 4)
        {
            if (C[j] == a && C[(j + 2) % 4] == b)
                e = true;
        }
        if (!e)
            ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
//Nihal Mittal - nihal_47
//Shine Like a Sun , Burn like a Sun 

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
using namespace std;
ll divisors(ll n) 
{ 
    ll cn=0 , ans= LLONG_MAX;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            ans = min(ans , abs(i-1) + abs((n/i) - 1));
        } 
    } 
    return ans;
}
signed main()
{
    fast;
   
    ll n,i;
    cin>>n;
    cout<<divisors(n);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    ll n;
    cin>>n;
    vector<ll> as(n);
    vector<ll> bs(n);

    rep(i, n) cin>>as[i]>>bs[i];
    reverse(as.begin(), as.end());
    reverse(bs.begin(), bs.end());
    ll cnt = 0;
    rep(i, n) {
        ll d = (bs[i] - ((as[i] + cnt) % bs[i])) % bs[i];
        cnt += d;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define WATCH(x) cout << (#x) << " is " << (x) << endl

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);

int main()
{   
    flash
    ll n;
    cin >> n;
    cout << (n*(n-1))/2;
      
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a==5&&b==7)&&c==5){
    cout<<"YES"<<endl;
    return 0;
  }
  if((a==5&&b==5)&&c==7){
    cout<<"YES"<<endl;
    return 0;
  }
  if((a==7&&b==5)&&c==5){
    cout<<"YES"<<endl;
    return 0;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    for (int i = 0; i < n;++i){
        int a;
        cin >> a;
        h -= a;
    }
    cout << (h > 0 ? "No" : "Yes");
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
a = list(map(int,input().split()))

total = 0
for i in range(n):
  total += a[i]


cnt = 0

for i in range(n):
  if a[i] >= total/4/m:
    cnt += 1

if cnt >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9164
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

for cakes in A, B, C:
    cakes.sort(reverse=True)

cake_values = []
for i in range(len(A)):
    if i + 1 > K:
        break
    for j in range(len(B)):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(len(C)):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            cake_values.append(A[i] + B[j] + C[k])
cake_values.sort(reverse=True)
for i in range(K):
    print(cake_values[i])


Measured memory_bytes: 8708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define LL long long

using namespace std;

int main(void){

    LL n, q, count = 0;
    string s;
  
    cin >> n >> q;
    cin >> s;

    LL list[n] = {0};

    for (LL i = 1; i < n; i++){
        if(s[i - 1] == 'A' && s[i] == 'C'){
            count++;
        }
        list[i] = count;
    }

    for (LL i = 0; i < q; i++){
        LL a, b;
        cin >> a >> b;
        cout << list[b - 1] - list[a - 1] << endl;
    }
    return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S; cin>>S;
  int temp=0, ans=1;
  for(int i=0; i<S.size()-1; i++){
    if(S[i]!=S[i+1]) ans++;
    else{
      ans+=2;
      i+=2;
      if(i==S.size()) ans-=2;
      else if(i==S.size()-1) ans--;
    }
  }
  if(S.size()==1){
    cout<<1<<endl;
    return 0;
  }
  else if(S.size()==2){
    if(S[0]==S[1]) cout<<1<<endl;
    else cout<<2<<endl;
    return 0;
  }
  cout<<ans<<endl;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> v(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        v[--a]++; v[--b]++;
    }
    for (int i = 0; i < n; i++) {
        if (v[i] % 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 768
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 998244353;

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

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int r, g; cin >> r >> g;
  cout << g*2 - r << endl;

  return 0;
}

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

stack<int> s;

int main()
{
    char c[105];
    int a, b;
    while(scanf("%s", c)!=EOF)
    {
        if(c[0]=='+')
        {
            a = s.top();
            s.pop();
            b = s.top();
            s.pop();
            s.push(a+b);
        }
        else if(c[0]=='-')
        {
            a = s.top();
            s.pop();
            b = s.top();
            s.pop();
            s.push(b-a);
        }
        else if(c[0]=='*')
        {
            a = s.top();
            s.pop();
            b = s.top();
            s.pop();
            s.push(b*a);
        }
        else
        {
            s.push(atoi(c));
        }
    }
    printf("%d\n", s.top());

    return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
  return 0;
}


Measured memory_bytes: 3632
def debug(*args):
    import sys
    print(*args, file=sys.stderr)

def solve(N, L):
    A = [0] * N
    for i in range(1, N+1):
        A[i-1] = L+i-1

    m = float("inf")
    debug(A)
    for i in range(0, N):
        res = sum(A[:i]) + sum(A[i+1:])
        t = abs(sum(A) - sum(A[:i]) - sum(A[i+1:]))
        #debug("i=%d"%i, "t=%d"%t, A[i], A[:i], A[i+1:], "res:%d"%res)
        if t < m:
            m = t
            ans = sum(A[:i]) + sum(A[i+1:])
    return ans

def main():
    N, L = [int(x) for x in input().split()]
    print(solve(N, L))

main()



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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < n; i++) {
		printf("%c%c", s[i], t[i]);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {

	int n;
	int a[100000];
	int ans = 0;
	int kazu = 0;
	int asans;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	asans = n;

	for (int i = 0; i < n;) {
		for (int j = i; j < n; j++) {
			if (a[i] == a[j])
				kazu++;
			else
				break;
		}
		if (a[i] < kazu)
			ans += kazu - a[i];
		else if(a[i]>kazu)
			ans += kazu;
		i += kazu;
		kazu = 0;
	}
	if (asans < ans)
		cout << asans << endl;
	else
		cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#define MAX_N 200020
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r-1);
}

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

  setComb();

  vector<ll> sum(N+1,0);
  for(int i=1;i<=N;i++) sum[i]=(sum[i-1]+inv[i])%MOD;

  ll ans=0;
  for(int i=0;i<N;i++){
    ll c=(sum[i+1]+sum[N-i]-inv[1]+MOD)%MOD;
    ll res=A[i]*c%MOD;
    ans=(ans+res)%MOD;
  }
  ans=ans*fac[N]%MOD;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define int long long
using namespace std;
void a(vector<vector<pair<int,char>>> &A,char c1,char c2,int b,int &ans){
  for(vector<pair<int,char>> &v:A){
    sort(v.begin(),v.end());
    for(int i=0;i+1<v.size();i++)
      if(v[i].second==c1 && v[i+1].second==c2)
        ans=min(ans,(v[i+1].first-v[i].first)*b);
  }
}
signed main(){
  int N;
  cin>>N;
  vector<vector<pair<int,char>>> A(200001),B(200001),C(400001),D(400001),E(400001),F(400001);
  for(int i=0;i<N;i++){
    int X,Y;
    char c;
    cin>>X>>Y>>c;
    if(c=='U'){
      A[X].push_back({Y,'U'});
      C[X-Y+200000].push_back({X,'U'});
      D[X+Y].push_back({X,'U'});
    }else if(c=='D'){
      A[X].push_back({Y,'D'});
      E[X+Y].push_back({X,'D'});
      F[X-Y+200000].push_back({X,'D'});
    }else if(c=='R'){
      B[Y].push_back({X,'R'});
      D[X+Y].push_back({X,'R'});
      F[X-Y+200000].push_back({X,'R'});
    }else{
      B[Y].push_back({X,'L'});
      C[X-Y+200000].push_back({X,'L'});
      E[X+Y].push_back({X,'L'});
    }
  }
  int ans=1000000000000000000;
  a(A,'U','D',5,ans);
  a(B,'R','L',5,ans);
  a(C,'U','L',10,ans);
  a(D,'R','U',10,ans);
  a(E,'D','L',10,ans);
  a(F,'R','D',10,ans);
  if(ans==1000000000000000000)puts("SAFE");
  else cout<<ans<<endl;
}

Measured memory_bytes: 68684
/// You just can't beat the person who never gives up

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

int n ,cnt[4];
string str[4] = {"AC" ,"WA" ,"TLE" ,"RE"};
void add(string s){
    for(int i=0;i<4;++i){
        if(s == str[i]) ++cnt[i] ;
    }
}
string s ;
bool Never_give_up(){
    cin >> n ;
    while(n--){
        cin >> s ;
        add(s) ;
    }
    for(int i=0;i<4;++i) cout << str[i] << " x " << cnt[i] << endl ;
    return 0 ;
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" ,"r" ,stdin);
    freopen("output.txt" ,"w" ,stdout);
#endif
    int t = 1 ;
    //scanf("%d",&t);
    while(t--) Never_give_up();
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int a, b;
	int d, r;
	double f = 1.0;
	
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = a / (b * f);
	
	printf("%d %d %f\n", d, r, f);
	
}

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

typedef uint32_t u32;
typedef uint64_t u64;

class Team {
public:
  Team();
  void AC(long problem_id, long time);
  void WA(long problem_id, long time);
  long Point() const;
  long Num_AC() const;
  void Dump();
  void Setid(long id_);
  long ID() const;
private:
  long miss[16];
  bool correct[16];
  long point;
  long num_ac;
  long id;
};

Team::Team() {
  for(long i = 0; i < 16; ++i) {
    miss[i] = 0;
    correct[i] = false;
  }
  point = 0;
  num_ac = 0;
}

void Team::AC(long problem_id, long time) {
  correct[problem_id] = true;
  point += miss[problem_id] * 1200 + time;
  num_ac += 1;
}

void Team::WA(long problem_id, long time) {
  correct[problem_id] = false;
  miss[problem_id] += 1;
}

long Team::Point() const {
  return point;
}

long Team::Num_AC() const {
  return num_ac;
}

void Team::Setid(long id_) {
  id = id_;
}

long Team::ID() const {
  return id;
}

void Team::Dump() {
  std::cout << id << ' ' << Num_AC() << ' ' << point << std::endl;
}

bool operator < (const Team& left, const Team& right) {
  if( left.Num_AC() != right.Num_AC() ) return -left.Num_AC() < -right.Num_AC();
  if( left.Point() != right.Point() ) return left.Point() < right.Point();
  return left.ID() < right.ID();
}

int main() {

  for(;;) {
    long T, P, R;
    std::cin >> T >> P >> R;
    if( T == 0 and P == 0 and R == 0 ) break;
    long tID, pID, time;
    std::string message;
    Team team[64];
    for(long i = 0; i < 64; ++i) {
      team[i].Setid(i);
    }                                 
    for(long i = 0; i < R; ++i) {
      std::cin >> tID >> pID >> time;
      std::cin >> message;
      if( message == "CORRECT" ) {
        team[tID].AC(pID, time);
      }
      else {
        team[tID].WA(pID, time);
      }
    }
    std::sort(team+1, team+T+1);
    for(long i = 1; i <= T; ++i) {
      team[i].Dump();
    }
  }  
  
  return 0;
}

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

#pragma GCC optimize("Ofast")

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define ll long long
#define mid(a,b) (a+b)/2
#define pii pair<ll,ll>

using namespace std;

ll mod = 1e9+7;
ll n,k;
ll fc[N],inv[N],a[N],sum;

int read(){
	char c=getchar();ll ans=0,b = 0;
	while(c < '0' or c > '9'){
		if(c == '-') b = 1;
		c=getchar();
	}
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	if(b) ans *= -1;
	return ans;
}

ll big(ll a,ll b){
	if(b == 0) return 1;
	ll x = big(a,b / 2);
	if(b % 2) return (((x * x) % mod) * a) % mod;
	return (x * x) % mod;
}

ll norm(ll x){
	if(x < 0) x += mod;
	else if(x >= mod) x -= mod;
	
	return x;
}

ll C(ll n,ll k){
	return (((fc[n] * inv[n - k]) % mod) * inv[k]) % mod;
}

int main()
{
	n = read(),k = read();
	fc[0] = 1;
	for(int i = 1;i <= n;i++)
		fc[i] = (fc[i - 1] * i) % mod;
	inv[n] = big(fc[n],mod - 2);
	for(int i = n - 1;i >= 0;i--)
		inv[i] = (inv[i + 1] * (i + 1)) % mod;
	for(int i = 1;i <= n;i++) a[i] = read();
	sort(a + 1,a + n + 1);
	
	for(int i = n;i >= k;i--){
		sum += ((a[i] * C(i - 1,k - 1)) % mod);
		sum %= mod;
	}
	for(int i = 1;i <= n - k + 1;i++){
		sum -= ((a[i] * C(n - i,k - 1)) % mod);
		sum = norm(sum);
	}
	printf("%lld",sum);
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int bitsum(int a) {//aの10進数での各桁の和を返す
	int ans = 0;
	string s = to_string(a);
	const int N = s.size();
	for (char x : s) ans += x - '0';
	return ans;
}

int main() {
	makei(N);
	if (N%bitsum(N) == 0)say("Yes");
	else say("No");
}

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

int main()
{
	long long int n=0,ans=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;++i){
    cin >> a[i];
  }//ここまで入力処理
  int bef_r=0;
  int xo=0,sum=0;//xorとsumの変数を確保
  int bef_x=0,bef_sum=0;
  for(int l=0;l<n;++l){
    xo = bef_x;
    sum = bef_sum;
    int r;
    for(r=bef_r;r<n;++r){
      bef_x = xo;
      bef_sum = sum;
      xo ^=a[r];
      sum += a[r];
      if(xo != sum){
        break;
      }
    }
    bef_r = r;
    ans += bef_r-l;
    bef_x ^= a[l];
    bef_sum -= a[l];
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
constexpr int kMod  =  1000000007;
constexpr int kNmax = 2e5 + 1;
constexpr int kCmax = 2e5 + 1;
typedef long long LL;

signed main(){
  int N; std::cin >> N;

  LL dp[kNmax] = {};
  std::vector<int> c_indices[kCmax];

  dp[0] = 1;
  int idx = 0;
  int prev = -1;
  for(int i = 0;i < N; ++i){
    int c; std::cin >> c;
    if (c == prev) continue;

    ++idx;
    prev = c;

    dp[idx] = dp[idx-1];
    if (!c_indices[c].empty()) {
      dp[idx] += dp[c_indices[c].back()];
      dp[idx] %= kMod;
    }

    c_indices[c].push_back(idx);
  }

  std::cout << dp[idx] << std::endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

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

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

ll digitsum(ll n, ll b) {
	ll sum = 0;
	for (; n > 0; n /= b) sum += n % b;
	return sum;
}


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



Measured memory_bytes: 256
N, H = list(map(int,input().split()))
a = 0
b = [0]
for i in range(N):
    A = list(map(int,input().split()))
    a = max(a,A[0])
    b += [A[1]]
b = sorted(b)[::-1]
for i in range(N+1):
    if(H<=0):
        break
    if (b[i] > a):
        H -= b[i]
    else:
        i += int(H/a)+(0!=H%a)
        break
print(i)



Measured memory_bytes: 8704
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

ll gdc(ll a, ll b){
    if(a<b){
        ll tmp=a;
        a=b;
        b=tmp;
    }
    //cout << a << b << endl;
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    //cout << b << endl;
    return b;
}

int main(){
    int N;
    cin >> N;
    vector<ll> T(N);
    rep(i,N) cin >> T[i];
    ll ans;
    ans = 1;
    for(int i=0; i<N; i++){
        ans = ans/gdc(T[i], ans)*T[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	string s;
	cin >> s;
	int n = s.length();
	set<char>m;
	rep(i, 0, n)m.insert(s[i]);
	string ans;
	if (m.size() == 26) {
		if (s == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
			return 0;
		}
		for (int i = 25; i >= 0; i--) {
			m.erase(s[i]);
			for (char j = 'a'; j <= 'z'; j++) {
				if (m.find(j) == m.end()) {
					ans = s.substr(0, i);
					ans[ans.length() - 1] = j;
					if (ans > s) {
						cout << ans;
						return 0;
					}
				}
			}
		}
	}
	else {
		cout << s;
		for (char j = 'a'; j <= 'z'; j++) {

			if (m.find(j) == m.end()) {
				cout << j << endl;
				return 0;
			}
		}

	}

}





Measured memory_bytes: 256
n,k=map(int,input().split())
p=list(map(int,input().split()))

for i in range(n):
    p[i]=0.5*(p[i]+1)

_sum=sum(p[:k])
_max=sum(p[:k])

for g in range(k,n):
    _sum=_sum+p[g]-p[g-k]
    _max = max(_sum,_max)
print(_max)

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

int main()
{
	int N, M, D, P;
	while (cin >> N >> M, N || M) {
		vector< int > dp(11);
		for (int i = 0; i < N; i++) {
			cin >> D >> P;
			dp[P] += D;
		}
		int res = 0;
		for (int i = 10; i >= 0; i--) {
			if (dp[i] < M) {
				M -= dp[i];
			}
			else {
				res += (dp[i] - M) * i;
				M = 0;
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

int main(){
    string s,A,tmp,B;
    int n,a,b;
    
    cin >> s >> n;
    
    for (int i=0; i<n; i++){
        cin >> A >> a >> b;
        if (A=="reverse"){
            //a 文字目から b 文字目までを逆順にする。
            tmp=s.substr(a,b-a+1);
            for (int i=0; i<tmp.size(); i++){
                s[a+i]=tmp[tmp.size()-1-i];
            }
        }
        else if (A=="replace"){
            cin >> B;
            s.replace(a,b-a+1,B);
        }
        else if (A=="print"){
            cout << s.substr(a,b-a+1) << endl;
        }
    }
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	map<vector<unsigned char>, long long> m;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		vector<unsigned char> v('z' - 'a' + 1, 0);
		for (int j = 0; j < s.size(); ++j) {
			++v[s[j] - 'a'];
		}
		if (m.find(v) == m.end()) {
			m[v] = 1;
		}
		else {
			++m[v];
		}
	}
	
	long long ret = 0;
	for (auto& i : m) {
		ret += i.second * (i.second - 1LL) / 2LL;
	}

	cout << ret << endl;


	return 0;
}

Measured memory_bytes: 12800
N = int(input())
ans = 0
for i in range(N):
    if ( 0 < i+1  and i +1 <10 ) :
        ans = ans +1
    elif ( 99 < i+1  and i +1 <1000 ) :
        ans = ans +1
    elif (  9999 <i+1 and i + 1  <100000 ) :
        ans = ans +1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int K, X;
  cin >> K >> X;
  int x = X - K + 1;
  for(int i = 0; i < 2 * K - 1; i++){
    cout << x + i << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    cin >> n;
    ll a;
    int cnt = 0, c_2 = 0;
    rep(i, n)
    {
        cin >> a;
        if (a % 4 == 0)
        {
            cnt++;
        }
        else if (a % 2 == 0)
        {
            c_2++;
        }
    }
    int ans = n / 2;
    // cout << cnt << "," << c_2 << endl;

    if (cnt >= ans)
    {
        cout << "Yes" << endl;
    }
    else if ((cnt + c_2 / 2) >= ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007
#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"

void solve(){
    ll a,b,n;
    cin>>a>>b>>n;
    cout<<(a*min(n,(b-1)))/b<<"\n";
}

int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	while(_--){
        solve();
    }
	return 0;
}

/*
   check for overflows int long long
   correct size of array
*/

Measured memory_bytes: 3660
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    # 同じグループに属するかを判定する関数
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素が属する木の深さを返す関数
    def get_depth(self, x):
        return self.rank[self.find(x)]
    
    # 要素が属する木のサイズを返す関数
    def get_size(self, x):
        return self.size[self.find(x)]
    
    # グループ数を返す関数
    def group_sum(self):
        c = 0
        for i in range(len(self.par)):
            if self.find(i) == i:
                c += 1
        return c

if __name__ == "__main__":
    N,K,L = map(int, input().split())
    uf_r = UnionFind(N)
    uf_t = UnionFind(N)
    d = defaultdict(int)

    for i in range(K):
        p, q = [int(i) for i in input().split()]
        uf_r.unite(p, q)
    
    for i in range(L):
        r, s = [int(i) for i in input().split()]
        uf_t.unite(r, s)
    
    for i in range(1,N+1):
        d[(uf_r.find(i), uf_t.find(i))] += 1
    
    print(*[d[(uf_r.find(i), uf_t.find(i))] for i in range(1,N+1)])
    

Measured memory_bytes: 59140
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int w,a,b;
    scanf("%d %d %d",&w,&a,&b);
    if( a + w < b)
        printf("%d",(b - (a+w)));
    else if(b + w < a)
        printf("%d",(a - (b+w)));
    else
        printf("0");
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

int N, A[123450];

int main(int argc, char *argv[])
{
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  sort(A, A + N, greater<int>());
  int ng = 0;

  int ans = A[0];
  for (int i = 1; i < N; i++) {
    if (ans <= A[i] && A[i] % ans == 0) continue;
    ng++;
    if (ng >= 2) break;
  }

  if (ng <= 1) {
    cout << ans << endl;
    return 0;
  }

  ans = max(A[1], (ans/2) + 1);
  bool ok = true;
  for (; ans >= 1; ans--) {
    if (ans > A[N-2]) continue;

    ng = 0;
    ok = true;
    for (int i = 0; i < N; i++) {
      if (ans <= A[i] && A[i] % ans == 0) continue;
      ng++;
      if (ng > 1) {
        ok = false;
        break;
      }
    }

    if (ok) {
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;
#include <queue>

int main(void){
    Cin(int, n);
    vector<vector<pair<int, int>>> g(n+1);
    Rep(n-1){
        Cin(int, a, b, c);
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    Cin(int, nq, k);
    vector<ll> d(n+1, -1);
    d[k] = 0;
    deque<int> q {k};
    while(!q.empty()){
        for(const auto &e : g[q.front()]){
            if(d[e.first] == -1){
                q.push_back(e.first);
                d[e.first] = d[q.front()] + e.second;
            }
        }
        q.pop_front();
    }

    Rep(nq){
        Cin(int, x, y);
        Cout(d[x] + d[y]);
    }
}


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

int main() {
    ll H; cin >> H;
    ll count = 1;
    while (H / 2 != 0) {
        H /= 2;
        count++;
    }
    ll ans = pow(2,count) - 1;
    cout << ans << endl;
}

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


int main(){
	    ll N;
        int K;
        cin >> N >> K;
        int ans = 1;
        ll temp = K;
        while(temp <= N){
            temp *= K;
            ans++;
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}

signed main()
{
	speed
	int n;cin>>n;
	map<string, int> mp;
	int pref=0;
	for (int i = 0; i < n; ++i)
	{
		string str;cin>>str;
		int tmp;cin>>tmp;
		pref+=tmp;
		mp[str]=pref;
	}
	string req;cin>>req;
	cout<<pref-mp[req];
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

#define mkt make_tuple

int N,M,S,T;

vector<tuple<int,ll,ll>> g[100010];

ll dist[100010][2];
const ll INF=1e18;
const ll MAX=1e15;

void dijkstra(int col){
    int start=S;
    if(col==1) start=T;
    for(int i=0;i<=N;i++) dist[i][col]=INF;
    dist[start][col]=0;
    priority_queue<pair<ll,int>> PQ;
    PQ.push(mkp(0,start));
    while(!PQ.empty()){
        auto f=PQ.top();
        PQ.pop();

        ll cost=-f.first;
        int now=f.second;
        if(dist[now][col]<cost) continue;

        for(int i=0;i<g[now].size();i++){
            int nex=get<0>(g[now][i]);
            ll a=get<1>(g[now][i]);
            ll b=get<2>(g[now][i]);

            ll neco=a;
            if(col==1) neco=b;
            if(dist[nex][col]<=dist[now][col]+neco) continue;
            dist[nex][col]=dist[now][col]+neco;
            PQ.push(mkp(-dist[nex][col],nex));
        }
    }
}

int main(){
  cin>>N>>M>>S>>T;
  for(int i=0;i<M;i++){
      int u,v,a,b;
      cin>>u>>v>>a>>b;
      g[u].push_back(mkt(v,a,b));
      g[v].push_back(mkt(u,a,b));
  }

  dijkstra(0);
  dijkstra(1);

  vector<pair<ll,int>> v;
  for(int i=1;i<=N;i++){
      v.push_back(mkp(dist[i][0]+dist[i][1],i));
  }
  sort(v.begin(),v.end());

  vector<ll> ans(N,0);
  int cnt=0;
  for(int i=0;i<N;i++){
      while(v[cnt].second<=i){
          cnt++;
      }
      ans[i]=v[cnt].first;
  }

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

  return 0;
}


Measured memory_bytes: 14704
from heapq import heapify, heappush, heappop

N, M = map(int, input().split())
a = map(int, input().split())
hq = list(map(lambda x: (-x, 1), a))

heapify(hq)

for _ in range(M):
    b, c = map(int, input().split())
    heappush(hq, (-c, b))

rest = N
ans = 0
while rest > 0 and hq:
    mv, b = heappop(hq)
    mv *= -1
    use = min(rest, b)
    ans += mv * use
    rest -= use
print(ans)


Measured memory_bytes: 93464
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws IOException{


		// 読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] temp;

		line=br.readLine();
		temp=line.split(" ");

		int n = Integer.valueOf(temp[0]);

		int x = 800*n;
		int y = 200*(n/15);



		System.out.println(x-y);


	}
}


Measured memory_bytes: 21332