akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	printf("%d\n", 2 * (b - a) + a);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{

    long long week;
    long long i;
    long long raise;
    long long buget = 100000;
    
    scanf("%lld",&week);
    for (i = 0; i < week; i++) {
        buget = buget + buget * 0.05;
        //printf("%lld\n",buget);
        raise = buget % 1000;
        //printf("%lld\n",raise);
        if (raise != 0) {
            buget -= raise;
            buget += 1000;
        }
    }
    printf("%lld\n",buget);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s, ans;

int main(){
	cin >> s;
	REP(i, s.size()){
		if (s[i] == 'B'){
			if (!ans.empty())ans.pop_back();
		}
		else{
			ans += s[i];
		}
	}
	cout << ans << endl;
}

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

int main(void)
{
    int n, m;
    // leftmost, rightmost
    int lm, rm;
    int l, r;
    int result;
    int i;

    cin >> n >> m;
    lm = 1;
    rm = n;
    result = -1;
    for (i = 0; i < m; ++i) {
        cin >> l >> r;
        if (lm < l) {
            lm = l;
        }
        if (r < rm) {
            rm = r;
        }
        if (rm < lm) {
            result = 0;
            break;
        }
    }

    if (result != 0) {
        result = rm - lm + 1;
    }
    cout << result << endl;

    return 0;
}


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

int main(void){
    int W;
    vector<int> A(2);
    cin>>W>>A[0]>>A[1];
    sort(A.begin(),A.end());
    int ans;
    if (A[0]+W >= A[1]) {
        ans = 0;
    }
    else {
        ans = A[1] - (A[0] + W);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import collections

h,w=map(int,input().split())
board=[]
for _ in range(h):
  board.append(list(input()))

ans=0
for i in range(h):
  for j in range(w):
    if board[i][j]=='#':
      continue
    q=collections.deque()
    q.append((i,j,0))
    checked=[[0]*w for _ in range(h)]
    checked[i][j]=1
    while 1:
      y,x,s=q.popleft()
      if x>0 and board[y][x-1]!='#' and checked[y][x-1]==0:
        q.append((y,x-1,s+1))
        checked[y][x-1]=1
      if x<w-1 and board[y][x+1]!='#' and checked[y][x+1]==0:
        q.append((y,x+1,s+1))
        checked[y][x+1]=1
      if y>0 and board[y-1][x]!='#' and checked[y-1][x]==0:
        q.append((y-1,x,s+1))
        checked[y-1][x]=1
      if y<h-1 and board[y+1][x]!='#' and checked[y+1][x]==0:
        q.append((y+1,x,s+1))
        checked[y+1][x]=1
      if len(q)==0:
        ans=max(ans,s)
        break
print(ans)

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int fibo[n + 1] = { 1, 1 };

	for (int i = 2; i <= n; i++) {
		fibo[i] = fibo[i - 1] + fibo[i - 2];
	}
	cout << fibo[n] << endl;

	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int i,j,k,n,x,z=0,y=0,mn=10000000000,sum=0;
    vector<long long int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
        sum+=x;
    }
    for(i=0;i<n-1;i++)
    {
        y+=v[i];
        z=sum-y;
        mn=min(mn,abs(z-y));
    }
    cout<<mn<<endl;

}


Measured memory_bytes: 2420
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <array>
using namespace std;
int n;
vector<int> c, s, f, result;
int main(void) {
    cin >> n;
    for(int i = 0; i < n - 1; i++) {
        int tc, ts, tf;
        cin >> tc >> ts >> tf;
        c.push_back(tc);
        s.push_back(ts);
        f.push_back(tf);
    }
    for(int i = 0; i < n; i++) {
        int t = 0;
        for(int j = i; j < n -1; j++) {
            if(t < s[j]) {
                t = s[j];
            } else if(t % f[j] == 0) {
            } else {
                t = t + f[j] - (t % f[j]);
            }
            t += c[j];
        }
        result.push_back(t);
    }
    for(int i = 0; i < n; i++) {
        cout << result[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    int n;
    cin >> n;
    vector<int> data(n, 0);
    for(int i = 0;i < n-1;++i){
        int a;
        cin >> a;
        data[a-1] += 1;
    }

    for(int i = 0;i < n;++i){
        cout << data[i] << endl;
    }

    return 0;
}

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

template <typename T>
class node {
public:
	node<T> *l, *r;
	T val, add;
	node(T val_ = 0, node<T>* l_ = nullptr, node<T>* r_ = nullptr)
		: l(l_), r(r_), val(val_), add(0) {}
};

template <typename T>
class RARS {
	const ll n;
	node<T> *root;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	T sub(ll l, ll r, node<T>* n, ll lb, ll ub) {
		if (!n || ub <= l || r <= lb) return 0;
		if (l <= lb && ub <= r) return n->val + n->add * (ub - lb);
		return sub(l, r, n->l, lb, (lb + ub) / 2) + sub(l, r, n->r, (lb + ub) / 2, ub) + n->add * (min(r, ub) - max(l, lb));
	}
	node<T>* suc(ll l, ll r, node<T>* n, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return n;
		if (!n) n = new node<T>;
		if (l <= lb && ub <= r) {
			n->add += val;
			return n;
		}
		n->val += val * (min(r, ub) - max(l, lb));
		n->l = suc(l, r, n->l, lb, (lb + ub) / 2, val);
		n->r = suc(l, r, n->r, (lb + ub) / 2, ub, val);
		return n;
	}
public:
	RARS(ll n_) : n(size(n_)), root(nullptr) {}
	void add(ll l, ll r, T val) {
		root = suc(l, r + 1, root, 0, n, val);
	}
	T getSum(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

template <typename T>
class node2 {
public:
	RARS<T> val, add;
	node2<T> *l, *r;
	node2(ll size) : val(size), add(size), l(nullptr), r(nullptr) {}
};

template <typename T>
class RARS2 {
	const ll h, w;
	node2<T> *root;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1ll;
		return res;
	}
	T sub(ll li, ll lj, ll ri, ll rj, node2<T>* n, ll lb, ll ub) {
		if (!n || ub <= li || ri <= lb) return 0;
		if (li <= lb && ub <= rj) return n->val.getSum(lj, rj) + n->add.getSum(lj, rj) * (ub - lb);
		return sub(li, lj, ri, rj, n->l, lb, (lb + ub) / 2) + sub(li, lj, ri, rj, n->r, (lb + ub) / 2, ub) + n->add.getSum(lj, rj) * (min(ri, ub) - max(li, lb));
	}
	node2<T>* suc(ll li, ll lj, ll ri, ll rj, node2<T>* n, ll lb, ll ub, T val) {
		if (ub <= li || ri <= lb) return n;
		if (!n) n = new node2<T>(w);
		if (li <= lb && ub <= ri) {
			n->add.add(lj, rj, val);
			return n;
		}
		n->val.add(lj, rj, val * (min(ri, ub) - max(li, lb)));
		n->l = suc(li, lj, ri, rj, n->l, lb, (lb + ub) / 2, val);
		n->r = suc(li, lj, ri, rj, n->r, (lb + ub) / 2, ub, val);
		return n;
	}
public:
	RARS2(ll h_, ll w_) : h(size(h_)), w(w_), root(nullptr) {}
	void add(ll li, ll lj, ll ri, ll rj, T val) {
		root = suc(li, lj, ri + 1, rj, root, 0, h, val);
	}
	T getSum(ll li, ll lj, ll ri, ll rj) {
		return sub(li, lj, ri + 1, rj, root, 0, h);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	RARS2<ll> lst(1, n);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type >> s >> t; s--; t--;
		if (type) {
			printf("%lld\n", lst.getSum(0, s, 0, t));
		}
		else {
			cin >> x;
			lst.add(0, s, 0, t, x);
		}
	}
	return 0;
}

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

int main()
{
	int m,n;
	char s[100001];
	int i,k;
	int deme[100000];
	int te=0;
	int p;
	int fix;

	scanf("%d %d\n", &n, &m);
	for (i=0;i<=n;++i){
		scanf("%c", &s[i]);
	}

	p=n;
	while (p>0){
		fix=0;
		k=m;
		while (fix==0){
			if (p-k>=0){
				if (s[p-k]=='0'){
					p=p-k;
					deme[te]=k;
					te=te+1;
					fix=1;
				}
			}
			k=k-1;
			if ((k==0)&&(fix==0)){
				printf("-1");
				return 0;
			}
		}
	}
	for(i=te-1;i>=0;--i){
		printf("%d ", deme[i]);
	}

	return 0;
}


Measured memory_bytes: 896
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'





int32_t main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int res=1;
  int n,mn;
  cin>>n>>mn;
  n--;
  while(n--){
    int p; cin>>p;
    if(p<=mn){
      res++;
    }
    mn = min(p,mn);
  }

  cout<<res<<endl;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner sc = new Scanner(System.in);
		int x=Integer.parseInt(sc.next());
		int y=Integer.parseInt(sc.next());
		while(x!=0 || y!=0){
			if(x<y) System.out.println(x+" "+y);
			else System.out.println(y+" "+x);
			x=Integer.parseInt(sc.next());
			y=Integer.parseInt(sc.next());
		}

	}

}

Measured memory_bytes: 35964
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

B = sorted([(A[i], i + 1) for i in range(N)], reverse=True)
dp = defaultdict(int)

for S in range(1, N + 1):
    for x in range(S + 1):
        y = S - x
        candid = []
        if x >= 1:
            candid.append(dp[(x - 1, y)] + B[S - 1][0]
                          * (B[S - 1][1] - x))
        if y >= 1:
            candid.append(dp[(x, y - 1)] + B[S - 1][0]
                          * ((N - y + 1) - B[S - 1][1]))
        dp[(x, y)] = max(candid)

print(max([dp[(i, N - i)] for i in range(N + 1)]))


Measured memory_bytes: 334984
s=input()
p="AKIHABARA"
c=[0,4,6,8]
for i in range(16):
    t=bin(i)[2:]
    t="0"*(4-len(t))+t
    d=p[:]
    for j in range(4):
        if t[j]!="1":
            d=d[:c[j]]+"?"+d[c[j]+1:]
    else:
        if d.replace("?","")==s:
            print("YES")
            break
else:
    print("NO")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define MAX 200004

char buf[MAX];
string s;

deque<int> v[MAX];

vector<pair<int, int> > star[MAX];

struct st {
	int bit[MAX];
	void add(int i, int x) {
		i++;
		while (i < MAX) {
			bit[i] += x;
			i += i&-i;
		}
	}
	int sum(int i) {
		int r = 0;
		i++;
		while (i) {
			r += bit[i];
			i -= i&-i;
		}
		return r;
	}
	st() {
		memset(bit, 0, sizeof(bit));
	}
};

st k;

int main() {
	scanf("%s", buf);
	s = buf;
	for (int i = 0; i < s.size(); i++) {
		v[s[i] - 'a'].push_back(i);
	}
	int cnt = 0;
	for (int i = 0; i < 26; i++) {
		cnt += v[i].size() % 2;
	}
	if (cnt > 1) {
		puts("-1");
		return 0;
	}
	long long int add = -1;
	for (int i = 0; i < 26; i++) {
		while (v[i].size() > 1) {
			int lef = v[i][0];
			v[i].pop_front();
			int rig = v[i].back();
			v[i].pop_back();
			star[lef].push_back(make_pair(rig, i));
		}
		if (v[i].size() == 1) {
			add = v[i][0];
		}
	}
	long long int way = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < star[i].size(); j++) {
			
			int en = star[i][j].first;
			if (add != -1) {
				if (i >= add || en <= add) {
					way++;
				}
			}
			way += k.sum(en) - k.sum(i);
			way += k.sum(i) * 2;
			k.add(en, 1);
		}
	}
	printf("%lld\n", way);
	return 0;
}


