akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  if (a > b) return puts("0"), 0;
  if (n == 1) return puts(a == b ? "1" : "0"), 0;
  printf("%lld\n", (n - 2LL) * (b - a) + 1LL);
  return 0;
}


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

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


using namespace std;



int main() {

	string p;
	cin >> p;
	for (int i = 0; i < p.size(); i++) {
		for (int j = i + 1; j < p.size(); j++) {
			if (p[i] == p[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
	return 0;

}




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

int main() {
    long long n;
    std::cin >> n;
    auto c = 0ll;
    while ((1ll << (c + 1)) - 1 <= n) c++;
    n -= (1ll << c) - 1;
    std::vector<long long> v;
    for (int i = 1; i <= c; i++) v.push_back(i);
    std::deque<long long> q;
    while (n) {
        auto i = 0ll;
        while ((1ll << (i + 1)) <= n) i++;
        q.push_back(i);
        n -= (1ll << i);
    }
    for (int i = 0; i < q.size(); i++) {
        v.insert(v.begin() + q[i],  c + i + 1);
    }

    std::cout << v.size() * 2 << std::endl;
    for (auto a : v) std::cout << a << " ";
    for (int i = 1; i <= c + q.size(); i++) std::cout << i << " ";
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 256
var lines = [];
var readline = require('readline');
var C = [].fill(0);
var result = Infinity;

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var N = Number(lines.shift()); var n = N;
    var counter = [].fill(0);

    for (var i = 2; i <= Math.sqrt(N); i++) {
        if (counter[i] === undefined && n % i === 0) { counter[i] = 0; }
        while (n % i === 0) {
            n = n / i;
            counter[i]++;
        }
    }

    if (counter.length === 0) {console.log(N.toString().length);}
    else {
        
        counter.forEach(function (value, index, array) {
            for (var i = 0; i < value; i++) {
                C.push(index);
            }
        });
        if (n !== 1) C.push(n);
        dfs(0, []);
        console.log(result);
    }
});

function dfs(n, comb) {
    if (n === C.length) { calc(comb); return (0); }

    comb[n] = 0;
    dfs(n + 1, comb);

    comb[n] = 1;
    dfs(n + 1, comb);
}

function calc(comb) {
    var a = 1; var b = 1;

    for (var i = 0; i < comb.length; i++) {
        if (comb[i] === 0) { a *= C[i]; }
        else { b *= C[i]; }
    }
    if (result > b.toString().length && a.toString().length <= b.toString().length) { result = b.toString().length; }
}


Measured memory_bytes: 15924
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
using pii = pair<int,int>;

int main() {
	int n,m,b,c,j=0;
	scanf("%d %d",&n,&m);
	vector<int> a(n);
    vector<pii> d(m);
	for(int i=0; i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0; i<m;i++){
		scanf("%d %d",&b, &c);
		d[i].first = b;
        d[i].second = c;
	}
	sort(a.begin(), a.end());
	sort(d.begin(), d.end(),[](pii x,pii y){
        return x.second > y.second;
    });
    for(int i=0;i<m&&j<n;i++){
        for(int k=0;k<d[i].first;k++){
            if(d[i].second>a[j]){
                a[j] = d[i].second;
                j++;
                if(j==n) break;
            }else{
                j=n;
                break;
            }
        }
    }
        
	long long ans = accumulate(a.begin(), a.end(), 0LL);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
	while(true) {

		int n;
		cin >> n;
		
		if(n == 0)	break;

		int a[n];
		double tmp1 = 0;
		for(int i=0;i<n;i++) {
			cin >> a[i];
			tmp1 += a[i];
		}
		double avg = tmp1 / n;

		double tmp2 = 0;
		for(int i=0;i<n;i++) {
			tmp2 += (a[i]-avg)*(a[i]-avg);
		}
		double vari = tmp2 / n;

		printf("%.8f", sqrt(vari));
		cout << endl;
	}

    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[2][n];
    rep(i,2){
        rep(j,n){
            cin>>a[i][j];
        }
    }
    int con,ans=0;
    rep(i,n){
        con=0;
        for(int j=0;j<=i;j++){
            con+=a[0][j];
        }
        for(int j=i;j<=n-1;j++){
            con+=a[1][j];
        }
        ans=max(con,ans);
    }
    cout<<ans<<endl;
}


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

int main(){
	int n;
	cin >> n;
	char s[105];
	rep(i,n){
		cin >> s[i];
	}
	map<char,int> mp;
	rep(i,n){
		mp[s[i]]++;
	}
	
	int count = 0;
	if(mp['P'] != 0) count++;
	if(mp['W'] != 0) count++;
	if(mp['G'] != 0) count++;
	if(mp['Y'] != 0) count++;
	
	if(count == 4){
		cout << "Four" << endl;
	}else{
		cout << "Three" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define eps 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N, K;
vector<ll> h;

int main () {
  cin >> N >> K;
  Rep(i, N) {
    ll tmp;
    cin >> tmp;
    h.push_back(tmp);
  }

  sort(All(h));

  ll ans = LINF;

  Rep(i, N) {
    if ((i + K - 1) >= N) continue;

    ll b = h[i];
    ll e = h[i + K - 1];

    chmin(ans, e-b);
  }

  cout << ans << "\n";
}

Measured memory_bytes: 1400
s = input()
t = input()

dic = {}
dic2 = {}

for i,j in zip(s,t):
    if j not in dic:
        if i in dic2:
            print("No")
            exit()
        dic[j] = i
        dic2[i] = j
    else:
        if dic[j] != i:
            print("No")
            exit()
print("Yes")

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

int main()
{
	int n, cnt = 0;
	cin >> n;
	char str[n];

	cin >> str;
	for(int i = 0; i < n; i++)
	{
		if(str[i]=='A')
		{
			if(str[i+1]=='B')
			{
				if(str[i+2]=='C')
				{
					cnt += 1;
					i+= 2;
				}
			}
		}
	}

	cout << cnt;
}


Measured memory_bytes: 3628
d = gets.chomp
if d == "SUN"
  puts 7
elsif d == "MON"
  puts 6
elsif d == "TUE"
  puts 5
elsif d == "WED"
  puts 4
elsif d == "THU"
  puts 3
elsif d == "FRI"
  puts 2
else
  puts 1
end


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;

int n; string s[10010];
int c[10010];//タイプ
int main() {
	cin >> n;
	int count = 0;
	fill(c, c + n, 1);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < s[i].length() - 1; j++) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
				count++;
			}
		}
		if (s[i][0] == 'B') {
			c[i] += 1;
		}
		if (s[i][s[i].length() - 1] == 'A') {
			c[i] += 2;
		}
	}
	int type2 = 0, type3 = 0, type4 = 0;
	for (int i = 0; i < n; i++) {
		if (c[i] == 2) {
			type2++;
		}
		else if (c[i] == 3) {
			type3++;
		}
		else if (c[i] == 4) {
			type4++;
		}
	}
	if (type4 == 0) {
		cout << count+min(type3, type2);
	}
	else {
		if (type2 + type3 > 0) {
			cout << count+type4 + min(type2, type3);
		}
		else {
			cout << count+type4 - 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)
        res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        ll n,k,num;cin>>n>>k;ll arr[n+1];
        for(ll i=0;i<=n;i++)arr[i]=i;
        for(ll i=1;i<=n;i++)arr[i]+=arr[i-1];ll sum=0;
        for(ll i=k;i<=n;i++){
            num=(arr[n]-arr[n-i]-arr[i-1]+1)%mod;
            sum=(sum+num)%mod;
        }
        sum=(sum+1)%mod;
        cout<<sum;
}


Measured memory_bytes: 5160
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INFL = 1e17+7;
const long long INFI = 1e9+7;
const long long MOD = 1e9+7;
const double EXP = 1e-8;
const double PI=acos(-1);

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<long long> ans; 
	long long x,y;
	cin >> x >> y;
	//1
	long long as_1=y-x;
	if(as_1>0){
		ans.push_back(as_1);
	}
	//2
	long long as_2=y-(-x)+1;
	if(as_2>0){
		ans.push_back(as_2);
	}
	//3
	long long as_3=(-y)-x+1;
	if(as_3>0){
		ans.push_back(as_3);
	}
	//4
	long long as_4=(-y)-(-x)+2;
	if(as_4>0){
		ans.push_back(as_4);
	}	
	
	sort(ans.begin(),ans.end());
	cout << ans[0] << endl;
	return 0;
}


Measured memory_bytes: 3596
# encoding:utf-8
import copy
import numpy as np
import random


n,k = map(int,input().split())
a = [int(i) for i in input().split()]

count_dic = {}

for i in range(len(a)):
    if a[i] in count_dic.keys():
        count_dic[a[i]] += 1
    else:
        count_dic[a[i]] = 1
# print(type(count_dic[1]))

# print(count_dic)
count_list = sorted(count_dic.items(),key=lambda x: x[1],reverse=True)

ans = 0
# print(len(count_list))
while len(count_list)>k:
    # print(count_list)
    delte_tuple = count_list[-1]
    add_tuple = count_list[0]
    count_list[0] = tuple([add_tuple[0],add_tuple[1]+delte_tuple[1]])
    ans += delte_tuple[1]
    del count_list[-1]

print(ans)


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

int main(){
    int n;
    cin >> n;
    int c[n-1], s[n], f[n];
    int time[n-1];
    for(int i = 0; i < n-1; i++)
        cin >> c[i] >> s[i] >> f[i];
    f[n-1]=1; s[n-1]=-100;
    int ans[n];
    for(int i = 0; i < n-1; i++){
        ans[i]=s[i];
        for(int j = i; j < n-1; j++){
            ans[i]=ans[i]+c[j];
            if(ans[i]<s[j+1])
                ans[i]=s[j+1];
            else if(ans[i]>=s[j+1]&&ans[i]%f[j+1]!=0)
                ans[i]=ans[i]+f[j+1]-(ans[i]%f[j+1]);    
        }
    }
    for(int i = 0; i < n-1; i++)
        cout << ans[i] << endl;
    cout << '0' << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long n,d[4],l,s,k,i;
while(cin>>n,n){
for(k=0;n!=6174;k++){
for(i=0;i<4;i++){d[i]=n%10;n/=10;}
sort(d,d+4,greater<long>());
for(l=i=0;i<4;i++){l=l*10+d[i];}
sort(d,d+4);
for(s=i=0;i<4;i++){s=s*10+d[i];}
n=l-s;
if(n==0)break;
}
if(n==0)cout<<"NA"<<endl;else cout<<k<<endl;
}
return 0;
}

Measured memory_bytes: 1180
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int i = int.Parse(s[1]);
        Console.WriteLine(N - i + 1);
    }
}


