akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  N=S.size();
  rep(i,1,N)if(S[i]=='9')sum++;
  if(sum!=N-1)flag=1;
  K=S[0]-48;
  Out(K+9*(N-1)-flag);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<40;//62


class WAR_FLY {
public:
    vector<vector<ll> > d; //辺の数
    ll V; //頂点の数
    
    WAR_FLY(ll n) {
        V = n;
        d = vector<vector<ll> > (n,vector<ll>(n));
        for(ll i = 0; i < V; i++) {
            for(ll j = 0; j < V; j++) {
                if(i == j) {
                    d[i][j] = 0;
                }
                else {
                    d[i][j] = LLINF;
                }
            }
        }
    }

    void warshall_floyd() {
        for(ll k = 0; k < V; k++) {
            for(ll i = 0; i < V; i++) {
                for(ll j = 0; j < V; j++) {
                    d[i][j] = min((ll)d[i][j], (ll)d[i][k] + (ll)d[k][j]);
                }
            }
        }
    }

    void add(ll from, ll to, ll cost) {
        d[from][to] = cost;
    }

    bool is_negative_loop() {
        for(ll i = 0; i < V; i++) {
            if(d[i][i] < 0) return true;
        }
        return false;
    }

    void show() {
        for(ll i = 0; i < V; i++) {
            for(ll j = 0; j < V; j++) {
                cout << d[i][j] << " ";
            }
            cout << endl;
        }
    }
};

int main(void){

    ll v,e,s,t,d;
    cin>>v>>e;
    WAR_FLY wa(v);
    rep(i,e){
        cin>>s>>t>>d;
        wa.add(s,t,d);
    }
    wa.warshall_floyd();
    // wa.show();
    if(wa.is_negative_loop()){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    rep(i,v){
        rep(j,v){
        if(wa.d[i][j]>=INF)cout<<"INF";
        else cout<<wa.d[i][j];
        if(j!=v-1)cout<<' ';
        }
        cout<<endl;
    }
}


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

typedef long long ll;

const long long MOD = 1000000007;

pair<ll, ll> iegcd(const ll a, const ll b, const ll x = 1, const ll u = 0)
{
    if (b == 0)
    {
        return make_pair(a, x);
    }
    else
    {
        return iegcd(b, a % b, u, x - (a / b) * u);
    }
}

ll modpls(const ll a, const ll b, const ll m = MOD)
{
    return (a + b) % m;
}

ll modmin(const ll a, const ll b, const ll m = MOD)
{
    ll res = (a - b) % m;
    if (res < 0)
    {
        return res + m;
    }
    else
    {
        return res;
    }
}

ll modinv(const ll a, const ll m = MOD)
{
    /* m should be a prime */
    pair<ll, ll> res = iegcd(a, m);
    return res.second;
}

ll modmult(const ll a, const ll b, const ll m = MOD)
{
    return ((a % m) * (b % m)) % m;
}

ll moddiv(const ll a, const ll b, const ll m = MOD)
{
    return modmult(a, modinv(b, m), m);
}

ll modfactorial(const ll n, const ll m = MOD)
{
    /* it should be that n >= 1 */
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = modmult(i, res, m);
    }
    return res;
}

ll modcombination(const ll n, const ll k, const ll m = MOD)
{
    /* it should be that n >= k >= 1 */
    ll k2 = min(n - k, k);

    ll num = 1;
    for (size_t i = n; i > n - k2; i--)
    {
        num = modmult(num, i, m);
    }

    ll den = 1;
    for (size_t i = k2; i > 1; i--)
    {
        den = modmult(den, i, m);
    }

    return moddiv(num, den, m);
}

ll modpow(const ll a, const ll n, const ll m = MOD)
{
    if (n == 1)
    {
        return a % m;
    }
    else if (n % 2 == 1)
    {
        return modmult(a, modpow(a, n - 1, m), m);
    }
    else
    {
        ll t = modpow(a, n / 2, m);
        return modmult(t, t, m);
    }
}

