akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

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

    ll ans = 10000000000;
    for (int i = 1; i <= h; i++)
    {
        ll rect1 = i * w;
        ll rect2 = (h - i) * (w / 2);
        ll rect3 = (h - i) * w - rect2;

        ll lrg = max(rect1, rect3);
        ll sml = min(rect1, rect2);

        ans = min(ans, lrg - sml);
    }

    for (int i = 1; i <= w; i++)
    {
        ll rect1 = i * h;
        ll rect2 = (w - i) * (h / 2);
        ll rect3 = (w - i) * h - rect2;

        ll lrg = max(rect1, rect3);
        ll sml = min(rect1, rect2);

        ans = min(ans, lrg - sml);
    }

    for (int i = 1; i <= h; i++)
    {
        ll rect1 = i * w;
        ll rect2 = ((h - i) / 2) * w;
        ll rect3 = (h - i) * w - rect2;

        ll lrg = max(rect1, rect3);
        ll sml = min(rect1, rect2);

        ans = min(ans, lrg - sml);
    }

    for (int i = 1; i <= w; i++)
    {
        ll rect1 = i * h;
        ll rect2 = ((w - i) / 2) * h;
        ll rect3 = (w - i) * h - rect2;

        ll lrg = max(rect1, rect3);
        ll sml = min(rect1, rect2);

        ans = min(ans, lrg - sml);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n, m, i;
  scanf("%d%d", &n, &m);
  if(n == 1) printf("%d\n", m);
  else if(n == 2) printf("0 %d\n", m);
  else {
    for(i = 0; i < n / 2 + 1; ++i) printf("0 ");
    for(; i < n; ++i) {
      if(i == n - 1) printf("%d\n", m);
      else printf("%d ", m);
    }
  }
  return 0;
}


Measured memory_bytes: 2732
#include<iostream>
#include<map>
#include<string>

using namespace std;

int main() {
  map<string, int> M;
  string word, fword, lword = "";
  int s = 0;
  while(cin >> word) {
    M[word]++;
    if(M[word] > s) {
      s = M[word];
      fword = word;
    }
    if(word.size() > lword.size()) lword = word;
  }
  cout << fword << " " << lword << endl;
  return 0;
}
    

Measured memory_bytes: 3188
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 N, X, T;
  std::cin >> N >> X >> T;
  std::cout << tools::ceil<i64>(N, X) * T << std::endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, K, ans;
  ans = 0;
  cin >> N >> K;
  int A[N+10] = {0};
  for (int i = 0; i < K; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int tmp;
      cin >> tmp;
      ++A[tmp];
    }
  }
  for (int i = 1; i <= N; ++i) {
    if (A[i] == 0) {
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3696
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int m=(s[5]-'0')*10+(s[6]-'0');
    int d=(s[8]-'0')*10+(s[9]-'0');
    int x=32*m+d;
    if(x<=32*4+30) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    lint N;
    cin >> N;
    cout << (N - 1) / 2 << endl;
}



Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int n,a[105],m=0,x=1,y=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%2==1)
		++m;
		x=x*3;
	}
	for(int i=1;i<=n-m;i++)
	y*=2;
	cout<<x-y<<endl;
	return 0;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 4e2 + 10;
const int maxC = 4e2 + 10;
const int maxS = 4e2 + 10;
const ll mod = 1e9 + 7;

int n, c, a[maxN], b[maxN];
ll dp[maxN][maxC], g[maxC][maxS];

