akhauriyash/Code-Regression huggingface dataset:
import fractions
import numpy as np
A, B, C, D = map(int, input().split())
# python3.5以前ではfractionsモジュールにgcdがあることに注意、それ以降ではmathモジュールにある
lcmofCD = int(C * D / fractions.gcd(C, D))
#A未満の「ＣでもＤでも割り切れない数」を求めたいのでA-1に対して計算を行うことに注意
divofAbyC = (A-1) // C
divofAbyD = (A-1) // D
divofBbyC = B // C
divofBbyD = B // D
divofBbylcm = B // lcmofCD
divofAbylcm = (A-1) // lcmofCD
ansofA = (A-1) - (divofAbyC + divofAbyD - divofAbylcm)
ansofB = B-(divofBbyC + divofBbyD - divofBbylcm)
ans = ansofB-ansofA

print("{}".format(ans))


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 300100;

int n;
int a[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	n *= 3;
	REP(i, 0, n) scanf("%d", a + i);
	sort(a, a + n);
	LL ret = 0;
	for (int i = n - 2, j = 0; i > j; ++j, i -= 2) ret += a[i];
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  ll N,M,i,a,f;scanf("%lld%lld",&N,&M);
  priority_queue<ll> q;
  for(i=0;i<N;i++){
    scanf("%lld",&a);
    q.push(a);
  }
  for(i=0;i<M;i++){
    f = q.top();q.pop();
    f /= 2;q.push(f);
  }
  ll ans = 0;
  for(i=0;i<N;i++){
    ans += q.top();q.pop();
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 4332
import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    val N = reader.nextInt()
    val X = reader.nextInt()
    val T = reader.nextInt()

    val count = N / X + if(N % X == 0) 0 else 1
    println(T*count)
}

Measured memory_bytes: 36356
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 (a > b) {
            System.out.println("a" + " " + ">" + " " + "b");
        } else if (a < b) {
            System.out.println("a" + " " + "<" + " " + "b");    
        } else if (a == b) {
            System.out.println("a" + " " + "==" + " " + "b");
        }
    }
}

Measured memory_bytes: 26072
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    A,B,M = map(int, input().split())
    aa = list(map(int, input().split()))
    bb = list(map(int, input().split()))
    ans = min(aa) + min(bb)
    for _ in range(M):
        x,y,c = map(int, input().split())
        ans = min(ans, aa[x-1] + bb[y-1] - c)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20744
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(r: usize, d: usize, x: usize);

    let mut buff = x;
    for _i in 0..10 {
        println!("{}", {
            buff = buff * r - d;
            buff
        });
    }
}