Measured memory_bytes: 143616
//rohitaas_15
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> o_set;
#define um(a,b) unordered_map<a,b>
#define ll  long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define f(a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define show(x) cout<<x<<"\n"
#define printvector(v,n) f(0,n-1){cout<<v[i]<<" ";}
#define input(v,n) f(0,n-1){cin>>v[i];}
#define vr vector<ll>
#define check() cout<<"hi"<<"\n"
#define MOD 1000000007
#define endl "\n"
#define maxv(v) *max_element(all(v));
#define minv(v) *min_element(all(v));
#define sumv(v) accumulate(all(v),0)
#define test() ll t;cin>>t;while(t--)
ll search(vr arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
ll CmP(ll n, ll r, ll p=MOD){if (r==0)return 1;ll fac[n+1];fac[0] = 1;for (ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p; return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p; }
int main()
{
	fastio();
	ll x;
	cin>>x;
	ll happy=0;
	happy+=(x/500)*1000;
	x=x%500;
	happy+=(x/5)*5;
	show(happy);
}







Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string S[1001];
	int P[1001];
	vector< pair< pair<string,int>,int > > SP;
	scan(N);
	rep(i,N){
		scan(S[i]>>P[i]);
		SP.push_back(mp(mp(S[i],-P[i]),i+1));
	}
	sort(SP.begin(),SP.end());
	rep(i,N){
		prin(SP[i].second);
	}
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	var c, d int
	if a == "A" {
		c = 10
	} else if a == "B" {
		c = 11
	} else if a == "C" {
		c = 12
	} else if a == "D" {
		c = 13
	} else if a == "E" {
		c = 14
	} else if a == "F" {
		c = 15
	}
	if b == "A" {
		d = 10
	} else if b == "B" {
		d = 11
	} else if b == "C" {
		d = 12
	} else if b == "D" {
		d = 13
	} else if b == "E" {
		d = 14
	} else if b == "F" {
		d = 15
	}
	if c > d {
		fmt.Println(">")
	} else if c < d {
		fmt.Println("<")
	} else {
		fmt.Println("=")
	}
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

int a = in.nextInt();
int b = in.nextInt();
int h = in.nextInt();

int area = (a+b)*h/2;
System.out.println(area);
}
}

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