ll power(ll a, ll b)
{
    ll r = 1;
    while (b)
    {
        if (b & 1)
        {
            r = r * a % mod;
        }
        b /= 2;
        a = a * a % mod;
    }
    return r;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> c;
    for1(i, n)
    {
        cin >> a[i];
    }
    for1(i, n)
    {
        cin >> b[i];
    }
    fore(i, 0, c)
    {
        for1(j, 4e2)
        {
            g[i][j] = (g[i][j - 1] + power(j, i)) % mod;
        }
    }
    dp[0][0] = 1;
    for1(i, n)
    {
        fore(j, 0, c)
        {
            fore(k, 0, j)
            {
                dp[i][j] += dp[i - 1][j - k] * ((g[k][b[i]] - g[k][a[i] - 1] + mod) % mod) % mod;
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n][c];
    return 0;
}


Measured memory_bytes: 6224
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long 
using namespace std;

int main(){
  int64 n,keta,saikoui;
  cin>>n;
  keta=static_cast<int>(floor(log10(n))+1);
  saikoui=static_cast<int>(floor((n+1)/pow(10,keta-1)));
  int ans=saikoui-1+9*(keta-1);
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,cnt=0;
cin>>a>>b;
for (int i=0;i<b;i++)
{
cin>>c;
cnt+=c;
}
if (cnt>=a)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct UF
{
  vector<int> par;
  vector<int> sz;
  vector<int> rank;
  UF(int n):par(n),sz(n),rank(n){
    for(int i = 0; i < n; i++){
      par[i] = i;sz[i] = 1;rank[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void merge(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int n){return sz[find(n)];}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  UF uni(n+10);
  ll cnt = n*(n-1)/2;
  vi ans;
  vector<pair<ll,ll>>E(m);
  for(auto &a:E)cin>>a.F>>a.S;
  for(int i=m-1;i>=0;i--){
    ans.pb(cnt);
    if(uni.same(E[i].F,E[i].S) == false){
      cnt -= uni.size(E[i].F)*uni.size(E[i].S);
      uni.merge(E[i].F,E[i].S);
    }
  }
  reverse(ALL(ans));
  for(auto a:ans){
    cout<<a<<endl;
  }
  return 0;
}



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

int n;

int left(int i) {return 2 * i;}
int right(int i) {return 2 * i + 1;} 

void maxHeapify(int H[], int i) {
	int l = left(i);
	int r = right(i);
	int largest = i;
	if (l <= n && H[l] > H[largest]) largest = l;
	if (r <= n && H[r] > H[largest]) largest = r;

	if (largest != i) {
		swap(H[i], H[largest]); //i??¨largest?????????????????????????????????????????????????????????
		maxHeapify(H, largest); 
	}
}

void buildMaxHeap(int H[]) {
	for (int i = n / 2; i >= 1; i--) {
		maxHeapify(H, i);
	}
}

int main() {
	cin >> n;
	int H[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> H[i];
	} 

	buildMaxHeap(H);

	for (int i = 1; i <= n; i++) {
		cout << ' ' << H[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a, ans;
    cin >> a;
    if(a=='A')
        ans = 'T';
        if(a=='T')
            ans = 'A';
            if(a=='C')
                ans = 'G';
                if(a=='G')
                    ans = 'C';
                cout << ans << endl;
                return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,y;
  cin >> x >> y;
  int ans = 4*x;
  if(ans == y) {
    cout << "Yes" << endl;
    return 0;
  }
  for(int i=0; i<x; i++) {
    ans -= 2;
    if(ans == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            BigInteger a = new BigInteger(sc.nextLine());
            BigInteger b = new BigInteger(sc.nextLine());
            BigInteger c = a.add(b);
            BigInteger limit = new BigInteger("100000000000000000000000000000000000000000000000000000000000000000000000000000000");
            System.out.println(c.compareTo(limit) < 0 ? c : "overflow");
        }
    }
}

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

int main() {
  int N;
  string a;
  cin >> N;
  
  for (int i=0; i<N; i++){
    cin >> a;
    if(a== "Y"){
      cout << "Four" << endl;
      break;
    }
  }
  if(a!= "Y")
    cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<random>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<unordered_map>
#include<time.h>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace std;
int h, w, a[1000][1000];
int dp[1000][1000][32];
int solve(int x, int y, int s) {
	if (x == h - 1 && y == w - 1)
		return 0;
	if (dp[x][y][s] != -1)
		return dp[x][y][s];
	int sum = 0, ans = 1145141919810;
	if (s & 1) sum += a[x][y];
	if (s & 2) sum += a[x - 1][y];
	if (s & 4) sum += a[x][y - 1];
	if (x + 1 < h)sum += a[x + 1][y];
	if (y + 1 < w)sum += a[x][y + 1];
	if (y + 1 < w) {//????????????
		if (sum == 0 || (sum == a[x][y] && s & 1)) {
			ans = min(ans, (sum + solve(x, y + 1, (s & 8 ? 2 : 0) + (x > 0 && y + 2 < w&&a[x - 1][y + 2] > 0 ? 8 : 0))));
		}
		else {
			if (s & 2)//??????????????????
				ans = min(ans, (sum - a[x - 1][y] + solve(x, y + 1, (s & 8 ? 2 : 0) + (y + 2 < w&&a[x - 1][y + 2] > 0 ? 8 : 0))));
			if (s & 4)//??????????????????
				ans = min(ans, (sum - a[x][y - 1] + solve(x, y + 1, (s & 8 ? 2 : 0) + (x > 0 && y + 2 < w&&a[x - 1][y + 2] > 0 ? 8 : 0))));
			if (x + 1 < h&&a[x + 1][y] > 0)//??????????????????
				ans = min(ans, (sum - a[x + 1][y] + solve(x, y + 1, 16 + (s & 8 ? 2 : 0) + (x > 0 && y + 2 < w&&a[x - 1][y + 2] > 0 ? 8 : 0))));
			if (y + 1 < w&&a[x][y + 1] > 0)//??????????????????
				ans = min(ans, (sum - a[x][y + 1] + solve(x, y + 1, 1 + (s & 8 ? 2 : 0) + (x > 0 && y + 2 < w&&a[x - 1][y + 2] > 0 ? 8 : 0))));
		}
	}
	if (x + 1 < h) {//????????????
		if (sum == 0 || (sum == a[x][y] && s & 1)) {
			ans = min(ans, (sum + solve(x + 1, y, (s & 16 ? 4 : 0) + (x + 2 < h&&y > 0 && a[x + 2][y - 1] > 0 ? 16 : 0))));
		}
		else {
			if (s & 2)//??????????????????
				ans = min(ans, (sum - a[x - 1][y] + solve(x + 1, y, (s & 16 ? 4 : 0) + (x + 2 < h&&y > 0 && a[x + 2][y - 1] > 0 ? 16 : 0))));
			if (s & 4)//??????????????????
				ans = min(ans, (sum - a[x][y - 1] + solve(x + 1, y, (s & 16 ? 4 : 0) + (x + 2 < h&&y > 0 && a[x + 2][y - 1] > 0 ? 16 : 0))));
			if (x + 1 < h&&a[x + 1][y] > 0)//??????????????????
				ans = min(ans, (sum - a[x + 1][y] + solve(x + 1, y, 1 + (s & 16 ? 4 : 0) + (x + 2 < h&&y > 0 && a[x + 2][y - 1] > 0 ? 16 : 0))));
			if (y + 1 < w&&a[x][y + 1] > 0)//??????????????????
				ans = min(ans, (sum - a[x][y + 1] + solve(x + 1, y, 8 + (s & 16 ? 4 : 0) + (x + 2 < h&&y > 0 && a[x + 2][y - 1] > 0 ? 16 : 0))));
		}
	}
	return dp[x][y][s] = ans;
}
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == '.')
				a[i][j] = 0;
			else
				a[i][j] = (int)s[j] - '0';
			for (int z = 0; z < 32; z++)
				dp[i][j][z] = -1;
		}
	}
	cout << solve(0, 0, 0) << endl;
	getchar(); getchar();
}

Measured memory_bytes: 261172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n;
	cin >> n;
	if (n % 2 == 1) cout << fixed << setprecision(10) << ceil((double)n / 2) / n << endl;
	else cout << fixed << setprecision(10) << ((double)n/2)/n << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]

H, W = read_values()
P = [[False for _ in range(W)] for _ in range(H)]
F = [input().strip() for i in range(H)]

def f(h, w):
    S = deque()
    S.append((h, w))
    P[h][w] = True
    T = [0, 1]
    while S:
        h, w = S.popleft()
        for hh, ww in [(h + 1, w), (h - 1, w), (h, w + 1), (h, w - 1)]:
            if not (0 <= hh < H and 0 <= ww < W):
                continue
            if P[hh][ww]:
                continue
            if F[hh][ww] == F[h][w]:
                continue
            P[hh][ww] = True
            t = 0 if F[hh][ww] == "." else 1
            T[t] += 1
            S.append((hh, ww))
    return T[0] * T[1]


def main():
    res = 0
    for h in range(H):
        for w in range(W):
            if P[h][w] or F[h][w] != "#":
                continue
            res += f(h, w)
    print(res)
    

if __name__ == "__main__":
    main()



Measured memory_bytes: 10808
#include "bits/stdc++.h"

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	string s;
	cin >> s;
	bool ac;

	if (s[0] != 'A') ac = false;
	else{
		int c = 0;
		for (int i = 2; i < s.length() - 1; i++)
			if (s[i] == 'C') c++;
		if (c != 1) ac = false;
		else{
			int cc = 0;
			for (int i = 0; i < s.length(); i++){
				if ('a' <= s[i] && s[i] <= 'z') cc++;
			}
			if (cc == s.length() - 2) ac = true;
			else ac = false;
		}
	}

	if (ac) cout << "AC" << endl;
	else cout << "WA" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=2e5+10;
    int n;
    char S[MAXN];
    int idxTree[MAXN];
    int query(int pos){
        int sum=0;
        for(int idx=pos;idx>=1;idx-=(idx)&(-idx)){
            sum+=idxTree[idx];
        }
        return sum;
    }
    void update(int pos,int v){
        for(int idx=pos;idx<MAXN;idx+=(idx)&(-idx)){
            idxTree[idx]+=v;
        }
    }
    vector<int>pos[26];
    int vis[MAXN];
    int cnt[26];
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>S+1;
        n=strlen(S+1);
        for(int u=1;u<=n;u++){
            pos[S[u]-'a'].push_back(u);
            cnt[S[u]-'a']++;
            update(u,1);
        }
        int odd=0;
        for(int u=0;u<26;u++){
            odd+=cnt[u]%2;
            if(odd>1){
                cout<<-1;
                return ;
            }
        }
        ll ans=0;
        for(int u=1;u<=n;u++){
            if(vis[u])continue;
            int x=pos[S[u]-'a'].back();
            if(u==x){
                ans+=(ll)(query(n)-query(u))/2;
                update(u,-1);
            }
            else{
                ans+=(ll)(query(n)-query(x));
                update(u,-1);
                update(x,-1);
            }
            vis[u]=vis[x]=true;
            pos[S[u]-'a'].pop_back();
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 3448
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static final BigInteger MOD = new BigInteger("1000000007");

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final long n = in.nextLong();
        final long a = in.nextLong();
        final long b = in.nextLong();
        final long all = fast_pow(2, n) - 1;
        System.out.println((all - c(n, a) - c(n, b) + 2 * 1_000_000_007) % 1_000_000_007);
    }

    private static long c(long top, long bottom) {
        long result = 1;
        for (int i = 0; i < bottom; i++) {
            result *= top - i;
            result %= 1_000_000_007;
        }
        for (int i = 2; i <= bottom; i++) {
            final long target = new BigInteger(String.valueOf(i)).modInverse(MOD).longValue();
            result *= target;
            result %= 1_000_000_007;
        }
        return result;
    }

    private static long fast_pow(long base, long top) {
        if (top == 0) {
            return 1;
        }
        if (top == 1) {
            return base;
        }
        final long temp = fast_pow(base, top / 2) % 1_000_000_007;
        final long result = (temp * temp) % 1_000_000_007;
        if (top % 2 == 0) {
            return result;
        } else {
            return (base * result) % 1_000_000_007;
        }
    }
}


Measured memory_bytes: 95500
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    vector<int64_t> p(n);
    for (auto&& pp : p) {
        cin >> pp;
    }

    int64_t m = 0;
    for (auto i : irange(1L, n - 1)) {
        if (p[i] >= max(p[i - 1], p[i + 1])) {
            continue;
        }

        if (p[i] <= min(p[i - 1], p[i + 1])) {
            continue;
        }

        ++m;
    }

    cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
int n,a[200001],b[200001],cnt,ans=INF;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>s;
	for (int i=0;i<s.size();++i)
	{
		if (s[i]=='.') ++cnt;
		a[i]=cnt;
	}
	int cnt=0;
	for (int i=s.size()-1;i>=0;--i)
	{
		if (s[i]=='.') ++cnt;
		b[i]=cnt;
	}
	for (int i=0;i<s.size();++i) ans=min(ans,i+1-a[i]+b[i+1]);
	cout<<min(ans,b[0]);
	return 0;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
int n,k;
vector<bool>d(11,1);
bool check(int x){
	int m;
	while(x>0){
		m=x%10;
		if(!d[m])return 0;
		x/=10;
	}
	return 1;
}
int main(){
	int x;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		cin>>x;
		d[x]=0;
	}
	while(!check(n)){
		n++;
	}
	cout<<n;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (l, r, d) = readIntList()
    var ans = 0
    for (i in l..r) {
        if(i % d == 0) ans++
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


Measured memory_bytes: 36340
#include <iostream>

using namespace std;

int main() {
    int x, y; cin >> x >> y;
    bool ans = false;
    for (int i = 0; i <= x; i++) {
        int tsuru = i;
        int kame = x - i;
        int legs = tsuru * 2 + kame * 4;
        if (legs == y) {
            ans = true;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
package main

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

var count = 0

func merge(as []int, bs []int) []int {
	var result []int
	as = append(as, 1000000001)
	bs = append(bs, 1000000001)
	i := 0
	j := 0
	for {
		if i == len(as)-1 && j == len(bs)-1 {
			break
		}
		count++
		if as[i] < bs[j] {
			if as[i] < 1000000001 {
				result = append(result, as[i])
				i++
			}
		} else {
			if bs[j] < 1000000001 {
				result = append(result, bs[j])
				j++
			}
		}
	}
	return result
}

func mergeSort(xs []int) []int {
	if len(xs) == 1 {
		return xs
	}
	m := len(xs) / 2
	var as = make([]int, len(xs[:m]))
	copy(as, xs[:m])
	var bs = make([]int, len(xs[m:]))
	copy(bs, xs[m:])
	return merge(mergeSort(as), mergeSort(bs))
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func printArray(xs []int) {
	fmt.Println(strings.Trim(fmt.Sprint(xs), "[]"))
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = nextInt(sc)
	}
	result := mergeSort(xs)
	printArray(result)
	fmt.Println(count)
}



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

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

  set<int> S;
  map<int, int> T;
  rep(i,0,M-1) {
    int p; string s;
    cin >> p >> s;
    if (S.count(p) == 0)
      if (s == "WA") T[p]++;
      else S.insert(p);
  }

  int wa = 0;
  for (int i:S) wa += T[i];

  cout << S.size() << " " << wa << endl;
  return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>

int main()
{
	char s[10];
	scanf("%s", &s);
//ex : coffee berarti f pertama = berindeks 2
					//f kedua = index 3
					//e pertama= index 4
					//e kedua = index ke 5
					//c adalah index ke 0
	if (s[2]==s[3]&& s[4]==s[5]){
		puts("Yes");
		
	}	else
		puts("No");
	
	return 0;

}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define iter(i,a,b) for(i=a;i<b;i++)


int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
{

int n;
      cin>>n;
      if(n%1000==0)
        cout<<0;
      else{
        int h=n/1000;
        cout<<(h+1)*1000-n;
      }

		







}

return 0;
}






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

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

	int a[44];
	a[0] = a[1] = 1;

	for (int i=2; i<=N; i++)
		a[i] = a[i-1] + a[i-2];

	cout << a[N] << endl;

	return 0;
}



Measured memory_bytes: 3104
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;


#define X first
#define Y second
using namespace std;
typedef long long ll;
const ll inf = 1e18;

ll n;
pair<ll,ll> a[200005];

int main()
{
    cin >> n;
    vector<pair<ll,ll>> a(n);
    for(ll i=0;i<n;i++) {
        cin >> a[i].X >> a[i].Y;
        if(a[i].X > a[i].Y) swap(a[i].X, a[i].Y);
    }
    sort(a.begin(), a.end());
    ll XMIN =	inf, XMAX = -inf, YMIN = inf, YMAX = -inf;
    for(ll i=0;i<n;i++) {
        XMIN = min(a[i].X, XMIN);
        XMAX = max(a[i].X, XMAX);
        YMIN = min(a[i].Y, YMIN);
        YMAX = max(a[i].Y, YMAX);
    }
    ll ans = (XMAX - XMIN) * (YMAX - YMIN);

    ll red = YMAX - XMIN;
    ll bu, bl;
    bu = bl = a[0].second;
    for(ll i=1;i<n;i++) {
        ans = min(ans, red * (max(bu, a[n-1].first) - min(bl, a[i].first)));
        bl = min(bl, a[i].second);
        bu = max(bu, a[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
using namespace std;
int main() {
    string s;
    cin >> s;
    vector<int> ans(s.size(), 0);
    for(int i=0; i<s.size(); i++){
        for(int j=i; j<s.size(); j++){
           if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T'){
               ans[i]++;
           }else{
               break;
           }
        }
    }
    printf("%d", *max_element(ans.begin(), ans.end()));
}


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

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
        String st = sc.next();
        String Sunny = "Sunny", Cloudy = "Cloudy", Rainy = "Rainy";
        if(st.equals(Sunny)){
            System.out.print("Cloudy");
        }else if(st.equals(Cloudy)){
            System.out.print("Rainy");
        }else{
            System.out.print("Sunny");
        }
    }
}

Measured memory_bytes: 26624
#include<iostream>
#include<cstdlib>
using namespace std;
#define MAX 500000

struct Node{
  int key;
  Node *p, *r, *l;
};

int m;
Node *root, *NIL;

void inorder(Node* r){
  if ( r->l != NIL){
    inorder(r->l);
  }
  cout << " " << r->key;
  if ( r->r != NIL){
    inorder(r->r);
  }
}

void preorder(Node* r){
  cout << " " << r->key;
  if ( r->l != NIL){
    preorder(r->l);
  }
  if ( r->r != NIL){
    preorder(r->r);
  }
}

void print(){
  inorder(root);
  cout << endl;
  preorder(root);
  cout << endl;
}

void insert(int key){
  Node *y = NIL; // xの親
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));

  z->key = key;
  z->l = NIL;
  z->r = NIL;
  while( x != NIL){
    y = x;
    if ( z->key < x->key){
      x = x->l;
    } else {
      x = x->r;
    }
  }

  z->p = y;
  if ( y == NIL){
    root = z;
  } else if ( z->key < y->key){
    y->l = z;
  } else {
    y->r = z;
  }
}

Node* find(int key){
  Node *x = root;
  while( x != NIL){
    if ( key == x->key){
      return x;
    } else if ( key < x->key){
      x = x->l;
    } else {
      x = x->r;
    }
  }

  return NIL;
}

Node* getMinimum(Node *x){
  while( x->l != NIL){
    x = x->l;
  }
  return x;
}

Node* getSuccessor(Node *z){
  if ( z->r != NIL){
    return getMinimum(z->r);
  }

  Node* y = z->p;
  while( y != NIL && y->r == z){
    z = y;
    y = y->p;
  }
  return y;
}

void deleteKey(Node *z){
  if ( z->l == NIL && z->r == NIL ){
    if ( z->key < z->p->key){ z->p->l = NIL;}
    else { z->p->r = NIL;}
    free(z);
  } else if ( z->l != NIL && z->r != NIL){
    Node *next = getSuccessor(z);
    z->key = next->key;
    deleteKey(next);
  } else {
    Node *child;
    if ( z->l != NIL){ child = z->l; }
    else { child = z->r; }

    if ( z->key < z->p->key){
      z->p->l = child;
      child->p = z->p;
    } else {
      z->p->r = child;
      child->p = z->p;
    }
    free(z);
  }
}

int main(){
  cin >> m;
  string order;
  int key;
  for ( int i = 0; i < m; i++){
    cin >> order;
    if (order == "insert"){
      cin >> key;
      insert(key);
    } else if (order == "print") {
      print();
    } else if ( order == "find"){
      cin >> key;
      if(find(key) != NIL){cout << "yes" << endl;}
      else { cout << "no" << endl;}
    } else if ( order == "delete"){
      cin >> key;
      deleteKey(find(key));
    }
  }

  return 0;
}



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


int main()
{
    int t=1;
    //cin>>t;
    while( t-- )
    {
        ll n;
        cin>>n;

        ll a[n];

        for( int i=0 ; i<n ; i++ )
            cin>>a[i];

        sort( a,a+n );

        ll ans=a[n-1];


        ll left=(n-2),i=n-2;

        if( left%2==0 )
        {
            left=left/2;
            while( left-- )
            {
                ans+=2*a[i];
                i--;
            }
        }
        else
        {
            left=left/2;
            while( left-- )
            {
                ans+=2*a[i];
                i--;
            }
            ans+=a[i];
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 5172
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;
import std.typecons;

void main() {
  auto M = readln.chomp.to!int;

  long keta;
  long digits_mul;
  long digits_keta;
  foreach(n; 0..M) {
	long d, c; readf("%d %d\n", &d, &c);
	keta += c;
	digits_mul += c * d;
  }
  writeln(keta - 1 + (digits_mul - 1)/9);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL& x, LL& y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % m;
}

// nCk mod p
LL mod_comb(LL n, LL k, LL m)
{
	if (n < k) return 0;
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

int main()
{
	LL N, K;
	in >> N >> K;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	std::sort(A.begin(), A.end());
	mod_fact(N + 1, mod);

	LL ans = 0;
	for (LL i = K - 1; i < N; ++i)
	{
		LL res = A[i] * mod_comb(i, K - 1, mod) % mod;
		(ans += res) %= mod;
	}
	rep(i, N - K + 1)
	{
		LL res = A[i] * mod_comb(N - i - 1, K - 1, mod) % mod;
		(ans += mod - res) %= mod;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 1792
program main
implicit None
integer(8)::n,k,t,i,p
integer(8),allocatable::h(:)
	read *,n,k
	allocate(h(n))
	
	do i = 1,n
	read *,h(i)
	enddo
	
	call hsort(h,n)
	
	do i = 1,n-k+1
		p = h(i+k-1) - h(i)
		if(t > p .or. i == 1)then
			t = p
		endif
	enddo
	
	print 101,t
	
101 format(i0)
end program main

subroutine makeheap(a,n)
Implicit None
	integer(8)::n,i,c1,c2,p,t,m
	integer(8)::a(n)
	
	do i = n/2,1,-1
		p = i; c1 = i * 2
		do while (c1 <= n)
			c2 = c1 + 1
			if(c2 <= n .and. a(c2) > a(c1)) c1 = c2
			if(a(p) < a(c1))then
				t = a(p)
				a(p) = a(c1)
				a(c1) = t
				p = c1
				c1 = p*2
				else
					exit
			endif
		enddo
	enddo
	
end subroutine makeheap

subroutine hsort(a,n)
Implicit None
	integer(8)::n,t,i,p,c1,c2,j
	integer(8)::a(n)
	
	call makeheap(a,n)
	
	do i = n,2,-1
		t = a(i)
		a(i) = a(1)
		a(1) = t
		
		p = 1
		do
			c1 = p*2
			if (c1 >= i) exit
			
			c2 = c1 +1
			if(c2 < i .and. a(c2) > a(c1))then
					c1 = c2
			endif
			
			if(a(c1) >a(p))then
				t = a(p)
				a(p) = a(c1)
				a(c1) = t
				p = c1
				else
					exit
			endif
		enddo
	enddo
end subroutine hsort

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

void solve(int TestCase) {
    int n, m;
    cin >> n >> m;
    int ret = 0;
    if(n > 1)
        ret += (n - 1) * n / 2;
    if(m > 1)
        ret += (m - 1) * m / 2;
    
    cout << ret << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
        //cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i,m,n) for(ll i=m ; i<n ; i++)
#define forr(i,m,n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N =2e5+5;
using namespace std;
int main()
{
    //IO;
    int n,m,total;
    cin>>n>>m>>total;
    n=max(n,m);
    total%n==0?cout<<total/n:cout<<(total/n)+1;
  
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

"""
・対象のうさぎの期待値だけ分かれば、次時点での期待値が分かる
・期待値の差分Yを持つ。操作は、Y[i-1]とY[i]の交換
"""

N = int(readline())
X = np.zeros(N+1,np.int64)
X[1:] = readline().split()
M,K = map(int,readline().split())
A = list(map(int,read().split()))

Y = np.diff(X)

# newY[i] = Y[P[i]]
P = list(range(N))
for a in A:
    P[a],P[a-1] = P[a-1],P[a]
P = np.array(P)

def mult_perm(P,Q):
    return P[Q]

def power_perm(P,N):
    if N == 0:
        return np.arange(len(P))
    Q = power_perm(P,N//2)
    Q = mult_perm(Q,Q)
    return mult_perm(P,Q) if N & 1 else Q

Q = power_perm(P,K)

newY = Y[Q]
newX = np.cumsum(newY)

print('\n'.join(newX.astype(str)))

Measured memory_bytes: 42800
# 解法3(山登り法)

import numpy as np

N=int(input())
x=np.zeros([N,2])
for i in range(N):
  x[i,:] = list(map(float,input().split()))
  
def norm(x,y):return np.sqrt(((x - y)**2).sum())

x0 = x.mean(0)
old = x0
rate = 0.06
decay = 0.999
epsilon=1e-15

while 1:
  d = np.sqrt(((x - old)**2).sum(1))
  max_, argmax = d.max(), d.argmax()
  direction = x[argmax, :] - old
  new = old + direction*rate
  rate *= decay
  if norm(new,old) <= epsilon:break
  old = new

print(norm(direction, 0))

Measured memory_bytes: 27148
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	s.erase(unique(all(s)), s.end());
	cout << s.size() << endl;
	return 0;
}

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

using namespace std;

#define lli long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(lli i=1;i<=n;i++)

lli dp[100010][4];

int main(){

	string s;
	cin>>s;
	lli N = s.size();

	for(lli i=N;i>=0;i--){
		for(lli j=3;j>=0;j--){
			if(i==N){
				dp[i][j] = (j==3 ? 1:0);
			}
			else{
				dp[i][j] = dp[i+1][j] * (s.at(i)=='?'?3:1);
				if(j<3 && (s.at(i) == '?' || s.at(i) == "ABC"[j])){
					dp[i][j] += dp[i+1][j+1];
				}
				dp[i][j] %= MOD;
			}
		}
	}
	cout<<dp[0][0]<<endl;
	return 0;
}



Measured memory_bytes: 3584
N, H = list(map(int, input().split()))
A = [0]*N
B = [0]*N
for i in range(N):
    a, b = list(map(int, input().split()))
    A[i], B[i] = a, b
a = max(A)
T = 0
ct = 0
B = reversed(sorted(B))
for b in B:
    if b > a:
        ct += 1
        T += b
    if T >= H:
        break
print(ct + max((H-T+a-1)//a, 0))


Measured memory_bytes: 78444
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		Set<String> colors = new HashSet<>();

		for(int i=0;i<n;i++) {
			colors.add(sc.next());
		}
		if(colors.size()==4) {
			System.out.println("Four");
		}else {
			System.out.println("Three");
		}
	}
}

Measured memory_bytes: 21844
n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
S = {1}

while A[L[-1]-1] not in S:
  last = L[-1]-1
  L.append(A[last])
  S |= {A[last]}

a = A[L[-1]-1]
j = L.index(a)
r = len(L)
l = r - j

if k+1 <= j:
    print(L[k])
else:
    print(L[j+(k-j)%l])


Measured memory_bytes: 33380
a=int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d=0
for i in range(a):
    if b[i] <= c[i]: #討伐の方が多い
        d += b[i]
        if (c[i] - b[i]) <= b[i+1]:
            b[i+1] =b[i+1] - (c[i] - b[i])
            d += (c[i] - b[i])
        else:
            d += b[i+1]
            b[i+1] = 0
    else:
        d += c[i]

print(d)


Measured memory_bytes: 18624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    rep(i,n+1){
        int t = i * 1.08;
        if(t == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


Measured memory_bytes: 888
#include<stdio.h>
 
int main()
{
  int room[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
room[b-1][f-1][r-1]+=v;

      
    
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",room[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}



Measured memory_bytes: 2084
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int n;
	cin >> n;
	int a[n];

	for(int i=0;i<n;i++) cin >> a[i];

	int num=0;

	bool check = true;

	for(int i=0;i<n;i++) {
		num = a[num]-1;
		if(num == 1) {
			check = false;
			cout << i+1 << endl;
			break;
		}
	}

	if(check) cout << -1 << endl;
}


Measured memory_bytes: 640
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 310000
ll MOD=998244353;

vector<vec> G(N);
pii mem={0,0};
void dfs(int x,int y,int p){
    if(mem.second<y)mem={x,y};
    for(auto u:G[x]){
        if(u!=p){
            dfs(u,y+1,x);
        }
    }
}
main(){
    int n=in();
    rep(i,n-1){
        int a=in(),b=in();
        G[a].pb(b);G[b].pb(a);
    }
    dfs(1,0,0);
    mem.second=0;
    dfs(mem.first,0,0);
    if((mem.second-1)%3){
        cout<<"First";
    }
    else cout<<"Second";
}



Measured memory_bytes: 23168
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int five_hundred_yen = x / 500;
        x = x % 500;
        int five_yen = x / 5;
        System.out.println((five_hundred_yen * 1000) + (five_yen * 5));
        sc.close();
    }
}


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

ll cnt[10][10]; // cnt[a][b] := 先頭がaで末尾がbの数の個数
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int N;
    cin >> N;
    for(int i=1;i<=N;i++){
        int head = to_string(i)[0] - '0';
        int end  = i%10;
        cnt[head][end]++;
    }
    ll ans = 0;
    for(int i=1;i<=9;i++)for(int j=1;j<=9;j++){
        ans += cnt[i][j] * cnt[j][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256