akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N, x;
long long a[2005];
long long w[2005];



//範囲のminimumを取得
//区間[l, r)
struct segtree {
	vector<long long> data;
	long long n;
	segtree(long long nin){
		n = pow( 2, ceil( log(nin) / log(2) ) );
		long long size = 2 * n - 1;
		this->data.resize(size, LONG_MAX);
	}

	//API for update val
	void update(long long idx, long long val){
		update(idx, val, 0, 0, n);
	}

	long long update(long long idx, long long val, long long node_id, long long left, long long right){
		//if query idx is within range return val
		if( !( left <= idx && idx < right ) ){
			return data[node_id];
		}
		if( left + 1 < right ) {
			//when node range is not 1, get update children val and update node data
			long long mid = (left + right) / 2 ;
			long long L = update(idx, val, 2 * node_id + 1, left, mid);
			long long R = update(idx, val, 2 * node_id + 2, mid, right);
			data[node_id] = min(L, R);
		} else {
			//when node range is 1, update node data
			data[node_id] = min(data[node_id], val);
		}
		return data[node_id];
	}
	
	//API for get value of [l, r)
	long long get(long long l, long long r){
		return get(l, r, 0, 0, n);
	}

	/*
	 *internaly used function
	 *query_l: query left range
	 *query_r: query right range
	 *node_id: node id of 
	 *node_l:  node left range 
	 *node_r:  node right range
	 */
	long long get(long long query_l, long long query_r, long long node_id, long long node_l, long long node_r){
		//query range is outside of node range: return INF
		if( query_r <= node_l || node_r <= query_l ){
			return LONG_MAX/3;
		}
		//query range is within node range: return node val
		if( query_l <= node_l && node_r <= query_r ){
			return data[node_id];
		}
		long long mid = (node_l + node_r) / 2;
		long long L = get(query_l, query_r, 2 * node_id + 1, node_l, mid);
		long long R = get(query_l, query_r, 2 * node_id + 2, mid, node_r);
		return min(L, R);
	}
};



long long cal(int slide){
	for(int i = 0; i < N; i++){
		w[i] = a[i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j <=slide; j++){
			w[(i + j)%N] = min(w[(i+j)%N], a[i]);
		}
	}


	long long ret = 0;
	for(int i = 0; i < N; i++){
		ret += w[i];
	}
	return ret + slide * x;
}




int main(){
	cin >> N >> x;
	segtree sg(N);
	for(int i = 0; i < N; i++){
		cin >> a[i];
		sg.update(i, a[i]);
	}

	long long ret = LONG_MAX;
	for(int slide = 0; slide < N; slide++){
		//cout << "slide = " << slide << endl;
		long long s = 0;
		for(int i = 0; i < N; i++){
			long long tmp = a[i];
			long long left = i - slide;
			long long right = i;
			//cout << "left = " << left << "right " << right << endl;
			if(left < 0){
				//cout << "roll left = " << (left + N)%N << endl;
				tmp = min(tmp, sg.get((left + N)%N, N));
			}
			tmp = min(tmp, sg.get(max((long long)0, left), right));
			s += tmp;
		}
		ret = min(ret, s + slide*x);
	}


	cout << ret << endl;
}



Measured memory_bytes: 512
from collections import defaultdict as dd
N,k = map(int, input().split())

# 0人の部屋がt個あるとすると、n-t個の部屋にn人がいる。
# k!=1のとき0<=t<=min(k, n-1)
# k==1のときt=1
res = 0
fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=10**9+7

dic = dd(int)

def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k):
    if (n,k) in dic.keys():
        return dic[(n,k)]
    if k<0 or k>n or n<0:
        return 0
    dic[(n,k)] = (fact[n]*ifact[k]*ifact[n-k])%(10**9+7)
    return dic[(n,k)]

combination(N,fact,ifact)
for t in range(0, min(k, N-1)+1):
    # n-t個の部屋にn人を入れる。ただし、どの部屋にも1人以上いる必要がある
    # n個の部屋のうちどのt個を0人にするかでnCt
    # n-t個の部屋の人数でn-1Cn-t-1
    res += (op(N-1, N-t-1) * op(N, t))%p