int N;
int ans[100010] = {};
struct edge{int to, len;};
vector<vector<edge>> v(100010);

void dfs(int n,int m,int c){
    ans[n] = c;
    for(auto x:v[n]){
        if(x.to==m) continue;
        if(x.len==0) dfs(x.to,n,c);
        else dfs(x.to,n,1-c);
    }
}


int main(){
    cin >> N;
    int a,b,w;
    for(int i=0;i<N-1;i++){
        cin >> a >> b >> w;
        w %= 2;
        v[a].push_back({b,w});
        v[b].push_back({a,w});
    }
    dfs(1,0,0);
    for(int i=1;i<=N;i++) cout << ans[i] << endl;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S[2] == S[3] && S[4] == S[5]){
        cout << YES << endl;
    }
    else cout << NO << endl;
    return;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    vll b(n);
    rep(i, n){
        cin >> b[i];
    }
    vll ans(29, 0);
    rep(m, 29){
        ll ca = 0, cb = 0;
        rep(i, n){
            ca += (a[i] >> m) & 1;
            cb += (b[i] >> m) & 1;
        }
        dump(ca, cb);
        ans[m] += (n-ca)*cb+ca*(n-cb);
    }
    dump(ans);
    repb(m, 28){
        ll mask = (1ll << (m+1)) - 1;
        rep(i, n){
            a[i] &= mask;
            b[i] &= mask;
        }
        sort(ALL(a));
        sort(ALL(b));
        ll pb = n-1, thr = (1ll << (m+1));
        dump(a, b, thr);
        // a[pa]+b[pb] >= thr
        rep(pa, n){
            while(pb >= 0 && a[pa]+b[pb] >= thr) pb--;
            ans[m+1] += n-1-pb;
        }
    }
    dump(ans);
    ll finalans = 0;
    rep(i, 29){
        if(ans[i] & 1) finalans |= (1ll << i);
    }
    cout << finalans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cstring>