void solve(long long n, long long a, long long b)
{
    if (n == 2 && a == 1 && b == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        ll res = modpow(2, n, MOD);
        res = modmin(res, 1, MOD);
        res = modmin(res, modcombination(n, a, MOD));
        res = modmin(res, modcombination(n, b, MOD));
        cout << res << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long n;
    scanf("%lld", &n);
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    solve(n, a, b);
    return 0;
}


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

l = []
for i in range(n):
    a,b = map(int,input().split())
    l.append([a,b])

l = sorted(l, key = lambda x:x[0])
cnt = 0    
for a,b in l:
    cnt += b
    
    if cnt >= k:
        print(a)
        break

Measured memory_bytes: 22144
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	char a,b;
	cin >> a >> b;
	if(a=='H') cout<<b<<endl;
	else if(b=='H') cout<<'D'<<endl;
	else cout<<'H'<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,m;
	while(scanf("%d%d",&n,&m)){
		if(n==0) break;
	int x[1000],i,sum=0;
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
		sum+=x[i];
	}
	sort(x,x+n);
	for(i=n%m;i<n;i+=m){
		sum-=x[i];
	}
	printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1044
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let ab: Vec<(usize, usize)> = (0..m)
        .map(|_| {
            let a = input();
            let b = input();
            (a, b)
        })
        .collect();

    let mut path = vec![vec![]; n + 1];
    for &(a, b) in &ab {
        path[a].push(b);
        path[b].push(a);
    }

    let mut v = vec![false; n + 1];
    v[0] = true;
    v[1] = true;
    println!("{}", dfs(1, &mut v, &path));
}

fn dfs(cur: usize, visited: &mut Vec<bool>, path: &Vec<Vec<usize>>) -> i64 {
    let mut temp = 0;
    for &next in &path[cur] {
        if !visited[next] {
            temp += 1;
        }
    }

    if temp == 0 {
        if visited.iter().all(|&b| b) {
            1
        } else {
            0
        }
    } else {
        let mut ans = 0;
        for &next in &path[cur] {
            if !visited[next] {
                visited[next] = true;
                ans += dfs(next, visited, path);
                visited[next] = false;
            }
        }
        ans
    }
}