print(res%p)

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(ll i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
//Write From this Line

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n),b(n),c(n);
	rep(i,n) cin >> a[i];SORT(a);
	rep(i,n) cin >> b[i];SORT(b);
	rep(i,n) cin >> c[i];SORT(c);

	//解法:b[i]に対して、aはどこまで行けるか見る。
	//b[i]にたいしてcが何個行けるか
	ll ans = 0 ;
	rep(i,n){
		//b[i] - 1 以下となるものの個数を数える。
		ll a_index = lower_bound(a.begin(),a.end(), ll(b[i] )) - a.begin();
		ll c_index = lower_bound(c.begin(),c.end(), ll(b[i] + 1)) - c.begin();
		ans += (a_index)* (n -c_index); 
	}
	cout << ans << endl;
}


Measured memory_bytes: 2688
#AGC023A 累積和
from itertools import accumulate
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
A = list(accumulate([0]+ a))
ans = 0
cnt = list(Counter(A).values())
            
for i in range(len(cnt)):
    ans += (cnt[i]*(cnt[i]-1))//2

print(ans)

Measured memory_bytes: 41612
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 1200005
#define MOD 1000000007
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define precise cout<<fixed<<setprecision(6)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int BIG=pow(2,20);
int32_t main(){
        // getFaster;
        int n;
        cin>>n;
        rep(i,1,10)rep(j,1,10)
        {
           if(i*j==n){cout<<"Yes"<<endl;return 0;}
        }
        cout<<"No"<<endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans,n,m,k,a[200001],d[200001],b[200001],c[200001],nt[200001];
void ksm(){
	ll i;
	while(k){
		if(k&1){
			for(i=1;i<=n;i++)nt[i]=b[c[i]];
			for(i=1;i<=n;i++)b[i]=nt[i];
		}
		for(i=1;i<=n;i++)nt[i]=c[c[i]];
		for(i=1;i<=n;i++)c[i]=nt[i];
		k/=2;
	}
}
int main(){
	ll i,x;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		d[i]=a[i]-a[i-1];
		b[i]=c[i]=i;
	}
	scanf("%lld%lld",&m,&k);
	for(i=1;i<=m;i++){
		scanf("%lld",&x);
		swap(c[x],c[x+1]);
	}
	ksm();
	for(i=1;i<=n;i++){
		ans+=d[b[i]];
		printf("%lld.0\n",ans);
	}
}
/*
思路：对于兔子x[i]，向左跳有2*x[i-1]-x[i]，向右跳有2*x[i+1]-x[i]，概率各位1/2，
得期望x[i-1]+x[i+1]-x[i]，令d[i] = x[i]-x[i-1]，
这条期望式子相当于swap(d[i], d[i+1])，那么连续执行K次，可参考快速幂的做法进行优化。O(NlogK)。
当然也可以O（n）

心得：没有想到用差分 
*/

Measured memory_bytes: 7552
#include <iostream>
#include <vector>