#include <functional>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn=2e3+10;
typedef long long ll;
const ll MOD=1e9+7;
ll Pow(ll x,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans=ans*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return ans;
}
ll fact[8050],inv[8050];
void init(){
	fact[0]=1;
	for (int i = 1; i < 8050; ++i)
	{
		fact[i]=fact[i-1]*i%MOD;
	}
	inv[8049]=Pow(fact[8049],MOD-2);
	for (int i = 8048; i >= 0; --i)
	{
		inv[i]=inv[i+1]*(i+1)%MOD;
	}
}
int a[200050],b[200050],n;
ll dp[4050][4050];
int main(int argc, char const *argv[])
{
	init();
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d%d", a+i,b+i);
		dp[2000-a[i]][2000-b[i]]++;
	}
	for (int i = 0; i <= 4000; ++i)
	{
		for (int j = 0; j <= 4000; ++j)
		{
			ll &u=dp[i][j];
			if(i) u=(u+dp[i-1][j])%MOD;
			if(j) u=(u+dp[i][j-1])%MOD;
		}
	}
	ll ans=0;
	for (int i = 0; i < n; ++i)
	{
		ans=(ans+dp[2000+a[i]][2000+b[i]]-fact[a[i]*2+b[i]*2]*inv[a[i]*2]%MOD*inv[b[i]*2]%MOD)%MOD;
	}
	ans=(ans*inv[2]%MOD+MOD)%MOD;
	printf("%lld\n", ans);
	return 0;
}

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

int check(string S){
  for(size_t i = 0;i < S.size();i++){
    if(S[i] == 'R' && (i+1) % 2 != 1) return 0;
    if(S[i] == 'L' && (i+1) % 2 != 0) return 0;
  }
  return 1;
}

