akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
using namespace std;

void extGCD(long long a, long long b, long long &x, long long &y) {
    if (a == 0) {
        x = 0;
        y = 1;
    }else{
      long long q = b/a;
      long long r = b%a;

      long long s;
      long long t;
      extGCD(r, a, s, t); // 再帰的に解く

      x = t - q * s;
      y = s;
    }
}

// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}


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

  long long inv[N]; //逆元
  long long p = 1000000007LL;
  long long sum[N+1] = {}; //累積和

  for(int i=0;i<N;i++){
    inv[i] = modinv(i+1,p);
    sum[i+1] = sum[i] + inv[i];
    if(sum[i+1] > p){
      sum[i+1] -= p;
    }
  }

  long long prob[N] = {}; //P(i,j)をiに関して総和をとったもの
  long long result = 0;
  for(int j=0;j<N;j++){
    prob[j] = sum[j+1];
    prob[j] += sum[N-j];
    prob[j] -= 1;
    if(prob[j] > p){
      prob[j] -= p;
    }else if(prob[j] < 0){
      prob[j] += p;
    }

    result += prob[j]*A[j];
    result %= p;
  }

  for(int j=0;j<N;j++){
    result *= (j+1);
    result %= p;
  }

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


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

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

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    int sum=0;
    int ans=0;
    rep(i,n){
        int a;
        cin>>a;
        ans=(ans+sum*a)%MOD;
        sum=(sum+a)%MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
int n;
int s[1111];
const int M=10001;

bool t[211111];
int main(){
	cin>>n;
	rep(i,n)cin>>s[i];
	
	t[0]=1;
	rep(i,n){
		for(int j=M;j>=0;j--){
			if(t[j])t[j+s[i]]=1;
		}
	}
	int ans=0;
	for(int i=1;i<M;i++)if(t[i]&&i%10>0)ans=max(ans,i);
	cout<<ans<<endl;
	return 0;
}


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

int main(int argc, const char * argv[]) {
   
    
    int a,b;
    string c;
    bool ok = true;
    
    cin >> a >> b;
    cin >> c;
    
    
    for(int i=0;i<a;i++){
        if(!('0' <= c[i] && c[i] <='9')) ok = false;
    }
    if(c[a]!='-') ok = false;
    for(int i=a+1;i<a+b+1;i++){
        if(!('0' <= c[i] && c[i] <='9')) ok = false;
    }
    
    if(ok) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> x(n);
  for (int i = 0; i < n; ++i)
    std::cin >> x.at(i);

  int min = INT_MAX;
  for (int i = 0; i <= 100; ++i) {
    int sum = 0;
    for (int j = 0; j < n; ++j) {
      sum += (x.at(j) - i) * (x.at(j) - i);
    }
    min = std::min(sum, min);
  }

  std::cout << min << std::endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i=0; i<m; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  if (n < sum) cout << -1 << endl;
  else cout << n - sum << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;

int main() {
  ll N,x; cin>>N>>x;
  if(x<2||x>(2*N-2)) {
    cout<<"No"<<endl;
    return 0;
  }

  cout<<"Yes"<<endl;

  if(N==2) {
    cout<<1<<endl;
    cout<<2<<endl;
    cout<<3<<endl;
    return 0;
  }

  vi v(2*N-1,-1);
  v[N-1]=x;


  if(x==2) {
    v[N-2]=2*N-1;
    v[N]=1;
    v[N+1]=2*N-2;
    REP(i,N-2) if(2+i<x) v[i]=2+i; else v[i]=3+i;
    FOR(i,N+2,2*N-1) if(i-2<x) v[i]=i-2; else v[i]=i-1;
  }else {
    v[N-2]=1;
    v[N]=2*N-1;
    v[N+1]=2;
    REP(i,N-2) if(3+i<x) v[i]=3+i; else v[i]=4+i;
    FOR(i,N+2,2*N-1) if(i-1<x) v[i]=i-1; else v[i]=i;
  }

  for(ll i:v) cout<<i<<endl;



}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
 
#define ll long long
 
#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));
 
int main(){
	ll N,K,sum = 0;
  cin >> N >> K;
  vector<ll> a(N,0);
  map<ll,ll> b;
  froop1(0,N){
    cin >> a.at(i);
    if(b.count(a.at(i))){
      b[a.at(i)]++;
    }else{
      b[a.at(i)] = 1;
    }
  }
  ll c = 0,kk = K * (K - 1) / 2;
  kk %= 1000000007LL;
  for(pair<ll,ll> p : b){
    sum += c * kk * p.second;
    sum %= 1000000007LL;
    c += p.second;
  }
  froop1(0,N){
    for(int j = i;j < N;j++){
     if(a.at(i) > a.at(j)) sum += K;
      sum %= 1000000007LL;
    }
  }
  cout << sum << endl;
}

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

#define    ll     long long int

int main( )
{
    int n, i, j, k;
    int odd = 0, four = 0, two = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> j;
        if (j % 2) {
            odd++;
        }
        else if (j % 4 == 0) {
            four++;
        }
        else {
            two++;
        }
    }
    if (odd <= four) {
        cout << "Yes\n";
    }
    else if (odd - four == 1 && two == 0) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 384
<?php
define('MOD', 10 ** 9 + 7);
init(100);
list($n) = strs();
list($k) = ints();
$l = strlen($n);
if ($k > $l) exit('0');
$cnt = nCr2($l, $k) * (9 ** $k);
$notzero = 0;
$i = 0;
while ($notzero < $k) {
    $cnt -= (9 - (int) $n[$i]) * nCr2($l - $i - 1, $k - ($notzero + 1)) * (9 ** ($k - ($notzero + 1)));
    if ($n[$i] !== '0') ++$notzero;
    ++$i;
}
echo $cnt;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modMul(nPr($n, $r - 1), $n - $r + 1);
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return modDiv(nPr($n, $r), modFac($r));
}

// 階乗、逆元を前処理
function init($n)
{
    global $fact, $ifact;
    $fact[0] = 1;
    for ($i = 1; $i <= $n; ++$i) $fact[$i] = modMul($fact[$i - 1], $i);
    $ifact[$n] = modDiv(1, $fact[$n]);
    for ($i = $n; $i >= 1; --$i)
        $ifact[$i - 1] = modMul($ifact[$i], $i);
}

// 順列（前処理）
function nPr2($n, $r)
{
    global $fact, $ifact;
    return modMul($fact[$n], $ifact[$n - $r]);
}

// 組み合わせ（前処理）
function nCr2($n, $r)
{
    global $fact, $ifact;
    return modMul(modMul($fact[$n], $ifact[$r]), $ifact[$n - $r]);
}


Measured memory_bytes: 16104
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 347589
#define mods 998244353
#define int long long
using namespace std;
int f[p],s[p],l[p],r[p];
signed main()
{
	int n,k;
	cin>>n>>k;
	for(fint i=1;i<=k;i++)
	cin>>l[i]>>r[i];
	f[1]=1,s[1]=1;
	for(fint i=2;i<=n;i++)
	{
		for(fint j=1;j<=k;j++)
		f[i]=f[i]-(s[(i-r[j]-1<0?0:i-r[j]-1)]-s[i-l[j]<0?0:i-l[j]]),f[i]%=mods;
		s[i]=s[i-1]+f[i],s[i]%=mods;
	}
	cout<<(f[n]+mods)%mods;
	return 0;
}

Measured memory_bytes: 6736
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    int k,a,b;
    cin>>k>>a>>b;
    if((b/k)*k>=a)
    {
        cout<<"OK";
    }
    else cout<<"NG";
}

