akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll k;cin>>k;
    vector<ll> h(n);
    For(i,0,n) cin>>h[i];
    sort(ALL(h));
    if(n<=k) ans=0;
    else{
        For(i,0,n-k){
            ans+=h[i];
        }
    }
    cout<<ans<<endl;    
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
  ini(A, B, C);
  if (A <= C && C <= B)
    out("Yes");
  else
    out("No");
}


Measured memory_bytes: 3652
#include<stdio.h>
 
int main() {
    int a;
    int temp = 0;
    int min = 10;
    int dishes = 5;
	for(int i = 0; i < dishes; i++) {
		scanf("%d", &a);
		if(a%10 == 0)
		    temp += a;
		else {
			temp += a + 10 - a%10;
			if(a%10 < min)
				min = a%10;
		}
	}
	int ans = temp + min - 10; 
	printf("%d", ans);
	
	return 0;
}

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

const int inf = 1000*1000*1000;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int& x : a) cin >> x;
	vector<int> suf(n, -inf), pre(n, -inf);
	for(int i = 1; i < n; i++) {
		pre[i] = max(pre[i-1], a[i-1]);
	}
	for(int i = n-2; i >= 0; i--) {
		suf[i] = max(suf[i+1], a[i+1]);
	}
	for(int i = 0; i < n; i++) {
		cout << max(pre[i], suf[i]) << '\n';
	}
}


Measured memory_bytes: 3968
//
//  main.cpp
//  C
//
//  Created by Vadim Zakharenko on 29/07/2017.
//  Copyright © 2017 Vadim Zakharenko. All rights reserved.
//

#include <iostream>
#include <vector>
#include <set>

using namespace std;

const int N = 222222;

set<int> first_step;
vector<int> a[N];

int main(int argc, const char * argv[]) {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        a[u].push_back(v);
        if (u == 1) {
            first_step.insert(v);
        }
    }
    for (auto it = first_step.begin(); it != first_step.end(); it++) {
        int u = *it;
        for (int j = 0; j < (int)a[u].size(); j++) {
            int v = a[u][j];
            if (v == n) {
                printf("POSSIBLE\n");
                return 0;
            }
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 13688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int ans;
  for (int i = 0; i < 5; i++){
    int n;
    cin >> n;
    if (n == 0) ans = i+1;
  } 
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll dp[2005];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    vector<ll>x,y;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        x.push_back(a+b);
        y.push_back(a-b);
    }
    sort(all(x));
    sort(all(y));
    ll X=x[n-1]-x[0];
    ll Y=y[n-1]-y[0];
    cout<<max(X,Y)<<endl;

    return 0;
}


Measured memory_bytes: 6624
"use strict"
// input data
function main(input) {
    const a = Number(input.split('\n')[0].split(' ')[0]);
    const b = Number(input.split('\n')[0].split(' ')[1]);
    const c = Number(input.split('\n')[0].split(' ')[2]);
    console.log(c + ' ' + a + ' ' + b);
}

// output
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<llong> A(n);
    rep(i, n) cin >> A[i];

    sort(all(A), greater<llong>());
    llong ans = A[0];
    for (int i = 1; i < n - 1; ++i) ans += A[ceil(static_cast<double>(i)/2)];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int A[100000];