Measured memory_bytes: 2160
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func chmax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func main() {
	var n, W int
	fmt.Scan(&n, &W)
	w := make([]int, n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&w[i], &v[i])
	}

	sw := n * 3
	dp := make([][]int, n+1)
	for k := 0; k <= n; k++ {
		dp[k] = make([]int, sw+1)
	}
	for i := 0; i < n; i++ {
		for k := n - 1; k >= 0; k-- {
			for u := 0; u+(w[i]-w[0]) <= sw; u++ {
				chmax(&dp[k+1][u+(w[i]-w[0])], dp[k][u]+v[i])
			}
		}
	}
	ans := 0
	for k := 1; k <= n; k++ {
		wmax := W - w[0]*k
		if wmax >= 0 {
			for u := 0; u <= wmax && u <= sw; u++ {
				chmax(&ans, dp[k][u])
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        sc.close();

        boolean result = false;

        if(A==B && B==C){
            result = true;
        }

        String str = result ? "Yes" : "No";

        System.out.println(str);

    }
}


Measured memory_bytes: 21588
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n;
int ans;
int aans;
int f[101][10];
int g[101];
int p[101][10];
int main()
{
	cin>>n;
	rep(i,n)
	{
		rep(j,10)cin>>f[i][j];
	}
	rep(i,n)
	{
		rep(j,11)cin>>p[i][j];
	}
	for(int S=1;S<1024;S++)
	{
		aans=0;
		rep(i,n)
		{
			g[i]=0;
			rep(j,10)
			{
				if((S>>j)&f[i][j])g[i]++;
			}
		}
		rep(i,n)
		{
			//if(S==1)cout<<"p"<<g[i]<<endl;
			aans+=p[i][g[i]];
		}
		if(S==1)
		{
			//cout<<"a"<<aans<<endl;
			ans=aans;
		}
		else ans=max(ans,aans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll h, w, n;
    cin >> h >> w >> n;

    cout << ceil(n / double(max(w, h))) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 8005, ZERO = 8000;

int p[2]; char str[MAXN];
bitset <MAXN << 1> bs[2];

int main(){
	int i, j, d;
	scanf("%s%d%d", str + 1, &p[0], &p[1]);
	for(i = 1; str[i] == 'F'; ++ i) -- p[0];
	if(p[0] < -ZERO){
		printf("No\n");
		return 0;
	} bs[0][ZERO] = bs[1][ZERO] = true;
	for(d = 0; str[i]; i = j){
		for(j = i; str[j] == 'F'; ++ j) ;
		bs[d] = (bs[d] << (j - i)) | (bs[d] >> (j - i));
		if(str[j] == 'T') ++ j, d ^= 1;
	} printf("%s\n", bs[0][p[0] + ZERO] && bs[1][p[1] + ZERO] ? "Yes" : "No");
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;

const int MOD = 1000000007;

matrix mult(matrix a, matrix b) {
  matrix c;
  for(int i = 0; i < a.size(); i++) {
    c.push_back({});
    for(int j = 0; j < b[0].size(); j++) {
      c[i].push_back(0);
      for(int k = 0; k < b.size(); k++) {
        c[i][j] += a[i][k] * b[k][j];
        c[i][j] %= MOD;
      }
    }
  }
  return c;
}
matrix pow(matrix b, ll e) {
  matrix r;
  for(int i = 0; i < b.size(); i++) {
    r.push_back({});
    for(int j = 0; j < b.size(); j++) {
      r[i].push_back(i == j);
    }
  }
  while(e) {
    if(e%2) {
      r = mult(r, b);
    }
    e /= 2;
    if(e) {
      b = mult(b, b);
    }
  }
  return r;
}

void solve() {
  matrix m;
  int n;
  ll k;
  cin >> n >> k;
  for(int i = 0; i < n; i++) {
    m.push_back({});
    for(int j = 0; j < n; j++) {
      int t;
      cin >> t;
      m[i].push_back(t);
    }
  }
  m = pow(m, k);
  ll ret = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      ret += m[i][j];
    }
  }
  cout << ret%MOD << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 384
'''
制約
0 ≦ A,B,C,D ≦ 9
入力は整数からなる
答えが存在しない入力は与えられない


'''
# from collections import deque # キュー、スタックに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

is_debug = False

def main():
    '''メイン処理'''
    # ABCDを受け取り、バラシてそれぞれintとして格納
    abcd = str(input()).strip()
    abcd_list = [int(n) for n in abcd]
    if is_debug:
        print(abcd_list)

    # 2**n(= 2^n)通りのパターンを試す。 （n=4なら、2**4=16）
    # ここでは、計算する数字の数 - 1 がoperator（演算子）の数nとなる
    n = len(abcd) - 1
    for i in range(2**n):
        op_list = [0] * n  # あらかじめ [0, 0, 0] というリストを作っておく
        # 2**nの全パターンを2進数で表す。
        # ここでは2**n=8であり、2進数で0 - 7を表す。つまり000 - 111.
        bin_str = bin(i)[2:].zfill(n)
        # 2進数で1の立っている桁をフラグとみなし、opを1へ書き換え
        for j in range(n):
            if bin_str[j] == '1':
                op_list[j] = 1
        
        if is_debug:
            print(i, bin_str)
            print(op_list)
        
        # op_listの各桁が1なら+, 0なら-とみなして計算してみる
        calc_result = abcd_list[0]
        for op, num in zip(op_list,abcd_list[1:]):
            if op == 1:
                calc_result += num
            else:
                calc_result -= num
        
        # 計算してみた結果が7になれば、その時点でprintし、処理終了する
        if calc_result == 7:
            print(abcd_list[0], end='')
            for op, num in zip(op_list, abcd_list[1:]):
                if op == 1:
                    print('+', end='')
                else:
                    print('-', end='')
                print(num, end='')
            print('=7')
            break


if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()


Measured memory_bytes: 3064
#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(void){
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    for (int i=0; i<M; i++) {
        cin >> B.at(i);
    }
    for (int i=0; i<N-M+1; i++) {
        for (int j=0; j<N-M+1; j++) {
           bool v = true;
           for (int k=0; k<M; k++) {
               for (int l=0; l<M; l++) {
                   if (A.at(i+k).at(j+l)!=B.at(k).at(l)) {
                       v = false;
                   }
               }
           }
           if (v) {
               cout << "Yes" << endl;
               return 0;
           }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
p = []
b = [True for i in range(55555)]
for i in range(2, 55555+1):
    if b[i-1]:
        k = 1
        while True:
            if k*i >= 55555:
                break
            b[k*i-1] = False
            k += 1
        if (i-1)%5 == 0:
            p.append(str(i))
            if len(p) > n:
                break
print(" ".join(p[0:n]))

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

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

void Main()
{
    int n;
    cin >> n;
    vector<long> a(n);
    mint sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    mint ans = 0;
    for (int i = 0; i < n; i++)
    {
        sum -= a[i];
        ans += sum * a[i];
    }
    
    cout << ans << endl;
    // a1a1+a1a2+a2a1
    // a1(a1+a2) + a2(a1+a2)
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n,m;
    int ans=0;
    cin >>n>>m;
    int base=0;
    base+=1900*m+100*(n-m);
    cout<<(base<<m)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int N;
  int kai;
  scanf("%d",&N);

  if(N>=64)
      kai=64;
  else if(N>=32)
    kai=32;
  else if(N>=16)
    kai=16;
  else if(N>=8)
    kai=8;
  else if(N>=4)
    kai=4;
  else if(N>=2)
    kai=2;
  else
    kai=N;
  
  printf("%d",kai);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e6+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

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

const int k=169;
ll n, a[N], okxd;
ll p[k] = {1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
map <ll,ll> m;

void solve()
{
	bool pairwise=true;
    cin >> n >> a[0]; okxd=a[0]; 
    for (int j=0; j<k; ++j) {
		if (p[j]>sqrt(a[0])) break;
		if (a[0]%p[j]==0) {
			m[p[j]]++;
			if (a[0]/p[j]==p[j]) {
				if (m[p[j]]>1&&p[j]!=1) pairwise=false;
			}else{
				m[a[0]/p[j]]++;
				if ((m[p[j]]>1&&p[j]!=1)||m[a[0]/p[j]]>1) pairwise=false;
			}
		}
	}
    for (int i=1; i<n; ++i) {
    	cin >> a[i], okxd = __gcd(a[i],okxd);
    	ll temp=sqrt(a[i]);
    	if (pairwise) {
    		for (int j=0; j<k; ++j) {
    			if (p[j]>temp) break;
	    		if (a[i]%p[j]==0) {
	    			m[p[j]]++;
	    			if (a[i]/p[j]==p[j]) {
	    				if (m[p[j]]>1&&p[j]!=1) pairwise=false;
	    			}else{
	    				m[a[i]/p[j]]++;
	    				if ((m[p[j]]>1&&p[j]!=1)||m[a[i]/p[j]]>1) pairwise=false;
	    			}
	    		}
	    	}
    	}
    }
    if (pairwise) {
    	nout("pairwise coprime");
    }else if (okxd==1) {
    	nout("setwise coprime");
    }else nout("not coprime");

	/*for (auto u : m) {
		sout(u.first); nout(u.second);
	} */
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11456
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

ll calc(int n,int k){
    ll res = 1;
    rep(i,k){
        res *= (n - i);
        res /= (i+1);
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,a,b;
    cin >> n >> a >> b;
    vll v(n);
    rep(i, n) cin >> v[i];
    sort(all(v),greater<ll>());
    int cnt = 0;
    int border = 0;
    rep(i,n){
        if (v[i]==v[a-1]){
            border++;
        }
    }
    while (v[cnt]>v[a-1]){
        cnt++;
    }
    ll s = 0;
    rep(i,a){
        s += v[i];
    }
    cout << fixed << setprecision(17) << (ld)s / (ld)a << endl;
    if (cnt==0){
        ll ans = 0;
        repf(i,a,min(border,b)+1){
            ans += calc(border, i);
        }
        cout << ans << endl;
    }
    else{
        ll ans = calc(border, a - cnt);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
N,M= map(int,input().split())
A = list(map(int,input().split()))
a = [-x for x in A]
heapify(a)
for i in range(M):
    item = -1*heappop(a)
    item = item//2
    heappush(a,-1*item)
print(-sum(a))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, T;
	scanf("%d%d", &n, &T);
	vector<int> t(n);
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &t[i]);
		if (i) ans += min(T, t[i] - t[i - 1]);
	}
	ans += T;
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;


int main(){  
    
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    int ans=0,cnt=0;
    sort(arr,arr+3);
    
    if((arr[2]-arr[0])%2 == 0){
        
        int diff = (arr[2]-arr[0])/2;
        ans += diff;
        cnt++;
        arr[0] = arr[2];
    }
    if((arr[2]-arr[1])%2 == 0){
        
        int diff = (arr[2]-arr[1])/2;
        ans += diff;
        cnt++;
        arr[1] = arr[2]; 
    }
    if(cnt == 2 || arr[0] == arr[1] && arr[2] == arr[0] && arr[1] == arr[2]){
        cout << ans;
        return 0;
    }
    
    if(cnt == 1){
        
        sort(arr,arr+3);
        ans += (arr[2]+1-arr[0])/2;
        ans += 1;
        cout << ans;
        return 0;
    }
    else{
        
        ans += (arr[1]-arr[0])/2;
        ans += arr[2]-arr[1];
        cout << ans;
        return 0;
    }
    
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, m; readV(n, m);
  int[] p, q, c; readC(m, p, q, c); p[] -= 1; q[] -= 1;
 
  alias SC = Tuple!(int, int);
  auto sc = new SC[](m*2);
  foreach (i; 0..m) {
    sc[i*2]   = SC(p[i], c[i]);
    sc[i*2+1] = SC(q[i], c[i]);
  }
  int[SC] h;
  foreach (i, sci; sc.sort().uniq.enumerate) h[sci] = i.to!int+n;
  auto nh = h.length.to!int;
 
  auto g = GraphW!int(n+nh);
  foreach (i; 0..m) g.addEdgeB(h[SC(p[i], c[i])], h[SC(q[i], c[i])], 0);
  foreach (sci, v; h) g.addEdgeB(sci[0], v, 1);
 
  auto d = g.dijkstra(0);
  writeln(d[n-1] >= g.inf ? -1 : d[n-1]/2);
}

struct GraphW(N = int, W = int, W i = 10^^9)
{
  alias Node = N, Wt = W, inf = i;
  struct Edge { Node src, dst; Wt wt; alias cap = wt; }
  Node n;
  Edge[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Edge[][](n); }
  void addEdge(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); }
  void addEdgeB(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); g[v] ~= Edge(v, u, w); }
}

template Dijkstra(Graph)
{
  import std.array, std.container, std.traits;
  alias Node = TemplateArgsOf!Graph[0], Wt = TemplateArgsOf!Graph[1];
  alias Edge = Graph.Edge;

  void dijkstra(ref Graph g, Node s, out Wt[] dist, out Node[] prev)
  {
    auto n = g.n, sent = n;

    dist = new Wt[](n);
    dist[] = g.inf;
    dist[s] = 0;

    prev = new Node[](n);
    prev[] = sent;

    auto q = heapify!("a.wt > b.wt")(Array!Edge(Edge(sent, s, 0)));
    while (!q.empty) {
      auto e = q.front; q.removeFront();
      if (prev[e.dst] != sent) continue;
      prev[e.dst] = e.src;
      foreach (f; g[e.dst]) {
        auto w = e.wt + f.wt;
        if (dist[f.dst] > w) {
          dist[f.dst] = w;
          q.insert(Edge(f.src, f.dst, w));
        }
      }
    }
  }

  auto dijkstra(ref Graph g, Node s)
  {
    Wt[] dist;
    Node[] prev;
    dijkstra(g, s, dist, prev);
    return dist;
  }
}
auto dijkstra(G, N)(G g, N s) { return Dijkstra!G.dijkstra(g, s); }


Measured memory_bytes: 71804
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    string ans;
    while(true){
        if (n%(-2) == 0) {
            ans = "0" + ans;
            n = n/(-2);
        }
        else {
            n = (n-1)/(-2);
            ans = "1" + ans;
        }

        if (n == 0) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[0]*10001
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      v=i**2+j**2+k**2+i*j+j*k+k*i
      if v<10001:
        a[v]+=1
for m in range(n):
  print(a[m+1])

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int mod = 1e9+7;
const int inf = (1<<28);
const ll infl = (1LL<<60);

int main() {
  int h, n; cin >> h >> n;
  vector<int> a(n), b(n);
  rep(i,n) {
    cin >> a[i] >> b[i];
  }
  vl dp(h+1, inf);
  dp[0] = 0;
  rep(i,n) {
    rep(j,h) {
      int jj = min(j+a[i], h);
      dp[jj] = min(dp[jj], dp[j]+b[i]);
    }
  }
  // outa(dp, h+1);
  cout << dp[h] << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main(void) {
	int a, b, i;
	scanf("%d %d", &a, &b);
	for(i=0; i<10000; i++){
		if(int(i*0.08)==a && int(i*0.1)==b){
			printf("%d", i);
			return 0;
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#define REP(i, n) for(int i = 0; i < (n); ++i)
using namespace std;


int main(void) {
  int x, n;
  cin >> x >> n;
  set<int> ss;
  REP(i, n) {
    int v;
    cin >> v;
    ss.insert(v);
  }

  for(int d = 0; ; ++d) {
    if(ss.count(x-d) == 0) {
      cout << x-d << endl;
      break;
    }
    if(ss.count(x+d) == 0) {
      cout << x+d << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3148
N,M=map(int,input().split())
H=list(map(int,input().split()))
tenbo=[[] for _ in range(N)]

ans=0
for i in range(M):
    A,B=map(int,input().split())
    tenbo[A-1].append(B-1)
    tenbo[B-1].append(A-1)
   
for i in range(N):
    flg=1
    for j in range(len(tenbo[i])):
        if H[i]<=H[tenbo[i][j]]:
            flg=0
            break
    if flg:
        ans+=1
        
        
print(ans)
    
        
        

Measured memory_bytes: 29572
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>

using namespace std;

int main(){
  int n;
  cin>>n;
  if (n==1) cout<<"Hello World"<<endl;
  else {
    int A,B;
    cin>>A>>B;
    cout<<A+B<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		long A = Long.parseLong(sc.next());
		long B = Long.parseLong(sc.next());
		PriorityQueue<Long> v = new PriorityQueue<>(Comparator.reverseOrder());
		for(int i=0;i<N;i++) {
			v.add(Long.parseLong(sc.next()));
		}
		double dp[] = new double[N+1];
		dp[0] = 0;
		int counter = 1, counter_= 1;
		long s=0,f=0,ins=0;
		s = v.peek();
		for(int i=1;i<A+1;i++) {
			f = v.poll();
			dp[i] = (dp[i-1]*(i-1)+f) / i;
			if(f == v.peek() && i!=A) {
				counter_ ++;
				counter ++;
			}
			else if(i!=A){
				counter = 1;
				counter_ = 1;
			}
		}
		long ln = A;
		for(int i=(int)(A+1);i<N+1;i++) {
			ins = v.poll();
			if(f == ins) {
				counter_++;
				ln++;
			}
			dp[i] = ((dp[(i-1)]*(i-1))+ins)/i;
		}

		Combination C = new Combination(counter_);
		long result = 0;
		//counter expresses the number of the replacible elements.
		if(counter_>=A && s==f) {
			for(int i=(int)A;i<=Math.min(ln, B);i++) {
				result += Combination.combine(counter_,i);
			}
		}
		else {
			result += Combination.combine(counter_,counter);
		}

		out.println(dp[(int)A]);
		out.println(result);

		out.flush();
	}
}

class Combination {

	int N;
	static long[][] dp;

	Combination(int N) {
		this.N = N;
		this.dp = new long[N + 1][N + 1];
		createPascalsTriangle();
	}

	static long combine(int n, int k) {
		return dp[n][k];
	}

	void createPascalsTriangle() {

		dp[0][0] = 1;

		for (int n = 1; n <= N; n++) {
			for (int k = 0; k <= n; k++) {
				if (k - 1 >= 0) {
					dp[n][k] = dp[n-1][k-1] + dp[n-1][k];
				} else {
					dp[n][k] = dp[n-1][k];
				}
			}
		}
	}

	void printTriangle() {
		for (int n = 0; n <= N; n++) {
			System.out.print(n + "| ");
			for (int k = 0; k <= n; k++) {
				System.out.print(dp[n][k] + " ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 25044
#include "stdio.h"
#define TOWN 100000
#define DAY 100000

int N, D;
int dis[TOWN+1] = {};
int move[DAY + 2] = {};
int sum[TOWN+1] = {};
long long int ans;
int now = 1;

int main() {
	scanf("%d %d", &N, &D);
	for (int i = 2; i <= N; i++) {
		scanf("%d", &dis[i]);
		sum[i] = sum[i - 1] + dis[i];
	}
	for (int i = 1; i <= D; i++) {
		scanf("%d", &move[i]);
		if (move[i] > 0) {
			ans += sum[now + move[i]] - sum[now];
			now += move[i];
		}
		else if (move[i] < 0) {
			ans += sum[now] - sum[now + move[i]];
			now += move[i];
		}
	}
	printf("%d\n", ans % 100000);
	return 0;
}

Measured memory_bytes: 2196
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	Set<Character> s = new HashSet<>();
    	for (char c : S.toCharArray()) {
    		s.add(c);
    	}
    	char a = 'a';
    	while (a <= 'z') {
    		if (!s.contains(a)) {
    			System.out.println(a);
    			System.exit(0);
    		}
    		a++;
    	}
    	System.out.println("None");
    }
}

Measured memory_bytes: 25816
import sys 
# sys.stdin = open('input.txt', 'r')  
# sys.stdout = open('output.txt', 'w') 
n = int(input())
sev = '7'
ans = 1
while ans <= 1000000:
	if int(sev) % n == 0:
		print(ans)
		exit()
	ans = ans + 1
	sev += '7'
	sev = str(int(sev) % n)
	# print(sev)
print(str(-1))

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <queue>
#define in std::cin
#define out std::cout
#define end std::endl
#define REP(i, A, N) for(int i=A;i<N;++i)
typedef long long int ll;

ll x, y;

int main()
{
	in >> x >> y;
	out << x + y / 2 << end;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int loop=sc.nextInt();
        for(int i=0;i<loop;i++){
            int d=sc.nextInt();
            a-=d;
        }
        if(a<0){
            System.out.println(-1);
        }
        else {
            System.out.println(a);
        }
        
    }
}


Measured memory_bytes: 46328
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		int W,H,a,b;
		Scanner br = new Scanner(System.in);
		while(true){
			H=br.nextInt();
			W=br.nextInt();
			if(H==0 && W==0 ){
				break;
			}else{
				for(a=1;a<=H;a++){
					if(a==1 || a==H){
						for(b=1;b<=W;b++){
							System.out.print("#");
						}
						System.out.println();
					}else{
						for(b=1;b<=W;b++){
							if(b==1 || b==W){
								System.out.print("#");
							}else{
								System.out.print(".");
							}
						}
						System.out.println();
					}
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 34788
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end(),greater<int>());
  int ans = a[1];
  int ansc = abs(a[0]-a[1]*2);
  for(int i = 1; n > i; i++){
    if(ansc > abs(a[0]-a[i]*2)){
      ans = a[i];
      ansc = abs(a[0]-a[i]*2);
    }
  }
  cout << a[0] << " " << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
typedef pair<int, int> PII;

vector<PII> le, ri;
char s[N];

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++){
        scanf("%s", s + 1);
        int len = strlen(s + 1);
        int l = 0, r = 0;
        for(int j = 1; j <= len; j ++){
            if(s[j] == '(') l ++;
            else{
                if(l > 0) l --;
                else r ++;
            }
        }
        if(l >= r) le.push_back({r, l});
        else ri.push_back({l, r});
    }
    sort(le.begin(), le.end());
    sort(ri.begin(), ri.end(), greater<PII>());
    int cnt = 0, mark = 1;
    for(int i = 0; i < le.size(); i ++){
        cnt -= le[i].first;
        if(cnt < 0) { mark = 0; break; }
        cnt += le[i].second;
    }
    for(int i = 0; i < ri.size(); i ++){
        cnt -= ri[i].second;
        if(cnt < 0) { mark = 0; break; }
        cnt += ri[i].first;
    }
    
    if(cnt) mark = 0;
    if(mark) puts("Yes");
    else puts("No");

    return 0;
}

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

using namespace std;

map<char, char>mp;

int main() {
    mp['A'] = 'T';
    mp['C'] = 'G';
    mp['T'] = 'A';
    mp['G'] = 'C';
    char c; cin>>c;
    cout<<mp[c]<<endl;
}


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

int main(void){
    int H,W;
    cin>>H>>W;
    vector<string> C(H);
    for (int i=0;i<H;i++) cin>>C[i];
    for (int i=0;i<H;i++) {
        cout<<C[i]<<endl;
        cout<<C[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	double n;
	cin >> n;
	printf("%.14lf\n",pow(n / 3,3));
}

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

int main(void) {
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18

void solve(){
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	rep(i,0,n)
		cin>>a[i]>>b[i]>>c[i];

	vector<vector<int>> dp(n,vector<int> (3));

	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];

	rep(i,1,n){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}

	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}
 
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 11132
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using BI = System.Numerics.BigInteger;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long y = 0;
		long cur = (long) 100;
		while(true){
			cur = (long)(cur * 1.01);
			y++;
			if(cur >= (long) X){
				Console.WriteLine(y);
				break;
			}
		}
		
		
	}
	long X;
	public Sol(){
		X = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27544
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[20][20];
int UF[1100];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;
	UF[a]+=UF[b];UF[b]=a;
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++){
			for(int j=0;j<=i;j++)scanf("%d",&c[i][j]);
		}
		int ret=-99999999;
		for(int i=0;i<a;i++){
			for(int j=0;j<=i;j++){
				if(c[i][j])continue;
				c[i][j]=b;
				for(int k=0;k<=a*a;k++)UF[k]=-1;
				int z=a*a;
				for(int k=0;k<a;k++){
					for(int l=0;l<=k;l++){
						if(c[k][l]==0)UNION(z,k*a+l);
						if(l<k&&!(c[k][l]&&c[k][l+1]&&c[k][l]!=c[k][l+1]))UNION(k*a+l,k*a+l+1);
						if(k<a-1&&!(c[k][l]&&c[k+1][l]&&c[k][l]!=c[k+1][l]))UNION(k*a+l,k*a+l+a);
						if(k<a-1&&!(c[k][l]&&c[k+1][l+1]&&c[k][l]!=c[k+1][l+1]))UNION(k*a+l,k*a+l+a+1);
					}
				}
				int tmp=0;
				for(int k=0;k<a;k++)for(int l=0;l<=k;l++){	
					if(!c[k][l])continue;
					if(FIND(z)!=FIND(k*a+l)){
						if(c[k][l]==b)tmp--;
						else tmp++;
					}
				}
				ret=max(ret,tmp);
				c[i][j]=0;
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1036
a,b = map(int,input().split())

total = int(max(-(-a//0.08),-(-b//0.1)))
for i in range(1,total+1):
  y1 = int(i * 0.08)
  y2 = int(i * 0.1)
  if y1 == a and y2 == b:
    print(i)
    exit()
print("-1")


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a[20],b[20],dp[1<<18][51],cnt[1<<18],ans=0x3f3f3f3f;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d",&a[i]);
	for(int i=0;i<n;++i)scanf("%d",&b[i]);
	for(int i=1;i<1<<n;++i)cnt[i]=cnt[i>>1]+(i&1);
	memset(dp,0x3f,sizeof(dp));dp[0][1]=0;
	for(int i=0;i<(1<<n)-1;++i)
		for(int j=1;j<=50;++j)
			if(dp[i][j]!=0x3f3f3f3f)
				for(int k=0,w,c=cnt[i];k<n;++k)
				{
					w=(k&1)==(cnt[i]&1)?a[k]:b[k];
					if(i>>k&1)--c;
					if(!(i>>k&1)&&w>=j)dp[i|(1<<k)][w]=min(dp[i|(1<<k)][w],dp[i][j]+c);
				}
//	for(int i=0;i<1<<n;++i)
//		for(int j=1;j<=3;++j)
//			printf("%d %d %d\n",i,j,dp[i][j]);
	for(int i=1;i<=50;++i)ans=min(ans,dp[(1<<n)-1][i]);
	printf("%d",ans==0x3f3f3f3f?-1:ans);
	return 0;
}


Measured memory_bytes: 53376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	long N;cin>>N;
	long A[N+1]; long sum = 0;
	rep(i,0,N){ cin>>A[i]; sum += A[i]; }
	if((2 * sum) % (N * (N + 1)) == 0){
		A[N] = A[0];
		long m = 2 * sum / N / (N + 1);
		long t;
		rep(i,0,N){
			t = m - (A[i+1] - A[i]);
            if(0 <= t && t <= N * m && t % N == 0) continue;
			else{ cout<<"NO"<<endl; return 0; }
		}cout<<"YES"<<endl;
	}else cout<<"NO"<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define swap(a, b) {int t; t=a; a=b; b=t;}
 
int main()
{
  int *a;
  int n, i, j, min, ans=0;
  scanf("%d", &n);
  a = (int *)malloc(sizeof(int)*n);
   
  for(i=0; i<n; i++){
    scanf("%d", a+i);
  }
 
  for(i=0; i<n-1; i++){
    min=i;
    for(j=i; j<n; j++){
      if(a[min] > a[j]) min=j;
    }
    if(min != i){
      swap(a[i], a[min]);
      ans++;
    }
  }
  printf("%d", a[0]);
  for(i=1; i<n; i++){
    printf(" %d", a[i]);
  }
  printf("\n%d\n", ans);
  return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(int &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

typedef vector<int> v;

struct heap{
	v h = {0};

	void insert(int x) {
		h.push_back(x);
		int c = h.size() - 1;
		for (int p = c / 2; p; c = p, p /= 2)
			if (x > h[p])
				h[c] = h[p];
			else
				break;
		h[c] = x;
	}
	void extract() {
		out(h[1], '\n');
		h[1] = h.back();
		int v = h[1];
		h.pop_back();

		int p = 1, H = h.size();
		for (int c = 2; c < H; c = p *2) {
			if (c + 1 < H && h[c] < h[c + 1])
				c++;
			if (v > h[c])
				break;
			h[p] = h[c];
			p = c;
		}
		h[p] = v;
	}
};

int main() {
	char s[20];
	heap h;

	for (;;) {
		scan(s);
		switch(s[2]) {
		case 's':
			h.insert(in());
			continue;
		case 't':
			h.extract();
			continue;
		}
		break;
	}
}




Measured memory_bytes: 6340
#include <iostream>
#include <vector>
#include <set>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;

vector<int> sccd(const vector<vector<int>> & G){
  vector<vector<int>> rG(G.size());
  for(int i = 0;i < G.size();i++){
    for(int to : G[i]) rG[to].push_back(i);
  }

  vector<bool> vis(G.size(),false);
  vector<int> vs;
  vector<int> res(G.size(),-1);

  function<void(int)> dfs = [&](int v){
    vis[v] = true;
    for(int to : G[v]){
      if(!vis[to]) dfs(to);
    }
    vs.push_back(v);
  };

  function<void(int,int)> rdfs = [&](int v,int k){
    vis[v] = true;
    res[v] = k;
    for(int to : rG[v]){
      if(!vis[to]) rdfs(to,k);
    }
  };

  for(int i = 0;i < G.size();i++){
    if(!vis[i]) dfs(i);
  }

  vis.assign(G.size(),false);
  int k = 0;
  for(int i = G.size() - 1;i >= 0;i--){
    if(!vis[vs[i]]) rdfs(vs[i],k++);
  }
  return res;
}

int N,M;
int s[101010] ,t[101010];
int IN[101010];

int main(){
  cin >> N >> M;
  vector<vector<int>> G(N);
  rep(i,0,M - 1){
    cin >> s[i] >> t[i];
    G[s[i]].push_back(t[i]);
  }
  vector<int> res = ::sccd(G);

  if(*max_element(res.begin(),res.end()) == 0){
    cout << 0 << endl;
    return 0;
  }

  int n = *max_element(res.begin(),res.end()) + 1;

  vector<vector<int>> gg(n);
  vector<set<int>> st(n);
  rep(i,0,M - 1){
    int a = s[i];
    int b = t[i];
    a = res[a];
    b = res[b];
    if(a == b) continue;
    if(st[a].count(b)) continue;
    gg[a].push_back(b);
    st[a].insert(b);
  }
  rep(i,0,n - 1){
    for(int j : gg[i]){
      IN[j] = 1;
    }
  }
  int OUTSUM = 0;
  int INSUM = 0;
  rep(i,0,n - 1){
    OUTSUM += gg[i].size() == 0;
    INSUM += !IN[i];
  }
  cout << max(OUTSUM,INSUM) << endl;

}



Measured memory_bytes: 11120
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
vvl v;
//vl vis,d;
ll f[100005];ll inv[100005];

void dfs(ll s, ll p){
    if(p==-1){
        if(k<sz(v[s])+1)kv=0;
        else kv*=f[k]*inv[k-sz(v[s])-1]%mod;
    }
    else{
        if(k<sz(v[s])-1)kv=0;
        else kv*=f[k-2]*inv[k-2-sz(v[s])+1]%mod;
    }
    kv%=mod;
    for(ll u:v[s]){
        if(u==p)continue;
        dfs(u,s);
    }
}

int main() {
    IOS;
    f[0]=1;
    fo(i,100004)f[i+1]=(i+1)*f[i]%mod;
    inv[100004]=bpow(f[100004],mod-2,mod);
    for(int i=100003;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    cin>>n>>k;
    kv=1;
    v.resize(n);
    fo(i,n-1){
        cin>>x>>y;x--;y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(0,-1);
    cout<<kv;
    return 0;
}


Measured memory_bytes: 12032