int main() {
  unsigned long long N;
  std::cin >> N;
  std::vector<unsigned long long> A(N);
  for (auto &i : A) {
    std::cin >> i;
  }
  unsigned long long ret = 0;
  unsigned long long counter = 1;
  for (const auto &i : A) {
    if (i == counter) {
      ++counter;
      continue;
    }
    if (i % counter == 0) {
      ret += i / counter - 1;
    } else {
      ret += i / counter;
    }
    if (counter == 1) {
      ++counter;
    }
  }
  std::cout << ret;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll MOD = (ll)1e9 + 7LL;

map<ll,ll> memo;

ll f(ll n){

	if (memo.count(n)) return memo[n];

	if (n <= 2LL) return n;

	ll res = (f(n/2LL) + f((n-1LL)/2LL)) % MOD;
	res = (res + f((n+1LL)/2LL)) % MOD; 

	return memo[n] = res;
}

int main()
{
	memo.clear();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll N; cin >> N;

	ll res = f(N+1LL);
	cout << res << endl;

	return 0;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N;
    cin >> N;
    vector<int> edges[200000];
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    create_mod_tables(200000);

    vector<int> num(N);
    vector<int64_t> dp(N);
    auto dfs1 = [&](auto&& dfs1, int i, int p)->void{
        dp[i] = 1;
        for(int j : edges[i]) if(j != p){
            dfs1(dfs1, j, i);
            mul(dp[i], dp[j] * comb_mod(num[i] + num[j], num[j]) % MOD);
            num[i] += num[j];
        }
        num[i]++;
    };
    dfs1(dfs1, 0, -1);

    vector<int64_t> ans(N);
    auto dfs2 = [&](auto&& dfs2, int i, int p, int64_t u)->void{
        ans[i] = dp[i] * u % MOD * comb_mod(N-1, num[i]-1) % MOD;
        for(int j : edges[i]) if(j != p){
            int64_t u2 = dp[i] * inv_mod(dp[j]) % MOD;
            mul(u2, inv_mod(comb_mod(num[i]-1, num[j])));
            mul(u2, u);
            int t = N-num[i], my = num[i]-num[j]-1;
            mul(u2, comb_mod(t+my, my));
            dfs2(dfs2, j, i, u2);
        }
    };
    dfs2(dfs2, 0, -1, 1);
    for(int i=0; i<N; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 22516
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	n := nextInt()
	a := nextIntArray(n)

	dic := make(map[int]bool)
	res := 0
	for i := 0; i < n; i++ {
		_, has := dic[a[i]]
		if !has {
			dic[a[i]] = true
			res++
		}
	}
	fmt.Println(res)
}


// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(next())
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    vector<vector<P>> graph(N);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].push_back({b, -c});
    }

    vector<ll> cost(N, INF);
    vector<bool> negative(N, false);
    cost[0] = 0;
    rep(i, N) {
        rep(j, N) {
            for (P &v: graph[j]) {
                if (cost[j] != INF && cost[v.first] > cost[j] + v.second) {
                    cost[v.first] = cost[j] + v.second;
                }
            }
        }
    }
    rep(i, N) {
        rep(j, N) {
            for (P &v: graph[j]) {
                if (cost[j] != INF && cost[v.first] > cost[j] + v.second) {
                    cost[v.first] = -INF;

                    negative[v.first] = true;
                }
            }
        }
    }
    if (negative[N - 1]) {
        cout << "inf" << '\n';
    } else {
        cout << -cost[N - 1] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = min(b,d)-max(a,c);
  if (ans > 0) {
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	ll a, b;
	cin >> a >> b;
	if(a == 0 || b == 0 || (a < 0 && 0 < b)){
		cout << "Zero" << endl;
	}else if(a > 0 && b > 0){
		cout << "Positive" << endl;
	}else{
		ll ret = a - b;
		if(a == b){
			cout << "Positive" << endl;
		}else if(ret % 2 == 0){
			cout << "Negative" << endl;
		}else{
			cout << "Positive" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        res = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(dat[r], res)
            l >>= 1
            r >>= 1
        return res


def gcd(x, y):
    if x * y == 0:
        return x + y
    elif x > y:
        return gcd(y, x)
    else:
        return gcd(y % x, x)


N = int(input())
A = [int(_) for _ in input().split()]
ST = SegmentTree(array=A, f=gcd, ti=0)
ans = 0
for i in range(N):
    ans = max(ans, gcd(ST.query(0, i), ST.query(i + 1, N)))
print(ans)


Measured memory_bytes: 122888
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

mod=1000000007
n=input();
arr = list(map(int, raw_input().split()))
l=arr[0];
for i in arr:
    x=gcd(l,i)
    l=(l*i)/x
    
ans=0
#print l
for i in arr:
    b=l/i
    ans+=b
ans=(ans%mod +mod)%mod
print ans


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

int main(){
  long long h, w;
  cin >> h >> w;
  long long ans;
  
  if(h == 1 || w == 1){
    cout << 1 <<endl;
  }else{
  if(h % 2 == 0 || w % 2 == 0){
    ans = h*w/2;
  }else{
    ans = h*w/2 + 1;
  }
  cout << ans << endl;
  }

}


Measured memory_bytes: 256
let () =
  let rec loop () = match read_int () with
      0 -> ()
    | n ->
      let nums = Str.split (Str.regexp " ") (read_line ())
                 |> List.map float_of_string  in
      let average =  (List.fold_left (+.) 0. nums) /. (float n) in
      let v = (List.fold_left (fun acc s -> acc +. (s -. average) ** 2. ) 0. nums) /. (float n) in
      let sd = sqrt v in
      Printf.printf "%f\n" sd;
      loop ()
  in loop ()

Measured memory_bytes: 2720
k=int(input())
L=[1,2,3,4,5,6,7,8,9]
temp1=[L[:]]
temp2=[]

def dfs(n):
	if n>3234566667:
		return
	temp2=[]
	for i in range(3):
		m=int(str(n)[-1])
		if 0<=m+i-1<=9:
			nn=n*10+m+i-1
			temp2.append(nn)
			L.append(nn)
	if temp2:
		temp1.append(temp2)
	for n in temp1[-1]:
		dfs(n)

for i in range(9):
	dfs(i+1)

LS=sorted(L)
print(LS[k-1])
		


Measured memory_bytes: 30736
void main() {
  problem();
}

void problem() {
  auto X = scan!int(5);

  int solve() {
    foreach(i; 0..5) {
      if (X[i] == 0) return i+1;
    }

    return 0;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 2712
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
X1 = [0] * (N+2)
X2 = [0] * (N+2)
 
for i in range(N):
    X1[i+1] = gcd(X1[i], A[i])
for i in range(N,0,-1):
    X2[i] = gcd(X2[i+1], A[i-1])

k = []
for i in range(N):
    k.append(gcd(X1[i],X2[i+2]))

print(max(k))
    

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int t, x; cin >> t >> x;
  double ans = (double)t / (double) x;
  printf("%.04lf\n", ans);

  return 0;
}


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

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	int B[M];
	for (int i = 0; i < M; i++)
		cin >> B[i];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++) {
			int in;
			cin >> in;
			sum += in * B[j];
		}
		sum += C;
		if (sum > 0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    string n;
    int num;
    cin >> n;
    num=n.size();
    if(n[num-1]=='2' || n[num-1]=='4' || n[num-1]=='5' || n[num-1]=='7' || n[num-1]=='9'){
        cout << "hon" << endl;
    }else if(n[num-1]=='0' || n[num-1]=='1' || n[num-1]=='6' || n[num-1]=='8'){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for(size_t i = 0; i < n-1; i++)
    {
        ans *= k-1;
    }
    
    cout << ans*k << endl;

    return 0;
}

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " = " << x << endl
#define print_array(arr, len) {cerr << #arr << " = "; for (int i = 0; i < len; i++) cerr << arr[i] << " "; cerr << endl;}
#define print_iterable(it) {cerr << #it << " = "; for (const auto &e : it) cerr << e << " "; cerr << endl;}
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) (void)0
#define print_iterable(it) (void)0
#endif

using ll = long long;
const int N = 200500;

int n;
char s[N];
int cnt[N];

void solve()
{
    scanf("%s", s);
    n = strlen(s);

    for (int i = 0; i < n; i++)
        cnt[s[i] - 'a']++;
    ll ans = 0;
    for (int i = 0; i < 26; i++)
        ans += (ll)cnt[i] * (n - cnt[i]);
    ans /= 2;
    ans++;

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

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

    solve();

    eprintf("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


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

int main(){
  int n; cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  int m; cin>>m;
  vector<string> t(m);
  for(int i=0;i<m;i++){
    cin>>t[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      if(s[i]==s[j])sum++;
    }
    for(int j=0;j<m;j++){
      if(s[i]==t[j])sum--;
    }
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;

    int s = S.length();
    int t = T.length();
    bool flag = false;

    if (s >= t){
        int check;
        for (int i = s - 1; i >= 0; i--){
            for (int j = 0; j < t; j++){
                if (S[i - j] == T[t - 1 - j] || S[i - j] == '?'){
                }else{
                    break;
                }
                if (j == t - 1){
                    flag = true;
                    check = i;
                }
            }
            if (flag == true){
                break;
            }
        }

        if (flag == true){
            for (int i = 0; i < t; i++){
                S[check + i - t + 1] = T[i];
            }
            for (int i = 0; i < s; i++){
                if (S[i] == '?'){
                    S[i] = 'a';
                } 
            }
        }
    }

    if (flag == false){
        cout << "UNRESTORABLE" << endl;
    }else{
        cout << S << endl;
    }

    return 0;
}

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

long long mod = 1000000007;
long long N, A[1 << 18];
long long M, B[1 << 18];
long long dp[2009][2009][2];

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

	dp[0][0][0] = 1; dp[0][0][1] = 1;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			dp[i + 1][j][0] += dp[i][j][0]; dp[i + 1][j][0] %= mod;
			dp[i + 1][j][1] += dp[i][j][0]; dp[i + 1][j][1] %= mod;
			dp[i][j + 1][1] += dp[i][j][1]; dp[i][j + 1][1] %= mod;

			if (A[i] == B[j] && i < N && j < M) {
				dp[i + 1][j + 1][0] += dp[i][j][1]; dp[i + 1][j + 1][0] %= mod;
				dp[i + 1][j + 1][1] += dp[i][j][1]; dp[i + 1][j + 1][1] %= mod;
			}
		}
	}
	cout << dp[N][M][1] << endl;
	return 0;
}

Measured memory_bytes: 65792
#define C
typedef long long readtype;

/* Header {{{ */
#ifdef C
#include <stdio.h>
#include <math.h>
#include <string.h>
#define isdigit(a) ((a) >= '0' && (a) <= '9' ? true : false)
template<typename type> type abs(type a) { return a < 0 ? -a : a; }
template<typename type> type min(type a, type b) { return a < b ? a : b; }
template<typename type> type beMin(type &a, type b) { return a = (a < b ? a : b); }
template<typename type> type max(type a, type b) { return a > b ? a : b; }
template<typename type> type beMax(type &a, type b) { return a = (a > b ? a : b); }
template<typename type> void swap(type &a, type &b) { type c; c = a; a = b; b = c; }
#endif

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

typedef long long var;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}
/* }}} */

const int N = 510005;

struct Water {
  long double t, v;
  void operator *= (Water x) { *this = *this * x; }
  Water operator * (Water x) {
    return (Water) {(t * v + x.t * x.v) / (v + x.v), v + x.v};
  }
};

int n, l;
Water q[N];
int head, tail;

long double val(Water);

int main() {
  /*
#ifndef ONLINE_JUDGE
  freopen("source.in", "r", stdin);
  freopen("source.out", "w", stdout);
#endif
  */
  n = read(), l = read();
  long double tot = 0, have = 0;
  for (int i = 1; i <= n; ++i) {
    q[++tail] = (Water) {(long double)read(), (long double)read()};
    tot += val(q[tail]), have += q[tail].v;
    while (head < tail && q[tail].t <= q[tail - 1].t) {
      if (q[tail].v + q[tail - 1].v <= l) {
        tot -= val(q[tail]) + val(q[tail - 1]);
        q[tail - 1] *= q[tail];
        tot += val(q[tail - 1]);
      } else {
        head = tail - 1;
        q[head].v = l - q[tail].v;
        q[head] *= q[tail];
        have = l, tot = val(q[head]);
      }
      tail--;
    }
    while (have > l) {
      if (have - q[head].v >= l) {
        tot -= val(q[head]), have -= q[head].v;
      } else {
        tot -= val(q[head]);
        q[head].v -= (have - l);
        tot += val(q[head]);
        have = l;
        break;
      }
      head++;
    }
    printf("%.7Lf\n", tot / have);
  }
  return 0;
}

long double val(Water x) {
  return x.t * x.v;
}


Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,mi=1000000000;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<=n-k;i++){
    if(a[i]<0&&0<a[i+k-1]){
      mi=min({mi,abs(a[i])*2+abs(a[i+k-1]),abs(a[i+k-1])*2+abs(a[i])});
    }else{
      mi=min(mi,max(abs(a[i]),abs(a[i+k-1])));
    }
  }
  cout<<mi;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;


int sum0[2002][2002];
int sum1[2002][2002];
int sum2[2002][2002];
int N,M,Q;
void f(int sum[2002][2002])
{
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++){
			sum[i][j]+=sum[i][j-1];
		}
	}
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++){
			sum[i][j]+=sum[i-1][j];
		}
	}
}
int g(int sum[2002][2002],int x1,int y1,int x2,int y2)
{
	return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}