Measured memory_bytes: 4352
/* 
 * Project: AtCoder Beginners Contest 151 C - Welcome to AtCoder
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/19
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
using namespace std;

int n;
int m;

int main() {

    cin >> n >> m;
    vector<bool> is_acs(n, false);
    vector<int> wa_cnt(n, 0);
    int ac_cnt = 0;
    int penalty = 0;
    for (int i=0;i<m;i++) {
        int p;
        string s;
        cin >> p >> s;
        if (is_acs[p-1])
            continue;
        if (!s.compare("AC")) {
            is_acs[p-1] = true;
            ac_cnt++;
            penalty += wa_cnt[p-1];
        }
        else
            wa_cnt[p-1]++;
    }
    cout << ac_cnt << " " << penalty << "\n";

}

Measured memory_bytes: 3340
#include<iostream>

using namespace std;

int main()
{
    //put here bitch 
    int n; cin>>n;
    int h[1000001];
    for(int i=0;i<n;i++) cin>>h[i];
    int dp[1000001];
    dp[0]=0,dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4736
n = int(input())
max_ = 2**n
a = []
for i in range(n):
  p = int(input())
  b = []
  for j in range(p):
    x, y = map(int, input().split())
    b.append((x-1,y))
  a.append(b)
c_max = 0
for i in range(max_):
  mujun = False
  bi = format(i, '0'+str(n)+'b')
  c1 = bi.count("1")
  
  for j in range(len(bi)):
    if bi[j] == "1":
      for syougen in a[j]:
        if bi[syougen[0]] != str(syougen[1]):
          mujun = True
  if not mujun:
    if c1 > c_max:
      c_max = c1
print(c_max)

Measured memory_bytes: 43868
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;

int main() {
	string N;
	cin >> N;
	ll souwa = 0;
	rep(i, N.size()) {
		souwa += N[i] - '0';
	}
	if ((souwa % 9) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3720
function main(input){
    let str = input.toLowerCase();
    let alp = "abcdefghijklmnopqrstuvwxyz";
    for(let i=0;i<alp.length;i++){
        let count = 0;
        for(let j =0;j<str.length;j++){
            let char = str[j];
            if(char===alp[i]){
                count++;

            }
        }
        console.log(alp[i]+" : "+count);
    }
    
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 15308
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, m, v[5000], h[5000], t[5000], s[5000], str[3100];
int main() {
    cin >> n >> m;
    vector<vector<ll> > dp(3100, vector<ll>(3100, INF));
    dp[0][0] = 0;
    REPO(i, n) {
        cin >> v[i] >> h[i];
    }
    REPO(i, n) {
        v[i + 1] += v[i];
    }
    REPO(i, m) {
        cin >> t[i] >> s[i];
    }
    REPO(i, n) {//i個目まで買ったときの最大のstr
        str[i] += h[i];
        str[i + 1] += abs(h[i] - h[i + 1]) + str[i];
        //cout << i << "  ! " << str[i] << endl;
    }
    REP(i, m) {
        //if(dp[i][j])
        ll sonsitsu = dp[i][0];
        ll nowev = i + 1;
        REP(j, n + 1) {//jこ買った
            if(t[nowev] < v[j]) break;
            dp[nowev][j] = min(dp[nowev][j], sonsitsu);
            if(j > 0)sonsitsu = min(sonsitsu, dp[i][j] + abs(h[j] - h[j + 1]));

            dp[nowev][j] = min(dp[nowev][j], dp[i][j]);
            //powercheck
            ll okson = str[j] - s[nowev];
            if (okson < dp[nowev][j]) dp[nowev][j] = INF;
           // cout << i + 1 << " " << j << " " << dp[i + 1][j] << " " << okson << endl;
        }
    }
    ll mi = INF;
    REP(i, n + 1) {
        if (dp[m][i] < INF) mi = min(mi, i);
    }
    ll ans = t[m];
    if (mi == INF) {
        cout << -1 << endl;
        return 0;
    }
    ans -= v[mi];
    cout << ans << endl;
}


Measured memory_bytes: 78148
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

const int MAX = 1000000;
in fac[MAX], finv[MAX], inv[MAX];
//fac:n!  ,  finv:1/n  ,  inv:1/n!
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
// 二項係数計算
in COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in x,y;
    cin>>x>>y;
    in a=2ll*x-y,b=2ll*y-x;
    if(a<0||b<0||a%3ll>0ll||b%3>0ll){
        cout<<0<<endl;
        return 0;
    }
    a /=3ll;
    b /=3ll;
    COMinit();
    in ans=COM(a+b,b);
    cout<<ans<<endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    map<pair<int, int>, int> mp;
    int n; cin >> n;
    vector<vector<int>> adj(n + 10);
    vector<pair<int, int>> edges;
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        edges.emplace_back(u, v);
    }
    int res = 0, first = 1;
    for (int i = 1; i <= n; i++) {
        if (SZ(adj[i]) > res) {
            res = SZ(adj[i]);
            first = i;
        }
    }
    auto paint = [&](int u, int v, int c) {
        mp[{u, v}] = mp[{v, u}] = c;
    };
    int cur = 1;
    function<void(int, int, int)> dfs = [&](int v, int from, int cant) {
        int cur = 1;
        for (int u : adj[v]) {
            if (u == from) {
                continue;
            }
            if (cur == cant) {
                cur++;
            }
            paint(u, v, cur);
            dfs(u, v, cur);
            cur++;
        }
    };
    dfs(first, -1, -1);
    cout << res << "\n";
    for (auto p : edges) {
        cout << mp[p] << "\n";
    }
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 300

int n;
ll a[MAX][MAX], d[MAX][MAX];
bool b[MAX][MAX];

void floyd(){
	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}
	return;
}

void floyd2(){
	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(i==j || i==k || j==k) continue;
				if(b[i][j] && b[i][k] && b[k][j] && a[i][j]>=a[i][k]+a[k][j]){
					b[i][j]=false;
					b[j][i]=false;
				}
			}
		}
	}
	return;
}

int main(){
	cin >> n;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin >> a[i][j];
			d[i][j]=a[i][j];
			b[i][j]=true;
		}
	}

	floyd();
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(a[i][j]!=d[i][j]){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	floyd2();
	
	ll ans=0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if(b[i][j]) ans+=a[i][j];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int a, b, c;
    cin >> a >> b >> c;

    double ans = b * a / 2;

    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;

  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);
  x4 = x1 - (y2 - y1);
  y4 = y1 + (x2 - x1);

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> m;
    long long cnt = 0;
    for (int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        cnt += m[i-A];
        m[i+A]++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 20484
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    long long N, M, K; cin >> N >> M >> K;
    vector<long long> A(N), B(M);
    vector<long long> sum_A(N), sum_B(M);

    for (int i = 0; i < N; i++) {
        cin >> A[i];

        if (i == 0) sum_A[i] = A[i];
        else sum_A[i] += sum_A[i-1] + A[i];
    } 
    for (int i = 0; i < M; i++) {
        cin >> B[i];
        
        if (i == 0) sum_B[i] = B[i];
        else sum_B[i] += sum_B[i-1] + B[i];
    }

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        long long tmp = i+1;

        if (sum_A[i] > K) break;

        long long time = sum_A[i];
        auto it = upper_bound(sum_B.begin(), sum_B.end(), K-time);

        tmp += it - sum_B.begin();

        ans = max(ans, tmp);
    }

    for (long long i = 0; i < M; i++) {
        if (sum_B[i] > K) break;
        ans = max(ans, i+1);
    }

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 9576
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)3e3 + 100;
const int N = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
 
int n, k, a[maxn], dp[N];

main () {
	cin >> n >> k;
	forn(i, 1, n)
		cin >> a[i];
	forn(i,1,k)
		forn(j,1,n)
			if(i>=a[j])
				dp[i]|=((dp[i-a[j]])^1);
	puts(dp[k] ? "First" : "Second");
}

Measured memory_bytes: 1024
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll MAX = 1000000000000000000;
  __int128 ans = 1;
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());

  rep(i, N)
  {
    ans *= A.at(i);
    if (ans == 0)
    {
      cout << 0 << endl;
      return 0;
    }
    if (ans > MAX)
    {
      cout << -1 << endl;
      return 0;
    }
    if (ans < 0)
    {
      cout << -1 << endl;
      return 0;
    }
    if (ans % A.at(i) != 0)
    {
      cout << -1 << endl;
      return 0;
    }
  }


  cout << ll(ans) << endl;

  return 0;
}


Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int R, int G, int B, int N, ll &ans){

    for(int r = 0; r*R <= N; ++r){
        for(int g = 0; g*G <= N; ++g){
            int b = (N - (r*R + g*G))/B;
            int b_mod = (N - (r*R + g*G))%B;

            if((b >= 0) && (b_mod == 0)) ++ans;
        }
    }

    return;
}

int main(){

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    ll ans{};
    solver(R, G, B, N, ans);

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

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9+7;
const int K = 1e5;
const int N = 100;

ll dp[N+1][K+1];
ll sum[N+1][K+1];

int main() {
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    for (int x = 0; x <= k; ++x) {
        sum[0][x] = 1;
    }
    for (int i = 1; i <= n; ++i) {
        dp[i][0] = 1;
        sum[i][0] = 1;
        for (int x = 1; x <= k; ++x) {
            dp[i][x] = sum[i-1][x];
            if (x-a[i-1] > 0) {
                dp[i][x] = (dp[i][x] - sum[i-1][x-a[i-1]-1] + MOD) % MOD;
            }
            sum[i][x] = sum[i][x-1] + dp[i][x];
            sum[i][x] %= MOD;
        }
    }
    cout << dp[n][k] << endl;
    return 0;
}


Measured memory_bytes: 158080
n = int(input())
a = [ int(input()) for _ in range(n) ]

d = {}
for i in a:
    if i not in d:
        d[i] = True
    else:
        if d[i] == True:
            d[i] = False
        else:
            d[i] = True
cnt = 0
for i in d:
    if d[i] == True:
        cnt += 1
print (cnt)


Measured memory_bytes: 16268
import itertools
N=int(input())
S=[input() for _ in range(N)]
M=0
A=0
R=0
C=0
H=0
alives=0
march=['M','A','R','C','H']
for i in S:
    if i.startswith('M'):
        M+=1
    elif i.startswith('A'):
        A+=1
    elif i.startswith('R'):
        R+=1
    elif i.startswith('C'):
        C+=1
    elif i.startswith('H'):
        H+=1

if M==0:
    march.pop(march.index('M'))
if A==0:
    march.pop(march.index('A'))
if R==0:
    march.pop(march.index('R'))
if C==0:
    march.pop(march.index('C'))
if H==0:
    march.pop(march.index('H'))

if len(march)<3:
    print(0)
    exit(0)

seq=list(itertools.combinations(march,3))

ans=0
for i in seq:
    temp=1
    for ch in i:
        if ch=='M':
            temp*=M
        if ch=='A':
            temp*=A
        if ch=='R':
            temp*=R
        if ch=='C':
            temp*=C
        if ch=='H':
            temp*=H
    ans+=temp

print(ans)

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

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("codefi.txt", "r", stdin);
	freopen("codefo.txt", "w", stdout);
#endif

	int n;
	cin >> n;

	int k;
	cin >> k;
	int a[n];
	int i;
	fo(i, n)
	cin >> a[i];

	int diff1 = 0, diff2 = 0;
	int sum = 0;
	fo(i, n)
	{
		diff1 = abs(a[i] - k);
		diff2 = abs(0 - a[i]);
		if (diff1 < diff2)
			sum += 2 * diff1;
		else
			sum += 2 * diff2;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

const string YES = "YES";
const string NO = "NO";

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> net(n);
    REP(i, m){
        ll ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        net.at(ai).push_back(bi);
        net.at(bi).push_back(ai);
    }

    REP(i, n){
        if(net.at(i).size() % 2 == 1){
            cout << NO << endl;
            return 0;
        }
    }
    cout << YES << endl;
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(k);
    rep(i,k)cin>>a[i];
    while(1)
    {
    bool flag=true;
        int temp=n;
        while(temp>0)
        {
            bool inflag=true;
            int m=temp%10;
            temp/=10;
            for(auto v:a)
            {
                if(v==m)
                {
                    inflag=false;
                    break;
                }
            }
            if(!inflag)
            {
                flag=false;
                break;
            }
        }
        if(flag)break;
        n++;

    }
    cout<<n;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long 
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int32_t main(){
    fast;
    int N{},m{},x{};    cin>>N;
    string S{}; cin>>S;
    for(int i=0;i<N;i++){
        if(S[i]=='I'){
            x++;
            m = max(m, x);
        }else
        x--;
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int mou[10];
    for(int i=0;i<10;i++)
        cin>>mou[i];
    for(int j=0;j<10;j++)
    {
        int temp=0;
        for(int i=0;i<9-j;i++)
    {
        if(mou[i]>mou[i+1])
            {int temp=mou[i];
            mou[i]=mou[i+1];
            mou[i+1]=temp;
            temp=1;}
    }
    if(temp=0)
        break;
    }
        cout<<mou[9]<<"\n"<<mou[8]<<"\n"<<mou[7]<<endl;
    return 0;
}

Measured memory_bytes: 3088
n, k, q = map(int, input().split())
# a = []
point = [k-q] * n
for i in range(q):
    input_num = int(input())
    point[input_num - 1] += 1
    # a.append(input_num)

for i in range(n):
    if point[i] <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 6596
#include<bits/stdc++.h>
#define ll long long int


using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string ans;
    ans="";
    //n--;
    while(n>0)
    {
    	ll k=n%26;
    	
    	if(k==0)
    	{
    		ans+='z';
    		n=n/26;
    		n--;
    		
    	
			
    	
		}
		else
		{
		
    		ans+=char(k-1+int('a'));
			n=n/26;	
		}
    
    	
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
using namespace std;

template<typename T> class segtree {
private:
    int n,sz;
    vector<pair<T, int> > node;
public:
    segtree(vector<T>& v) : sz((int)v.size()){
        n = 1;
        while(n < sz){
            n *= 2;
        }
        node.resize(2*n, make_pair(numeric_limits<T>::min(), -1));
        for(int i = 0; i < sz; i++){
            node[i+n] = make_pair(v[i], -i);
        }
        for(int i=n-1; i>=1; i--){
            node[i] = max(node[2*i], node[2*i+1]);
        }
    }
    void update(int k, T a)
    {
    	node[k+n] = make_pair(a, k);
    	k+=n;
        while(k>>=1){
            node[k] = max(node[2*k], node[2*k+1]);
    	}
    }
    pair<T, int> query(int a,int b,int k=0,int l=0,int r=-1)
    {
        pair<T, int> res1 = make_pair(numeric_limits<T>::min(), -1);
        pair<T, int> res2 = make_pair(numeric_limits<T>::min(), -1);
        a += n, b += n;
        while(a != b){
            if(a % 2) cmx(res1, node[a++]);
            if(b % 2) cmx(res2, node[--b]);
            a >>= 1, b>>= 1;
        }
        return max(res1, res2);
    }
    void print()
    {
        for(int i = 0; i < sz; i++){
            pair<T, int> p;
            p = query(i,i+1);
            cout << "st[" << i << "]: " << p.fi << " " << p.se << endl;
        }
    }
};

ll res[100010];
ll sm[100010];

int main(){
    int n;
    cin >> n;
    vector<ll> v(n+1);
    priority_queue<pair<ll,int> > pq;
    rep(i,n){
        ll a;
        cin >> a;
        v[i+1] = a;
        sm[i+1] = 1;
        pq.push(MP(a,-i-1));
    }
    segtree<ll> sg(v);
    int last = -1;
    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        ll a = x.first;
        int i = -x.second;
        pair<ll,int> ppp = sg.query(0,i);
        ll val = ppp.first;
        int id = -ppp.second;
        
        if(!pq.empty()){
            auto y = pq.top();
            pq.pop();
            ll b = y.first;
            int j = -y.second;
            if(i<j){
                res[i] += (b-val)*sm[j];
                sm[id] += sm[j];
                pq.push(MP(a,-i));
            }else{
                res[i] += (a-b)*sm[i];
                sm[j] += sm[i];
                pq.push(MP(b,-j));
            }
        }else{
            res[i] += a*sm[i];
        }
    }
    rep(i,n){
        cout << res[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 9200
#include <stdio.h>
int main(void){
    // Your code here!
    int a[100004];
    int x;
    
    scanf("%d", &x);

    for(int i = 2; i < 100004; i++){
        a[i] = 1;
    }
    
    for(int i = 2; i < 1002; i++){
        if(a[i] == 0) continue;
        
        for(int j = 2; i*j < 100004; j++){
            a[i*j] = 0;
        }
    }
    
    while(a[x] != 1){
        x++;
    }
    printf("%d", x);
}


Measured memory_bytes: 640
// AOJ 2503 Project Management
// 2018.3.21 bal4u

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

short hi[401], to[401][401];
short r_hi[401], rev[401][401], day[401][401];
int   dp[401];

short q[405], top, end;
short count[405];
short ord[405]; int sz;
void tsort(int n)
{
    int i, j, k;

	for (i = 0; i < n; i++) for (j = 0; j < hi[i]; j++) count[to[i][j]]++;
    top = end = 0, sz = 0;
    for (i = 0; i < n; i++) if (!count[i]) q[end++] = i;
    while (top < end) {
		i = q[top++];
		ord[sz++] = i;
        for (j = 0; j < hi[i]; j++) {
            k = to[i][j];
            if (--count[k] == 0) q[end++] = k;
        }
    }
}

int main()
{
	int n, m, a, b, c, i, j;
	
	n = in(), m = in();
	while (m--) {
		a = in(), b = in(), c = in();
		to[a][hi[a]++] = b;
		rev[b][r_hi[b]] = a, day[b][r_hi[b]++] = c;
	}
	tsort(n);

	for (j = 1; j < sz; j++) {
		b = ord[j];
		for (i = 0; i < r_hi[b]; i++) {
			a = rev[b][i];
			c = dp[a] + day[b][i];
			if (c > dp[b]) dp[b] = c;
		}
	}
	printf("%d\n", dp[n-1]);
	return 0;
}



Measured memory_bytes: 2632
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> len(n);
	for (int i = 0; i < n; ++i) {
		cin >> len[i];
	}

	sort(len.begin(), len.end());

	int side1 = -1, side2 = -1;
	for (int i = n - 1; i > 0; --i) {
		if (len[i] == len[i - 1]) {
			if (side1 == -1) {
				side1 = len[i];
			}
			else if (side2 == -1) {
				side2 = len[i];
			} else {
				cout << (long long) side1 * side2 << "\n";
				return 0;
			}

			--i;
		}
	}

	if (side1 == -1 || side2 == -1) {
		cout << "0\n";
	} else {
		cout << (long long) side1 * side2 << "\n";
	}

	return 0;

}

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

int main() {
	int N;
	int ans = 0;
//	int temp = 0;
	int num[9] ={111,222,333,444,555,666,777,888,999};

	cin >> N;

	for(int i=0; i < 9;i++){
		if(N > num[i]){
			continue;
		}
		else if(N == num[i]){
			ans = num[i];
			break;
		}
		else{
			ans = num[i];
			break;
		}
	}


	cout << ans;

	return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pti;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, const pair<T*, int>& a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
//#define GEN
#ifndef GEN
#define LOG
#endif
#endif

const int N = 20;

int D, G;
int p[N], c[N];

bool read() {
  if (!(cin >> D >> G)) return false;
  forn(i, D) assert(cin >> p[i] >> c[i]);
  return true;
}

const int C = 1010;
int z[N][C];

void solve() {
  memset(z, -1, sizeof(z));
  z[0][0] = 0;
  forn(i, D)
    forn(k, C) {
      if (z[i][k] == -1) continue;
      forn(j, p[i] + 1) {
        int nv = z[i][k] + (i + 1) * 100 * j + (j == p[i] ? c[i] : 0);
        if (z[i + 1][k + j] < nv) z[i + 1][k + j] = nv;
      }
    }

  forn(i, C)
    if (z[D][i] >= G) {
      cout << i << endl;
      return;
    }
  throw;
}

int main() {
#ifdef SU1
  assert(freopen("input.txt", "rt", stdin));
  //assert(freopen("output.txt", "wt", stdout));
#endif

  cout << setprecision(10) << fixed;
  cerr << setprecision(5) << fixed;

  while (read()) {
    ld stime = gett();
    solve();
#ifdef SU1
    cerr << "Time: " << gett() - stime << endl;
#endif
    //break;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int a,b,n; cin>>a>>b>>n;
    if(n<b){
    	cout<<floor(a*n/double(b))-a*floor(n/double(b))<<'\n';
    }
    else{
    	cout<<floor(a*(b-1)/double(b))-a*floor((b-1)/double(b))<<'\n';
    }
}

signed main() { 
    IO();
    #ifndef ONLINE_JUDGE
    freopen(input, "r", stdin);
    freopen(output, "w", stdout);
    freopen(error, "w", stderr);
    #endif
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3800
#include <stdio.h>
int main(){
    int H1, M1, H2, M2, K;

    scanf("%d%d%d%d%d", &H1, &M1, &H2, &M2, &K);
    
    int ans;
    int h, m;

    h = (H2 - H1) * 60;
    
    if( M1 < M2 ){
        m = M2 - M1;
        ans = h + m;
    }
    else{
        m = M1 - M2;
        ans = h - m;
    }

    ans = ans - K;

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

    return 0;

}


Measured memory_bytes: 1732
#define _USE_MATH_DEFINES //M_PIを使用するため
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair

int main()
{
    ld A, B, H, M;
    cin >> A >> B >> H >> M;

    ld theta = (11.0 * M - 60.0 * H) * M_PI / 360.0;
    if(theta < 0.0)
    {
        theta *= -1.0;
    }
    if(theta > M_PI)
    {
        theta = 2.0 * M_PI - theta;
    }
    ld costheta = cos(theta);
    ld result = sqrt(A * A + B * B - 2.0 * A * B * costheta);
    //OUTX(result); //デフォルトだと桁数が6桁
    cout << setprecision(20) << result << endl;


    return 0;
}


Measured memory_bytes: 4116
#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int a,b; cin >> a >> b;
    if(a>b) cout << a-1 << endl;
    else cout << a << endl;
    return 0;
}

Measured memory_bytes: 3540
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    if S == "Sunny":
        print("Cloudy")
    elif S == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,r;
    cin>>n>>r;
    int c=0,temp=0;
    while(temp<=n)
    {
        temp = pow(r,c);
        c++;
    }
    cout<<c-1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
	int A, B, ans = 0;
	scanf("%d %d", &A, &B);
	
	ans = max(max(A + B, A - B), A * B);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
import java.lang.Math.pow

fun main(){
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0
    val useD = pow(d.toDouble(), 2.toDouble())
    for (i in 0 until n){
        val (x, y) = readLine()!!.split(" ").map { it.toInt() }
        if ((pow(x.toDouble(), 2.toDouble()) + pow(y.toDouble(), 2.toDouble())) <= useD){
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 60224
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>
#define rep(i,n) for (int i = 0; i < n; ++i)


using namespace std;

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

	map<long long, long long> vNum;
	for (long long i = 1; i <= sqrt(N + 0.5f); i++)
	{
		if (N % i == 0)
		{
			vNum.insert(make_pair(N / i, i));
		}
	}

	struct PAIR{
		long long A;
		long long B;
	};
	PAIR tmp = { (*vNum.begin()).first,(*vNum.begin()).second };
	long long diff = abs(((*vNum.begin()).first) - (*vNum.begin()).second);
	for(auto it = vNum.begin(); it != vNum.end(); ++it)
	{
		if (abs(((*it).first) - (*it).second) < diff)
		{
			diff = abs(((*it).first) - (*it).second);
			tmp.A = (*it).first;
			tmp.B = (*it).second;
		}
	}

	cout << tmp.A + tmp.B -2;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define endl '\n'
#define vi vector<int>
#define rep(i, n) for (i = 0; i < n; i++)

 
int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif 
   
   int x,max;
   cin>>x;
  
  int n1=360,n2=x;

   max = (n1 > n2) ? n1 : n2;

    do
    {
        if (max % n1 == 0 && max % n2 == 0)
        {
            //cout << "LCM = " << max;
            break;
        }
        else
            ++max;
    } while (true);
   
   cout<<max/x;
}   

   

Measured memory_bytes: 3640
A,B,C = map(int,input().split())

for i in range(50):
    if A%2 or B%2 or C%2:
        print(i)
        exit()
    if A==B==C:
        print(-1)
        exit()
    a = (B+C)//2
    b = (A+C)//2
    c = (A+B)//2
    A,B,C = a,b,c

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if((i+1)%2 == 1){
            if(S[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(S[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

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

int main() {
	int n; cin >> n;
	int m; cin >> m;
	int maxl; int l=0; int r=0;
	int maxr;
	cin >> maxl;
	cin >> maxr;
	for (int i = 1; i < m; i++) {
		cin >> l;
		cin >> r;
		if (maxl<l) {
			maxl=l;
		}
		if (r<maxr) {
			maxr = r;
		}

		
	}
	int sum=0;
	if (maxr < maxl) {
		cout << 0;
	}
	else {
		cout<<maxr - maxl + 1;
	}
	
	
	
	
	return 0;
}

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

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

  int ans = 0;
  for (int i = 0; i <= N - 3; i++)
  {
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C')
      ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256