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

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


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

int main2() {
  string S; cin >> S;
  if (S == "ARC") cout << "ABC" << endl; else cout << "ARC" << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3528
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a*b%2!=0||(a*b*2)%2!=0||(a*b*3)%2!=0)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
hash = Hash.new(0)
n.times do |i|
  key = gets.chomp.chars.sort.join
  hash[key] += 1
end

count = 0
hash.each do |_, v|
  next unless v > 1
  next count += 1 if v == 2
  count += (v * (v - 1)) / 2
end
puts count

Measured memory_bytes: 18324
#include <iostream>
#include <string>
using namespace std;
 
int idx[100010] = {0};
 
int main()
{
    int N, Q;
    string s;
 
    cin >> N >> Q;
    cin >> s;
 
    int cnt = 1;
    for (int i = N-2; i >= 0; i--)
    {
        if (s[i] == 'A' && s[i+1] == 'C')
        {
            idx[i] = idx[i+1]+1;
        }
        else
        {
            idx[i] = idx[i+1];
        }
    }
 
 
    int l, r;
    for (int i = 0; i < Q; i++)
    {
        cin >> l >> r;
        cout << idx[l-1]-idx[r-1] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


lli power(lli x,lli y,lli m)
{
    lli res=1;
    while(y>0)
    {
        if(y&1)res=((res%m)*(x%m))%m;
        y>>=2;
        x= ((x%m)*(x%m))%m;
    }
    return res%m;
}

int main()
{
   
                        
     fio


     lli n;
     cin>>n;

     lli s[n+100]={0};


     fr(i,2,n+100)
     {
           if(s[i]==0)
            for( lli j=i+i;j<n+100;j+=i)
            {
                if(s[j]==0)s[j]=1;
                lli cnt=0,l=j;
                while(l%i==0){l/=i;cnt++;}
                s[j]*=(cnt+1);



            }

     }

  
     s[1]=1;
     lli ans=0;
     fr(i,1,n+1)
     if(s[i]==0)ans+=(i*2); else ans+=(i*s[i]);

     cout<<ans;


     
    
     




      
     

     
              


return 0;}    


Measured memory_bytes: 81812
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    ll H, N;
    scan(H, N);
    vector<ll> a(N);
    scan(a);
    ll sum = accumulate(all(a), 0);
    if (H <= sum) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

unordered_map<ll, int> decomposit_prime(ll n) {
    vl pp;
    // 割る数の初期値
    ll a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            pp.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    // cerr << "HH";
    pp.push_back(n);
    unordered_map<ll, int> pn;
    for(auto p : pp) {
        pn[p] = 0;
    }
    for(auto p : pp) {
        pn[p]++;
    }
    return pn;
}
vl all_devisors(ll n) {
    vl ds;
    FOR(i, 1, ll(sqrt(n))+1) {
        if(n%i==0) {
            ds.push_back(i);
            if(i != n/i) ds.push_back(n/i);
        }
    }
    return ds;
}
signed main() {
    ll n;
    cin >> n;
    // if(n==2) {
    //     cout << 1 << endl;
    //     return 0;
    // }
    ll ans = 0;
    auto devs = all_devisors(n-1);
    ans += devs.size() - 1;
    // for (auto d : devs) {
    //     if(d==1) continue;
    //     ans++;
    // }
    auto devs2 = all_devisors(n);
    for (auto d : devs2) {
        if(d==1) continue;
        auto _n = n;
        while(_n%d==0) _n /= d;
        if(_n%d == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  int c;
  cin >> a >> b;
  c = (a + b) / 2;
  if ( a % 2 + b % 2 == 1) {
    c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>

#define N 100

void trace(int A[], int n){
  int i;
  for (i=0;i < n;i++){
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void swap(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

int main(){
  int A[N];
  int n=0;
  int i,j;
  int count=0;
  
  scanf("%d",&n);
  
  if(n > 100 || n < 0){
    return 0;
  }
  
  for(i=0;i < n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i < n;i++){
    for(j=n-1;j > i;j--){
      if(A[j] < A[j-1]){
	swap(&A[j],&A[j-1]);
	count++;
      }
    }
  }
  trace(A,n);
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,m,x=0,c=0;
    cin>>n>>m;
    vector<vector<long>> a(n,vector<long>(2));
    
    for(int i=0;i<n;i++) cin>>a.at(i).at(0)>>a.at(i).at(1);
    
    sort(&a[0], &a[n], [](auto& x, auto& y){return x[0] < y[0];});
    
    for(int i=0;;i++){
        x+=a.at(i).at(1);
        c+=a.at(i).at(0)*a.at(i).at(1);
        if(x==m) break;
        if(x>m){
            c-=a.at(i).at(0)*(x-m);
            break;
        }
    }
    
    cout<<c<<"\n";
}

Measured memory_bytes: 5760
#include <stdio.h>
#define MIN_P -1000000000

int main(){
  int i,n,min,profit = MIN_P,nowprice;

  scanf("%d",&n);

  for(i=0;i<n;++i){
    scanf("%d",&nowprice);

    if(i==0)min = nowprice;

    else {
      if(profit < nowprice - min)profit = nowprice - min;
      if(min > nowprice) min = nowprice;
    }

  }
  printf("%d\n",profit);

  return 0;
}



Measured memory_bytes: 2112
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
int sum(int n){return n * (n + 1)/ 2;}
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	if (line.length < args.length) return;
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
struct line{int y,p,q;}
void main(){	
	int v,h,nowx;
	while(read(v,h,nowx),v|h|nowx){
		line[] lines;
		for(;h>0;h--){
			int y,p,q;
			read(y,p,q);
			lines ~= line(y,p,q);
		}
		lines.sort!("a.y > b.y");
		foreach(ln;lines){
			if(nowx == ln.p) nowx = ln.q;
			else if(nowx == ln.q) nowx = ln.p;
		}
		nowx.writeln;
	}
}

Measured memory_bytes: 3416
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- Sun Apr 19 17:54:42 2020

*/ 
#include<bits/stdc++.h>
using namespace std;


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 
	double x;
	cin>>x;
	double pi=acos(-1.0);
	double ans=2.0*pi*x;
	cout<<fixed<<setprecision(6);
	cout<<ans<<endl;

 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 3784
n=int(input())
a=list(int(input()) for i in range(n))
max1=sum(a)
a.sort()
count=0
for i in range(n):
    if max1%10==0:
        if a[i]%10!=0:
           max1-=a[i]
        else:
           count+=1
if count==n:
    print(0)
else:
    print(max1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N=12,mod=998244353;
const ll inf=2e9;
int c[N],a[N][N],n,m,x,ans;
void sol(int b[], int s, int cost){
    if(s==n) return;
    int d[m],cnt=0;
    for(int i=0;i<m;i++){
        d[i]=b[i]+a[s][i];
        if(d[i]>=x) cnt++;
    }
    if(cnt==m){
        ans=min(ans,cost+c[s]);
        sol(b, s + 1, cost);
    }
    else{
        sol(b, s + 1, cost);
        sol(d, s + 1, cost + c[s]);
    }
}
void solve(){

    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    ans=INT_MAX;
    int b[m]={0};
    sol(b, 0, 0);
    if(ans==INT_MAX) cout<<"-1"<<endl;
    else cout<<ans<<endl;
}

int main(){
    //#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	//#endif
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    double a, b, x; cin >> a >> b >> x;
    x /= a;
    double theta;
    if (a * b < 2 * x) {
        theta = atan2(2 * (a * b - x), a * a);
    } else {
        theta = M_PI / 2 - atan2(2 * x, b * b);
    }
    cout << fixed << setprecision(12);
    cout << theta * 180 / M_PI << endl;
}

Measured memory_bytes: 4140
////////////////////////////////////
//          ,.                    //
//         (_|,.                  //
//        ,' /, )_______   _      //
//     __j o``-'        `.'-)'    //
//    (")                 \'      //
//     `-j                |       //
//        `-._(           /       //
//           |_\  |--^.  /        //
//          /_]'|_| /_)_/         //
//             /_]'  /_]'         //
//                                //
//           PIGMEISTER™          //
//                                //
////////////////////////////////////

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define mod (ll)1000000007
#define sidha(i, x, n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i, x, n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mii map<ll, ll>
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define modInv(x) powah(x, mod-2)
#define test ll t;cin>>t;while(t--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
//ll powah(ll, ll);

vi dp(100005, -1), h;

ll minCost(ll n) {
    if (dp[n] > -1) return dp[n];

    if (n == 1)
        dp[n] = 0;
    else if (n == 2)
        dp[n] = abs(h[2] - h[1]);
    else 
        dp[n] = min(minCost(n-1) + abs(h[n]-h[n-1]), minCost(n-2) + abs(h[n]-h[n-2]));
    return dp[n];
}

int main()
{
    jaldi;
    
    ll n;
    cin >> n;
    h.resize(n+1);
    sidha (i, 0, n)
        cin >> h[i+1];
    cout << minCost(n) << endl;
    
    return 0;
}

// ll powah(ll x, ll y) { 
//     ll res = 1;
//     x = x % mod;
//     while (y > 0) { 
//         if (y & 1) 
//             res = (res*x) % mod; 
//         y = y>>1;
//         x = (x*x) % mod; 
//     } 
//     return res; 
// }

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

int main(void){
  int p, q, r;
  cin >> p >> q >> r;
  
  vector<int> vector = {p, q, r};
  
  sort(vector.begin(), vector.end());
  
  int ans = vector.at(0) + vector.at(1);
  
  cout << ans << endl;
}

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

int main() {
  int a ,b ,c;
  cin >> a >> b >> c;
  string ans = "No";
  if (a == b && b != c) ans = "Yes";
  if (a == c && b != a) ans = "Yes";
  if (c == b && b != a) ans = "Yes";
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<ll> b = a;
    sort(a.begin(),a.end());
    ll x = a[n/2 - 1];
    ll y = a[n/2];
    for(int i=0;i<n;i++){
        if(b[i] <=x){
            cout<<y<<endl;
        }
        else{
            cout<<x<<endl;
        }
    }
    return 0;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int h, w; cin>>h>>w;
  vector<int> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
  vector<vector<char>> a(h, vector<char>(w));
  pair<int, int> s, e;
  map<pair<int, int>, bool> enemy;
  map<pair<int, int>, bool> wall;
  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      cin >> a[i][j];
      pair<int, int> p = make_pair(i, j);
      if(a[i][j] == '@') s = p;
      else if(a[i][j] == '%') e = p;
      else if(a[i][j] == '$') enemy[p] = true;
      else if(a[i][j] == '#') wall[p] = true;
    }
  }

  vector<vector<int>> d(h, vector<int>(w, INF));
  queue<pair<int, int>> q;
  map<pair<int, int>, bool> sel;
  q.push(s);
  sel[s] = true;
  d[s.first][s.second] = 0;
  while(!q.empty()) {
    pair<int, int> now = q.front(); q.pop();
    // cout << now.first << ":" << now.second << endl;
    for(int i=0;i<4;++i) {
      pair<int, int> next = make_pair(now.first + dy[i], now.second + dx[i]);
      if(0 <= next.first && next.first < h && 0 <= next.second && next.second < w && !wall[next] && !sel[next]) {
        q.push(next);
        sel[next] = true;
        d[next.first][next.second] = d[now.first][now.second] + 1;
      }
    }
  }

  int d_prin = d[e.first][e.second];
  int d_enemy = INF;

  vector<vector<int>> de(h, vector<int>(w, INF));
  map<pair<int, int>, bool> sele;
  q.push(e);
  sele[e] = true;
  de[e.first][e.second] = 0;
  while(!q.empty()) {
    pair<int, int> now = q.front(); q.pop();
    if(enemy[now]) {
      d_enemy = de[now.first][now.second];
      break;
    }
    for(int i=0;i<4;++i) {
      pair<int, int> next = make_pair(now.first + dy[i], now.second + dx[i]);
      if(0 <= next.first && next.first < h && 0 <= next.second && next.second < w && !wall[next] && !sele[next]) {
        q.push(next);
        sele[next] = true;
        de[next.first][next.second] = de[now.first][now.second] + 1;
      }
    }
  }

  // cout << d_prin << ":" << d_enemy << endl;
  if(d_prin < d_enemy) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}



Measured memory_bytes: 10384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int A, B, x;

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

  int res = -1;

  for(int x=10; x < 10000; ++x){
    int tmp1 = floor(x * 0.08);
    int tmp2 = floor(x * 0.10);
    if(tmp1 == A && tmp2 == B){
      res = x;
      break;
    }
  }

  cout << res << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner= new Scanner(System.in);
        int A,B,C,X,Y;
        A=scanner.nextInt();
        B=scanner.nextInt();
        C=scanner.nextInt();
        X=scanner.nextInt();
        Y=scanner.nextInt();
        int ans=(int)1e9;//1e9=10^9
        for(int i=0;i<2*(X+Y)+1;i++){
            int ABpizza=i;
            int Apizza=(X - (i / 2));
            int Bpizza=(Y - (i / 2));
            if(Apizza < 0) Apizza = 0;
            if(Bpizza < 0) Bpizza = 0;
                    ans=Math.min(ans,Apizza*A+Bpizza*B+ABpizza*C);

        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long lint;
int main(){
    int i;
    string s;
    bool flag = false;
    cin >> s;
    REP(i,s.size()){
        if(s[i] == 'h'){
            if(s[i + 1] == 'i'){
                if(s[i + 2] == '\0')
                    flag = true;
            }

        }
    }
    if(s.size() % 2 == 1)
        flag = false;
    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    cin >> s;
    if(s.size() == 3){
        reverse(s.begin(), s.end());
        cout << s << endl;
    }else{
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N , K;

signed main(){
    cin >> N >> K;
    if(K == 1)printf("0\n");
    else cout << max(0, N - K) << endl;


    return 0;
}

/*

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans;
vector<string> Tiles;
void counts(int NW,int NH,int W,int H){
	if(NW!=0){
		if(Tiles[NH][NW-1]=='.'){
			ans++;
			Tiles[NH][NW-1] = 'D';
			counts(NW-1,NH,W,H);
		}
	}
	if(NH!=0){
		if(Tiles[NH-1][NW]=='.'){
			ans++;
			Tiles[NH-1][NW] = 'D';
			counts(NW,NH-1,W,H);
		}
	}
	if(NW<W-1){
		if(Tiles[NH][NW+1]=='.'){
			ans++;
			Tiles[NH][NW+1] = 'D';
			counts(NW+1,NH,W,H);
		}
	}
	if(NH<H-1){
		if(Tiles[NH+1][NW]=='.'){
			ans++;
			Tiles[NH+1][NW] = 'D';
			counts(NW,NH+1,W,H);
		}
	}
	return;
}

int main(){
	int W,H;
	int FW,FH;
	cin >> W >> H;
	int loop,loop2;
	while(W){
		vector<string> (H).swap(Tiles);
		for(loop=0;loop<H;loop++){
			cin >> Tiles[loop];
		}
		for(loop=0;loop<H;loop++){
			for(loop2=0;loop2<W;loop2++){
				if(Tiles[loop][loop2]=='@'){
					FW = loop2;
					FH = loop;
					loop = H;
					break;
				}
			}
		}
		ans = 1;
		counts(FW,FH,W,H);
		cout << ans << endl;
		cin >> W >> H;
	}
	return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(void){
    int N; string S;
    cin>>N>>S;
    int w[300000],e[300000],ans=300000;
    w[0]=0,e[N+1]=0;
    for(int i=0;i<N;i++){
        if(S[i]=='W'){
            w[i+1]=w[i]+1;
        }
        else{
            w[i+1]=w[i];
        }
    }
    for(int i=N-1;i>=0;i--){
        if(S[i]=='E'){
            e[i+1]=e[i+2]+1;
        }
        else{
            e[i+1]=e[i+2];
        }
    }
    for(int i=1;i<=N;i++){
        int tmp=w[i-1]+e[i+1];
        ans=min(ans,tmp);
    }
    cout<<ans;
}

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

#define pb push_back
#define INF 1e9
#define mod 998244353
#define mod2 1000000007
#define dbg(x) cout << (#x) << " --> " << x << "\n";
#define dbgarr(y)                                                                                            \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x << '\n';
#define dbgparr(y)                                                                                           \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x.first << ", " << x.second << '\n';
using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;

void goodLuckHaveFun() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
/* clang-format off */
  #ifdef _DEBUG
  freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
  #endif
  /* clang-format on */
}

int main() {
  goodLuckHaveFun();
  ll x;
  cin >> x;
  ll res =0;
  res = (x/500)*1000 + ((x-(x/500)*500)/5)*5;
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define pi acos(-1)
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int, int> P;
const int maxn = 1e5 + 5;

LL GCD(LL a, LL b)
{
    if (b == 0) return a;
    return GCD(b, a%b);
}
int main(void)
{
//	freopen("C:\\Users\\wave\\Desktop\\NULL.exe\\NULL\\in.txt","r", stdin);
    LL a, b;
    while (cin >> a >> b)
    {
        LL gcd = GCD(a, b);
        a /= gcd;
        b /= gcd;
        LL lcm = a * b * gcd;
        cout << gcd << " " << lcm << endl;
    }

    return 0;
}

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

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

int main() {
    int n; cin >> n;
    string s;
    int p;
    pair<pair<string, int>, int> x[n]; 
    rep(i, n){
        cin >> s >> p;
        x[i] = make_pair(make_pair(s, -p), i);
    }

    sort(x, x+n);

    rep(i, n) cout << x[i].second+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  string str1,str2,str3;
  cin >> str1 >> str2 >> str3;
  char k1 = str1[0]-32;
  char k2 = str2[0]-32;
  char k3 = str3[0]-32;
  cout << k1 << k2 << k3;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	string s;
	int k,x=1;
	ll a1=0,a2=0;
	cin>>s>>k;
	bool b=1;
	fo(i,1,s.size()) if(s[i]!=s[i-1])b=0;
	if(b){
		cout<<(ll)k*(ll)s.size()/2;
		return 0;
	}
	fo(i,1,s.size()){
		if(s[i]==s[i-1])x++;
		else{
			a1+=x/2;
			x=1;
		}
	}
	a1+=x/2;
	s+=s;
	x=1;
	fo(i,1,s.size()){
		if(s[i]==s[i-1])x++;
		else{
			a2+=x/2;
			x=1;
		}
	}
	a2+=x/2;
	cout<<(a2-a1)*(k-1)+a1<<endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  string S, T;
  cin >> S;
  T = S.substr(0, N/2);
  //cout << T << endl;
  
  if(S == T+T) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,k,r =0,d,i,j;
	int m[55]={4,2,0,9,7,1,10,8,6,4,9,7,5,3,1,6,4,2,0,9,3,1,10,8,6,0,9,7,5,3,8,6,4,2,0,5,3,1,10,8,2,0,9,7,5,10,8,6,4,2,7,5,3,1,10};
	scanf("%d%d",&n,&k);
	r = (n-2)/11;
	r*=5;
	d = (n-2)%11;
	for(i = 0;i <= 10;i++){
		if(d > i){
			for(j = 0;j <= 4;j++){
				if(k == m[i*5+j]){r++;}
			}
		}
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 128
import itertools
n = int(input())
l = []
for i in range(n):
    d = int(input())
    for dd in range(d):
        x, y = map(int, input().split())
        l.append([i, x-1, y])

ans = 0
for p in itertools.product([0, 1], repeat=n):
    for ll in l:
        if p[ll[0]] == 1 and p[ll[1]] != ll[2]:
            break
    else:
        ans = max(ans, sum(p))
print(ans)


Measured memory_bytes: 9132
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>	// require INT_MAX etc
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;
typedef pair <string, vector <int> > B;
int dp[3][330][330];
int main()
{
//	cut here before submit 
//	freopen ("testcase.tbm", "r", stdin );
	int n, m;
	string str = "";

	while (getline (cin, str )){
		stringstream ss (str );
		ss >> n >> m;

		B bydol[n];
		memset (dp, 0, sizeof(dp ) );

		for (int i = 0; i < n; ++i){
			getline (cin, str );
			bydol[i].first = str;
			vector <int> in (4, 0 );	// c, v, d, l order 
			getline (cin, str );
			stringstream ss (str );
			for (int j = 0; j < 4; ++j ){
				ss >> in[j];
			} // end for
			bydol[i].second = in;
		} // end for
		for (int i = 0; i < 3; ++i ){	// c, v, d order
			for (int j = 0;j < n; ++j ){	// bydol order
				vector <int> d = bydol[j].second;
				for (int k = 0; k <= m; ++k ){ // cost
					if (k < d[0] ){
						dp[i][j+1][k] = dp[i][j][k];
					}else{
						dp[i][j+1][k] = max (dp[i][j][k], dp[i][j+1][k - d[0]] + d[i+1] );
					} // end if
				} // end for
			}
		} // end for

		int res = 0;
		for (int k = m; k >= 0 ; --k ){
			for (int i = 0; i < 3; ++i ){
				res = max (res, dp[i][n][k] );
			} // end for
		} // end for
		cout << res << endl;					
	} // end loop
		
	return 0;
}

Measured memory_bytes: 2240
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()
total = sum(A)
A = list(accumulate(A))
r = bisect_left(A, total / 2)
l = r - 1
if r == n - 1:
    print(abs((total - A[l]) - A[l]))
else:
    print(min(abs((total - A[r]) - A[r]), abs((total - A[l]) - A[l])))






Measured memory_bytes: 78704
#coding: utf-8

inpt = input().split(" ")
a = int(inpt[0])
b = int(inpt[1])
c = int(inpt[2])
d = int(inpt[3])

if abs(b - a) <= d and abs(c - b) <= d:
    print("Yes")
elif abs(c - a) <= d:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include<stdio.h>
int main(void){
  int a,b,c,n,i;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d %d",&a,&b,&c);
    a*=a; b*=b; c*=c;
    if(a+b==c || b+c==a || c+a==b)
      printf("YES\n");
    else
      printf("NO\n");
  }
}

Measured memory_bytes: 1816
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
vector<long long> A(200200, 0);
vector<long long> sum(200200, 0);

int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> A.at(i);

    sum.at(0) = A.at(0);
    for(int i = 1; i < n; ++i) {
        sum.at(i) += sum.at(i-1) + A.at(i);
    }

    long long cnt = 0;
    map<long long, long long> mp;
    set<long long> st;
    for(int i = 0; i < n; ++i) {
        if(sum.at(i) == 0) cnt++;
        mp[sum.at(i)]++;
        st.insert(sum.at(i));
    }

    for(auto itr = st.begin(); itr != st.end(); ++itr) {
        long long mcnt = mp[*itr];
        cnt += (mcnt*(mcnt-1)) / 2;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 25216
N, T = list(map(int, input().split(" ")))
c = N*[0]
t = N*[0]

for i in range(N):
    c[i], t[i] = list(map(int, input().split(" ")))

ans = 1e9

for i in range(N):
    if(t[i] <= T):
        if(ans > c[i]):
            ans = c[i]

if(ans == 1e9): print("TLE")
else: print(ans)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

mod = 1000000007

S = [0]
for i in range(N):
    S.append((S[-1] + A[i]))

ans = 0
for i in range(N):
    sum = (S[N] - S[i + 1]) % mod
    ans += (A[i] * sum)
    ans %= mod

print(ans % mod)

Measured memory_bytes: 31360
from itertools import permutations

n, m, R = map(int, input().split())
r = list(map(int, input().split()))

INF = 10 ** 9

d = [[INF for _ in range(n)] for _ in range(n)]
p = [[] for _ in range(n)]

for i in range(n):
    d[i][i] = 0

for i in range(R):
    r[i] -= 1

for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
    p[a].append(b)
    p[b].append(a)

#for q in d: print(q)

for k in range(n):
    for i in range(n-1):
        for j in range(i+1, n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
                d[j][i] = d[i][j]

ans = INF
for x in permutations(r):
    temp = 0
    for i in range(R-1):
        temp += d[x[i]][x[i+1]]
    ans = min(temp, ans)

print(ans)


Measured memory_bytes: 4468
def main():
    n = int(input())
    t0 = int(input())
    t1 = int(input())
    tmpmin = t0
    tmpmax = t1 - t0
    tmpmin = min(t0, t1)

    for _ in range(2,n):
        t = int(input())
        if t - tmpmin > tmpmax:
            tmpmax = t - tmpmin 
        if t < tmpmin:
            tmpmin = t
    print(tmpmax)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> e(n);
  int inp;
  rep(i, n){
    cin >> inp;
    e[i]=(inp+1);
  }
  vector<int> ksum(n-k+1);
  int ans=-1;
  rep(i, k){
    ksum[0]+=e[i];
  }
  repo(i, n-k+1){
    ksum[i]=ksum[i-1]-e[i-1]+e[i+k-1];
  }
  rep(i, n-k+1){
    ans=max(ksum[i], ans);
  }
  cout << fixed;
  cout << setprecision(8) << ((double)ans)/2 << endl;
  return 0;
}


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

int main (){
    int N;
  	cin>>N;
    vector<ll> A(N);
    for(int i=0; i<N; i++){
        cin>>A.at(i);
    }
    ll Ans=0;
  	int Cou=0;
    while(A.at(N-1)>0){
        ll COU=0;
        for(int i=0; i<N; i++){
            if(A.at(i)%2){
                COU ++;
            }
            A.at(i)/=2;
        }
      	ll t=pow(2, Cou);
      	t%=K;
      	ll s=COU*(N-COU);
      	s%=K;
        Ans += s*t;
        Ans %= K;
      	Cou ++;
        sort(A.begin(), A.end());
    }
    cout<<Ans;
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#define debug(a) {for (int i=1; i<=n; i++) cout << a[i] << ' '; cout << endl;}
using namespace std;
int n, a[200], f[200], sum, res = 999999999;
void inarr()
{
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i], f[i] = f[i-1] + a[i];
}
int main()
{
    //freopen("inp.txt","r",stdin);
    inarr();
    for (int i=n; i>=1; i--){
        sum += a[i];
        res = min(res, abs(sum - f[i-1]));
    }
    cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int ans=0,cnt=0;
    int n; cin >> n;
    vector <int> A(n); 
    for (int i=0; i<n; i++) cin >> A[i];
    
    for (int i=0; i<n-1; i++){
        if (A[i]>=A[i+1]){
            cnt++;
        }
        else {
            cnt=0;
        }
        ans=max(ans,cnt);

    }
    
    cout << ans;
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  
  vector<vector<ll>> dp(60, vector<ll>(2, -1));
  dp[59][0] = 0;
  for (int d = 58; d >= 0; d--) {
    ll cnt1 = 0, cnt0 = 0;

    for (int i = 0; i < n; i++) {
      if (a[i] & (1LL << d)) cnt1++;
      else cnt0++;
    }

    ll cost1 = cnt0 * (1LL << d);
    ll cost0 = cnt1 * (1LL << d);

    if (dp[d + 1][1] != -1) {
      dp[d][1] = max(dp[d][1], dp[d + 1][1] + max(cost0, cost1));
    }
    if (k & (1LL << d)) {
      dp[d][0] = max(dp[d][0], dp[d + 1][0] + cost1);
      dp[d][1] = max(dp[d][1], dp[d + 1][0] + cost0);
    } else {
      dp[d][0] = max(dp[d][0], dp[d + 1][0] + cost0);
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
  return 0;
} 

Measured memory_bytes: 3968
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

# def can_reach(x, default_pos, x_moves):
#     for tries in range(2**len(x_moves)):  # x_moves は最大 4000, 2**100 で既に 10**30 なのでぜんぜん間に合わない。
#         result = default_pos
#         for digit in range(len(x_moves)):
#             result += (x_moves[digit] if tries & (1<<digit) else -x_moves[digit])
#         if result == x:
#             return True
#     return False

def can_reach(x_aim, default_pos, x_moves):  # ソートして貪欲？
    for i in sorted(x_moves, reverse=True):
        if x_aim > default_pos:
            default_pos += i
        else:
            default_pos -= i
    if default_pos == x_aim:
        return True
    else:
        return False

def main(): 
    s = SI()
    x, y = LI()

    x_moves = []
    y_moves = []
    moving_x = True
    for i in s.split('T'):
        if moving_x:
            x_moves.append(len(i))
        else:
            y_moves.append(len(i))
        moving_x = not moving_x

    if can_reach(x, x_moves[0], x_moves[1:]) and can_reach(y, 0, y_moves):
        print('Yes')
    else:
        print('No')


main()

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll k = min(b-1, n);
    cout << a*k/b - a*(k/b) << endl;
    return 0;
}

Measured memory_bytes: 3624
function Main(input){
  var inp = input.split('\n');
  var N = parseInt(inp[0].trim());
  var K = parseInt(inp[1].trim());
  var x = inp[2].trim().split(' ').map(n => { return parseInt(n)});

  var sum = 0;

  for(var i = 0; i < N; i++){
    var distanceA = x[i];
    var distanceB = K - x[i] ;
    // 距離の小さい方を選択
    var distance = distanceA < distanceB ? distanceA : distanceB;
    distance *= 2;
    sum += distance;
  }
  console.log(sum);

}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

main(){
	int n; cin>>n;
	int a[n];
	for(int &it : a) cin>>it;
	
	int ans = 0;
    for(int i=1; i<n; i++){
		if(a[i] < a[i-1]){
			ans += a[i-1]-a[i];
			a[i] += a[i-1]-a[i];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5080
from sys import stdin
import collections
n = int(stdin.readline().rstrip())
V = [int(x) for x in stdin.readline().rstrip().split()]
V_odd = [V[2 * k] for k in range(int(n / 2))]
V_even = [V[2 * k + 1] for k in range(int(n / 2))]
co = collections.Counter(V_odd)
ce = collections.Counter(V_even)
if co.most_common()[0][0] != ce.most_common()[0][0]:
    print(n - co.most_common()[0][1] - ce.most_common()[0][1])
elif len(co.most_common()) == 1 and len(ce.most_common()) == 1:
    print(co.most_common()[0][1])
else:
    print(n - (max(co.most_common()[1][1] + ce.most_common()[0][1], co.most_common()[0][1] + ce.most_common()[1][1])))

Measured memory_bytes: 19032
#include<stdio.h>

int gcd(int a,int b){ 
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    printf("%d\n",gcd(x,y));
    return 0;
}

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

int main() {
  int a[3][3]; 
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }
  bool ok[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      ok[i][j] = false;
    }
  }
  
  int N; cin >> N;
  
  for (int i = 0; i < N; i++) {
    int b; cin >> b;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a[i][j]==b) {ok[i][j] = true;}
      }
    }
  }
  
  bool res = false;
  for (int i = 0; i < 3; i++) {
    if (ok[i][0] && ok[i][1] && ok[i][2]) {res = true;}
  }
  for (int i = 0; i < 3; i++) {
    if (ok[0][i] && ok[1][i] && ok[2][i]) {res = true;}
  }
  if (ok[0][0] && ok[1][1] && ok[2][2]) {res = true;}
  if (ok[0][2] && ok[1][1] && ok[2][0]) {res = true;}
  
  if (res) {cout << "Yes" << endl;}
  else {cout << "No"<< endl;}
}

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

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

    int n, y;
    cin >> n >> y;
    y /= 1000;

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            int k = n - i - j;
            if (y == 10*i + 5*j + k && k >= 0) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int n, m;

int main() {
	cin >> n >> m;
	for(int i = 0; i <= m / 10000; i++)
		for(int j = 0; j <= (m - i * 10000) / 5000; j++)
		{
			int k = (m - i * 10000 - j * 5000) / 1000;
			if(i + j + k == n)
			{
				printf("%d %d %d\n", i, j, k);
				return 0;
			}
		}
	puts("-1 -1 -1");
}

Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math","-fno-stack-protector")
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
const int MOD=1e9+7;
#define SZ 666666
int d,c[26],s[999][26],g[999],g_[999];
ll f()
{
	int lp[26];
	memset(lp,0,sizeof lp);
	ll ans=0;
	for(int i=1;i<=d;++i)
	{
		assert(g[i]>=0&&g[i]<26);
		lp[g[i]]=i;
		ans+=s[i][g[i]];
		for(int j=0;j<26;++j)
			ans-=(i-lp[j])*(ll)c[j];
	}
	return ans;
}
int main()
{
	srand(19260817);
	cin>>d;
	for(int i=0;i<26;++i) cin>>c[i];
	for(int i=1;i<=d;++i)
		for(int j=0;j<26;++j) cin>>s[i][j];
	for(int i=1;i<=d;++i) g[i]=rand()%26;
	ll of=f();
	int gc=0;
	while((++gc)%100!=0||clock()<CLOCKS_PER_SEC*1.8)
	{
		for(int i=1;i<=d;++i) g_[i]=g[i];
		int x=1;
		while(rand()%2) ++x;
		while(x--)
		{
			int p=rand()%d+1;
			g[p]=rand()%26;
		}
		ll cf=f();
		if(cf<of)
		{
			for(int i=1;i<=d;++i) g[i]=g_[i];
		}
		else of=cf;
	}
	for(int i=1;i<=d;++i)
		cout<<g[i]+1<<"\n";
	cerr<<of<<"\n";
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

int N;
vector<long double> P;
vector<vector<long double>> DP;

int main() {
	cin >> N;
	P.resize(N+1);
	for (int n = 1; n <= N; n++)cin >> P[n];
	DP.resize(N + 1, vector<long double>(N + 1, 0));
	DP[1][1] = P[1];
	DP[1][0] = 1 - P[1];
	for (int n = 2; n <= N; n++) {
		for (int k = 0; k <= n; k++) {
			DP[n][k] += DP[n - 1][k] * (1-P[n]);
			if (k - 1 >= 0)DP[n][k] += DP[n - 1][k - 1] * P[n];
		}
	}
	long double ans = 0;
	for (int k = N; 2 * k > N; k--)ans += DP[N][k];
	cout << setprecision(12) << ans << endl;
	return 0;
}

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

int main(){
    int h, w; cin >> h >> w;
    vector<vector<int>> dp(10, vector<int> (10)); //dp[i][j]はiからjにする最小コスト
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> dp.at(i).at(j);
        }
    }
    vector<vector<int>> a(h, vector<int> (w)); 
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a.at(i).at(j);
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]); //iを経由してjからkに行くのを比較
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a.at(i).at(j) == -1) continue;
            ans += dp[a.at(i).at(j)][1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int N;
int a[101];
int cost, min = 987654321;

int main(void)
{
  int i, j;
  
  scanf("%d", &N);
  for (i = 0; i < N; ++i)
  {
    scanf("%d", &a[i]);
  }
  
  for (i = -100; i <= 100; ++i)
  {
    cost = 0;
    for (j = 0; j < N; ++j)
    {
      cost += (a[j]-i)*(a[j]-i);
    }
    if (cost < min) min = cost;
  }
  printf("%d\n", min);
  
  return 0;
}

Measured memory_bytes: 128