int main()
{
  string S;
  int ans;

  cin>>S;

  ans = check(S);

  if(ans == 1){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a-2*b>=0)
     cout<<a-2*b;
    else 
     cout<<"0";
    return 0;
}
     
   




Measured memory_bytes: 3592
#include<stdio.h>

int main(){
  int i, j, n, s[100000], q, t[50000], cnt = 0;
  int l, r, m;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &s[i]);
  }

  scanf("%d", &q);
  for(j = 0; j < q; j++){
    scanf("%d", &t[j]);

    l = 0;
    r = n;
    while(l < r){
      m = (l + r)/2;
      if(s[m] == t[j]){
	cnt++;
	break;
      }
      else if(t[j] < s[m]){
	r = m;
      }
      else {
	l = m + 1;
      }
    }
  }

  printf("%d\n", cnt);

  return 0;
}



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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
using ll = long long;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int dp[33][33][4];
int W, H;

void init() {
    REP(i, H) {
        REP(j, W) {
            REP(k, 4) { dp[i][j][k] = 1e9; }
        }
    }
    dp[0][0][0] = 0;
}

int A[55][55];

using arr4 = array<int, 4>;
int C[5];
bool solve() {
    cin >> W >> H;
    if (W == 0) return false;
    init();
    REP(i, H) {
        REP(j, W) { cin >> A[i][j]; }
    }
    REP(i, 4) cin >> C[i];
    priority_queue<arr4, vector<arr4>, greater<arr4>> que;
    que.push({0, 0, 0, 0});
    while (!que.empty()) {
        arr4 ar = que.top();
        que.pop();
        int c = ar[0], x = ar[1], y = ar[2], dir = ar[3];
        if (c > dp[x][y][dir]) continue;
        if (A[x][y] != 4) {
            int nx = x + dx[(dir + A[x][y]) % 4];
            int ny = y + dy[(dir + A[x][y]) % 4];
            if (nx < H && nx >= 0 && ny < W && ny >= 0) {
                int nd = (dir + A[x][y]) % 4;
                if (dp[nx][ny][nd] > dp[x][y][dir]) {
                    dp[nx][ny][nd] = dp[x][y][dir];
                    que.push({dp[nx][ny][nd], nx, ny, nd});
                }
            }
        }
        REP(i, 4) {
            int nd = (dir + i) % 4;
            int nx = x + dx[nd];
            int ny = y + dy[nd];
            if (nx < H && nx >= 0 && ny < W && ny >= 0) {
                if (dp[nx][ny][nd] > dp[x][y][dir] + C[i]) {
                    dp[nx][ny][nd] = dp[x][y][dir] + C[i];
                    que.push({dp[nx][ny][nd], nx, ny, nd});
                }
            }
        }
        //
    }
    int ans = 1e9;
    REP(i, 4) { ans = min(ans, dp[H - 1][W - 1][i]); }
    cout << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fr(a,b) for(int i=a;i<b;i++)
#define prDouble(x) cout<<fixed<<setprecison(18)<<x
#define mod 1000000007

int solve(std::vector<int>& v, int n, int k)
{
	ll dp[n + 2][k + 2];


	//base case
	//number of candies greater then maxm
	for (int j = 0; j <= k; j++)
		dp[1][j] = (j > v[1]) ? 0 : 1;

	//considering first i children distribute j candies
	for (int i = 2; i <= n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (j == 0)//give zero candies as we have zero candies
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = (mod +  dp[i][j - 1] + dp[i - 1][j] - ((j - v[i] - 1 >= 0) ? dp[i - 1][j - v[i] - 1] : 0)) % mod;
		}
	}
	return dp[n][k];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	std::vector<int> v(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	cout << solve(v, n, k);
}

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

int main() {
 long long a,b,c,k;
 cin>>a>>b>>c>>k;
 
  if(a>k){
	cout<<k<<endl;
    return 0;
  }
  	if(a+b>=k){
		 cout<<a<<endl;	//a
    }
	
	else{
		 cout<< 2*a+b-k <<endl;	
    }
	
}


Measured memory_bytes: 3624
my ($a,$b,$k);
{
    chomp(my $in = <STDIN>);
    ($a,$b,$k) = split(" ", $in); 
}

if($a >= $k){
    $a = $a - $k;
    print "$a $b";
}elsif($a + $b <= $k){
    print 0 . " " . 0;
}else{
    $b = $b -($k - $a);
    print 0 . " " . $b
}

Measured memory_bytes: 384
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int n,l,r;
ll last,a[55],jic[99]={1},res;
double ans;
map<ll,int> mp,cnt,vis;
bool bo;
double maxit(){
ll sum=0;
for (int i=1;i<=l;++i)
  sum+=a[i],cnt[a[i]]++;
last=a[l];
if (a[1]==a[l]) bo=1;
return 1.0*sum/l;
}

ll zuhe(int a,int b){
int i;
ll ans=1;
for (i=a-b+1;i<=a;++i){
  ans=ans*i/(i-a+b);
  } 
return ans;
}

int main(){
re0 i;n=read(),l=read(),r=read();
for (i=1;i<=n;++i) read(a[i]),mp[a[i]]++;
sort(a+1,a+n+1,greater<ll>());
printf("%.9lf\n",ans=maxit());
if (bo){
  for (i=l;i<=r;++i) res+=a[1]==a[i]?zuhe(mp[a[1]],i):0; 
  write(res);
  }
else write(zuhe(mp[last],cnt[last]));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
	string s1,s2;
	cin>>s1>>s2;
	int len1=s1.length(),len2=s2.length();
	if(len1>len2){
		printf("GREATER\n");
		return 0;
	}
	else if(len2>len1){
		printf("LESS\n");
		return 0;
	}
	else
	{
		for(int i=0;i<len1;i++){
			if(s1[i]>s2[i]){
				printf("GREATER\n");
				break;
			}
			if(s2[i]>s1[i]){
				printf("LESS\n");
				break;
			}
			if(i==len1-1&&s1[i]==s2[i]){
				printf("EQUAL\n");
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,t,x,y,ans=100000;
  	cin>> n >> t;
  	while(n--){
      	cin>> x >> y;
      	if(y<=t) ans=min(ans,x);
    }
  	if(ans<100000) cout<< ans <<endl;
  	else puts("TLE");
  	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,m,k,a,b,c,d;
string s,t;

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

Measured memory_bytes: 772
N = int(input())
B = list(map(int, input().split()))
A = [B[0]]

if N == 2:
    print(sum(B)*2)
else:
    for i in range(1,N-1):
        A.append(min(B[i-1],B[i]))
    A.append(B[i])
    print(sum(A))
        

Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 1<<17;

char s[MAX];

int main()
{
  scanf("%s", s);
  int len = (int) strlen(s);
  int k;
  scanf("%d", &k);

  for (int i=0; i<len; i++) {
    if (s[i] == 'a')
      continue;
    if ('z' - s[i] + 1 <= k) {
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }

  int c = s[len-1] - 'a';
  c = (c + k) % 26;
  s[len-1] = 'a' + c;

  printf("%s", s);

  return 0;
}


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

int main() {
  string s;
  int k;
  cin >> s >> k;

  set<string> ans;

  for(int i=0;i<s.size();i++) {
    int lim = min(5, (int)s.size() - i);
    for(int j=1;j<=lim;j++) {
      string ss = s.substr(i, j);
      ans.emplace(ss);
    }
  }

  set<string>::iterator it = next(ans.begin(), k-1);

  cout << *it << endl; 
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V.at(i);
  
  int ans = 0;
  for (int A = 0; A <= min(N, K); A++) {
    for (int B = 0; B <= min(N, K); B++) {
      if (A + B > min(N, K)) continue;
      int S = 0;
      priority_queue<int, vector<int>, greater<int>> Q;
      for (int i = 0; i < A; i++) {
        S += V.at(i);
        Q.push(V.at(i));
      }
      for (int i = 0; i < B; i++) {
        S += V.at(N - 1 - i);
        Q.push(V.at(N - 1 - i));
      }
      for (int i = 0; i < K - (A + B); i++) {
        if (Q.empty()) break;
        int p = Q.top();
        Q.pop();
        if (p < 0) S -= p;
        else break;
      }
      ans = max(ans, S);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

	int w,h;
int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int dfs(vs &f,vvi &used,pii cur,char color){
	if(f[cur.first][cur.second]=='.')used[cur.first][cur.second]=1;
	bool flag=false;
	if(f[cur.first][cur.second]!=color&&f[cur.first][cur.second]!='.'){
		return -1;
	}else if(f[cur.first][cur.second]==color){
		return 0;
	}
	int ret=1;
	REP(d,4){
		int y=cur.first+dy[d];
		int x=cur.second+dx[d];
		if(y>=0&&x>=0&&y<h&&x<w&&!used[y][x]){
			int v=dfs(f,used,make_pair(y,x),color);
			if(v==-1){
				flag=true;
			}else{
				ret+=v;
			}
		}
	}
	if(flag){
		return -1;
	}else{
		return ret;
	}
}
int main(){
	while(cin>>w>>h,w|h){
		vs f(h);
		bool flag=false;
		REP(i,h){
			cin>>f[i];
			REP(j,w){
				if(f[i][j]!='.')flag=true;
			}
		}
		if(!flag){
			cout<<"0 0"<<endl;
			continue;
		}
		vi areas(2);
		REP(c,2){
			vvi used(h,vi(w));
			REP(i,h){
				REP(j,w){
					if(!used[i][j]&&f[i][j]=='.'){
						char color=!c?'B':'W';
						int v=dfs(f,used,make_pair(i,j),color);
						if(v!=-1){
							areas[c]+=v;
						}
					}
				}
			}
		}
		cout<<areas[0]<<" "<<areas[1]<<endl;
	}
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int d; cin >> d;
	string ans;
	if (d==25) ans="Christmas";
	else if(d==24) ans="Christmas Eve";
	else if(d==23) ans="Christmas Eve Eve";
	else ans="Christmas Eve Eve Eve";

	cout << ans << endl;

}


Measured memory_bytes: 256
N, K = map(int, input().split())
D = list(map(int, input().split()))
S = ""
ND = []
for i in range(10):
  if i not in D:
    ND.append(i)

if K == 9:
  S = str(ND[0])
  while int(S) < N:
    S = str(ND[0]) + S[:]
  print(int(S))
else:
  l = 0
  F = ND[0]
  j = 10 - K
  cnt = 0
  while F < N:
    l += 1
    s = l
    F = 0
    ju = 1
    if l == j:
      l, s = 0, 0
      j *= 10 - K
      cnt += 1
    for x in range(cnt+1):
      F += ND[s%(10 - K)] * ju
      ju *= 10
      s //= 10 - K
  print(F)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/27  Problem: ABC 115 A / Link: http://abc115.contest.atcoder.jp/tasks/abc115_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N; 
	cin >> N;
	
	cout << "Christmas";
	int cnt = 25 - N;
	FOR(i, 0, cnt) {
		cout << " Eve";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
template<class T>
class BIT {
    vector<T> bit;


public:
    BIT(int n): bit(vector<T>(n+1, 0)){}

    T sum(int k){
        T ret = 0;
        for (++k; k > 0; k -= (k & -k)) ret += bit[k];
        return ret;
    }

    void add(int k, T x){
        for (++k; k < bit.size(); k  += (k & -k)) bit[k] += x;
    }
};


int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> v(n), v2(n);
    vector<int> used(n, 0);
    ll sum = 0;
    ll ans = (ll)n*(n+1)/2;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        sum += x-k;
        v2[i] = v[i] = sum;
        ans -= (v[i] < 0);
    }
    BIT<int> dp(n);
    sort(v2.begin(), v2.end());
    for (int i = 0; i < n; ++i) {
        int x = static_cast<int>(lower_bound(v2.begin(), v2.end(), v[i]) - v2.begin());
        dp.add(x+used[x], 1);
        ans += dp.sum(x+used[x])-i-1;
        used[x]++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	string S;
	cin>>S;
	int wcnt=0;
	ll ans=0;
	REP(i,S.size()){
		if(S[i]=='W'){
			ans+=i-wcnt;
			wcnt++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 720
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll a, b, n; cin >> a >> b >> n;
	if (n >= b)cout << (a*(b - 1)) / b << endl;
	else cout << (a*n) / b << endl;
}

Measured memory_bytes: 3596
N = int(input())
A = list(map(int, input().split()))
neg = sum([1 for i in range(N)  if A[i] < 0])
s = [abs(A[i]) for i in range(N)]
ans = sum(s)
if neg % 2 == 0:
  print(ans)
else:
  print(ans - 2*min(s))

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

int main(){
	int N = 0, S = 0;
	string s;

	cin >> s;
	N = atoi(s.c_str());

	for (string::iterator itr = s.begin(); itr != s.end(); ++itr){
		char c = *itr;
		S += atoi(&c);
	}

	if (N % S == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	

	return 0;
}

Measured memory_bytes: 256
object Main {

    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNext){
	        val a,b,c,d,e = sc.nextInt
	        val list = List(a,b,c,d,e).sortWith(_>_)
            println(list.mkString(" "))
    	}
    }
}

Measured memory_bytes: 44956
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[101], p[101], s2[202] = "";
	char *ret;
	scanf("%s", s);
	scanf("%s", p);
	
	strcat(s2, s);
	strcat(s2, s);
	ret = strstr(s2, p);
	if (ret == NULL) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	
	return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int a,p;cin>>a>>p;
    p += a*3;
    cout<<p/2<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll bas[2323];
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	ll a,b;
	cin>>a>>b;
	if(a==b)
    {
        return !printf("1\n");
    }
	ll ans=0ll;
	bas[0]=1;
	repd(i,1,60)
	{
		bas[i]=bas[i-1]*2ll;
	}
	int d=60;
	while((a&bas[d])==(b&bas[d]))
		d--;
	a&=bas[d+1]-1;
	b&=bas[d+1]-1;
	ll l1=a;
	ll r1=bas[d];
	ans+=(r1-l1+1ll);
	int k=d-1;
	while(k>=0&&!(b&(bas[k])))
		k--;
	ll l2=bas[d];
	ll r2=bas[d]+bas[k+1]-1;
	ans+=(r2-l2);
	ll l3=bas[d]+a;
	ll r3=bas[d+1]-1;
	l3=max(l3,r2+1);
	ans+=r3-l3+1;
	cout<<ans<<endl;


    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();}
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9')
{*p = *p * 10 + ch - '0';}}}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length())
	   cout<<"GREATER"<<endl;
	else if(a.length()<b.length())
	   cout<<"LESS"<<endl;
	else 
	{
		if(a>b)
		   cout<<"GREATER"<<endl;
		else if(a<b)
		   cout<<"LESS"<<endl;
      	else
          cout<<"EQUAL"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
#include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif




int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    std::string S; std::cin >> S;
    const int n = S.size();
    const auto sur_arr = atcoder::suffix_array(S);
    const auto lcp_arr = atcoder::lcp_array(S, sur_arr);
    long long int res = static_cast<long long int>(n + 1) * n / 2;
    for(const auto p : lcp_arr) res -= p;
    std::cout << res << '\n';
    return 0;
}

Measured memory_bytes: 15584
n,k = gets.split.map(&:to_i)
d = gets.split.map(&:to_i)
av = 10.times.reject { |v| d.include? v }.sort
price = n.to_s.chars.map(&:to_i)
pay = Array.new(price.size,av.last)
if price.join.to_i > pay.join.to_i
    price.unshift 0
    pay.unshift 0
end

price.size.times do |i|
   av.find do |v| 
     pay[i] = v
     pay.join.to_i(10) >= n
   end
end
puts pay.join.to_i(10)

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}



long long combination(int n, int k){
    static const int maxi = 1e6+1;
    static vector<ll> fac(maxi,0),finv(maxi,0),inv(maxi,0);
    static const int mod = 1e9+7;
    // キャッシュされてない場合COMinit()と同様のことをする。
    if (fac[0]==0) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < maxi; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


string N;
ll K;

// i桁目まで見たとして、残りがk回0以外を入れられていて、未満確定ならsmallerはtrueで答えを出す。
ll solve(ll i,ll k,bool smaller) {
    // 途中だがkが0になった。(=残りの桁があっても、0で埋まるので1を返す)
    if (k == 0) return 1;

    // 最後の桁まで走査した(= 最後の桁まで決定した && k != 0 なので 0を返す)
    if ( i == N.size()) return 0;

    // N未満であることが確定しているならば残りの桁は何でも入るので組み合わせを使って返す
    if (smaller) return combination(N.size()-i,k) * (ll)pow((ll)9,(ll)k);

    // まだ未満とは限らない場合

    // 今見ている桁に相当するNの値が0なら先に進む。
    if (N[i] == '0') return solve(i+1,k,false);

    // N[i]が0でない場合、 その桁には0,1,...と入る可能性がある。
    // i桁目に0を入れた場合の個数 (明らかにN以下の値になるためフラグはtrueになる)
    auto zero = solve(i+1,k,true);
    // i桁目に0<k<N[i]を満たす様な値を入れた場合(明らかにN以下の値になるためフラグはtrueになる)
    // N[i] == 1ならmidはないし、N[i] == 3ならmidはN[i] == 1,2のことになるので適宜調整をする。
    auto mid =  solve(i+1,k-1,true) * (N[i]- '1');
    // i桁目にN[i]を入れた場合
    auto last = solve(i+1,k-1,false);

    return zero + mid + last;

}

int main() {

    cin >> N;

    cin >> K;


    cout << solve(0,K, false) << endl;
    return 0;
}


Measured memory_bytes: 23936