int partition(int* A, int p, int r)
{
	int x = A[r];
	int i = p - 1;
	int tmp;

	rep1(j, p, r - 1) {
		if (A[j] <= x) {
			i++;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;

	return i + 1;
}

int main()
{
	int n;
	int ptstd;

	cin >> n;
	rep(i, n) cin >> A[i];
	ptstd = partition(A, 0, n - 1);

	cout << A[0];
	rep1(i, 1, ptstd - 1) cout << ' ' << A[i];
	cout << " [" << A[ptstd] << ']';
	rep1(i, ptstd + 1, n - 1) cout << ' ' << A[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 3464
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <math.h>

using namespace std;

int main() {
	int n, l, t;
	cin >> n >> l >> t;
	vector<int>x;
	vector<int>w;
	for (int i = 0; i < n; i++) {
		int tmpX, tmpW;
		cin >> tmpX >> tmpW;
		x.push_back(tmpX);
		w.push_back(tmpW);
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (w[i] == 1) cnt -= (t + x[i]) / l;
		else cnt += (t + (l - x[i] - 1)) / l;
	}
	for (int i = 0; i < n; i++) {
		int tempX = x[i];
		if (w[i] == 1)
			tempX += t;
		else

			tempX -= t;
		tempX %= l;
		if (tempX < 0)
			tempX = (tempX + l)%l;
		x[i] = tempX;
	}

	//if(cnt >= 0)
		//cnt %= n;
	//else cnt = -(-cnt % n) + n;
	cnt = (cnt % n + n) % n; // 負の数にも対応した便利なmod計算
	sort(x.begin(), x.end());

	//cout << cnt << endl;
	// x[cnt] == x[0]がもともと一番目の蟻だった
	vector<int> newPosition(n);
	for (int i = 0; i < n; i++) {
		newPosition[(cnt + i) % n] = x[i];
	}
	for (int i = 0; i < n; i++) {
		cout << newPosition[i] << endl;
	}
	return 0;
}

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

int n, m, cnt = 0;
bool a[1005] = {0};

int main() {
  int i, x;
  cin >> n >> m;
  for(i = 0; i < m; ++i) {
    cin >> x;
    --x;
    a[x] = 1;
  }
  for(i = 0; i < m; ++i)
    if(!a[i]) ++cnt;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3100
n = int(input())
a = list(map(int,input().split()))
mt = False
lt = False

ap = a[0]
count = 0
l = 0
for i in range(n):
    l += 1
    if mt + lt == 0:
        if a[i]-ap > 0:
            mt = True
        elif a[i]-ap < 0:
            lt = True
    if mt:
        if a[i]-ap <0:
            lt = True
            mt = False
            if l > 1:
                count += 1
                l = 0
                lt = False
            else:
                l = 1
    if lt:
        if a[i]-ap > 0:
            mt = True
            lt = False
            if l > 1:
                mt = False
                count += 1
                l = 0
            else:
                l = 1
    ap = a[i]
print(count+1)

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

using namespace std;

typedef long long ll;

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

    int N;
    cin >> N;
    ll sum = 0;
    int minuscount = 0;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] < 0) minuscount++;
        a[i] = a[i] < 0 ? -a[i] : a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end());
    if (minuscount % 2 == 0) {
        cout << sum << endl;
    } else {
        sum -= 2 * a[0];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int n, k, x;
	int ans = 0;

	cin >> n >> k;
	for  (int i = 0; i < n;i++)
	{
		cin >> x;
		if (x < k - x) {
			ans += x * 2;
		}
		else {
			ans += (k - x) * 2;
		}
	}


	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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

bool graph[101][101];
vector<ll> to[101010];
vector<ll>ball(101010, 1);
char c[10][10];
bool visited[10][10];
char math[1010][1010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	for (ll i = 0;i <= n;++i) {
		for (ll j = 0;j <= m;++j) {
			ll ans = i * m + j * n - i * j * 2;
			if (ans == k) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int n, m;
#define N 200000
#define LL long long
int vis[N], col[N];
vector <int> bi[N];
int si, ho;
LL z0, z1, z2;
LL ans;
void dfs(int t, int c = 0)
{
    col[t] = c;
    vis[t] = 1;
    si ++;
    for (int i = 0; i < bi[t].size(); ++ i) if (!vis[bi[t][i]])
        dfs(bi[t][i], !c);
    else if (col[t] == col[bi[t][i]]) ho = 1;
}
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; ++ i)
    {
        int a, b;
        cin >> a >> b;
        bi[a].push_back(b);
        bi[b].push_back(a);
    }
    for (int i = 1; i <= n; ++ i)
        if (!vis[i])
        {
            ho = 0;
            si = 0;
            dfs(i);
            if (si == 1) z0 ++;
            else if (ho) z2 ++;
            else z1 ++;
        }
    ans = z0 * (n - z0) * 2 + z0 * z0 + z1 * z1 * 2 + z2 * z1 * 2 + z2 * z2;
    cout << ans;
}


Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int n;
    cin >> n;
    cout << lcm(2, n) << "\n";
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

S.sort()

max = 0
Output = []
pt = 0
while pt < N:
    st,tmp = S[pt],0
    while pt < N and st == S[pt]:
        pt += 1
        tmp += 1
        if max == tmp:
            Output.append(st)
        if max < tmp:
            max = tmp
            Output.clear()
            Output.append(st)

for i in range(len(Output)):
    print(Output[i])


Measured memory_bytes: 20680
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int M1, D1, M2, D2;
	std::cin >> M1 >> D1 >> M2 >> D2;

	if (M1 != M2) {
		std::cout << "1\n";
	} else {
		std::cout << "0\n";
	}
}


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


int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  a = s.size();
  b = t.size();
  int ans = b;
  
  rep(i,a-b+1){
    int m = 0;
    rep(j,b){
      if(t[j] != s[i+j]){
        m++;
      }
    }
    ans = min(m,ans);
  }
  cout << ans;
  return 0;
}






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

int main(){
    string S; cin>>S;
    int judge=0;
    int N=S.length();

    for(int i=0; i<N; i++){
        if(S[i] != S[N-i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    int N2=(N-1)/2;
    for(int i=0; i<N2; i++){
        if(S[i] != S[N2-i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    int N3=(N+3)/2;
    int i2=0;
    for(int i=N3-1; i<N; i++){
        if(S[i] != S[N-i2-1]){
            cout<<"No"<<endl;
            return 0;
        }
        i2++;
    }

    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3612
// https://atcoder.jp/contests/abc179/tasks/abc179_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  ll res = 0;

  rep1(a, N) { res += (N - 1) / a; }

  cout << res << "\n";
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 5e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
char str[MAXN];

int main() {
	int i, j;
	scanf("%d", &N);
	for (i = 1; i <= 9; ++i) {
		if (N % i == 0 && N / i <= 9) break;
	}
	if (i == 10) printf("No");
	else printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;

const int N = 600 + 5;
int mp[N][N], n, m;
pair<int, int> node[N * N];
double ans = INT_MAX;
inline void calc (int id) {
	static double dp[N];
	dp[n] = 0;
	per (i, n - 1, 1) {
		dp[i] = 0;
		double mx = -1;
		rep (j, 1, mp[i][0]) {
			int v = mp[i][j];
			if (dp[v] < 0) { dp[i] = -1; break; }
			dp[i] += dp[v];
			mx = max (mx, dp[v]);
		}
		if (dp[i] < 0) continue;
		if (mp[i][0] - (i == id) == 0) dp[i] = -1;
		else {
			if (i == id) dp[i] -= mx;
			dp[i] = (dp[i] / (mp[i][0] * 1.0 - (i == id))) + 1;
		}
	}
	if (dp[1] > 0) ans = min (ans, dp[1]);
}

int main () {
	scanf ("%d%d", &n, &m);
	rep (i, 1, m) {
		int x, y;
		scanf ("%d%d", &x, &y);
		node[i] = {x, y};
		mp[x][ ++mp[x][0] ] = y;
	}
	rep (i, 0, n) {
		calc (i);
	}
	printf ("%.7lf\n", ans);
	return 0;
}

Measured memory_bytes: 3840
#include<stdio.h>
int main()
{
  int N,M,sum=0,i;
  scanf("%d %d",&N,&M);
  int arr[M];
  for(i=0;i<M;i++)
  {
    scanf("%d",&arr[i]);
  }
  for(i=0;i<M;i++)
  {
    sum=sum+arr[i];
  }
  if(sum<=N)
  printf("%d",N-sum);
  else
    printf("-1");
  return 0;
}
  

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


int main(){


 long long n;
 cin>>n;

 int enable = 0; long long price=0;

 for(long long i=1;i<=n;i++){


    if( (int)(i*1.08) == n){

        enable = 1;
        price = i;
         break;
        }
 }

  //cout<<price<<" "<<enable<<endl;

 if(enable == true)
    cout<<price<<endl;
 else
    cout<<":("<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    ll n, m;
    cin >> n >> m;
    UnionFind un(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        un.unite(a, b);
    }
    vector<ll> size(n);
    for(int i = 0; i < n; i++){
        size[un.root(i)]++;
    }
    ll mx = 0;
    for(int i = 0; i < n; i++){
        mx = max(mx, size[i]);
    }
    cout << mx << "\n";
}

Measured memory_bytes: 11912
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, c):
    color[v] = c
    for vi, wi in g[v]:
        if vi == p: continue
        if wi % 2 == 0: dfs(vi, v, c)
        else: dfs(vi, v, 1-c)
    return color

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append((v, w))
    g[v].append((u, w))

color = [0 for _ in range(n)]
for i in dfs(0, -1, 0):
  print(i)

Measured memory_bytes: 79488
n ,k = map(int, input().split())
an = list(map(int, input().split()))
result = 0
def keta(i):
  return len(bin(i)[2:])

for j in range(keta(k), 0, -1):
  cnt = 0
  b = 1 << j-1
  for a in an:
    if a & b != 0:
      cnt += 1
  
  if len(an) - cnt > cnt and k >= b:
    result += b
    k -= b
wanted = 0
for a in an:
  wanted += result ^ a
  
print(wanted)

    


Measured memory_bytes: 14700
#include <stdio.h>
#define SIZE 500000+1
int heep[SIZE];
int n;

void swap(int *,int *);
void maxHeapify(int);
void buildMaxheap();

int main(){
  int i; 
  scanf("%d",&n);
  for(i=1; i<=n; i++) scanf("%d",&heep[i]);
  
  buildMaxheap();
  
  for(i=1; i<=n; i++){
    printf(" %d",heep[i]);
  }
  printf("\n");
  
  return 0;
}

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

void maxHeapify(int i){
  int left,right,maximum;
  left = i*2;
  right = i*2+1;
  if(left <= n && heep[left] > heep[i])
    maximum = left;
  else maximum = i;
  
  if(right <= n && heep[right] > heep[maximum])
    maximum = right;
  
  if(maximum != i){
    swap(&heep[i],&heep[maximum]);
    maxHeapify(maximum);
  }
}

void buildMaxheap(){
  int i;
  for(i=n/2; i>=1; i--){
    maxHeapify(i);
  }
}



Measured memory_bytes: 3684
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll h, w, d;

	cin>>h>>w>>d;

	vector<tuple<ll, ll, ll>> a;

	rep(i, h){
		rep(j, w){
			int c;
			cin>>c;
			a.push_back(make_tuple(c-1, j+1, i+1));
		}
	}
	sort(all(a));

	ll q;

	cin>>q;

	vll ans(h*w, 0);

	rep(i, h*w){
		if(i>d-1){
			ll prevx=get<1>(a[i-d]), prevy=get<2>(a[i-d]), x=get<1>(a[i]), y=get<2>(a[i]);
			//cout<<prevx<<","<<prevy<<"/"<<x<<","<<y<<endl;
			ans[i]+=ans[i-d]+labs(x-prevx)+labs(y-prevy);
		}
		//cout<<ans[i]<<endl;
		//cout<<ans[i]<<","<<get<1>(a[i])<<","<<get<2>(a[i])<<endl;
	}

	rep(i, q){
		int l, r;
		cin>>l>>r;
		cout<<ans[r-1]-ans[l-1]<<endl;
	}
}

Measured memory_bytes: 4084
import math
import sys

X,Y,Z,K=map(int,input().split())

x=sorted(list(map(int,input().split())),reverse=True)
y=sorted(list(map(int,input().split())),reverse=True)
z=sorted(list(map(int,input().split())),reverse=True)



"""
if X*Y*Z<=3000:
    ans=[]
    for i in range(X):
        for j in range(Y):
            for k in range(Z):  ans.append(x[i]+y[j]+z[k])
    ans.sort()
    for i in range(min(3000,X*Y*Z)):
        print(ans[i])
    sys.exit()
"""

ans=[]
for i in range(min(X,K)):
    tmp1=math.ceil(K/(i+1))
    for j in range(min(Y,tmp1)):
        tmp2=math.ceil(tmp1/(j+1))
        for k in range(min(Z,tmp2)):
            ans.append(x[i]+y[j]+z[k])

ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Measured memory_bytes: 9772
#include<iostream>
#include <string>

using namespace std;

int main() {
	int n,num;
	int a[100][100] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++) {
		string SHCD;
		cin >> SHCD >> num;
		int x;
		if (SHCD == "S") {
			x = 0;
		}
		else if (SHCD == "H") {
			x = 1;
		}
		else if (SHCD == "C") {
			x = 2;
		}
		else if (SHCD == "D") {
			x = 3;
		}
		a[x][num] = 1;

	}
	for (int j = 0; j < 4; j++) {
		for (int k = 1; k < 14; k++) {
			if (!a[j][k]) {
				string shcd;
				if (j == 0) {
					shcd = "S";
				}
				else if (j == 1) {
					shcd = "H";
				}
				else if (j == 2) {
					shcd = "C";
				}
				else if (j == 3) {
					shcd = "D";
				}
				cout << shcd <<" "<< k << endl;
			}
		}
	}
}

Measured memory_bytes: 1252
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

char buf[50000];
int main()
{
	int T;
	scanf("%d", &T);
	for (int testCase = 0; testCase < T; ++testCase)
	{
		int N;
		scanf("%d", &N);
		scanf("%s", buf);

		bool need[2][11111];
		for (int i = 0; i < 2; ++i)
			fill(need[i], need[i]+11111, false);

		for (int i = 0; i < 2*N; ++i)
			need[0][(i+1)/2] |= buf[i] == 'Y';
		for (int i = 0; i < 2*N; ++i)
			need[1][(i+1)/2] |= buf[i+2*N] == 'Y';

		int first[2], last[2];
		first[0] = first[1] = 11111;
		last[0] = last[1] = -1;

		int ans = N;
		for (int i = 0; i < 2; ++i)
		{
			for (int j = 0; j < N+1; ++j)
			{
				if (need[i][j])
				{
					++ans;
					if (first[i] == 11111)
						first[i] = j;
					last[i] = j;
				}
			}
		}
		if (first[0] > first[1])
			++ans;
		if (last[0] < last[1])
			++ans;

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

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,m;cin>>n>>m;
    vector<int> g(n,0);
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;a--;b--;
        g[a]++;
        g[b]++;
    }
    for(int i=0;i<n;i++) cout<<g[i]<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
string s;
int main() {
	cin >> s;
	int ret = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') ret++;
	}
	cout << ret << endl;
	return 0;
}

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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合.
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

signed main() {
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;    
}

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

using namespace std;

int main()
{
  int count = 0,max = 0;
  string s;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++)
  {
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
    {
      count++;
      if(count > max)
      {
        max = count;
      }
    }
    else
    {
      count = 0;
    }
  }
  
  cout << max;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
        int[] ABCD = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int ans;
        if (ABCD[0] * ABCD[1] >= ABCD[2] * ABCD[3]) { ans = ABCD[0] * ABCD[1]; }
        else { ans = ABCD[2] * ABCD[3]; }
        Console.WriteLine(ans.ToString());
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m,l;
 	cin >> n>>m>>l;
 	if(m/n>l){
 		cout << l << endl;
 	}else{
 		cout << m/n << endl;
 	}
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100000+5;

int n;
int L[N];
int R[N];

int main(){
	ri(n);
	for(int i=0; i<n; i++){
		ri2(L[i],R[i]);
	}
	sort(L,L+n,greater<int>());
	sort(R,R+n);
	ll ans = 0LL;
	ll sum = 0LL;
	for(int i=0; i<n; i++){
		sum += L[i];
		ans = max(ans,sum);
		sum -= R[i];
		ans = max(ans,sum);
	}
	sum = 0LL;
	for(int i=0; i<n; i++){
		sum -= R[i];
		ans = max(ans,sum);
		sum += L[i];
		ans = max(ans,sum);
	}
	ans <<= 1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define VALS(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define INF 1234567890ll
#define EPS (1e-7)
#define PI (acos((ld)-1.0))
#define ll long long int 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
typedef pair <int, int> pi;
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << '\n'; err(++it, args...);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(ll x){stringstream s; s << x; return s.str(); }
ll stl(string x){stringstream s(x); ll temp; s >> temp; return temp; }
const int MOD = 1e9 + 7;

int main()
{
  IAMSPEED
  int a,b; cin >> a >> b;
  if (a>=10 || b >= 10) {
    cout << -1;
  } else {
    cout << a * b;
  }
}

Measured memory_bytes: 256
def main():
     def cmb(n, r, mod):
          if ( r<0 or r>n ):
               return 0
          r = min(r, n-r)
          return g1[n] * g2[r] * g2[n-r] % mod
    
     mod = 10**9+7 #出力の制限
     N = 10**6
     g1 = [1, 1] # 元テーブル
     g2 = [1, 1] #逆元テーブル
     inverse = [0, 1] #逆元テーブル計算用テーブル
     
     for i in range( 2, N + 1 ):
          g1.append( ( g1[-1] * i ) % mod )
          inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
          g2.append( (g2[-1] * inverse[-1]) % mod )

     n,m,k = map(int,input().split())
     nm = n*m%(10**9+7)
     a = (cmb(nm-2,k-2,mod)%(10**9+7))*(nm*(m*(n**2-1)+n*(m**2-1)))//6
     print(a%(10**9+7))
     
if __name__=='__main__':
     main()

Measured memory_bytes: 122120
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (abs(b - a) <= d && abs(c - b) <= d){
        cout << "Yes" << endl;
    }
    else if (abs(c - a) <= d){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> c[i];
    }

    cout << "\n";
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll count=0;
    for(int i = 0; i < n; i++) {
        ll ref =b[i];
        ll ac = lower_bound(a.begin(),a.end(),ref) - a.begin();
        ll cc = c.end()-upper_bound(c.begin(),c.end(),ref);
        count +=(ac*cc);
    }

    cout << count << "\n";
    return 0;
}

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

using namespace std;

const int N = 1e6+5;
int n, ehPrimo[N];
vector<int> primos;

void sieve(){
	for (int i = 0; i < N; i++)
		ehPrimo[i] = true;

	ehPrimo[1] = false;
	ehPrimo[2] = true;

	for (int i = 2; i < N; i++){
		if (ehPrimo[i]){
			primos.push_back(i);
			for (int j = i+i; j < N; j += i){
				ehPrimo[j] = false;
			}
		}
	}
}

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	sieve();

	scanf("%d", &n);

	int op1 = upper_bound(primos.begin(), primos.end(), n) - primos.begin(),
		op2 = lower_bound(primos.begin(), primos.end(), n) - primos.begin();

	if (primos[op2] == n){
		printf("%d\n", primos[op2]);
	} else {
		printf("%d\n", primos[op1]);
	}

	return 0;
}

Measured memory_bytes: 7812
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

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

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;



int main(){

    ll a,b,n;
    cin >> a >> b >> n;

    ll x = min(b - 1, n);

    cout << floor(a * x / b) - a * floor(x / b) << endl;
    

    return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long t,i,j,n,m,l=0;
    cin>>n;
    m=n-1;
    for(i=1; i<=(m/i); i++)
    {
        if(m%i==0)
        {
            if((m/i)!=i)
            {
                l+=2;
            }
            else
            {
                l++;
            }
        }
    }
    for(i=2; i<=(n/i); i++)
    {
        m=n;
        if(m%i==0)
        {
            while((m%i)==0)
            {
                m/=i;
            }
            if(m%i==1)
            {
                l++;
            }
        }
    }
    cout<<l<<"\n";
    return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;



int main(){
    ll x, y;
    cin >> x >> y;

    ll cnt = 0;

    if(abs(x) == abs(y)){
        x *= -1;
        cnt++;
    }
    if(abs(x) < abs(y)){
        if(x < 0){
            x *= -1;
            cnt++;
        }
        while(abs(x) != abs(y)){
            x++;
            cnt++;
        }
        if(x != y){
            x *= -1;
            cnt++;
        }
    }
    else if(abs(y) < abs(x)){
        if(0 < x){
            x *= -1;
            cnt++;
        }
        while(abs(x) != abs(y)){
            x++;
            cnt++;
        }
        if(x != y){
            x *= -1;
            cnt++;
        }
    }



    cout << cnt << 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;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int N;
	cin >> N;
	v1 a(N);
	rep(i, N){
		cin >> a.at(i);
	}
	rep(i, N){
		int j = i-1;
		int v = a.at(i);
		while(j >= 0 && a.at(j)>v){
			a.at(j+1) = a.at(j);
			a.at(j) = v;
			j--;
		}
		rep(k, N){
			cout << a.at(k);
			if(k == N-1) {
				cout << endl;
			}else{
				cout << " ";
			}
		}
	}
}



Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << "=" << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << " "
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

vector<ll> toNodeIndex[200005];
vector<ll> counter;

void bfs(ll root, ll from = -1){
    vector<ll> childNodes;
    ll thisCounter = counter[root];
    childNodes = toNodeIndex[root];

    if(childNodes.size() == 0)return;

    for(ll childNodeIndex :childNodes){
        if(childNodeIndex == from) continue;

        counter[childNodeIndex] += thisCounter;

        bfs(childNodeIndex, root);
    }

    return;
}

int main(){
    ll n,q;
    cin >>n >>q;

    loop(i,n-1){
        ll a,b;
        cin >>a >>b;
        --a; --b;

        toNodeIndex[a].push_back(b);
        toNodeIndex[b].push_back(a);
    }

    counter.resize(n);

    loop(i,q){
        ll p,x;
        cin >>p >>x;
        p--;
        counter[p] += x;
    }

    bfs(0);

    loop(i,n){
        cout << counter[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 36736
#include <bits/stdc++.h>
using namespace std;
int n,K;
int b[2002][2002];
int s[4002][4002];
int get(int x , int y){
	return s[x+K-1][y+K-1] + s[x-1][y-1] - s[x-1][y+K-1] - s[x+K-1][y-1];
}
int main(){
	cin >> n >> K;
	for (int i=0; i<n; i++){
		int x,y;
		char c;
		cin >> x >> y >> c;
		if(c=='W') y += K;
		++b[x%(2*K)+1][y%(2*K)+1];
	}
	for (int i=1; i<4*K+1; i++){
		for (int j=1; j<4*K+1; j++){
			s[i][j] = s[i][j-1] + b[(i-1)%(2*K)+1][(j-1)%(2*K)+1];
		}
	}
	for (int j=1; j<4*K+1; j++){
		for (int i=1; i<4*K+1; i++){
			s[i][j] += s[i-1][j];
		}
	}
	int ans = 0;
	for (int i=1; i<2*K+1; i++){
		for (int j=1; j<2*K+1; j++){
			ans = max(ans , get(i,j) + get(i+K,j+K));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
#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 INF (2e9)
#define EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    if (n == 1) cout << "Hello World" << endl;
    else {
        int a, b;
        cin >> a;
        cin >> b;
        cout << a+b << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    if (accumulate(a.begin(), a.end(), 0) <= 21) {
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int a[5][5];
bool c[5][5];
int main(void)
{
    int n,b;
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            scanf("%d" ,&a[i][j]);
    scanf("%d" ,&n);
    while(n--)
    {
        scanf("%d" ,&b);
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
            {
                if(a[i][j]==b)
                    c[i][j]=true;
            }
    }
    for(int i=0;i<3;i++)
        if(c[0][i] && c[1][i] && c[2][i])
        {
            printf("Yes");
            return 0;
        }
    for(int i=0;i<3;i++)
        if(c[i][0] && c[i][1] && c[i][2])
        {
            printf("Yes");
            return 0;
        }
    if(c[0][0] && c[1][1] && c[2][2])
    {
        printf("Yes");
            return 0;
    }
    if(c[0][2] && c[1][1] && c[2][0])
    {
        printf("Yes");
            return 0;
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int n,a;
int main(){
	int i,count=0,res=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a);
		if(a==i)
			count++;
		else{
			res+=(count+1)/2;
			count=0;
		}
	}
	if(count){
		res+=(count+1)/2;
	}
	printf("%d\n",res);
	return 0;
}

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

int main(void)
{
  std::string n;
  std::cin >> n;

  bool flag = false;

  for (int i = 0; i < n.size(); i++) {
    if (n[i] == '7') {
      flag = true;
      break;
    }
  }
  
  if (flag) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }
}

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

int main() {
    //ifstream cin("b.in");

    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    
    bool ans = false;

    for(int i = 1; i < n - 1; ++i) {
        pair<long long, long long> left = make_pair(a + 1LL * (i) * c, a + 1LL * (i) * d);
        pair<long long, long long> right = make_pair(b + 1LL * (n - 1 - i) * c, b + 1LL * (n - 1 - i) * d);
        if(right.first >= left.first and right.first <= left.second) {
            ans = true;
            break;
        }
        if(left.first >= right.first and left.first <= right.second) {
            cerr << left.first << " " << left.second << "\n";
            cerr << right.first << " " << right.second << "\n";
            ans = true;
            break;
        }
    }

    if(ans) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<vector<int>> flower(101,vector<int>(n,0));

    for(int i = 0; i < n; i++){
        for(int j = 0; j < h[i]; j++){
            flower[100-j][i] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i <= 100; i++){
        bool is_sequence = false;
        for(int j = 0; j < n; j++){
            if(flower[i][j] == 1 && is_sequence){
                ;
            }else if(flower[i][j] == 1 && !is_sequence){
                is_sequence = true;
                ans++;
            }else{
                is_sequence = false;
            }
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  double ans = (double)(N/2+1)/N;
  if(N%2==0){
    printf("%.10f", 0.5);
  }
  else{
    printf("%.10f", ans);
  }
  
}


Measured memory_bytes: 256
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
  	double[] a=new double[n];
  	for(int c=0;c<n;c++){
  	a[c]=sc.nextDouble();
    }
    double b=0;
  	for(int c=0;c<n;c++){
    b+=1/a[c];
    }
    System.out.println(1/b);
    }
}

Measured memory_bytes: 22868