Measured memory_bytes: 11092
n, q = [int(x) for x in input().split()]
vs   = []
	
for _ in range(0, n + 1):
	vs.append([])
	
xs    = [0]     * (n + 1)
fs    = [False] * (n + 1)
us    = [0]     * n
fs[1] = True
us[0] = 1
ui    = 0

for _ in range(0, n - 1):
	a, b = [int(x) for x in input().split()]
	vs[a].append(b)
	vs[b].append(a)

for _ in range(0, q):
	p, x   = [int(x) for x in input().split()]
	xs[p] += x
	
for i in range(0, n):
	x = xs[us[i]]
	for v in vs[us[i]]:
		if fs[v] == False:
			xs[v] += x
			ui    += 1
			us[ui] = v
			fs[v]  = True

print(" ".join(str(x) for x in xs[1:]))


Measured memory_bytes: 68480
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a, b = 0;
  for (int i=0; i<n; ++i) {
    cin >> a;
    b |= a;
  }
  for (int i=0; i<64; ++i) {
    if ((b >> i) & 1) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, vector<int> > T;

llint D;
llint c[30], csum;
llint s[400][30];
vector<int> ans;
vector<T> vec;

inline llint score(vector<int> ans, int n)
{
	int last[26];
	for(int i = 0; i < 26; i++) last[i] = 0;
	
	llint ret = 0, sub = 0;
	for(int i = 0; i < n; i++){
		llint x = ans[i];
		ret += s[i][x];
		sub -= (i-last[x]) * c[x];
		sub += csum;
		ret -= sub;
		last[x] = i;
	}
	return ret;
}

inline void search(vector<int> &ret)
{
	llint cur = score(ret, D);
	for(int t = 0; t < 1; t++){
		llint x = rand() % D, y = rand() % D;
		swap(ret[x], ret[y]);
		llint nxt = score(ret, D);
		if(nxt < cur) swap(ret[x], ret[y]);
		else cur = nxt;
		
		x = rand() % D, y = rand() % 26;
		llint tmp = ret[x];
		ret[x] = y;
		nxt = score(ret, D);
		if(nxt < cur) ret[x] = tmp;
		else cur = nxt;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	srand(time(NULL));
	
	cin >> D;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 0; i < D; i++){
		for(int j = 0; j < 26; j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < 26; i++) csum += c[i];
	
	ans.resize(D);
	for(int i = 0; i < D; i++){
		llint max_val = -inf, max_j;
		for(int j = 0; j < 26; j++){
			ans[i] = j;
			llint res = score(ans, i+1);
			if(res > max_val){
				max_j = j;
				max_val = res;
			}
		}
		ans[i] = max_j;
	}
	search(ans);
	
	const int M = 50;
	llint res = score(ans, D);
	for(int i = 0; i < M; i++) vec.push_back(T(res, ans));
	
	for(int t = 0; t < 4000; t++){
		vector<T> nvec;
		for(int i = 0; i < vec.size(); i++){
			vector<int> tmp = vec[i].second;
			search(tmp);
			nvec.push_back(vec[i]);
			nvec.push_back(T(score(tmp, D), tmp));
		}
		for(int i = 0; i < vec.size(); i++){
			llint x = rand() % (int)vec.size(), y = rand() % (int)vec.size();
			vector<int> tmp = vec[x].second;
			tmp.resize(D/2);
			tmp.insert(tmp.end(), vec[y].second.begin()+D/2, vec[y].second.end());
			nvec.push_back(T(score(tmp, D), tmp));
		}
		sort(nvec.rbegin(), nvec.rend());
		nvec.resize(M);
		vec = nvec;
	}
	ans = vec.front().second;
	
	for(int i = 0; i < D; i++) cout << ans[i]+1 << endl;
	
	return 0;
}

Measured memory_bytes: 3876
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  ll x[N], y[N], z[N];
  for(int i=0;i<N;++i) cin>>x[i]>>y[i]>>z[i];
  vector<ll> arr(N);
  ll ans = 0;
  ll tmp;
  for(int i=0;i<N;++i) {
    arr[i] = x[i]+y[i]+z[i];
  }
  sort(arr.begin(), arr.end(), greater<ll>());
  tmp = 0;
  for(int i=0;i<M;++i) tmp += arr[i];
  ans = max(ans, tmp);
  for(int i=0;i<N;++i) {
    arr[i] = -x[i]+y[i]+z[i];
  }
  sort(arr.begin(), arr.end(), greater<ll>());
  tmp = 0;
  for(int i=0;i<M;++i) tmp += arr[i];
  ans = max(ans, tmp);
  for(int i=0;i<N;++i) {
    arr[i] = x[i]-y[i]+z[i];
  }
  sort(arr.begin(), arr.end(), greater<ll>());
  tmp = 0;
  for(int i=0;i<M;++i) tmp += arr[i];
  ans = max(ans, tmp);
  for(int i=0;i<N;++i) {
    arr[i] = x[i]+y[i]-z[i];
  }
  sort(arr.begin(), arr.end(), greater<ll>());
  tmp = 0;
  for(int i=0;i<M;++i) tmp += arr[i];
  ans = max(ans, tmp);
  for(int i=0;i<N;++i) {
    arr[i] = -x[i]-y[i]+z[i];
  }
  sort(arr.begin(), arr.end(), greater<ll>());
  tmp = 0;
  for(int i=0;i<M;++i) tmp += arr[i];
  ans = max(ans, tmp);
  for(int i=0;i<N;++i) {
    arr[i] = -x[i]+y[i]-z[i];
  }
  sort(arr.begin(), arr.end(), greater<ll>());
  tmp = 0;
  for(int i=0;i<M;++i) tmp += arr[i];
  ans = max(ans, tmp);
  for(int i=0;i<N;++i) {
    arr[i] = x[i]-y[i]-z[i];
  }
  sort(arr.begin(), arr.end(), greater<ll>());
  tmp = 0;
  for(int i=0;i<M;++i) tmp += arr[i];
  ans = max(ans, tmp);
  for(int i=0;i<N;++i) {
    arr[i] = -x[i]-y[i]-z[i];
  }
  sort(arr.begin(), arr.end(), greater<ll>());
  tmp = 0;
  for(int i=0;i<M;++i) tmp += arr[i];
  ans = max(ans, tmp);
  cout<<ans<<endl;
}



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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t a,b;
  int64_t n;
  cin >> a >> b >> n;
  
  int64_t value = 0;
  int64_t max = 0;

  max = (a*n)/b - a*(n/b);

  if((b-1)<n){
     value = (a*(b-1))/b - a*((b-1)/b);
    if(value>max)max=value;
  }
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 3672
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  f(i,0,n)
    cin >> a[i];
  int ans = a[n-1]-a[0];
  f(i,0,n-1){
    ans = min(ans,(k - a[i+1]+a[i]));
  }
  cout<<ans<<'\n';


  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 3010

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
string s, t;
int n1, n2;
int dp[N][N];
int p[N][N];
int dpf(int i, int j)
{
	if(i == n1 || j == n2)
		return 0;
	if(dp[i][j] >= 0)
		return dp[i][j];
	if(s[i] == t[j])
	{
		dp[i][j] = 1 + dpf(i + 1, j + 1);
		p[i][j] = 2;
	}
	else
	{
		int k1, k2;
		dp[i][j] = max(k1 = dpf(i + 1, j), k2 = dpf(i, j + 1));
		if(dp[i][j] == k1)
			p[i][j] = 1;
		else
			p[i][j] = 3;
	}
	return dp[i][j];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	memset(dp, -1, sizeof(dp));
	// memset(s, -1, sizeof(s));
	cin >> s >> t;
	n1 = s.size(), n2 = t.size();
	int ans = dpf(0, 0);
	int i = 0, j = 0;
	string an;
	while(i < n1 && j < n2)
	{
		if(p[i][j] == 1)
		{
			i++;
		}
		else if(p[i][j] == 2)
		{
			an += s[i];
			i++;
			j++;
		}
		else
		{
			j++;
		}

	}

	cout << an << '\n';
	return 0;
}

Measured memory_bytes: 71296
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main_b():
	s = input()
	pp=0
	na=0
	for i, c in enumerate(s[::-1]):
		cc=na+int(c)
		na=0
		if cc <= 4:
			pp+=cc
		else:
			na = 1
			if i==len(s)-1:
				pp+=1
			pp+=10-cc
			
	print(pp)
	
def main():
	s = input()
	pmin=1000
	mmin=0
	s='0'+s
	for c in s[::-1]:
		v = int(c)
		npmin = min(pmin + 10 - (v+1), mmin + 10 - v)
		nmmin = min(pmin + v + 1, mmin + v)
		pmin = npmin
		mmin = nmmin
	return min(pmin, mmin)
	
	
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 78960
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int main() {
	int N, n, t = 0;
	cin >> N;
	n = N;
	while (n != 0) {
		t += (n % 10);
		n /= 10;
	}
	if (N % t == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{ll sum,on,tw,th;};
int main(){
  ll x,y,z,k;cin >> x >> y >> z >> k;
  vector<ll> a(x),b(y),c(z);
  for(int i=0;i<x;i++){
    cin >> a[i];
  }
  for(int i=0;i<y;i++){
    cin >> b[i];
  }
  for(int i=0;i<z;i++){
    cin >> c[i];
  }
  vector<ll> ans;
  sort(a.begin(),a.end(),greater<ll>());
  sort(b.begin(),b.end(),greater<ll>());
  sort(c.begin(),c.end(),greater<ll>());
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      for(int l=0;l<z;l++){
        if((i+1)*(j+1)*(l+1)>k){
          break;
        }
        ans.push_back(a[i]+b[j]+c[l]);
      }
    }
  }
  sort(ans.begin(),ans.end(),greater<ll>());
  for(int i=0;i<k;i++){
    cout << ans[i] << endl;
  }
}

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

using namespace std;

int ver[30];

int main (){
	int n;

	scanf("%d", &n);

	int cnt = 0;

	for(int i = 0 ; i < n ; i++){
		char c;

		scanf("\n%c", &c);

		if(ver[c - 'A'] == 0){
			cnt++;
			ver[c - 'A'] = 1;
		}
	}

	if(cnt == 3){
		printf("Three\n");
	}else{
		printf("Four\n");
	}

	return 0;
}

Measured memory_bytes: 256
N = gets.to_i

def _753?(x)
  x = x.to_s
  x.include?('7') && x.include?('5') && x.include?('3')
end

def dfs(x)
  cnt = 0
  if x <= N
    # 0スタートで10倍+3,5,7だと753数字しか来ない
    cnt += 1 if _753?(x)
    cnt += dfs (x*10 + 3) #3 -> 33 -> 333
    cnt += dfs (x*10 + 5)
    cnt += dfs (x*10 + 7)
  end
  cnt
end

puts dfs(0)

Measured memory_bytes: 3836
H,W,h,w=map(int,input().split())
if H%h==0 and W%w==0:
    print("No")
else:
    c=10**9
    ans=[[(c-1)//(h*w-1) for i in range(W)] for j in range(H)]
    for i in range(H):
        for j in range(W):
            if (i+1)%h==0 and (j+1)%w==0:
                ans[i][j]=-c
    if sum(ans[i][j] for i in range(H) for j in range(W))>0:
        print("Yes")
        for i in range(H):
            print(*ans[i])
    else:
        print("No")


Measured memory_bytes: 50652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxM = 1e5+7;
const int maxV = 90010;

const int MOD = 1e9+7;

int T;
const int maxN = 1e2+8;
const ll INF = 1000000000000000010LL;
const int K = 15;
int n,d;
int main() {
	scanf("%d%d",&n,&d);
	int x = 2 * d + 1;
	int ans = (n-1)/x + 1;
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int total_books;
  int total_sell_books;
  while(~scanf("%d %d",
	       &total_books,
	       &total_sell_books)){
    vector<int> books[11];
    for(int book_idx=0;book_idx<total_books;book_idx++){
      int price,category;
      scanf("%d %d",&price,&category);
      books[category].push_back(price);
    }

    for(int category=1;category<=10;category++){
      sort(books[category].begin(),books[category].end(),greater<int>());
    }

    int dp[2001];
    memset(dp,0,sizeof(dp));
    for(int category=1;category<=10;category++){
      for(int sell=total_sell_books;sell>=0;sell--){
	int sum = 0;
	for(int book_idx=0;book_idx<books[category].size();book_idx++){
	  if(sell + (book_idx+1) > total_sell_books) continue;
	  int price = books[category][book_idx];
	  sum += price;
	  dp[sell+(book_idx+1)] = max(dp[sell] + sum + (book_idx+1)*book_idx,
				      dp[sell+(book_idx+1)]);
	}
      }
    }
    printf("%d\n",dp[total_sell_books]);
  }
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

void primeFactorization2(uint64_t number, list<uint64_t> &factors){
  uint64_t val = sqrt(number);
  for (uint64_t i = 2; i <= val; i++){
    while (number % i == 0){
      number /= i;
      factors.push_back(i);
	}
  }
  if(number != 1){
    factors.push_back(number);
  }
}

signed main() {
  uint64_t n;
  cin >> n;
  list<uint64_t> factors;
  primeFactorization(n,factors);
  
  uint64_t totalCount = 0;
  while(factors.size()>0) {
  	bool isFirst = true;
    uint64_t val = 0;
    uint64_t factCount = 0;
  	for(auto factor: factors){
      if(isFirst){
        val = factor;
        isFirst = false;
        factCount++;
      }
      else if(val==factor){
        factCount++;
      }
  	}
    for(int j=0;j<factCount;j++){
      factors.pop_front();
    }
    uint64_t currCount = 1;
    while(factCount>=currCount){
      for(int j=0;j<currCount;j++){
      	n /= val;
      	factCount--;
      }
      totalCount++;
      currCount++;
    }
  }
  cout << totalCount << endl;
  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



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

    string ans = s;
    int sum = 0;
    REP(i,0,s.size()){
        if (s[i] == '(') sum++;
        else if (sum == 0) ans = '(' + ans;
        else sum--;
    }
    REP(i,0,sum){
        ans = ans + ')';
    }

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

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int K = sc.nextInt();
		char[][] c = new char[H][W];
		for(int i = 0; i < H; i++)
			c[i] = sc.next().toCharArray();
		int ans = 0;
		for(int i = 0; i < 1<<(H+W); i++) {
			boolean[] x = new boolean[H+W];
		    for(int j = 0; j < (H+W); j++)
		        if ((1 & i >> j) == 1)
		            x[j] = true;
		    int black = 0;
		    for(int j = 0; j < H; j++)
		    	for(int k = 0; k < W; k++)
		    		if(x[j] && x[H+k] && c[j][k] == '#')
		    			black++;
		    if(black == K)
		    	ans++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 36708
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<algorithm>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include<bitset>
#include<list>
#include<vector>
#include<forward_list>
#include<array>
#define ll long long
#define ull unsigned long long
#define lowbit(x) (x&(-x))
#define inf 0x3f3f3f3f
#define IOS std::ios::sync_with_stdio(false)
#define undocin cin.tie(NULL)
using namespace std;
const int maxn=1e5+7;
const int maxm=2e6+7;
int Read(){
	int out=0,flag=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
	while(c>='0'&&c<='9'){out=out*10+c-'0';c=getchar();}
	return flag*out;
}

int main()
{
	string s;
	int ans=0;
	cin>>s;
	for(int i=0,j=s.length()-1;i<j;i++,j--)
		if(s[i]!=s[j])ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

string ans;

void ps(int n,char a){
    for(int i=0;i<n;i++) ans+=a;
    return;
}

int sumd(int n){
    int res=0;
    while(n>0){
        res=n%10;
        n/=10;
    }
    return res;
}

int F(ll a,ll b){
    string s,t;
    s=to_string(a);
    t=to_string(b);
    return max(s.size(),t.size());
}
int main(){
    ll N;cin>>N;
    int ans=10000;
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i==0){
            ll j=N/i;
            ans=F(i,j);
        }
    }
    cout<<ans<<endl;
}    

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

int main(){
		double W,H,x,y;
		cin >> W >> H >> x >> y;
		bool other = false;
		if(x*2==W and y*2==H){
				other = true;
		}
		printf("%.9f", W*H/2);
		cout << " "<< other << endl;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef rsd511
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    #ifndef rsd511
    #define trace(...) {}
    #define cotra(...) {}
    #endif
} 

// Code Here

int main()
{
    Fast_IO();
    ll n; cin >> n;
    vector < pair<ll,ll> > p(n);
    f(i,0,n-1) cin >> p[i].ff >> p[i].ss;
    vector <ll> plus, minus;
    f(i,0,n-1) plus.pb(p[i].ff + p[i].ss), minus.pb(p[i].ff - p[i].ss);
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end());
    ll ans = max(plus[n-1] - plus[0], minus[n-1] - minus[0]);
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    if(a>=3200){
        cout<<s<<endl;

    }

    else {
        cout<<"red"<<endl;
        
    }
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  ll n = s.size();
  for (ll i = n - 2; i >= 2; i -= 2) {
    if(s.substr(0, i/2) == s.substr(i/2, i/2)){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;

int mo[4]={0,1,0,-1};

int main(){
    int ans;
    int a,b,c,d,e;
    
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    
    ans = min(a,min(b,c))+min(d,e)-50;
    
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n,w,a[101],i,x;
	while(scanf("%d%d",&n,&w),n)
	{
		vector<int>v;
		for(i=0;i<n;++i)scanf("%d",a+i);
		sort(a,a+n);
		a[n]=1e9;
		i=0;
		for(x=w;i<n;x+=w)
		{
			v.push_back(0);
			while(a[i]<x)++i,++v.back();
		}
		double res=0.01;
		x=*max_element(v.begin(),v.end());
		for(i=0;i<v.size();++i)
			res+=(v.size()-i-1.0)/(v.size()-1)*v[i]/x;
		printf("%f\n",res);
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> c(9,vector<int>(9));
  int sum=0;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      int k=0;
      while(k<=N){
        int I=k;
        while(I>9){
          I=I/10;
        }
        if(I==i && k%10==j) c.at(i-1).at(j-1)++;
        k++;
      }
    }
  }
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      sum += c.at(i-1).at(j-1)*c.at(j-1).at(i-1);
    }
  }
  cout << sum << endl;
  
}

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

int main(){
    int a, b;
    cin >> a >> b;

    float c = a, d = b;
    float y = 0;
    float x = modf((c + d) / 2, &y);

    //cout << "x:" << x << endl;
    //cout << "y:" << y << endl;
    if(x >= 0.5){
        cout << ((a + b) / 2) + 1 << endl;
    }
    else{
        cout << (a + b) / 2 << endl;
    }

    return 0;
}

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

ll fact(ll n){
	return n==0 ? 1 : (n*fact(n-1))%MOD;
}

int main(void){
	int N,M;
	cin>>N>>M;
	ll res=1;
	if(abs(N-M)>1)res=0;
	if(abs(N-M)==0)res=2;
	res=(res*fact(N)*fact(M))%MOD;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
///////////////////////////
int main(){fastio
    
    string t="keyence";
    string s;cin>>s;
    ll c=0,d=0;
    rep(i,0,6){
        if(s[i]==t[i]){
            c++;
        }else{
            break;
        }
    }
    rep(i,0,6){
        if(s[s.size()-1-i]==t[6-i]){
            d++;
        }else{
            break;
        }
    }
    if(c+d<=6)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


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

int m,n,k;
int x11, x2, y11, y2;
int dx[4]= {-1,1,0,0};
int dy[4] = {0,0,1,-1};
vector<vector<char>> graph;
vector<vector<int>> visited,dist;

void djikstra(int x,int y){
	queue<pair<int,int> > q;
	q.push({x,y});
	visited[x][y]=1;
	dist[x][y]=0;
	while(!q.empty()){
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int i=0;i<4;i++){
			for(int l=1;l<=k;l++){
				int nx = x+dx[i]*l;
				int ny=y+dy[i]*l;
				if(nx<1 || nx>n|| ny<1 || ny>m)
				 break;
				if(visited[nx][ny] && dist[x][y]+1>dist[nx][ny])
				 break;
				if(graph[nx][ny]=='@')
				 break;
				if(visited[nx][ny])
				 continue;
				dist[nx][ny]=dist[x][y]+1;
				visited[nx][ny]=true;
				q.push({nx,ny});
			}
		}
	}
}

int main(){
	cin>>n>>m>>k;
	cin>>x11>>y11>>x2>>y2;
	graph = vector<vector<char>>(n+1,vector<char>(m+1));
	visited = dist = vector<vector<int>> (n+1,vector<int>(m+1,0));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>graph[i][j];
	djikstra(x11,y11);
	if(!visited[x2][y2])
		cout<<"-1";
	else
		cout<<dist[x2][y2];
	
}

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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
      x = (int) (1LL * x * p.x % mod);
      return *this;
  }

  ModInt &operator/=(const ModInt &p) {
      *this *= p.inverse();
      return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
      int a = x, b = mod, u = 1, v = 0, t;
      while(b > 0) {
          t = a / b;
          swap(a -= t * b, b);
          swap(u -= t * v, v);
      }
      return ModInt(u);
  }

  ModInt pow(int64_t n) const {
      ModInt ret(1), mul(x);
      while(n > 0) {
          if(n & 1) ret *= mul;
          mul *= mul;
          n >>= 1;
      }
      return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
      return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
      int64_t t;
      is >> t;
      a = ModInt< mod >(t);
      return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< MOD >;

ll N, K;

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

    cin >> N >> K;

    // gcd が i になるパターン数
    vector<modint> pat(K + 1);

    modint ans(0);
    for(int i = K; i >= 1; --i) {
        modint cnt(K / i);
        pat[i] = cnt.pow(N);
        if(cnt.x > 1) {
            // i の倍数がいるならそれしか出ないパターンぶん引く
            for(int j = 2; i * j <= K; ++j) {
                pat[i] -= pat[i * j];
            }
        }
        ans += modint(i) * pat[i];
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    int n;
    int counts=0;
    cin >> n;
    map <int, int> sheet;
    for (int i=0; i<n; i++){
        int num;
        cin >> num;
        if (sheet[num]==0){
            counts++;
            sheet[num]++;
        }
        else if (sheet[num]>0){
            sheet[num]=0;
            counts--;
        }
    }
    cout << counts << endl;
}


Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
vector <int> vec[100005];
vector <int> order;
int n,m;
int visit[100005];
int dp[100005];

void dfs(int x)
{
	visit[x]=true;
	for(int i=0;i<vec[x].size();i++)
	{
		if(visit[vec[x][i]]) continue;
		dfs(vec[x][i]);
	}
	order.push_back(x);
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>m;
	int x,y;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&x,&y);
		x--;
		y--;
		vec[x].push_back(y);
	}
	for(int i=0;i<n;i++)
	{
		if(!visit[i])
		{
			dfs(i);
		}
	}
	reverse(order.begin(),order.end());
	for(int i=0;i<n;i++)
	{
		dp[i]=1;
	}
	int res=0;
	for(int i=0;i<n;i++)
	{
		res=max(res,dp[order[i]]);
		for(int j=0;j<vec[order[i]].size();j++)
		{
			dp[vec[order[i]][j]]=max(dp[vec[order[i]][j]],dp[order[i]]+1);
		}
	}
	cout<<res-1<<endl;
	return 0;
}

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

int main() {
  std::int_fast64_t h, w;
  std::cin >> h >> w;
  std::vector<std::vector<char>> s(h, std::vector<char>(w));
  for (std::int_fast64_t i = 0; i < h; ++i) {
    std::string s_i;
    std::cin >> s_i;
    std::copy(s_i.begin(), s_i.end(), s[i].begin());
  }

  for (std::int_fast64_t i = 0; i < h; ++i) {
    for (std::int_fast64_t j = 0; j < w; ++j) {
      if (s[i][j] == '#') continue;

      std::int_fast64_t mine_count = 0;
      for (std::int_fast64_t dy = -1; dy <= 1; ++dy) {
        for (std::int_fast64_t dx = -1; dx <= 1; ++dx) {
          if (0 <= i + dy && i + dy < h && 0 <= j + dx && j + dx < w && s[i + dy][j + dx] == '#') ++mine_count;
        }
      }
      s[i][j] = '0' + mine_count;
    }
  }

  for (std::int_fast64_t i = 0; i < h; ++i) {
    for (std::int_fast64_t j = 0; j < w; ++j) {
      std::cout << s[i][j];
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[105];

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

  int ans = 0;
  for (int i = 1; i <= N; i+=2){
    if (A[i] % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main(void){
    int n,m,i;
    int sum = 0;
    int t[101],p[101],x[101];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf(" %d",&t[i]);
        sum = sum + t[i];
    }
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d %d",&p[i],&x[i]);
    }
    for(i=0;i<m;i++){
        printf("%d\n",sum - t[p[i] - 1] + x[i]);
    }
}

Measured memory_bytes: 128