akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>

using namespace std;
typedef long long int ll;

int main()
{
	int n;
	ll a[100000];
	multimap<ll, int, greater<ll> > mp;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		mp.insert(make_pair(a[i], i));
	}
	ll ans[100000]={};
	set<int> st;
	ll a0;
	for(auto itr=mp.begin(); itr!=mp.end(); itr++){
		ll a1=itr->first, i1=itr->second;
		if(itr==mp.begin()){
			a0=a1;
			st.insert(i1);
		}else if(a1==a0){
			st.insert(i1);
		}else{
			auto b=st.begin();
			int i0=*b;
			int m=st.size();
			ans[i0]+=((a0-a1)*m);
			a0=a1;
			st.insert(i1);
		}
	}
	auto b=st.begin();
	int i0=*b;
	int m=st.size();
	ans[i0]+=(a0*m);
	for(int i=0; i<n; i++){
		printf("%lld\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 13568
/*
    Problem 95
    https://atcoder.jp/contests/abc149/tasks/abc149_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    ll tmp = A;
    A = max(A - K, 0LL);
    K = max(K - tmp, 0LL);
    B = max(B - K, 0LL);
    cout << A << ' ' << B << '\n';
}


Measured memory_bytes: 3624
#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;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(a.rbegin(),a.rend());
    ll ans=0;
    int cnt=n-1;
    rep(i,(n-1)/2){
        ans+=a[i];
        cnt--;
    }
    int i=1;
    while(cnt--){
        if(cnt==0&&n%2==0){
            ans+=a[i-1];
            break;
        }
        ans+=a[i];
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4024
// Author : Radhesh Sarma
   #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N =  200005;

    int dp[N];

    int n,k,r,p,s;
      string str;
    char winner(char ch)
    {
      if(ch == 'r')
      {
        return 'p';
      }
      if(ch == 's')
      {
        return 'r';
      }
      if(ch == 'p')
      {
        return 's';
      }
    }

    int pts(char ch)
    {
        if(ch == 'r')
      {
        return r;
      }
      if(ch == 's')
      {
        return s;
      }
      if(ch == 'p')
      {
        return p;
      }
    }
    bool ok[N];

  int32_t main() 
  {
    IOS

      
     
     cin >> n >> k >> r >> s >> p >> str;


     rep(i,0,n+1)
     {
      ok[i] = true;
     }
     // trace6(n,k,r,s,p,str);

     for(int i = 1; i <=k; i++)
     {
      dp[i] = dp[i-1] + pts(winner(str[i-1]));
    // trace4(i,str[i-1],winner(str[i-1]),pts(winner(str[i-1])));
     }

     for(int i = k + 1; i <= n; i++)
     {
      //trace4(i,str[i-1],winner(str[i-1]),pts(winner(str[i-1])));

      if((str[i-1]) == str[i-1 -k] and ok[i-k-1])
      {
       // trace2(i,str[i-1]);
        dp[i] = dp[i-1];
        ok[i-1] = false;
      }
      else
      {

        dp[i] = dp[i-1] + pts(winner(str[i-1]));
      }
     }

     rep(i,1,n)
     {
      //trace2(i,dp[i]);
     }

     cout << dp[n];
    
    return 0;
  }

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);

  if (N > 2 && M > 2) {
    put((N - 2) * (M - 2));
    return 0;
  }

  if (N > M) swap(N, M);
  if (N == 1) {
    ll ans = 0;
    if (M == 1) ans = 1;
    if (M > 1) ans = M - 2;
    put(ans);
    return 0;
  }

  put(0);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n,@m = gets.split.map(&:to_i)
    @g = Array.new(n){ [] }
    m.times do
      l,r,d = gets.split.map(&:to_i)
      l -= 1
      r -= 1
      g[l] << [r,d]
      g[r] << [l,-d]
    end
  end

  def bfs(init)
    q = [init]
    while q.size > 0
      v = q.shift
      g[v].each do |nv,diff|
        yield v,nv,diff,q
      end
    end
  end

  def solve
    seen = Array.new(n,nil)
    n.times do |i|
      next unless seen[i].nil?
      seen[i] = 0
      bfs(i) do |v,nv,diff,q|
        if seen[nv].nil?
          seen[nv] = seen[v] + diff
          q << nv
        elsif seen[v] + diff != seen[nv]
          return false
        end
      end
    end
    true
  end

  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  show(solve)
  # pp self
end

Measured memory_bytes: 50812
/* AUTHOR :  SHIVANK JAIN */

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

#define ll long long
#define li long int

#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define reprev(i,n,a) for(int i=n;i>=a;i--)
#define endl "\n"

#define vi vector<int>
#define vll vector<ll>
#define vpi vector< pair<int , int> >
#define mapi map<int , int>
#define mapll map<ll ,ll >
#define seti set<int> 

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define sort(v) sort(v.begin() , v.end())

#define BIG 1000000007
int gcd(int a, int b) 
{ // builtin function __gcd(a,b)
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){

     fast;itt;now;
 
//    #ifndef ONLINE_JUDGE
//    // for getting input from input.txt
//    freopen("input.txt", "r", stdin);
//    // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
//    #endif
    ll k ;  cin>>k;
     string s ;  cin>>s;
     
     if(k >= s.size())
      cout<<s<<endl;
     else{
     	rep(i,0,k)
     	 cout<<s[i];
     	 cout<<"..."<<endl;
	 } 
}

Measured memory_bytes: 3644
total = 0
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
for i in range(x[0]):
  z = [int(k) for k in input().split()]
  cnt = 0
  for j in range(len(z)):
    cnt += z[j]*y[j]
  if cnt + x[2] > 0:
    total+=1
print(total)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

const int MOD = 1000000007;

typedef pair<int, int> edge;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	string S1, S2;
	cin >> S1 >> S2;


	long long ans = 1;
	int idx = 0;
	bool vert = false;

	if (S1[idx] == S2[idx]) {
		ans = 3;
		vert = true;
		idx += 1;
	} else {
		ans = 6;
		idx += 2;
	}

	while (idx < N) {
		if (S1[idx] == S2[idx]) {
			if (vert) {
				ans *= 2;
			} else {
				ans *= 1;
			}
			idx += 1;
			vert = true;
		} else {
			if (vert) {
				ans *= 2;
			} else {
				ans *= 3;
			}
			idx += 2;
			vert = false;
		}

		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100010
int main() {
	int flag=0,ans=0;
	char c=getchar();
	while(isdigit(c)) {
		if(c!='0') flag++;
		ans+=c-'0';
		c=getchar();
	}
	if(flag==1&&ans==1) {
		puts("10");
		return 0;
	}
	printf("%d\n",ans);
}

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

ll N, AI;
map<ll, ll> A;

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

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

	ll ans = 0;
	for (auto x : A) {
		if (x.second < x.first) {
			ans += x.second;
		}
		else {
			ans += x.second - x.first;
		}
	}

	cout << ans << "\n";

}

Measured memory_bytes: 6272
#B
A,B = list(map(int, input().split()))
ans = 0
s = A
if B == 1:
    print(ans)
else:
    ans = 1
    for i in range(B):
        if  s >= B:
            print(ans)
            break
        else:
            s = s + A -1
            ans += 1

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import java.lang.*;

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

        if (a == 3 || a == 5 || a == 7)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  int K = nextLong();
  vector<ll> A(N);
  REP(i, N) A[i] = nextLong();

  REP(_, K) {

    if (count(ALL(A), N) == N) break;

    // pv(ALL(A));
    vector<ll> B(N);

    REP(i, N) {
      B[max(0LL, i - A[i])]++;

      int right = min((ll)N, 1 + i + A[i]);
      if (right < N) B[right]--;
    }
    for (int i = 1; i < N; i++) {
      B[i] += B[i-1];
    }

    swap(A, B);
  }
  pv(ALL(A));


  return 0;
}

int main() {

  // int N = 200000;
  // cout << N << " " << 10 << endl;
  // REP(i, N)
  //   cout << 0 << " ";
  // cout << endl;
  // return 0;
#ifdef LOCAL
  // for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 6772
import sys
S = list(input())
s = list(set(S))
s.sort()
alfa = list('abcdefghijklmnopqrstuvwxyz')
ans = 0
if(len(s)==len(alfa)):
  print('None')
  sys.exit()
else:
  for i in range(len(s)):
    if(s[i]!=alfa[i]):
      print(alfa[i])
      sys.exit()
  print(alfa[len(s)])

Measured memory_bytes: 9684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const int n_max=3010;
ll dp[n_max][n_max][3];
const int mod = 998244353;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n,s;
  cin >> n >> s;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  dp[0][0][0]=1;
  rep1(i,n){
    rep(l,s+1){
      dp[i][l][0] += dp[i-1][l][0];
      dp[i][l][1] += dp[i-1][l][0] + dp[i-1][l][1];
      dp[i][l][2] += dp[i-1][l][0] + dp[i-1][l][1] + dp[i-1][l][2];
      if(l+a[i-1] <= s){
	dp[i][l+a[i-1]][1] += dp[i-1][l][0] + dp[i-1][l][1];
	dp[i][l+a[i-1]][2] += dp[i-1][l][0] + dp[i-1][l][1];
      }
      rep(j,3)dp[i][l][j] %= mod;
    }
    //    cout << dp[i][s][2] << endl;
  }
  cout << dp[n][s][2] << endl;
  
  return 0;
    

}


Measured memory_bytes: 211968
import re

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(input())

MOD = int(1e9) + 7

acgt = ["A", "C", "G", "T"]
changed = list(map(lambda pat: re.compile(pat), [r"AGC", r"GAC", r"ACG", r"A.GC", r"AG.C"]))
abcl = [ a+b+c for a in acgt for b in acgt for c in acgt]

dp = {}
for now in abcl:
    if any(map(lambda ch: ch.search(now), changed)):
        dp[now] = 0
    else:
        dp[now] = 1

N -= 3

while N > 0:
    dpNow = {}
    for abc in abcl:
        abc = abc[:min(N, 3)]
        dpNow[abc] = 0
        for key, value in dp.items():
            now = key + abc
            if not any(map(lambda ch: ch.search(now), changed)):
                dpNow[abc] += value
                dpNow[abc] %= MOD
    dp = dpNow
    N -= 3

ans = 0
for v in dp.values():
    ans += v
    ans %= MOD

print(ans)


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

using namespace std;

struct DisjointSet/*{{{*/
{
    vector<int> parent;

    int root(int x)
    {
        if (parent[x] < 0) {
            return x;
        } else {
            parent[x] = root(parent[x]);
            return parent[x];
        }
    }

    explicit DisjointSet(int n) : parent(n, -1) {}

    bool unite(int x, int y)
    {
        const int a = root(x);
        const int b = root(y);
        if (a != b) {
            if (parent[a] < parent[b]) {
                parent[a] += parent[b];
                parent[b] = a;
            } else {
                parent[b] += parent[a];
                parent[a] = b;
            }
            return true;
        } else {
            return false;
        }
    }

    bool find(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -parent[root(x)]; }
};/*}}}*/

struct Edge {
    int a, b;
    int cost;

    bool operator <(const Edge &other) const {
        return cost < other.cost;
    }
};

bool solve() {
    int N, M;
    if(!(cin >> N >> M)) return false;
    if(!N && !M) return false;

    vector<Edge> edges(M);
    for(int i = 0; i < M; ++i) {
        Edge &e = edges[i];
        cin >> e.a >> e.b >> e.cost;
        e.a--;
        e.b--;
    }
    sort(edges.begin(), edges.end());
    DisjointSet ds(N);
    int cnt = 0;
    for(Edge &e : edges) {
        if(ds.unite(e.a, e.b)) {
            ++cnt;
            if(cnt == N/2) {
                cout << e.cost << endl;
                break;
            }
        }
    }
    return true;
}

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

    while(solve()) ;
    return 0;
}

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

