akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string> 
#include <iomanip>
#include <list>
#include <random>
#include <numeric> //iota - iota(v.begin(), v.end(), x) x, x + 1, x + 2...

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef int INT;
#define int ll
#define mmin(a, b) a = min(a, b)
#define mmax(a, b) a = max(a, b)
#define all(a) a.begin(),a.end()
#define sz(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;

/*
tuple<int, string> f() {
return {485, "Hello"};
}
int a;
string b;
tie(a, b) = f();
*/

const double PI = 2 * acos(0.0), eps = 1e-8;
const int oo = 1e15;

template<class T>
void show(const vector<T> &a) {
	cout << sz(a) << endl;
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const ll M = 998244353;

ll MOD(ll a) {
	if (a >= 0) return a >= M ? a % M : a;
	if (a <= -M) a %= M;
	return a ? a + M : a;
}

int gcd(int a, int b)
{
	while (a > 0)
	{
		if (a < b)
			swap(a, b);
		a %= b;
	}
	return b;
}


/*______________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
______________________________________________________________________________________________________________________________*/


#define N 3001



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

	int n, k;
	cin >> n >> k;
	
	int sum = 0;
	int u = n / k;
	sum += u*u*u;
	if (k % 2 == 0)
	{
		u += (n % k >= k / 2);
		sum += u*u*u;
	}

	cout << sum;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 110;
const int MAX_V = 10100;
const int INF = 1001001001;
int n, W;
int w[MAX_N], v[MAX_N];
int dp[MAX_N][MAX_V];

int main() {
    cin >> n;
    cin >> W;
    rep(i,n){
        cin >> v[i] >> w[i];
    }
    
    rep(i,MAX_N){
        rep(j,MAX_V){
            if(j == 0){
                dp[i][j] = 0;
            }else{
                dp[i][j] = INF;
            }
        }
    }

    rep(i,n){
        rep(j,MAX_V){
            if(i == 0){
                if(j == v[i]){
                    dp[i][j] = w[i];
                }
            }else{
                if(j < v[i]){
                    dp[i][j] = dp[i-1][j];
                }if(j == v[i]){
                    dp[i][j] = min(w[i], dp[i-1][j]);
                }else if(v[i] < j){
                    dp[i][j] = min(dp[i-1][j-v[i]] + w[i], dp[i-1][j]);
                }
            }
        }
    }

    /*
    rep(i,n){
        rep(j,15){
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
    */
    
    drep(i,MAX_V){
        if(dp[n-1][i] <= W){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}
 
 



Measured memory_bytes: 7456
import numpy as np
from collections import deque

def parse():
  H, W = map(int, input().split(" "))
  grid = [list(input()) for y in range(H)]
  return H, W, grid

def print_grid(grid):
  H = len(grid)
  print("grid:")
  for line in grid:
    for c in line:
      print(c, end="")
    print("")

def main():
  H, W, grid = parse()
  # print(H, W)
  # print_grid(grid)

  dark_points = [(x + 1, y + 1) for x in range(W) for y in range(H) if grid[y][x] == "#"]

  visited = [[True] * (W + 2)]
  visited += [[True] + [False for x in range(W)] + [True] for y in range(H)]
  visited.append([True for x in range(W + 2)])
  # for y in range(H + 2):
  #   print(visited[y])
  # exit(0)
  for x, y in dark_points:
    visited[y][x] = True
  
  # visited = np.zeros((H, W), int)
  # for y in range(H):
  #   for x in range(W):
  #     if grid[y][x] == ".":
  #       visited[y][x] = H * W

  # for y in range(1, H):  # ↓
  #   visited[y][:] = np.minimum(visited[y][:], visited[y - 1][:] + 1)

  # for y in range(H - 2, -1, -1):
  #   visited[y, :] = np.minimum(visited[y, :], visited[y + 1][:] + 1)

  # for x in range(1, W):
  #   visited[:, x] = np.minimum(visited[:, x], visited[:, x - 1] + 1)

  # for x in range(W - 2, -1, -1):
  #   visited[:, x] = np.minimum(visited[:, x], visited[:, x + 1] + 1)

  # print(dark_points)
  # exit(0)

  q = dark_points
  ans = 0
  while len(q) > 0:
    ans += 1
    next_q = []
    for x, y in q:
      if not visited[y - 1][x]: # 上
        visited[y - 1][x] = ans
        next_q.append((x, y - 1))
      if not visited[y + 1][x]: # 下
        visited[y + 1][x] = ans
        next_q.append((x, y + 1))
      if not visited[y][x - 1]: # 左
        visited[y][x - 1] = ans
        next_q.append((x - 1, y))
      if not visited[y][x + 1]: # 右
        visited[y][x + 1] = ans
        next_q.append((x + 1, y))
      
    # for y in range(H + 2):
    #   print(visited[y])
    # input()
    
    q = next_q

  print(ans - 1)

if __name__ == "__main__":
  main()

Measured memory_bytes: 147396
/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define FILLBIG(a) FILL(a,0x7f)
#define ALL(a) (a).begin(),(a).end()
#define Inf ((int)0x7f7f7f7f)
#define Mod 1000000007
#define foreach(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
#define cddx(a) priority_queue<a >
#define cxdd(a) priority_queue<a,vector<a >,greater<a > >
#define deval(a) {cerr<<#a<<" = "<<a<<endl;}
#define dearr(be,en) {cerr<<#be;cerr<<" = {";for(auto i=be;i!=en;i++)cerr<<' '<<*i;cerr<<" }\n";}
#define reg register
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int uint;
typedef long long INT;
typedef long double ldouble;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;
const int INF=1e9+7;
using namespace std;
int a,b,c,d;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>a>>b>>c>>d;
	if (a+b>c+d) cout<<"Left"; else if (a+b==c+d) cout<<"Balanced"; else cout<<"Right";
	return 0;
}


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
    return 0;
}


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

int main() {
  int n,T,s=0;
  cin >> n >> T;
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    ans += min(t-s,T);
    s = t;
  }
  ans += T;
  cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	auto len = S.length;
	long ans;
	foreach (i; 1..len)
	{
		auto len2 = len - i;
		if (len2 % 2 == 1) continue;

		bool ok = true;
		foreach (j; 0..len2/2)
		{
			if (S[j] != S[len2/2+j])
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			ans = len2;
			break;
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char num[1000];
	int total=0,count=0,i;
	while(1){
		scanf("%s",num);
		if(num[0]=='0') break;
		while(num[count]!='\0'){
			count++;
		}
		for(i=0;i<count;i++){
			total+=num[i]-'0';
		}
		printf("%d\n",total);
		total=0;
		count=0;
	}
	return 0;
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9;
inline int mod(ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit(ll b, ll i) { return b & (1 << i); }
inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
// struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int x; cin >> x;
    cout << 8 - (x-400)/200 << endl;
}

Measured memory_bytes: 3628
N=int(input())
A=list(map(int, input().split()))
abs_min=10**10
abs_sum=0
neg_cnt=0
for a in A:
    if a<0:
        neg_cnt+=1
        a=-a
    abs_min = min(abs_min, a)
    abs_sum+=a
if neg_cnt&1==0:
    print(abs_sum)
else:
    print(abs_sum-abs_min-abs_min)

Measured memory_bytes: 14284
def solve():
    N,M,K = map(int,input().split())
    MOD = 998244353

    fac, finv, inv = COMinit(N+1,MOD)

    ans = 0
    for i in range(K+1):
        ans += M % MOD * pow(M-1,N-1-i,MOD) % MOD * COM(N-1,i,MOD,fac,finv,inv) % MOD
    
    print(ans%MOD)

# COMの前処理
# テーブルを作る
# O(n)
def COMinit(N, mod):
    fac = [0] * N
    finv = [0] * N
    inv = [0] * N

    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1

    for i in range(2, N):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    
    return fac, finv, inv

# nCrを計算 前処理としてCOMinitの実行が必要
# O(1)
def COM(n, r, mod, fac, finv, inv):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
if __name__ == '__main__':
    solve()

Measured memory_bytes: 72808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
int main()
{
    int x,y,kame,tsuru;
    cin>>x>>y;
    kame=(y/2)-x;
    tsuru=x-kame;
    if((kame>=0)&&(tsuru>=0)&&(y==2*tsuru+4*kame)) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
	double v,y;
	double N;
	int n;
	while( scanf("%lf",&v) != EOF ){
		y=4.9*(v/9.8)*(v/9.8);
		N=(y+5)/5;
		n=(y+5)/5;
		if(n<N) n++;
		printf("%d\n",n);
	}
return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll>a;
	vector<ll>b;
	ll sum = 0LL;

	a.push_back(0);
	for (int i = 0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		sum += tmp;
		a.push_back(sum);
	}
	sum = 0;
	b.push_back(0);
	for (int i = 0; i < m; i++) {
		int tmp;
		cin >> tmp;
		sum += tmp;
		b.push_back(sum);
	}

	int ans = 0;
	/*for (int v : a) {
		printf("%d ", v);
	}
	printf("\n");
	for (int v : b) {
		printf("%d ", v);
	}
	printf("\n");*/
	int reft = b.size() - 1;
	for (int i = 0; i <= n; i++) {
		if (a[i] > k)break;
		ll t = k - a[i];
		while (b[reft] > t) {
			reft--;
		}
		if (ans < reft + i) {
			ans = reft + i;
		}
	}
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 7988
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    ll n; cin>>n;
    ll ans=0;
    while(true){
        ll hoge=n%3;
        n/=3;
        if(hoge)n+=1;
        ans++;
        if(n<=1)break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int,int> > vp;
string s;
vi answers;
int main()
{
  int num[1005];
  num[0]=0;
  for(int i=1;i<=1000;i++)
    {
      num[i]=i*(i+1)/2;
    }
  while(1)
    {
      int n;
      cin >> n;
      if(!n) break;
      int ans=0;
      for(int i=0;i<=n;i++)
	{
	  for(int j=i+1;j<=n;j++)
	    {
	      if(num[j]-num[i]==n && (j-i)>1) 
		{
		  ans++;
		}
	    }
	}
      answers.push_back(ans);
    }
  for(int i=0;i<answers.size();i++)
    {
      cout << answers[i] << endl;
    }
  return 0;
}



Measured memory_bytes: 3136
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
import sys
import itertools
import collections

INF = 1145141919


def solve(S: int):
    l = list(reversed(str(S)))
    a = [int(l[c]) * pow(10, c, 2019) for c in range(len(l))]

    def list_cumsum(l):
        return list(itertools.accumulate(l))
    s = [n % 2019 for n in list_cumsum([0]+a)]

    return sum([sum(range(v)) for v in collections.Counter(s).values()])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    print(solve(S))


if __name__ == '__main__':
    main()


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 200010;
const string W = "CB";

int main() {
	string s; cin >> s;
	int n = s.size();

	ll ans = 0;
	int cnt = 0;

	for (int i = n-1; i >= 0; --i) {
		if (s[i] == 'A') {
			if (cnt % 2 == 0) {
				ans += cnt / 2;
			} else {
				cnt = 0;
			}
		} else {
			if (s[i] == W[cnt % 2]) {
				++cnt;
			} else {
				cnt = 0;
				if (s[i] == 'C') {
					cnt = 1;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long 
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define setbit(x,k) (x |= (1 << k))
#define clearbit(x,k) (x &= ~(1ll << k))
#define checkbit(x,k) (x & (1ll << k))
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define pii pair<int,int> 
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nn printf("\n") 
#define mod 10000007
using namespace std;    

ll n,w;
vector<pair<ll,ll> >a;
ll dp[105][100005];

ll solve(int pos, int we)
{
    if(pos == n || we == w || w-we<a[pos].first) return 0;
    if(dp[pos][we]!=-1) return dp[pos][we];

    ll res = 0;
    if(we+a[pos].first<=w) res = max(res, a[pos].second + solve(pos+1, we+a[pos].first));
    
    res = max(res, solve(pos+1, we));

    return dp[pos][we] = res;
}

int main()
{
    memset(dp, -1, sizeof(dp));
    cin>>n>>w;
    ll x,y;
    for(int i=0; i<n; i++) {cin>>x>>y; a.pb({x,y});}
    sort(a.begin(), a.end());
    cout<<solve(0,0); nn;
}


Measured memory_bytes: 85672
# -*- coding: utf-8 -*-

def do_binary_search(target_value, target_list, target_list_length=None):
    left = 0
    right = target_list_length

    while right - left > 0:
        mid = (right + left) / 2
        key = target_list[mid]
        if key == target_value:
            return True
        elif target_value < key:
            right = mid
        else:
            left = mid + 1
    return False



def main():
    s_length = int(raw_input())
    s = [int(x) for x in raw_input().strip().split(' ')]
    t_length = raw_input()
    t = [int(x) for x in raw_input().strip().split(' ')]

    counter = 0
    for value in t:
        counter += int(do_binary_search(value, s, s_length))

    print counter 

if __name__ == '__main__':
    main()

Measured memory_bytes: 15144
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

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

char a[100][100];



int main()
{
  int i,j,k,m,n,b1,x,y;
  scanf("%d%d",&m,&n);
  for (i=0;i<m;i++)
    scanf("%s",a[i]);
  for (i=0;i<m;i++)
    for (j=0;j<n;j++)
      if (a[i][j]=='#')
      {
        b1=0;
        for (k=0;k<4;k++)
        {
          x=i+neigh[k][0];
          y=j+neigh[k][1];
          if ((x>=0)&&(x<m)&&(y>=0)&&(y<n)&&(a[x][y]=='#'))
            b1=1;
        }
        if (b1==0)
        {
          printf("No\n");
          return 0;
        }
      }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [float('inf')] * (N + K + 5)
dp[0] = 0
for i in range(N):
    for k in range(1, K + 1):
        if i + k < N:
            dp[i + k] = min(dp[i + k], dp[i] + abs((H[i] - H[i + k])))
# print(dp)
print(dp[N - 1])


Measured memory_bytes: 55264
//abc154_a.cpp
//Sat Mar 28 17:43:13 2020

#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
#define MOD 1000000007

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

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

	string u;
	cin >> u;

	if (u==s){
		cout << a-1 << " " << b << endl;
	}else {
		cout << a << " " << b-1 << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int E,Y,S=0;
	scanf("%d %d",&E,&Y);
	if (E==0) {
		if(Y>=1868&&Y<=1911) { 
		S=Y-1868+1;
		printf("M%d\n",S);
		}
		else if(Y>=1912&&Y<=1925) {
		S=Y-1912+1;
		printf("T%d\n",S);
		}
		else if(Y>=1926&&Y<=1988) {
		S=Y-1926+1;
		printf("S%d\n",S);
		}
		else if(Y>=1989&&Y<=2016) {
		S=Y-1989+1;
		printf("H%d\n",S);
		}
	}
	else if(E==1) {
		S=1868+Y-1;
		printf("%d\n",S);
	}
	else if(E==2) {
		S=1912+Y-1;
		printf("%d\n",S);
	}
	else if(E==3) {
		S=1926+Y-1;
		printf("%d\n",S);
	}
	else if(E==4){
		S=1989+Y-1;
		printf("%d\n",S);
	}
	return 0;
}
		
		


Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

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

typedef long long ll;

using namespace std;

ll a[8][3] = {{1,1,1},{1,1,-1},{1,-1,1},{1,-1,-1},{-1,1,1},{-1,1,-1},{-1,-1,1},{-1,-1,-1}};


int main() {
    
    ll n,m;
    cin >> n >>m;
    
    vector<ll> x(n),y(n),z(n);
    
    FOR(i, 0, n){
        cin >> x[i] >> y[i] >> z[i];
    }
    
    ll ans = -(1ll<<60);
    FOR(i, 0, 8){
        vector<ll> tmp(n);
        FOR(j, 0, n){
            tmp[j] = x[j] * a[i][0] + y[j] * a[i][1] + z[j] * a[i][2] ;
        }
        sort(tmp.begin(),tmp.end(),greater<ll>());
        ll sum=0;
        FOR(j, 0, m){
            sum += tmp[j];
        }
        ans = max(sum,ans);
    }
    
    cout << ans << endl;
    
    
    return 0;
}


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

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

int dp[1000][1000]={0}; //dp[n+1][w] = max(dp[n][w-w[n+1]]+v[n+1],dp[n][w])

int main(){
    ll num;
    cin>>num;
    ll x= num/2;
    ll y= num - num/2;
    cout<<x*y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  string s;
  cin >> s;
  s.insert(s.begin(),'0');
  for(auto ite = s.rbegin(); ite != s.rend(); ++ite) {
    if (*ite == '0') {
      *ite = '1';
      break;
    } else {
      *ite = '0';
    }
  }
  LL n = s.size();
  LL answer = 0;
  LL tmp = 1;
  vector<LL> pow3(n+1);
  pow3[0] = 1;
  REP(i,n) pow3[i+1] = pow3[i] * 3 % p;
  REP(i,n) if(s[i] == '1') {
    answer += pow3[n-i-1] * tmp;
    tmp *= 2;
    tmp %= p;
    answer %= p;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000009
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<ll> L(n + 3);
    L[0] = 2;
    L[1] = 1;
    rep(i,n-1){
        L[i + 2] = L[i] + L[i + 1];
    }
    cout << L[n] << endl;
}


Measured memory_bytes: 256
a=input()
n=len(a)
p=0
q=0
r=0
i=0
while i<n:
  while a[i]=="<":
    i+=1
    p+=1
    if i==n:
      print(r+p*(p+1)//2)
      exit(0)
  while a[i]==">":
    i+=1
    q+=1
    if i==n:
      break
  r+=p*(p+1)//2+q*(q+1)//2-min(p,q)
  p=0
  q=0
print(r)

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


			

int main(){
	
	int K,N;
	cin>>K>>N;
	
	
	if(K%2==0){
		cout<<K/2<<' ';
		for(int i=0;i<N-1;i++){
			cout<<K;
			if(i!=N-2)cout<<' ';
		}
		cout<<endl;
	}
	else{
		vector<int> V(N,(K+1)/2);
		reverse(V.begin(),V.end());
		int a = 0;
		for(int i=0;i<N/2;i++){
			for(int j=a;j<V.size();j++){
				if(V[j]==0)continue;
				V[j]--;
				if(V[j]!=0){
					for(int k=0;k<j;k++){
						if(V[k]!=0)break;
						V[k]=K;
					}
					a=0;
				}
				else{
					a=j+1;
				}
				break;
			}
		}
		reverse(V.begin(),V.end());
		for(int i=0;i<V.size();i++){
			if(V[i]==0)break;
			if(i!=0)cout<<' ';
			cout<<V[i];
		}
		cout<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>

using namespace std;

u_int64_t A[100'000];

int main()
{
    u_int64_t N, K;

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

    u_int64_t x = 0;
    bool smaller = false;
    for (int i = 63; i >= 0; i--)
    {
        u_int64_t mask = (1LL << i);
        int zeros = 0;
        for (int j = 0; j < N; j++)
        {
            if ((A[j] & mask) == 0)
            {
                zeros++;
            }
        }
        u_int64_t cand = zeros * 2 > N ? mask : 0;

        if (smaller)
        {
            x |= cand;
            continue;
        }

        if ((K & mask) == 0)
        {
            x |= 0;
        }
        else
        {
            if (cand == 0)
            {
                smaller = true;
            }
            x |= cand;
        }
    }

    u_int64_t result = 0;
    for (int i = 0; i < N; i++)
    {
        result += A[i] ^ x;
    }

    cout << result << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#define fo(i, x, y) for(int i = x; i <= y; i ++)
using namespace std;

int n, mx, a[200005], b[200005];

int main() {
	scanf("%d", &n); fo(i, 1, n) scanf("%d", &a[i]);
	fo(i, 1, n) {
		if(b[a[i] - 1])
			b[a[i]] = b[a[i] - 1] + 1; else b[a[i]] = 1;
		mx = mx > b[a[i]] ? mx : b[a[i]];
	}
	printf("%d", n - mx);
}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main(void){
    int m, nmin, nmax;
    while(cin >> m >> nmin >> nmax && m) {
        int p[m];
        for (int i = 0; i < m; ++i) {
            cin >> p[i];
        }
        int diff = 0, pass = 0;
        for (int i = nmin - 1; i < nmax; ++i) {
            int d = p[i] - p[i + 1];
            if (diff <= d) {
                pass = i + 1;
                diff = d;
            }
        }
        cout << pass << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const auto MOD = static_cast<ll>(1e9 + 7);

ll A = 0;
ll ans = 0;

int main() {
    cin >> A;
    ans = A / 11 * 2;
    A -= ans / 2 * 11;
    bool turn = true;
    while (A > 0) {
        if (turn) {
            A -= 6;
            ans += 1;
            turn = false;
        }
        else {

            A -= 5;
            ans += 1;
            turn = true;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int p = 2000 , j = 2000;
    int i;
    int a;
    
    for (i = 0; i < 3; i++){
        scanf("%d", &a);
        if (a < p){
            p = a;
        }
    }
    
    for (i = 0; i < 2; i++){
        scanf("%d", &a);
        if (a < j){
            j = a;
        }
    }
    
    printf("%d\n", j + p - 50);
    
    
    
    return (0);
}

Measured memory_bytes: 592
#include <cstdio>
#include <cmath>

using namespace std;

int main(){

  int n,sum =0;
  if(scanf("%d",&n) != 1){
    printf("No number.\n");
  }
  
  int a[n]={0};			// 料理
  int b[n]={0};			// 満足度
  int c[n-1]={0};			// 満足度の追加

  
  for(int i=0; i<n; i++){
    if( scanf("%d",&a[i]) != 1){
      printf("No Number\n");
    }
  }
  
  for(int i=0; i<n; i++){
    if(scanf("%d",&b[i]) != 1){
       printf("No Number\n");
    }
  }
  
  for(int i=0; i<n-1; i++){
    if(scanf("%d",&c[i]) != 1){
       printf("No Number\n");
    }
  }
  
  int p = 0;
  for (int i=0; i<n; i++){
    p = a[i]-1;
    sum += b[p];
    if (a[i] == a[i-1]+1){
      p = a[i-1]-1;
      sum += c[p];
    }
  }
  
  
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;

int main(void) {
	int N;
	cin >> N;
	while (1) {
		int a = N / 100;
		int b = N % 100 / 10;
		int c = N % 10;
		if (a == b && a == c) break;
		N++;
	}
	cout << N << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
board[left] = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while board[left] is None:
        left += 1
        if left == i:
            break
    if left < i:
        board[i] = left
# print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))

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

int  main()
{
	int h1, m1; cin >> h1 >> m1;
	int h2, m2; cin >> h2 >> m2;
	int k; cin >> k;

	int a = (h1 * 60) + m1;
	int b = (h2 * 60) + m2;

	int ans = b - a - k;
	cout << ans << endl;
	return (0);
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll A, B, K;
    cin >> A >> B >> K;
    if(A-K>=0) cout << A - K << " " << B << endl;
    else cout << 0 << " " << max(0ll, B - (K-A)) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 504
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		// 計算
		long result = 1;
		int MOD = 1000000007;
		Combination comb = new Combination(m);
		for(int i = 0; i < n; i++){
		    result *= m-i;
		    result %= MOD;
		}
		long cnt = 0;
		for(int i = 0; i <= n; i++){
		    if(i%2 == 0){
		        cnt += comb.combination(n, i)*comb.permutation(m-i, n-i)%MOD;
		    }else{
		        cnt -= comb.combination(n, i)*comb.permutation(m-i, n-i)%MOD;
		    }
		    cnt = (cnt + MOD)%MOD;
		}
		result *= cnt;
		result %= MOD;
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}

class Combination {
	static final int MOD = 1000000007;
	long[] fact;
	long[] invFact;
	long[] inv;
	
	public Combination (int n) {
		fact = new long[n+1];
		invFact = new long[n+1];
		inv = new long[n+1];
		fact[0] = 1;
		fact[1] = 1;
		invFact[0] = 1;
		invFact[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < n+1; i++) {
			fact[i] = fact[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			invFact[i] = invFact[i - 1] * inv[i] % MOD;
		}
	}
	
	public long combination(int n, int k) {
		if (n < k || n < 0 || k < 0) {
			return 0;
		}
		return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
	}
	
	public long permutation(int n, int k) {
		if (n < k || n < 0 || k < 0) {
			return 0;
		}
		return fact[n] * invFact[n - k] % MOD;
	}
}


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

int main() {
    int N;
    cin >> N;
    vector<int> p(N), q(N);
    rep(i,N) { cin >> p[i]; p[i]--; }
    rep(i,N) { cin >> q[i]; q[i]--; }

    vector<int> v(N, 0);
    iota(v.begin(), v.end(), 0);

    int a = 0, b = 0, cur = 1;

    do {

        bool oka = true, okb = true;
        rep(i, N) {
            if (p[i] != v[i]) oka = false;
            if (q[i] != v[i]) okb = false;
        }

        if (oka) {
            a = cur;
        }
        if (okb) {
            b = cur;
        }

        cur++;

    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a-b) << endl;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, N;
    cin >> X >> N;
    set<int> st;
    for (int i=0;i<N;i++) {
        int p;
        cin >> p;
        st.insert(p);
    }
    int ans = 0;
    for (int i=0;i<=100;i++){
        if (st.find(X-i) == st.end()){
            ans = X-i;
            break;
        }
        if (st.find(X+i) == st.end()){
            ans = X+i;
            break;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
using namespace std;
int C[26], n, m, P[4];
char p[110][110];
int main(){
    int i, j;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%s",p[i]);
        for(j=0;j<m;j++)C[p[i][j]-'a']++;
    }
    for(i=0;i<26;i++)P[C[i]%4]++;
    if(n%2==0&&m%2==0){
        if(!P[1]&&!P[2]&&!P[3])puts("Yes");
        else puts("No");
    }
    else if(n%2==0){
        if(!P[1]&&!P[3]&&P[2] <= n/2)puts("Yes");
        else puts("No");
    }
    else if(m%2==0){
        if(!P[1]&&!P[3]&&P[2] <= m/2)puts("Yes");
        else puts("No");
    }
    else{
        if(P[1]+P[3]<=1&&P[2]<=n/2+m/2)puts("Yes");
        else puts("No");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    ll a,b;
    cin >> a >> b;
    ll tmpa = a, tmpb = b;
    map<int,int> mpa,mpb;
    for(int i = 2; i < sqrt(tmpa)+1; i++){
        while(a % i == 0){
            mpa[i]++;
            a /= i;
        }
    }
    if(a != 1) mpa[a]++;

    for(int i = 2; i < sqrt(tmpb)+1; i++){
        while(b % i == 0){
            mpb[i]++;
            b /= i;
        }
    }
    if(b != 1) mpb[b]++;
    
    int ans = 0;
    for(auto elem : mpa){
        //cout << elem.first << " " << elem.second << endl;
        if(mpb[elem.first] >= 1)ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N;
	cin >> N;

	int ans = INT_MAX;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		
		int cnt = 0;
		while (n%2==0) {
			if (n / 2) {
				cnt++;
				n /= 2;
			}
			else {
				break;
			}
		}

		ans = min(ans, cnt);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, d; cin >> n >> d;
    d = d*2+1;
    cout << (n+d-1)/d << endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const ll INF_LONG = 1LL << 62;
const ll INF_LONG_NEG = INF_LONG * -1;

int main()
{
    int N; cin >> N;
    vector<double> v(N); rep(i, N) cin >> v[i];

    sort(v.begin(), v.end());
    double ave;
    rep(i, N - 1){
        ave = (double)(v[i] + v[i + 1]) / 2.0;
        v[i + 1] = ave;
    }

    printf("%.6f\n", ave);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long int count(long long int a, long long  int b, long long  int n)
{
	long long int res = 0;
	if (a == b && a <= n)res++;
	long long int max, min;
	max = min = 10 * a + b;
	while (max <= n)
	{
		res += (max - min + 10) / 10;
		max = (max - b + 9) * 10 + b;
		min = (min - b) * 10 + b;
	}
	while (n % 10 != b && n >= 0)n--;
	if (n >= min)
		res += (n - min + 10) / 10;
	return res;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i, j, k;
	long long int ans = 0;
	for (i = 1; i < 10; i++)
		for (j = 1; j < 10; j++)
			ans += count(i, j, n) * count(j, i, n);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n;
vector<pa> v;
int main(){
	cin>>n;
	if (n%2==0){
		FOR(i,1,n)
			FOR(j,i+1,n){
				if (i+j==n+1) continue;
				v.pb(mp(i,j));
			}
	}
	else{
		FOR(i,1,n)
			FOR(j,i+1,n){
				if (i+j==n) continue;
				v.pb(mp(i,j));
			}
	}
	cout<<SZ(v)<<endl;
	FOR(i,0,SZ(v)-1) printf("%d %d\n",v[i].fi,v[i].se);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = scanner.nextInt();
        int arr[] = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i] = scanner.nextInt();

        }
        long ans[][][] = new long[arr.length][arr.length][2];
        for (int i = 0; i < ans.length; i++) {
            for (int j = 0; j < arr.length; j++) {
                for (int k = 0; k < 2; k++) {
                    ans[i][j][k] = Long.MIN_VALUE;
                }
            }
        }
        // System.out.println(getXY(arr, 0, arr.length - 1, 0));
        System.out.println(getXY2(arr, 0, arr.length - 1, 0, ans));
        // System.out.println(visited);

    }

   
   
    public static int visited = 0;

    public static long getXY2(int arr[], int start, int end, int p, long ans[][][]) {
        if (ans[start][end][p] != Long.MIN_VALUE) {
            visited++;
            return ans[start][end][p];
        }
        if (start == end) {
            if (p == 0) {
                ans[start][end][p] = arr[start];
                return arr[start];
            } else
                ans[start][end][p] = -arr[start];
            return -arr[start];
        }

        int o = (p == 1) ? 0 : 1;
        long op1 = getXY2(arr, start + 1, end, o, ans);
        long op2 = getXY2(arr, start, end - 1, o, ans);
        if (p == 0) {
            op1 += arr[start];
            op2 += arr[end];
            ans[start][end][p] = Math.max(op1, op2);
            return ans[start][end][p];
        } else {
            op1 -= arr[start];
            op2 -= arr[end];
            ans[start][end][p] = Math.min(op1, op2);

            return ans[start][end][p];
        }

    }
}


Measured memory_bytes: 358120
#include <iostream>

using namespace std;

int main()
{
	int  h, w;

	while (true)
	{
		cin >> h >> w;

		if (h == 0 && w == 0)
		{
			break;
		}

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


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

int main(){
        int n;
        cin >> n;
        char mark;
        int num;

        bool card[4][13];
        int i, j;
        for(i = 0; i < 4; i++){
          for(j = 0; j < 13; j++){
            card[i][j] = false;
          }
        }

        for(i = 0; i < n; i++) {
                cin >> mark >> num;

                if(mark == 'S') {
                        card[0][num - 1] = true;
                }
                else if(mark == 'H') {
                        card[1][num - 1] = true;
                }
                else if (mark == 'C') {
                        card[2][num - 1] = true;
                }
                else{
                        card[3][num - 1] = true;
                }
        }

        for(i = 0; i < 4; i++) {
                for(j = 0; j < 13; j++) {
                        if(card[i][j] == false) {
                                if(i == 0) {
                                        cout << 'S' << " " << j + 1;
                                }
                                else if(i == 1) {
                                        cout << 'H' << " " << j + 1;
                                }
                                else if(i == 2) {
                                        cout << 'C' << " " << j + 1;
                                }
                                else {
                                        cout << 'D' << " " << j + 1;
                                }
                                cout << endl;
                        }
                }
        }
}



Measured memory_bytes: 3096
#include<iostream>
#include<vector>
using namespace std;
typedef pair<int, int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<P> ans;
    for (int i = 2; i <= N; i++) {
        ans.push_back(P(1, i));
    }
    int now_k = (N - 1) * (N - 2) / 2;
    for (int i = 2; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            if (now_k == K) {
                cout << ans.size() << endl;
                for (int i = 0; i < ans.size(); i++) {
                    cout << ans[i].first << ' ' << ans[i].second << endl;
                }
                return 0;
            }
            ans.push_back(P(i, j));
            now_k--;
        }
    }
    if (now_k == K) {
        cout << ans.size() << endl;
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i].first << ' ' << ans[i].second << endl;
        }
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384