int main() {
	cin >> N >> M >> Q;
	char in[2002];
	for(int i=1;i<=N;i++)
	{
		cin >> (in+1);
		for(int j=1;j<=M;j++){
			if(in[j]=='1')
			{
				sum0[i][j]=1;
				if(sum0[i-1][j]==1)
				{
					sum1[i-1][j]=1;
				}
				if(sum0[i][j-1]==1)
				{
					sum2[i][j-1]=1;
				}
			}
		}
	}
	f(sum0);
	f(sum1);
	f(sum2);
	//cerr << sum0[N][M] << endl;
	for(int i=0;i<Q;i++){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int s=g(sum0,x1,y1,x2,y2)
			-g(sum1,x1,y1,x2-1,y2)
			-g(sum2,x1,y1,x2,y2-1);
		cout << s << endl;
	}

	return 0;
}



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

int main(){
	int a, b, c, countup = 0;
    cin >> a >> b >> c;
    for (int i = a; i < b+1; i++){
        if (c % i == 0){
            countup += 1;
        }
	}
    cout << countup << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,q;
    cin>>n>>k>>q;
//    ll* a = NULL;
//    a = (ll*)malloc(1000000005*sizeof(ll));
    ll a[q];
    for(ll i=0; i<q; i++) {
        cin>>a[i];
    }
    ll member[n] = {0};
    for(int i=0; i<q; i++) {
        member[a[i]-1] += 1;
    }

    for(int i=0; i<n; i++) {
 //       dbg(member[i]-q+k);
        if((member[i]-q+k) > 0){
            cout<<"Yes"<<endl;
        } else {
            cout<<"No"<<endl;
        }
    }

    return  0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans = 1;
ll a[100005];

int main(void) {
    ll n;
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        if (a[i]==0) {
            puts("0");
            return 0;
        }
    }

    rep(i, 0, n) {
        if (ans>((ll)1e18)/a[i]) {
            puts("-1");
            return 0;
        }
        ans *= a[i];
    } 
    cout << ans << "\n";
    return 0;
}



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