signed main(void)
{
	int n, x, ans;
	string s;
	cin >> n >> s;
	x = ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'I')
			x++;
		else if (s[i] == 'D')
			x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
LL n,pw=1;
int cal(LL x){
	int ans=0;
	while (x)
		ans+=x%10,x/=10;
	return ans;
}
int main(){
	n=read();
	int ans=cal(n);
	while (n){
		ans=max(ans,cal(n*pw-1));
		pw*=10,n/=10;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int nmax=105;
struct edge{int to;int cost;};
vector<edge> tree[nmax];
int dist[nmax];
int n;
void dijkstra(int s){
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
  fill(dist,dist+n,1e9);
  dist[s]=0;
  pq.push(make_pair(0,s));
  while(!pq.empty()){
    pair<int,int> p=pq.top();
    pq.pop();
    int v=p.second;
    if(dist[v]<p.first){
      continue;
    }
    for(int i=0;i<tree[v].size();i++){
      edge e=tree[v][i];
      if(dist[e.to]>dist[v]+e.cost){
        dist[e.to]=dist[v]+e.cost;
        pq.push(make_pair(dist[e.to],e.to));
      }
    }
  }
}
int main(){
  int m;
  cin >> n >> m;
  vector<int> a(m),b(m),c(m);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
    tree[a[i]].push_back(edge{b[i],c[i]});
    tree[b[i]].push_back(edge{a[i],c[i]});
  }
  vector<vector<int>> d(n,vector<int>(n,1e9));
  for(int i=0;i<n;i++){
    dijkstra(i);
    for(int j=0;j<n;j++){
      d[i][j]=dist[j];
    }
  }
  int cnt=0;
  for(int i=0;i<m;i++){
    bool f=true;
    for(int j=0;j<n;j++){
      if(d[j][a[i]]+c[i]==d[j][b[i]]){
        f=false;
      }
    }
    if(f){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int kazu = sc.nextInt();
		int iro = sc.nextInt();
		int SUM = iro;

		for(int i = 1; i < kazu; i++) {
			SUM = SUM * (iro - 1);
		}
		System.out.print(SUM);
	}
}

Measured memory_bytes: 23764
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

int main()
{
    fast
    lli n;
    cin>>n;
    string str;
    while(n)
    {
        lli tp=n%26;
        // print(tp)
        if(tp>0)
        {
            tp--;
            char ch='a'+tp;
            str=str+ch;
            n=n/26;
        }
        else
        {
            str=str+'z';
            n=(n-1)/26;
        }
    }
    reverse(str.begin(),str.end());
    cout<<str;
}
//a+b=a?b+2?(a&b)
//a+b==(a&b)+(a|b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";



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

int main() {
  double a,b,c,s,l,h,pi = 0;
  cin >> a >> b >> c;
  pi = acos(-1);
  c = c*pi/180.0;
  s = a*b*sin(c)*0.5;
  l = b*b + a*a - 2*b*a*cos(c);
  l = sqrt(l)+ a + b;
  h = b*sin(c);
  cout << fixed << setprecision(10) << s << endl;
  cout << fixed << setprecision(10) << l << endl;
  cout << fixed << setprecision(10) << h << endl;
  return 0;
}


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

int main(){
    int N;
    while(cin>>N && N){
        int a[21][21]={};
        for(int i=0;i<N;i++){
            int x,y;
            cin>>x>>y;
            a[y][x]=1;
        }
        int M;
        cin>>M;
        int x=10,y=10;
        for(int i=0;i<M;i++){
            int z;
            char h;
            cin>>h>>z;
            for(int k=0;k<z;k++){
                if(h=='E'){
                    x++;
                }else if(h=='W'){
                    x--;
                }else if(h=='N'){
                    y++;
                }else{
                    y--;
                }
                a[y][x]=0;
            }
        }
        int count=0;
        for(int i=0;i<21;i++){
            for(int j=0;j<21;j++){
                count+=a[i][j];
            }
        }
        if(count==0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 2996
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		var h = read();
		var k = (int)h[1];
		var s = new int[h[0]].Select(_ => read()).OrderByDescending(x => x[1]).ToArray();

		var g0 = s.Take(k).ToLookup(x => x[0], x => x[1]);
		var l0 = g0.SelectMany(g => g.Skip(1)).OrderBy(x => x).ToList();
		var l1 = s.Skip(k).Where(x => !g0.Contains(x[0])).GroupBy(x => x[0]).Select(g => g.First()[1]).OrderByDescending(x => x).ToList();

		var f = new long[Math.Min(l0.Count, l1.Count) + 1];
		f[0] = g0.SelectMany(x => x).Sum() + (long)g0.Count * g0.Count;
		for (int i = 1; i < f.Length; i++) f[i] = f[i - 1] + l1[i - 1] - l0[i - 1] + 2 * (g0.Count + i - 1) + 1;
		Console.WriteLine(f.Max());
	}
}


Measured memory_bytes: 38976
N=int(input())
c=[[0 for _ in range(10)] for _ in range(10)]
for h in range(1,N+1):
    num=str(h)
    c[int(num[-1])][int(num[0])]+=1

ans=0
for i in range(10):
    for j in range(10):
        ans+=c[i][j]*c[j][i]

print(ans)

Measured memory_bytes: 3064
N = int(input())
num = input().split()
ans = int(num[0])
cov = 10**18
if ('0' in num):
  ans = 0  
else:
  for i in range (int(N)-1):
    if ans == -1 or ans == 0:
      break
    else:
      ans *= int(num[i+1])
    if int(ans) > int(cov):
      ans = -1
print(ans)
    

Measured memory_bytes: 19396
#include<bits/stdc++.h>
using namespace std;
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%lld%lld", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
ll dp[100005],v[105],w[105];
ll maxm(ll a,ll b){
	return a>b?a:b;
}
int main(){
	ll n,W;
	while(~getII(n,W)){
		for(ll i=0;i<=W;i++) dp[i]=0;
		F(i,0,n) getII(w[i],v[i]);
		F(i,0,n) for(ll j=W;j>=w[i];j--) dp[j]=maxm(dp[j-w[i]]+v[i],dp[j]);
		printf("%lld\n",dp[W]);
	}
}


Measured memory_bytes: 1024
'use strict';

function main(inputs) {
  let i = 0;
  let input = inputs.split('\n');
  let numbers = input[1].split(' ');
  console.log(count_up(numbers, i));
}

function count_up(numbers, i) {
  let results = [];
  for (let k = 0, len = numbers.length; k < len; k++) {
    if (parseInt(numbers[k]) % 2 === 0) {
      results.push(numbers[k] / 2);
    } else {
      return i;
    }
  }
  i += 1;
  return count_up(results, i);
}

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


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll search(vll& A, vb& flag, ll start){
  ll tmp = INFLL;
  ll start_copy = start;
  if(start%10>0){
    start -= start%10;
    start += 10;
  }
  REP(i,5){
    if(flag[i]) continue;
    flag[i] = true;
    chmin(tmp, search(A, flag, start+A[i]));
    flag[i] = false;
  }
  if(tmp==INFLL) return start_copy;

  return tmp;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  vll A(5);
  REP(i,5) IN(A[i]);

  vb flag(5, false);

  OUT(search(A, flag, 0));

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,c,k;cin>>n>>c>>k;
    ll t[n];for(ll i=0;i<n;i++)cin>>t[i];
    sort(t,t+n);
    ll ans = 0,cur=0,cnt=0;
    for(ll i=0;i<n;i++){
        if(t[i]>cur || cnt>=c){
            ans++;
            cur=t[i]+k;
            cnt=1;
        }
        else cnt++;
    }
    cout<<ans;
}

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

using namespace std;


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

    int dp[s.length()+1][t.length()+1];
    for(int i=0; i<=s.length(); i++){
        for(int j=0; j<=t.length(); j++){
            if(i == 0 || j == 0){
                dp[i][j] = 0;
            }else if(s[i-1] == t[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    string ans;
    int i = s.length(), j = t.length();
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans.push_back(s[i-1]);
            i--;
            j--;
        }else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }else{
            j--;
        }
    }

    reverse(ans.begin(), ans.end());

    cout << ans << "\n";

    return 0; 
} 

Measured memory_bytes: 35456
a,b,c = map(int,input().split())
if a < b:
    if b < c:
        print(a,b,c)
    else:
        if a < c:
            print(a,c,b)
        else:
            print(c,a,b)
else:
    if a < c:
        print(b,a,c)
    else:
        if b < c:
            print(b,c,a)
        else:
            print(c,b,a)


Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <iomanip>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<double> vec(N);

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

    sort(vec.begin(),vec.end());

    double keep = (vec[0]+vec[1])/2;

    double ans = keep;

    for(int i=2;i<N;i++){

        keep = (keep + vec[i])/2;

        ans +=  keep;

    }

    cout << keep << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
        
n,m = map(int,input().split())

uf = UnionFind(n)
for _ in range(m):
    x,y,z = map(int,input().split())
    uf.union(x-1, y-1)
    
print(uf.group_count())

Measured memory_bytes: 69592
import java.util.*;

public class Main{
    public static void main(String[] args){
        int h, w;
        int i, j, k = 0;
        String n = System.getProperty("line.separator");
        Scanner scanner = new Scanner(System.in);
        String nu;
        while(true){
            nu = scanner.next();
            h = Integer.parseInt(nu);
            nu = scanner.next();
            w = Integer.parseInt(nu);
            if(h == 0 && w == 0) break;
            else{
                for(i = 0; i < h; i++){
                    for(j = 0; j < w; j++){
                        if((j + i)% 2 == 0){
                            System.out.print("#");
                        }
                        else System.out.print(".");
                    }
                    System.out.print(n);

                }
            }
            k = 0;
            System.out.print(n);
        }
        scanner.close();
    }
}


Measured memory_bytes: 37792
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	string s;
	cin >> s;
	int ans=1;
	if(s.at(0)!='A'){
		ans=0;
	}
	if(s.at(1)<'a' || s.at(1)>'z'){
		ans=0;
	}
//	cout << ans << endl;
	int flag=0;
	for(int i=2; i<s.size()-1; i++){
		if(s.at(i)=='C'){
			if(flag==0){
				flag=1;
			}else{
				ans=0;
			}
		}else{
			if(s.at(i)<'a' || s.at(i)>'z'){
				ans=0;
			}
		}
	}
//	cout << ans << endl;
	if(flag==0){
		ans = 0;
	}
	if(s.at(s.size()-1)<'a' || s.at(s.size()-1)>'z'){
		ans=0;
	}

	if(ans){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

void solve(){
    int n ;
    cin >> n ;
    vi a(n) ;
    for(auto& x : a) cin >> x ;
    map<int,int> mp ;
    int ans = 0 ;
    for(int i = 0 ; i < n ; i++){
        mp[i-a[i]]++ ;
    }
    for(int i = 0 ; i < n ; i++){
        ans += mp[i+a[i]] ;
    }
    cout << ans << endl ;
}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner(System.in);
		String A=sc.nextLine();
		char b[]=A.toCharArray();
		long N=b.length;
		Arrays.sort(b);
		int i=0;char x='a';long c=0;
		long ans=N*(N-1)/2+1;
		while(i<N) {
			while(i<N&&x==b[i]) {
				c++;i++;
			}
			ans=ans-c*(c-1)/2;
			x++;
			c=0;
		}
		
		System.out.println(ans);
	}
}


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

int main() {
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (int i = 0; i < R; i++) cin >> r.at(i);
  sort(r.begin(), r.end());
  vector<vector<int>> G(N, vector<int>(N, 1000000000));
  for (int i = 0; i < N; i++) G.at(i).at(i) = 0;
  for (int i = 0; i < M; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    G.at(A-1).at(B-1) = C;
    G.at(B-1).at(A-1) = C;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        G.at(i).at(j) = min(G.at(i).at(j), G.at(i).at(k) + G.at(k).at(j));
      }
    }
  }
  int ans = 1000000000;
  do {
    int dis = 0;
    for (int i = 0; i < R-1; i++) {
      dis += G.at(r.at(i)-1).at(r.at(i+1)-1);
    }
    ans = min(ans, dis);
  } while (next_permutation(r.begin(), r.end()));
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>

using namespace std;


#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//wrong answer

int main(){

  while(1){

	int n,m;
	double p;
	int x[200];
	int ans;
	double sum=0;

	cin >> n >> m >> p;

	if(n==0&&m==0&&p==0)
	  break;

	m--;

	REP(i,n){
	  cin >> x[i];
	  sum += x[i];
	}

	sum = sum * 100;
	if(x[m]==0){
	  ans = 0;
	}else{
	  ans = sum * (100-p)/100 / x[m];
	}

	cout << ans <<endl;

  }

}

Measured memory_bytes: 1228
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int minn=987654321,res=0;
    forn(i,n)
    {
        int x;
        scanf("%d",&x);
        if(x<=minn)
        {
            minn=x;
            res++;
        }
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 128
h,w,d=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(h)]
q=int(input())
LR=[list(map(int,input().split())) for _ in range(q)]

B=[[] for _ in range(h*w+1)]
for i in range(h):
    for j in range(w):
        B[A[i][j]]=[i,j]

DP=[0]*(h*w+1)
for i in range(d+1,h*w+1):
    x,y=B[i]
    z,w=B[i-d]
    DP[i]=DP[i-d]+abs(x-z)+abs(y-w)

for l,r in LR:
    print(DP[r]-DP[l])

Measured memory_bytes: 42252
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

void solve()
{
	int n;
	cin>>n;
	
	double arr[n];
	
	rep(i,0,n)
	{
		cin>>arr[i];
	}
	
	double dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,1,n+1)
	{
		dp[0][i]=dp[0][i-1]*(1-arr[i-1]);
	}
	rep(i,1,n+1)
	{
		rep(j,i,n+1)
		{
			dp[i][j]=dp[i-1][j-1]*arr[j-1]+dp[i][j-1]*(1-arr[j-1]);
		}
	}
	
//	rep(i,0,n+1)
//	{
//		rep(j,0,n+1)
//		{
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	double ans=0;
	
	for(int i=(n+1)/2;i<=n;i++)
	{
		ans=ans+dp[i][n];
	}
	cout<<setprecision(9)<<ans<<endl;
}


signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t=1;
		while(t--)
		{
			solve();
		}
}

Measured memory_bytes: 70656
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int BinarySearchUnder(int a[], int l, int r, int val) // 昇順
{
  int idx = (r + l) / 2;
  if (l - r >= 0)
    return l;
  else
  {
    if (val > a[idx])
      return BinarySearchUnder(a, l, idx, val);
    else
      return BinarySearchUnder(a, idx + 1, r, val);
  }
}

int main(void)
{
  int n, a[100001];
  scanf("%d", &n);

  int ai;
  for (ai = 0; ai < n; ai++)
    scanf("%d", &a[ai]);

  int colors[100001];
  int ci, size = 1;
  colors[0] = a[0];
  for (ci = 1; ci < n; ci++)
    colors[ci] = -1;

  for (ai = 1; ai < n; ai++)
  {
    ci = BinarySearchUnder(colors, 0, size - 1, a[ai]);
    if (ci == size - 1 && colors[ci] >= a[ai])
      colors[size++] = a[ai];
    else
      colors[ci] = a[ai];
  }

  printf("%d\n", size);
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main(void){
	int n,a,min,max;
	long long sum;
	cin>>n;
	cin>>a;
	min=a;
	max=a;
	sum=a;
	for(int i=1;i<=n-1;i++){
		cin>>a;
		if(min>a) min=a;
		if(max<a) max=a;
		sum=sum+a;
	}
	cout<<min<<" "<<max<<" "<<sum<<endl;
	return 0;
}

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

int main()
{
   int n,k;
   int ans=0;
   scanf("%d%d",&n,&k);
   while(n--)
   {
       int b;
       scanf("%d",&b);
       if(b>=k)
        ans++;
   }
   cout<<ans;
}

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

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  string s;
  cin >> s;
  int toppings = 0;
  for (auto& e : s) toppings += e == 'o';
  cout << 700 + toppings * 100 << "\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>

constexpr unsigned int MAX_INPUT = 4e5 + 5e4;
char Input[MAX_INPUT];
char* input = Input;

template <class Integer = long long int>
inline Integer get(void){
    Integer res = 0;
    if(*input == '-'){
        while(*(++input) >= '0'){ res = 10 * res + *input - '0'; }
        return -res;
    }
    do{ res = 10 * res + *(input++) - '0'; } while(*input >= '0');
    return res;
}

struct circle{
    long long int x, y;
    int radius;
    circle(void):x(),y(),radius(){}
    static double distance(const long long int dx, const long long int dy){
        return __builtin_sqrt(dx * dx + dy * dy);
    }
    inline void in0(void){x = get(); input++; y = get(); input++;}
    inline void in(void){ x = get(); input++; y = get(); input++; radius = get<int>(); input++;}
    inline double distance(const circle& other){
        double d = distance(x - other.x, y - other.y) - (radius + other.radius);
        return (d < 0) ? 0 : d;
    }
};

inline void chmin(double& v, const double val){ if(v > val) v = val; }

using uint = unsigned int;
constexpr uint MAX_N = 1000;
constexpr double inf = 3e18 + 3e17 + 4e16;
circle Point[MAX_N + 2];
bool visited[MAX_N + 2];
double dist[MAX_N + 2];

int main(void){
    fread(Input, sizeof(char), MAX_INPUT, stdin);

    Point[0].in0(); Point[1].in0();

    uint n = get(); input++;
    Point[++n] = Point[1]; dist[n] = inf;

    for(uint i = 1; i < n; ++i) { Point[i].in(); dist[i] = inf;}

    for(uint _ = 0, s = 0; _ < n; ++_){
        double min = inf; uint nearest = 0; visited[s] = true;
        for(uint v = 1; v <= n; ++v) if(not visited[v]){
            const double d = Point[s].distance(Point[v]);
            chmin(dist[v], dist[s] + d);
            if(min > dist[v]){ min = dist[v]; nearest = v; }
        }
        s = nearest;
        if(s == n) break;
    }
    printf("%.16lf\n", dist[n]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
int main()
{
    IOS
    int a,b,c;  cin>>a>>b>>c;
    if(a == b && b == c)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

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

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

  int ans = 0;
  for (char i = '0'; i <= '9'; ++i) {
    for (char j = '0'; j <= '9'; ++j) {
      for (char k = '0'; k <= '9'; ++k) {
        int a = 0;
        rep(l, n) {
          if (a == 0 && s[l] == i) ++a;
          else if (a == 1 && s[l] == j) ++a;
          else if (a == 2 && s[l] == k) ++a;
        }
        if (a == 3) ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> a[11];
int p[11];
int main()
{
	int n, k; 
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int x; cin >> x;
		for (int j = 0; j < x; j++) {
			int y; cin >> y;
			a[i].push_back(y);
		}
	}

	for (int i = 0; i < k; i++)cin >> p[i];

	int ans = 0;

	for (int i = 0; i < (1 << n); i++) {
		bool f = false;
		for (int j = 0; j < k; j++) {
			int cnt = 0;
			for (int o = 0; o < a[j].size(); o++) {
				if (i & (1 << (a[j][o] - 1))) {
					cnt++;
				}
			}
			cnt %= 2;
			if (cnt != p[j]) {
				f = true; break;
			}
		}
		if (!f)ans++;
	}
	cout << ans << '\n';
}
// 11111   
// 1 번 : 2   2 번 : 2 3                       


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>

char str[1001];
char s[100][1001];
int m=0;
int print(int, int);
int reverse(int, int);
int replace(int, int, char p[]);

int main(void){
int n,i,j,k,a,b;
scanf("%s",str);
scanf("%d",&n);

for(i=0;i<n;i++){
	char command[20],com[10];
		scanf("%s",com);
		scanf("%d%d",&a,&b);

	if(strcmp(com,"print")==0){
		print(a,b);
	}else if(strcmp(com,"reverse")==0){
		reverse(a,b);
	}else if(strcmp(com,"replace")==0){
		char p[b-a+3];
		scanf("%s",p);
		replace(a,b,p);
	}
};
for(i=0;i<m;i++){
	printf("%s\n",s[i]);
}
return 0;
}

int print(int a,int b){
int i;
for (i=0;i<=b-a;i++){
	s[m][i]=str[i+a];
}
	s[m][b-a+1]='\0';
	m++;

return 0;
}

int reverse(int a,int b){
char t[b-a+1];
int i;
for(i=0;i<=b-a;i++){
	t[i]=str[a+i];
};
for(i=0;i<=b-a;i++){
	str[b-i]=t[i];
};
return 0;
}

int replace(int a,int b,char p[]){
int i;
for(i=0;i<=b-a;i++){
	str[a+i]=p[i];
}
return 0;
}

Measured memory_bytes: 2624
#include<iostream>
using namespace std;
int d[1<<17]={0},n,q,a,b,c;
int main(){
	cin>>n>>q;
	while(q--){
		cin>>a>>b>>c;
		if(a){
			a=0,b--;
			while(b)a-=d[b],b-=b&-b;
			while(c)a+=d[c],c-=c&-c;
			cout<<a<<endl;
		}
		else while(b<=n)d[b]+=c,b+=b&-b;
	}
	return 0;
}

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


int main(){
  int N, A, c, i, max = 50;

  cin >> N;
  
  for(i = 0; i < N; i++){
    cin >> A;
    c = 0;
    while(A % 2 == 0){
      A /= 2;
      c++;
    }
    if(c < max)
      max = c;
  }
  
  cout << max << endl;    
}


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 n, k; cin >> n >> k;
    int r, s, p; cin >> r >> s >> p;
    string t; cin >> t;

    int score = 0;
    rep(i, n) {
        if(k <= i && t[i-k] == t[i]) t[i] = 0;
        if(t[i] == 'r') score += p;
        if(t[i] == 's') score += r;
        if(t[i] == 'p') score += s;
    }

    cout << score << endl;
    return 0;
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abc061/tasks/abc061_b
#include <bits/stdc++.h>
using namespace std;

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

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

  vector<int> c(N);
  rep(i, M * 2) {
    int d;
    cin >> d;
    c.at(d - 1) += 1;
  }
  rep(i, N) cout << c.at(i) << endl;

  return 0;
}


Measured memory_bytes: 256