int main()
{
    fast;
    int t;
    solve();
}


Measured memory_bytes: 3652
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

template <typename T>
T abs(T x) { return (x < 0) ? (-x) : x; }

int gcd(int x, int y) {
	if(x > y) swap(x, y);
	while(x) {
		y %= x;
		swap(x, y);
	}
	return y;
}

cat solve(int W, int H, int K) {
	// vector< vector<int> > divs(H+1);
	// for(int i = 1; i <= H; i++)
	// 	for(int j = i; j <= H; j += i)
	// 		divs[j].push_back(i);
	cat ret = 0;
	for(int r = 1; r <= (H-1)/2; r++) {
		for(int c2 = 1; c2 < W && c2*(H-r) <= 2*(K-1+H); c2++) {
			int c1 = 1, c1b = min(W-1, (2*(K-1)-c2*(H-r))/r);
			if(c1 <= c1b) {
				ret += c1b-c1+1;
				c1 = c1b+1;
			}
			while(c1 < W && c1*r+c2*(H-r) <= 2*(K-1)+min(c2,r)+2*H-r) {
				ret += (c1*r+c2*(H-r) <= 2*(K-1)+gcd(c1,H-r)+gcd(c2,r)+gcd(abs(c1-c2),H));
				c1++;
			}
		}
	}
	ret *= 2;
	if(H%2 == 0) {
		int r = H/2;
		for(int c2 = 1; c2 < W && c2*(H-r) <= 2*(K-1+H); c2++) {
			int c1 = 1, c1b = min(W-1, (2*(K-1)-c2*(H-r))/r);
			if(c1 <= c1b) {
				ret += c1b-c1+1;
				c1 = c1b+1;
			}
			while(c1 < W && c1*r+c2*(H-r) <= 2*(K-1)+min(c2,r)+2*H-r) {
				ret += (c1*r+c2*(H-r) <= 2*(K-1)+gcd(c1,H-r)+gcd(c2,r)+gcd(abs(c1-c2),H));
				c1++;
			}
		}
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	int W, H, K;
	cin >> W >> H >> K;
	cout << 2 * (solve(W, H, K) + solve(H, W, K)) << "\n";
}

// look at my code
// my code is amazing


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

int main(int argc, char *argv[]) {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int r = x2 - x1;
  int u = y2 - y1;
  int x3 = x2 - u;
  int y3 = y2 + r;
  int x4 = x3 - r;
  int y4 = y3 - u;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct goods{
  int weit;
  int value;
};
goods g[100];

int n,w;
int dtp[101][10001];
int rec(int now_g,int capa){
  if(dtp[now_g][capa]!=-1){
    return dtp[now_g][capa];
  }

  int total_val;
  if(now_g==n){
    total_val=0;
  }else if(capa<g[now_g].weit){
    total_val=rec(now_g+1,capa);
  }else{
    total_val=max(
      rec(now_g+1,capa),
      rec(now_g+1,capa-g[now_g].weit)+g[now_g].value
    );
  }
  return dtp[now_g][capa]=total_val;
}

int main(void){
  cin>>n>>w;
  for(int i=0;i<n;i++){
    cin>>g[i].value>>g[i].weit;
  }
  for(int k=0;k<101;k++){
    for(int i=0;i<10001;i++){
      dtp[k][i]=-1;
    }
  }
  cout <<rec(0,w)<<endl;
}



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

using namespace std;

int arr[101];

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", arr + i);
    int cost = INT_MAX;
    for (int tr = -100; tr <= 100; tr++) {
        int cur = 0;
        for(int i=0; i<n; i++){
            cur += (arr[i] - tr) * (arr[i] - tr);
        }
        cost = min(cost, cur);
    }
    printf("%d\n", cost);
    return 0;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
S = input()

dp = [[0]*N for i in range(N)]

ans = 0
for i in range(N):
	for j in range(i + 1, N):
		max_length = j - i
		if i == 0:
			if S[i] == S[j]:
				dp[i][j] = 1
			else:
				dp[i][j] = 0
		else:
			if S[i] == S[j]:
				dp[i][j] = min(max_length, dp[i - 1][j - 1] + 1)
			else:
				dp[i][j] = 0
		ans = max(ans, dp[i][j])
print(ans)

Measured memory_bytes: 231560
using System;

namespace C
{
    class Program
    {
		public static int gcd(int a, int b){
			if (a % b == 0)
			{
				return b;
			}
			return gcd(b, a%b);
		}

        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
			K++;
			
			long ans = 0;
			for (int i = 1; i < K; i++)
			{
				for (int j = 1; j < K; j++)
				{
					for (int k = 1; k < K; k++)
					{
						ans = ans + gcd(i,gcd(j,k));
					}
				}
			}

			Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27524
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    println!("{}", [a + b, a - b, a * b].iter().max().unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n,k;
  cin>>n>>k;
  int x[n];
  rep(i,n) cin>>x[i];
  int ans = 0;
  rep(i,n) {
    ans += min(x[i], k - x[i]) * 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(map(int, input().split()))

count = 0
for i in range(N):
    mini = min(S[i:N])
    for j in range(i,N):
        if S[j]==mini and i!=j and S[i]!=S[j]:
            S[i], S[j] = S[j], S[i]
            count += 1

for i in range(N):
    if i==N-1:
        print(S[i])
    else:
        print(S[i],end=' ')
print(count)


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int calc(vector<int> &color, int pos)
{
    int c = color[pos];
    int res = 0, left = pos, right = pos + 1;
    int cnt;
    while(true)
    {
        cnt = 0;
        while(left >= 0)
        {
            if(color[left] != c) break;
            left--;
            cnt++;
        }
        while(right < color.size())
        {
            if(color[right] != c) break;
            right++;
            cnt++;
        }
        if(cnt < 4) break;
        res += cnt;
        if(color[left] != color[right]) break;
        c = color[left];
    }
    return res;
}
int solve(vector<int> &color, const int n)
{
    int res = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int c = 1; c <= 3; c++)
        {
            if(color[i] == c) continue;
            int tmp = color[i];
            color[i] = c;
            res = max(res, calc(color, i));
            color[i] = tmp;
        }
    }
    return n - res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        vector<int> color(n);
        for(int i = 0; i < n; i++) cin >> color[i];
        cout << solve(color, n) << endl;
    }
    return 0;
}




Measured memory_bytes: 3136
#include<stdio.h>   //A - Placing Marbles

int main(){

    char s[3];
    scanf("%s",s);

    int count=0;
    for(int i=0;i<3;i++){
        if(s[i]=='1'){
            count++;
        }
    }
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n: i64);
    puts!("{}\n", (n - 1) / 2);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <unordered_set>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>
#include <set>

void run() {
	int N;
	int Y;
	std::cin >> N;
	std::cin >> Y;
	Y /= 1000;
	int x = 0;//10
	int y = 0;//5
	int z = 0;//1
	while (Y > 0) {
		if (Y > 5 * N) {
			Y -= 10;
			++x;
		}
		else if (Y == 5 * N) {
			Y -= 5;
			++y;
		}
		else {
			Y -= 1;
			++z;
		}
		--N;
		if (N == 0)
			break;
	}
	if (!(Y == 0 && N == 0)) {
		x = -1;
		y = -1;
		z = -1;
	}
	printf("%d %d %d\n", x, y, z);
}
int main() {
	run();
	return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(1 <= a && a < 10 && 1 <= b && b < 10){
            System.out.println(a*b);
        }else{
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
 
int const INF = 1<<29;
 
struct tree; typedef tree* tree_ptr;
 
struct tree {
  tree_ptr lch, rch;
  int num;
  tree()
    : lch(NULL), rch(NULL), num(-INF) { }
};
 
void consume(string& S, char expected) {
  if(S[0] == expected) {
    S = S.substr(1);
    return;
  }
  cout << S << ", " << expected << endl;
  assert(0);
}
 
bool consume_if(string& S, char expected) {
  if(S[0] == expected) {
    consume(S, expected);
    return true;
  }
  else {
    return false;
  }
}
 
int read_num(string& S) {
  stringstream ss(S);
  int x; ss >> x;
  ss >> S;
  return x;
}
 
void make_tree(string& S, tree_ptr curr) {
  if(consume_if(S, '(')) {
    tree_ptr lch = new(tree);
    curr->lch = lch;
    make_tree(S, lch);
    consume(S, ')');
    
    consume(S, '[');
    curr->num = read_num(S);
    consume(S, ']');
    
    consume(S, '(');
    tree_ptr rch = new(tree);
    curr->rch = rch;
    make_tree(S, rch);
    consume(S, ')');
    return;
  }
}
 
void dfs(tree* ptr1, tree* ptr2) {
  if(ptr1->num == -INF || ptr2->num == -INF) { return; }
  
  if(ptr1->lch && ptr2->lch) {
    cout << "(";
    dfs(ptr1->lch, ptr2->lch);
    cout << ")";
  }
  cout << "[" << (ptr1->num + ptr2->num) << "]";
  if(ptr1->rch && ptr2->rch) {
    cout << "(";
    dfs(ptr1->rch, ptr2->rch);
    cout << ")";
  }
}
 
int main() {
 
  string a; cin >> a;
  string b; cin >> b;
  
  tree_ptr atree = new(tree);
  tree_ptr btree = new(tree);
  
  make_tree(a, atree);
  make_tree(b, btree);
 
  dfs(atree, btree);
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int main(){
  string s;
  cin >> s;
  REP(i,s.size()){
    cout << s[i];
    i++;
  }
  cout << endl;
}

Measured memory_bytes: 512
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n;
    cin>>n;

    vi f(n+1,1);
    for(int i=2;i<=n;++i)
    {
        for(int j=i;j<=n;j+=i)
            f[j]++;
    }

    int ans=0;
    for(int i=1;i<=n;++i)
        ans+=i*f[i];
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 81320
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <bitset>
using namespace std;

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

int main()
{
    int n; cin >> n;
    vector<int> honest(n, 0), unkind(n, 0);
    int ai, xij, yij;
    rep(i, n){
        cin >> ai;
        rep(j, ai){
            cin >> xij >> yij;
            if(yij) honest[i] |= (1<<(xij-1));
            else unkind[i] |= (1<<(xij-1));
        }
    }

    int ans = 0, cnt;
    bool isOk = true;
    rep(b, 1<<n){
        rep(i, n){
            if(!(b & (1<<i))) continue;
            
            if((b & unkind[i]) || ((~b) & honest[i])){
                isOk = false;
                break;
            }
        }

        if(isOk){
            cnt = bitset<16>(b).count();
            ans = max(ans, cnt);
        }
        isOk = true;
    }

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

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;

int main()
{
    //cout << "Hello world!" << endl;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 3632
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,a,sum=0,ans,mn=1e9;

int main()
{
	cin>>n>>a;
	repn(i,n) sum+=a+i-1;
	repn(i,n)
	{
		int res=0;
		repn(j,n) if(i!=j) res+=a+j-1;
		if(mn>abs(res-sum))
		{
			mn=abs(res-sum);
			ans=res;
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 3000005
#define MOD 1000000007 
int up=3e6,l1,r1,l2,r2,ans,fc[N],invF[N];
int inv(int x) {return x==1?1:1ll*inv(MOD%x)*(MOD-MOD/x)%MOD;}
int C(int x,int y) {return 1ll*fc[x]*invF[y]%MOD*invF[x-y]%MOD;}
int slv(int n,int m)
{
	int res=0;
	for(int i=1;i<=m;++i) res=(res+C(n+i+1,i+1))%MOD;return (res-m+MOD)%MOD;
}
int main()
{
	scanf("%d %d %d %d",&l1,&l2,&r1,&r2);--l1;--l2;
	fc[0]=invF[0]=1;for(int i=1;i<=up;++i) fc[i]=1ll*fc[i-1]*i%MOD;
	invF[up]=inv(fc[up]);for(int i=up-1;i>=1;--i) invF[i]=1ll*invF[i+1]*(i+1)%MOD;
	printf("%d\n",((slv(r1,r2)-slv(l1,r2)-slv(r1,l2)+slv(l1,l2))%MOD+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 23680
import java.util.Scanner;


	public class Main {
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int x = sc.nextInt();
			int sum = 0;
			
			for(int i=1;;i++) {
				sum+=i;
				if(sum>=x) {
					System.out.println(i);
					return;
				}
			}
			
		}
		
		
	}


Measured memory_bytes: 23892
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 二分探索、浮き沈みの沈みに注意
N, K = lr()
A = np.array(lr()); A.sort()
F = np.array(lr()); F.sort(); F = F[::-1]

def check(x):
    limit = x // F # このラインまでにAを落とす
    Y = A - limit
    cost = Y[Y>=0].sum()
    return cost <= K

ok = 10 ** 15; ng = -1
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 37184
li=list(map(int,list(input())))
for i in range(2**3):
  val=li[0]
  outp=str(val)
  for j in range(3):
    if((i>>j)&0b1):
      val+=li[j+1]
      outp+="+"+str(li[j+1])
    else:
      val-=li[j+1]
      outp+="-"+str(li[j+1])
  if(val==7):break
print(outp+"=7")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"------------------------"<<endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
ll a,b;
ll ara[100009];
ll dp[100009];
ll call(ll p)
{
    if(p==a) return 1;
    if(p>a) return 0;
    ll c=0,d=0;
    ll &ret=dp[p];
    if(ret!=-1) return ret;
    if(ara[p+1]==false)  c+=call(p+1),c%=mod;
    if(ara[p+2]==false) d+=call(p+2),d%=mod;
    return ret=(c+d)%mod;

}
int  main()
{
    fast;
    memset(dp,-1,sizeof dp);
    cin>>a>>b;
    for(ll i=0;i<b;i++)
    {
        ll x;
        cin>>x;
        ara[x]=true;
    }
    ll d=call(0);
    cout<<d<<endl;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int R;
cin >> R;

if(R < 1200){
     cout << "ABC";
}
else if(R < 2800){
     cout << "ARC";
}
else{
     cout << "AGC";
}

cout << endl;

return 0;
}

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

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint a,b,c;

void solve(){
  cin >> a >> b >> c;
  int cnt=0;
  for(int i=a;i<=b;i++){
    if(c%i==0)cnt++;
  }
  cout << cnt << endl;
}

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



Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder_Beginners_selection
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);
            int Y = int.Parse(input[1]);

            Console.WriteLine(X + Y / 2);

        }
    }
}

Measured memory_bytes: 11220
import sys
sys.setrecursionlimit(10**8)
def knapsack(N,W,weight,value):
  #初期化
  inf=float("inf")
  dp=[[-inf for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0

  #DP
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある
        dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
      else: #入る可能性はない
        dp[i+1][w]=dp[i][w]
  return dp[N][W]
n1,w1=map(int,input().split())
lw=[]
lv=[]
for i in range(n1):
  w,v=map(int,input().split())
  lw.append(w)
  lv.append(v)
print(knapsack(n1,w1,lw,lv))


Measured memory_bytes: 300984
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};module.exports=I;

function main(input) {
  const o = new I(input);

  const N = o.a();
  let b = [];
  for (let i = 0; i < N; i++) {
    b.push(o.a());
  }

  let result = [];
  while (b.length > 0) {
    let flag = true;
    for (let i = b.length - 1; i>=0;i--) {
      if (b[i] === i + 1) {
        let removed = b.splice(i, 1);
        result.push(removed[0]);
        flag = false;
        break;
      }
    }

    if (flag) {
      break;
    }
  }

  if (b.length === 0) {
    result.reverse().forEach(r => console.log(r));
  } else {
    console.log("-1");
  }


}


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


Measured memory_bytes: 22964
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll x=5;
	vector<ll> a(x);
	
	for(int i=0;i<x;i++)
		cin>>a[i];
	ll k;
  	cin>>k;
  	if(a[4]-a[0]>k)
      	cout<<":(";
  	else
      	cout<<"Yay!";
  
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main()
{
	int w, h, n;
	cin >> w >> h >> n;
	
	int LD_x = 0, LD_y = 0;
	int RU_x = w, RU_y = h;
	
	int x, y, a, i;
	bool check = false;
	
	for(i = 0; i < n; i++)
	{
		cin >> x >> y >> a;
		if( a == 1 )
		{
			if( LD_x < x and x < RU_x )
				LD_x = x;
			else if( x >= RU_x )
				check = true;
		}else if( a == 2 ){
			if( LD_x < x and x < RU_x )
				RU_x = x;
			else if( x <= LD_x )
				check = true;
		}else if( a == 3 ){		
			if( LD_y < y and y < RU_y )
				LD_y = y;
			else if( y >= RU_y )
				check = true;
		}else{
			if( LD_y < y and y < RU_y )
				RU_y = y;
			else if( y <= LD_y )
				check = true;
		}
	}
	if( check )
		cout << 0;
	else
		cout << ( RU_x - LD_x ) * ( RU_y - LD_y );
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> a(h);
    int ans=0;
    for(auto& it:a) cin>>it;
    for(int m1=0;m1<(1<<h);m1++){
        for(int m2=0;m2<(1<<w);m2++){
            int cnt=0;
            forn(i,h){
                forn(j,w){
                    if(m1>>i&1) continue;
                    if(m2>>j&1) continue;
                    if(a[i][j]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////
#define MAX 10000100
ll inv[MAX];
ll finv[MAX];
ll fac[MAX];
ll beki(ll a,ll b){
    a %= mod;
    if (b == 0){
        return 1;
    }
    ll ans = beki(a,b / 2);
    ans = ans * ans % mod;
    if (b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
 
void cominit(){
    const int MA = 10000002;
    fac[0] = 1;
    inv[0] = 1;
    for (int i = 1;i <= MA;i++){
        fac[i] = fac[i-1] * i % mod;
    }
    finv[MA] = beki(fac[MA],mod - 2);
    for (ll i = MAX - 1;i >= 0;i--){
        finv[i] = finv[i+1] * (i + 1) % mod;
    }
    for (int i = 1;i <= MA;i++){
        inv[i] = finv[i] * fac[i - 1] % mod;
    }
}
ll com(ll a,ll b){
    if ((a == b) or (b == 0)){
        return 1;
    }
    if (a < b) return 0;
    ll ret = 1;
    for (ll i = 0;i < b;i++){
        ret *= (a - i);
        ret %= mod;
        ret *= beki(i + 1,mod - 2);
        ret %= mod;
    }
    return ret;
}
 
int main(){
    int n;
    cin >> n;
    ll ans = 1;
    ll one = 1, two = 1, three = 1;
    for (int i = 0;i < n;i++){
        two *= 10;
        two %= mod;
        ans *= 9;
        ans %= mod;
        one *= 8;
        one %= mod;
    }
 
    ans = two - ans - ans + one;
  	ans %= mod;
  	ans = (ans + mod) % mod;
    cout << ans << endl; 
}

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

int main(){
	string s;
	cin >> s;
	int cnt = 0;
	if(s[0] != 'A'){
		cout << "WA";
		return 0;
	}
	else{
		for(int i = 1; i < s.size(); ++i){
			if(isupper(s[i])){
				if(i == 1 || i == s.size() - 1 || s[i] != 'C'){
					cout << "WA";
					return 0;
				}
				++cnt;
			}
		}
	}
	if(cnt != 1) cout << "WA";
	else cout << "AC";
}


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

int mypow(int mpx,int mpn){
	if(mpn==0) return 1;
	if(mpn%2==0) return mypow((mpx*mpx),mpn/2);
	else return (mpx*mypow(mpx,mpn-1));
} 

int main() {
	// your code goes here
	int n,i,j,ca=0,cb=0;
	long long s[300000],max=0,h[300000],ma,mb,sm=1;
	vector<long long> nod;
	priority_queue<long long> a,b,c;
	cin >> n;
	for(i=0;i<mypow(2,n);i++){
		cin >> s[i];
		if(max<s[i]) max=s[i];
		a.push(s[i]);
	}
	h[0]=1;
	for(i=1;i<=n;i++){
		for(j=mypow(2,i-1);j<mypow(2,i);j++){
			h[j]=h[j-mypow(2,i-1)]+1;
		}
	}
	for(i=0;i<mypow(2,n);i++){
		b.push(h[i]);
	}
	sort(s,s+mypow(2,n));
	nod.push_back(s[0]);
	for(i=1;i<mypow(2,n);i++){
		if(s[i-1]!=s[i]) nod.push_back(s[i]);
	}
	for(i=0;i<n;i++){
		if(s[mypow(2,n)-mypow(2,i)]<=nod[n-i-1]){
			cout << "No" << endl;
			return 0;
		}
	}
	ma=a.top(); mb=b.top();
	a.pop(); b.pop();
	for(i=1;i<mypow(2,n);i++){
		if(ma>a.top()) ca++;
		if(mb>b.top()) cb++;
		if(cb>ca){
			cout << "No" << endl;
			return 0;
		}
		ma=a.top(); mb=b.top();
		a.pop(); b.pop();
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 12016
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		long A=sc.nextLong();
		long B=sc.nextLong();
		long ans=N/(A+B)*A+Math.min(A,N%(A+B));
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 22996
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int d = sc.nextInt();
    int ans;

    if(n % (2 * d + 1) == 0){
      ans = n / (2 * d + 1);
    } else {
      ans = (n / (2 * d + 1)) + 1;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,a,b = LI()

    return min(n*a,b)



print(main())




Measured memory_bytes: 7108
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    /** O(log(n)): n = min(a, b) */
    tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

    val (_, x) = readLongList()
    val ans = readLongList()
        .map { abs(it - x) }
        .filter { it != 0L }
        .reduce(::gcd)
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 58720
n = gets.to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i
ans = 0
n.times.each do |i|
  c = [a[i], b[i]].min
  ans += c
  c = [a[i+1], b[i]-c].min
  ans += c
  a[i+1] -= c
end
p ans

Measured memory_bytes: 19356
local x,y,a,b,c=io.read("n","n","n","n","n")
local t={}
for i=1,a do
    table.insert(t,{io.read("n"),"a"})
end
for i=1,b do
    table.insert(t,{io.read("n"),"b"})
end
for i=1,c do
    table.insert(t,{io.read("n"),"c"})
end
table.sort(t,function(a,b)
    return a[1]<b[1]
end)

local max=0
local aounter=0
local bounter=0
local counter=0
for i=a+b+c,1,-1 do
    if aounter<x and t[i][2]=="a" then
        aounter=aounter+1
        max=max+t[i][1]
    end
    if bounter<y and t[i][2]=="b" then
        bounter=bounter+1
        max=max+t[i][1]
    end
    if aounter+bounter+counter<x+y and t[i][2]=="c" then
        counter=counter+1
        max=max+t[i][1]
    end
    if aounter+bounter+counter==x+y or aounter+bounter==x+y then
        break
    end
end
print(max)

Measured memory_bytes: 43372
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int n, k, x, y; cin >> n >> k >> x >> y;
	ll ans = 0;
	if(n >= k){
		ans += k * x + (n - k) * y;
	}else{
		ans += n * x;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
def main():
    N =  int(input())
    a = [int(i) for i in input().split()]
    #print(N)
    #print(a)
    
    count_ = [0] * ( max(a)+2 )
    #print(len(count_))
    #a_plus  = [ i+1 for i in a ]
    #a_sub = [ i-1 for i in a ]
    #print( [ i+1 for i in a ] )
    
    for num in a:
        if(num > 0):
            count_[num-1] += 1
            count_[num] += 1
            count_[num+1] += 1
        else:
            count_[num] += 1
            count_[num+1] += 1
    
    #print(count_)
    print(max(count_))
    
if __name__=="__main__":
    main()

Measured memory_bytes: 13964
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>

using namespace std;
vector<long> a;

long getans(long b, long n) {
	long ans = 0;
	for (long j = 0; j < n; ++j) {
		ans = ans + abs(a.at(j) - (b + j + 1));
	}
	return ans;
}

int main() {

	long n = 0;
	cin >> n;
	for (long i = 0; i < n; ++i) {
		long tmp = 0;
		cin >> tmp;
		a.push_back(tmp);
	}

	//解の宣言
	long ans = 0;

	vector<long> b;
	//bの値を決定する
	for (long i = 0; i < n; ++i) {
		long tmp = 0;
		tmp = a.at(i) - (i + 1);
		b.push_back(tmp);
	}
	sort(b.begin(), b.end());

	long med[2] = {};
	med[0] = b[n / 2];
	med[1] = b[n / 2 - 1];

	long ans1 = 0;
	ans1 = getans(med[0], n);
	long ans2 = 0;
	ans2 = getans(med[1], n);

	ans = min(ans1, ans2);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4848
n=int(input())
if 400<=n and n<=599:
 print(8)
if 600<=n and n<=799:
 print(7)
if 800<=n and n<=999:
 print(6)
if 1000<=n and n<=1199:
 print(5)
if 1200<=n and n<=1399:
 print(4)
if 1400<=n and n<=1599:
 print(3)
if 1600<=n and n<=1799:
 print(2)
if 1800<=n and n<=1999:
 print(1)

Measured memory_bytes: 9200
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int main(){
int n, dp[50];
while(cin>>n,n!=0){
fill(dp,dp+50,0);
dp[0]=0,dp[1]=1,dp[2]=1,dp[3]=2;
for(int i=3;i<=n+1;i++)dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
int ans=dp[n+1];
ans/=3650;
if(dp[n]%3650!=0)ans++;
cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 1160
from sys import stdin
import sys, math

n = int(stdin.readline().rstrip())

a = [0 for i in range(n)]
d = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(n-1):
    k = d[i]
    a[k-1] = a[k-1] + 1

for i in range(n):
    print(a[i])

Measured memory_bytes: 35152
a = int(input())
b = list(map(int, input().split()))
b.sort()
c = 1
e = 0
for d in range(a):
  c = c * b[0]
  b.pop(0)
  if c > 1000000000000000000:
    print(-1)
    e = 1
    break
if e == 0:
  print(c)

Measured memory_bytes: 21476
/*
  AOJ 2208
  Title:The Melancholy of Thomas Right
  @kankichi573
*/
#include <stdio.h>
int count(int array[],int n,int x)
{
  int i,ret;

  for(i=0,ret=0;i<n;i++)
    ret += (array[i]==x)?1:0;
  return(ret);
}

void dump(int row[],int col[],int nrow,int ncol)
{
  int i;
  for(i=0;i<nrow;i++)
    printf("%d|",row[i]);
  printf("\n");
  for(i=0;i<ncol;i++)
    printf("%d|",col[i]);
  printf("\n");
}
int check(int row[],int col[],int nrow,int ncol)
{
  int i,ac1,ac2,zc1,zc2;

  if(nrow==0 && ncol==0)
    return(-1);
  else if(nrow==0 || ncol==0)
    return(0);
  //dump(row,col,nrow,ncol);

  zc1=count(row,nrow,0);
  zc2=count(col,ncol,0);
  ac1= count(row,nrow,ncol);
  ac2= count(col,ncol,nrow);
  
  //printf("zcac=%d %d %d %d\n",zc1,zc2,ac1,ac2);

  if(zc1||zc2)
    {
      if((zc2  && ac1)||(zc1 && ac2))
	return(0);
      else
	return(check(row+zc1,col+zc2,nrow-zc1,ncol-zc2));
    }
  else
    {
      if(ac1==nrow && ac2==ncol)
	return(-1);
      if(ac1==0 && ac2==0)
	return(0);
      for(i=0;i<nrow;i++)
	row[i] -= ac2;
      for(i=0;i<ncol;i++)
	col[i] -= ac1;
      return(check(row,col,nrow-ac1,ncol-ac2));
    }
}
int comp(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


main()
{
  int i,gs,rs;
  int N,gyo[10000],retu[10000];

  while(scanf("%d",&N) && N)
    {
      for(gs=0,i=0;i<N;i++)
	{
	  scanf("%d",&gyo[i]);
	  gs += gyo[i];
	}
      for(rs=0,i=0;i<N;i++)
	{
	  scanf("%d",&retu[i]);
	  rs += retu[i];
	}
      qsort(gyo ,N,sizeof(int),comp);
      qsort(retu,N,sizeof(int),comp);
      
      if((rs==gs) && check(gyo,retu,N,N))
	printf("Yes\n");
      else
	printf("No\n");
    }
  return(0);
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	int ans=0;
	cin>>s;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512