using namespace std;

int pan3(int n ,vector<int> p){
  int i;
  int num=0;
  if(p[0]>0) num+=p[0];
  for(i=1;i<n-1;++i){
    while(p[i]>0){
      p[i]--;
      p[i+1]--;
      num+=2;
    }
  }
  if(p[n-1]>0) num+=p[n-1];

  return num;
}

int pan2(int n ,vector<int> p){
  int i;
  int num=0;
  p[0]-=2;
  num+=2;
  for(i=0;i<n-1;++i){
    while(p[i]>0){
      p[i]--;
      p[i+1]--;
      num+=2;
    }
  }
  if(p[n-1]>0) num+=p[n-1];

  return num;
}

int pan1(int n ,vector<int> p){
  int i;
  int num=0;
  p[0]--;
  num++;
  for(i=0;i<n-1;++i){
    while(p[i]>0){
      p[i]--;
      p[i+1]--;
      num+=2;
    }
  }
  if(p[n-1]>0) num+=p[n-1];

  return num;
}

int pan0(int n ,vector<int> p){
  int i;
  int num=0;
  for(i=0;i<n-1;++i){
    while(p[i]>0){
      p[i]--;
      p[i+1]--;
      num+=2;
    }
  }
  if(p[n-1]>0) num+=p[n-1];

  return num;
}

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

  vector<int> pan(4);
  pan[0]=pan0(n,p);
  pan[1]=pan1(n,p);
  pan[2]=pan2(n,p);
  pan[3]=pan3(n,p);
  sort(pan.begin(),pan.end());

  cout << pan[0] << endl;
  return 0;
}



Measured memory_bytes: 3200
import math


A = 1
while True:
    n = int(input())
    if n == 0:
        break
    A = math.factorial(n)
    
    m = 0    
    while True:
        if A % 5 != 0:
            break
        else:
            A = A // 5
            m = m + 1
            
    print(m)



Measured memory_bytes: 5788
#https://atcoder.jp/contests/abc159/tasks/abc159_b
s=input()
n=len(s)
first=int((n-1)/2)
last=int((n+3)/2)

rev_s=s[::-1]
s_first=s[:first]
s_last=s[last-1:]
rev_s_first=s_first[::-1]
rev_s_last=s_last[::-1]

for i in range(len(s_first)):
    if s_first[i]!=rev_s_first[i]:
        print("No")
        exit()

for i in range(len(s_last)):
    if s_last[i]!=rev_s_last[i]:
        print("No")
        exit()

for i in range(n):
    if s[i]!=rev_s[i]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 38384
import math
from collections import Counter
from functools import reduce
from operator import mul


def get_factors(n):
    """
    素因数分解
    :param int n:
    :type: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


def comb(n, r):
    """
    組み合わせの数 nCr
    :param n:
    :param r:
    :return:
    """
    r = min(n - r, r)
    if r == 0:
        return 1
    return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))


n, m = map(int, input().split())
MOD = 10 ** 9 + 7

# divs = sorted(get_divisors(m))
# # dp[d]: 累積積が d となる数列の数
# dp = {d: 1 for d in divs}
# for _ in range(n - 1):
#     for i in reversed(range(len(divs))):
#         div = divs[i]
#         dp[div] = sum([dp[d] for d in divs if div % d == 0]) % MOD
#     print(dp)
# print(dp)
# おそい


factors = get_factors(m)
counts = Counter(factors)
# k**v を全部かけあわせたやつが m に一致する
# print(functools.reduce(operator.mul, [k ** v for k, v in counts.items()]))

# v 個の k を n 個の数に配分する組み合わせの数
# → v + (n-1) 個のスペースへの v の置き方の組み合わせの数
ans = 1
for k, v in counts.items():
    ans *= comb(v + (n - 1), v)
    ans %= MOD
print(ans)


Measured memory_bytes: 3572
//arc081_d.cpp
//Sat Jul 20 18:16:50 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	ll MOD = 1000000007;

	ll ans = 1;
	int samelength = 1;
	int start;
	int prevdomino = 1;
	if (s[0]==s[1]){
		ans = 6;
		start = 2;
		prevdomino = 2;
	}else {
		ans = 3;
		start = 1;
		prevdomino = 1;
	}
	for (int i=start;i<s.length()-1;i++){
		if (s[i] != s[i+1]){
			if (samelength==1){
				if (prevdomino == 1){
					ans = ans * 2 % MOD;
				}
				prevdomino = 1;
			}else if (samelength==2){
				if (prevdomino == 2){
					ans = ans * 3 % MOD;
				}else {
					ans = ans * 2 % MOD;
				}
				prevdomino = 2;
			}
			samelength = 1;
		}else {
			samelength++;
		}
	}

			if (samelength==1){
				if (prevdomino == 1){
					ans = ans * 2 % MOD;
				}
				prevdomino = 1;
			}else if (samelength==2){
				if (prevdomino == 2){
					ans = ans * 3 % MOD;
				}else {
					ans = ans * 2 % MOD;
				}
				prevdomino = 2;
			}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>

using namespace std;




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


	long long int T;
	long long int l = 0;
	long long int r = 1000000000;
	
	while(r-l>=1){
		
		long long int M = 0;
		long long int j = (l + r) / 2;
		
		for (long long int i = 0; i < N; i++) {
			if (H[i] - j * B >= 0) {
				M += (H[i] - j * B + A-B - 1) / (A-B);
			}
		}
		if (M <= j) {
			T = j;
			r = j;
		}
		else {
			l = j + 1;
		}
	}
	
	cout << T << endl;
	return 0;
}

Measured memory_bytes: 1024
import math

amount, avoid_num = tuple([ int(x) for x in raw_input().split() ])
avoids = tuple([ int(x) for x in raw_input().split() ])
non_avoids = tuple([ x for x in range(10) if x not in avoids ])
# print amount
# print avoid_num
# print avoids
# print non_avoids

result = amount
result_str = list(str(result))
length = len(result_str)
for index in range(1, length+1):
    num = int(result_str[-index])
    # print index, num
    if num in avoids:
        new_num = None
        for x in non_avoids:
            if x > num:
                new_num = x
                break
        if new_num:
            # print new_num
            result = int(result + (new_num - num) * math.pow(10, index-1))
            result_str = list(str(result))
        else:
            # print 'kuriage'
            result = int(result + (10 - num) * math.pow(10, index-1))
            result_str = list(str(result))
result = int(result)
while True:
    result_str = list(str(result))
    num = int(result_str[0])
    if num in avoids:
        new_num = None
        for x in non_avoids:
            if x > num:
                new_num = x
                break
        if new_num:
            result = int(result + (new_num - num) * math.pow(10, len(result_str)-1))
        else:
            result = int(result + (10 - num) * math.pow(10, len(result_str)-1))
    else:
        break

result_str = list(str(result))
base_str = list(str(amount))
for index in range(2, len(result_str)+1):
    num = int(result_str[-index])
    base_num = int(base_str[-index]) if index <= len(base_str) else None
    # print num, base_num
    if base_num is None or num > base_num:
        result_str[-index+1:len(result_str)] = [str(non_avoids[0])] * (index - 1)
# print int(result)
print ''.join(result_str)


Measured memory_bytes: 2824
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
      int b = scan.nextInt();
      int result = a+b>a*b?a+b:a*b;
      result = result>a-b?result:a-b;
      System.out.println(result);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int a,p;cin >> a >> p;
    cout << (a*3+p)/2 << endl;
    return 0;
}


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

pair<double,string> ds(string s){
  stringstream ss(s);
  double res1 = 0;
  string res2 = "";
  ss>>res1;
  ss.ignore(100,' ');
  getline(ss,res2);
  return make_pair(res1,res2);
}

pair<char,string> cs(string s){
  stringstream ss(s);
  char res1 = 0;
  string res2 = "";
  ss>>res1;
  ss.ignore(100,' ');
  getline(ss,res2);
  return make_pair(res1,res2);
}

double solve(string s){
  stack<double> st;
  double res = 0;
  while(s.size()!=0){
    while(s[0]==' ')s = s.substr(1);
    if((s[0] == '+' || s[0] == '-' || s[0]=='/' || s[0]=='*') && (s.size()==1 || s[1]==' ')){
      auto tmp = cs(s);
      char c = tmp.first;
      s = tmp.second;
      double b = st.top();st.pop();
      double a = st.top();st.pop();
      switch(c){
        case '+':
          a += b;
          break;
        case '/':
          a /= b;
          break;
        case '*':
          a *= b;
          break;
        case '-':
          a -= b;
          break;
      }
      st.push(a);
    }else{
      auto tmp = ds(s);
      st.push(tmp.first);
      s = tmp.second;
    }
  }
  return st.top();
}
 
int main(){
  string s;
  while(!cin.eof()){
    getline(cin,s);
    if(s.size()==0)return 0;
    cout<<setprecision(100)<<solve(s)<<endl;
  }
}

Measured memory_bytes: 1316
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int ans=0;
  if(2*C<A+B){
    int Z=min(X,Y);
    ans+=2*C*Z;
    X-=Z;
    Y-=Z;
  }
  if(2*C<A){
    ans+=2*C*X;
    X=0;
  }
  if(2*C<B){
    ans+=2*C*Y;
    Y=0;
  }
  ans+=A*X+B*Y;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string moji;
  cin>>moji;
 int start=-1,end=-1;
 int size=moji.size();
for(int i=0;i<size;i++){
  	if(moji[i]=='A'){
    	 start=i;
      break;
    }
}
  
for(int j=size-1;j>0;j--){
	if(moji.at(j)=='Z'){
    	end=j;
      	break;
    }
}
int ans=end-start+1;
cout<<ans<<endl;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = []
for _ in range(N):
  w, d = map(int, input().split())
  a.append((w, d))

def check(x):
  res = 0
  for t in a:
    w, d = t
    res += max(0, x - w) // d + int(x >= w)
  return res >= K

ok = 10 ** 19
ng = 0
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(m): ok = m
  else: ng = m
print(ok)

Measured memory_bytes: 51272
S = input()

lowStr = "abcdefghijklmnopqrstuvwxyz"
uppStr = lowStr.upper()

if S[0] != 'A':
  print("WA")
  exit(0)

if S[1] in uppStr or S[-1] in uppStr:
  print("WA")
  exit(0)

fl = False

for i in range(2,len(S)):
  if S[i] in lowStr:
    continue
  elif S[i] == 'C':
    if fl:
      print("WA")
      exit(0)
    else:
      fl = True
  else:
    print("WA")
    exit(0)

if fl:
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int d,e,f;
	cin>>d>>e>>f;
	  if(d==e && e==f)
	    cout<<"No";
    else if(d==e || e == f || d==f)
	 {
	 	cout<<"Yes";
	 	
	 }

     else
         cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>
#include <numeric>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

int main(void) {
  int N, K; cin >> N >> K;
  vector<double> E(N);
  rep(i, N) {
    int p; cin >> p;
    E[i] = (p + 1) / 2.0;
    if (i - 1 >= 0) E[i] += E[i - 1];
  }
  double maxi = 0.0;
  for (int i = 0; i + K - 1 < N; i++) {
    double e = E[i + K - 1];
    if (i - 1 >= 0) e -= E[i - 1];
    maxi = max(maxi, e);
  }
  printf("%.10f\n", maxi);
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;



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

    ll N, K, temp, temp2;
    ll count = 0;
    cin >> N >>K;
    vector <bool> sunuke(N + 1);
    for (int i = 1; i <= K; i++) {
        cin >> temp;
        for (int j = 1; j <= temp; j++) {
            cin >> temp2;
            if (!sunuke[temp2]) {
                sunuke[temp2] = true;
                count++;
            }
        }
    }
    cout << (N-count) << endl;
    return 0;
}

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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003
#define MM 1000000000
#define MN 1000000000000000000
int main()
{
    ios;
    ll p=100;
    ll x,yrs=0;
    cin>>x;
    while(p<x)
    {
        p+=p/100;
        yrs++;
    }
    cout<<yrs;
    return 0;
}


Measured memory_bytes: 3644
/**
*    author:  Dooloper
*    created: 06.07.2020 01:14:55
**/

#include <bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;

const int mod = 1000000007;
class mint {
    long long x;
public:
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  ll V = 0, E = 0;
  for(int i = 1; i <= n; i++) V += ll(i)*(n-i+1);
  rep(i,n-1){
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a,b);
    E += ll(a)*(n-b+1);
  }
  ll ans = V-E;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3660