akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, K;
    scanf("%d%d", &n, &K);
    double p[n];
    rep(i, n) scanf("%lf", &p[i]);
    double tmp = 0;
    rep(i, K) tmp += (p[i]+1) / 2;
    double ans = tmp;
    For(i, 1, n-K+1){
        tmp -= (p[i-1]+1) / 2;
        tmp += (p[i+K-1]+1) / 2;
        chmax(ans, tmp);
    }
    printf("%.20lf\n", ans);
}

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

int main() {
  string s;
  cin >> s;
  
  string t = "CODEFESTIVAL2016";
  
  int n=0;
  for(int i=0;i<16;i++){
    if(s.at(i)!=t.at(i)){
      n++;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
typedef long long int ll;
using namespace std;
int main()
{
   ll n,k;
   cin>>n>>k;
   ll maxi=(n-2)*(n-1);
     maxi/=2;
    //  cout<<maxi<<endl;
     if(k>maxi){ cout<<-1; return 0; }
     
         
    if(k==maxi){
        cout<<n-1<<endl;
        for(int i=2;i<=n;i++){
            cout<<1<<" "<<i<<endl;
        }
        return 0;
    }
   ll val= maxi-k;
     cout<<n-1+val<<endl;
     for(int i=2;i<=n;i++){
            cout<<1<<" "<<i<<endl;
        }
        int i=2;
        int j;
        j=i;
        while(val--){
            j++;
            if(j==n+1){
                i++;
                j=i+1;
            }
            cout<<i<<" "<<j<<endl;
        }
     
   
}

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

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define digits(x) floor(log10(x) + 1)
#define countbits(x) ((int)log2(x)+1)
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define deb(x) cout << #x << "=" << x << endl;
#define test unsigned int tet;cin >> tet;while(tet--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const ll N   = 500500;

signed main(void)
{
    	fastio
        int n,k;
        cin >> n >> k;
        vector<int> a(n+1),dp(n+1);
        for(int i=1; i<=n; i++) cin >> a[i];

        dp[1] = 0;

        for(int i=2; i<=n; i++){
            dp[i] = INF;
            for(int j=1; j<=k; j++){
                if(i-j>=1)
                dp[i] = min(dp[i],dp[i-j] + abs(a[i]-a[i-j]));
                else break;
            }
        }
        cout << dp[n];

    	return 0;
}



Measured memory_bytes: 4736
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce
 
main :: IO ()
main = do
    [n, m] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve m xs
 
solve :: Int -> U.Vector Int -> Int
solve m xs = go 0 $ IM.keys im
  where
    !im = U.foldl' (\acc x -> IM.insertWith (++) (rem x m) [x] acc) IM.empty xs
    go !acc (k:ks)
      | (k + k == m || k == 0), Just xs<-IM.lookup k im = go (acc + same xs) ks
      | Just xs<-IM.lookup k im = case IM.lookup (m-k) im of
          Just ys | k < (m-k) -> go (acc + diff xs ys) ks
                  | otherwise -> go acc ks
          Nothing -> go (acc + go0 0 (sort xs)) ks
    go acc [] = acc
    same xs = length xs `div` 2
    diff :: [Int] -> [Int] -> Int
    diff xs ys
        | lx == ly = lx
        | lx < ly = go0 lx $ drop lx ys'
        | otherwise = go0 ly $ drop ly xs'
      where
        !lx = length xs
        !ly = length ys
        xs' = concat . map snd . sort . concatMap f .group $ sort xs
        ys' = concat . map snd . sort . concatMap f .group $ sort ys
        f :: [Int] -> [(Int, [Int])]
        f xs
            | even l || l == 1 = [(l, xs)]
            | otherwise = [(1, [head xs]), (l-1, tail xs)]
          where
            !l = length xs
    go0 !acc (x:y:xs)
         | x == y = go0 (acc+1) xs
         | otherwise = go0 acc (y:xs)
    go0 acc _ = acc

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define MAX 2000000

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483646;
const LL LLINF = 9223372036854775806;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

VI A;
int H=0;


int hparent(int i){return i/2;}
int hleft(int i){return i*2;}
int hright(int i){return i*2+1;}

void maxHeapify(int i) {
  int L = hleft(i);
  int R = hright(i);
  int largest;
  if (L<=H && A[L] > A[i]) {
    largest = L;
  }else{
    largest = i;
  }
  if (R<=H && A[R] > A[largest]) {
    largest = R;
  }
  if (largest!=i) {
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if (H<1) return -INTINF;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}


void increaseKey(int i, int key){
  if (key<A[i]) return;
  A[i]=key;
  while (i>1 && A[i/2]<A[i]) {
    swap(A[i], A[i/2]);
    i=i/2;
  }
}


void insert(int key){
  H++;
  A[H]=-INTINF;
  increaseKey(H,key);
}

int main(int argc, char const *argv[]) {
  A.reserve(MAX);
  cin.tie(0); ios::sync_with_stdio(false);
  int tmp;
  string com;
  while (1) {
    std::cin >> com;
    if (com=="insert") {
      std::cin >> tmp;
      insert(tmp);
    }else if (com=="extract"){
      tmp = extract();
      std::cout << tmp << '\n';
    }else if(com=="end"){
      break;
    }
  }

  return 0;
}



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

#define ll long long
#define MAX_W 100002
#define MAX_V 1000000002

ll w[101];
ll v[101];
ll mem[101][MAX_W];
//int N;

void lcs(string x, string y, int m, int n)
{
    int mem[m+1][n+1];
    for(int i = 0; i <= m; i++)
    {
       mem[i][0] = 0;
    }
    for(int i = 0; i <= n; i++)
    {
       mem[0][i] = 0;
    }

    for(int i = 1; i <= m; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(x[i-1] == y[j-1])
            {
                mem[i][j] = 1+mem[i-1][j-1];
            }
            else
            {
                mem[i][j] = max(mem[i-1][j],mem[i][j-1]);
            }
        }
    }

    int i = m, j = n;
    vector<char>s;
    while(i > 0 & j > 0)
    {
        if(x[i-1] == y[j-1])
          {
              s.push_back(x[i-1]);
              i--;
              j--;
          }
        else
        {
            if(mem[i][j-1] > mem[i-1][j])
            {
                j--;
            }
            else
            {
                i--;
            }
        }
    }

        reverse(s.begin(),s.end());
        for(int i = 0; i < s.size(); i++)
        {
            cout<<s[i];
        }
         cout<<endl;

}



int main()
{
  //OJ;
  int t = 1;
  //cin>>t;
  while(t--){
  string x;
  string y;
  cin>>x>>y;
  int m = x.size();
  int n = y.size();
  lcs(x,y,m,n);
  }
   return 0;
}


Measured memory_bytes: 38800
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


ll gcd(ll a, ll b);

int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	int N;
	cin >> N;

	vector<ll> A;
	for (int i = 0; i < N; i++) {
		ll temp;
		cin >> temp;
		A.emplace_back(temp);
	}

	ll ans = gcd(A[0], A[1]);
	for (int i = 0; i < N; i++) {
		ans = gcd(ans, A[i]);
	}

	cout << ans;
}

//---最大公約数を求める---
ll gcd(ll a, ll b) {
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}



Measured memory_bytes: 1400
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int N,M;
const int SIZE = 500005;
int c[SIZE];
int A[SIZE];
int Next[SIZE];
int res[2000005];
int show[10000005];
bool fir[SIZE];
struct Q
{
    int l,r;
    int pos;
}q[2000005];
int lowbit(int k)
{
    return k&(-k);
}
void modify(int n,int v)
{
    while(n <= N)
    {
        c[n] += v;
        n += lowbit(n);
    }
}
int sum(int n)
{
    int ans = 0;
    while(n > 0)
    {
        ans += c[n];
        n -= lowbit(n);
    }
    return ans;
}
int cmp(Q a, Q b)
{
    return a.l < b.l;
}
int main()
{
    cin>>N>>M;
    for(int i=1;i<=N;i++) scanf("%d",&A[i]);
 
 
    for(int i=N;i>=1;i--)
    {
        if(!show[A[i]])
        {
            show[A[i]] = i;
            fir[i] = true;
        }
        else
        {
            Next[i] = show[A[i]];
            fir[Next[i]] = false;
            fir[i] = true;
            show[A[i]] = i;
        }
    }
 
 
   
    for(int i=1;i<=M;i++)
    {
        scanf("%d%d",&q[i].l,&q[i].r);
        q[i].pos = i;
    }
    sort(q+1,q+1+M,cmp);
 
 
    for(int i=1;i<=N;i++)
        if(fir[i])
        {
            modify(i,1);
        }
    int qtemp = q[1].l;
    int ptr = 1;
    for(int i=1;i<=M;i++)
    {
        for(;ptr<q[i].l;ptr++)
        {
            if(fir[ptr])
            {
                modify(ptr,-1);
                fir[ptr] = false;
                if(Next[ptr])
                {
                    fir[Next[ptr]] = true;
                    modify(Next[ptr],1);
                }
            }
        }
        ptr = q[i].l;
        qtemp = q[i].l;
        res[q[i].pos] = sum(q[i].r) - sum(q[i].l-1);
    }
    for(int i=1;i<=M;i++) printf("%d\n",res[i]);
    return 0;
}

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

using namespace std;

int check[105];

vector<int> PRIME;

void E(void) {

	check[1] = 1;

	for (int i = 2; i <= 100; i++) {
		if (check[i] == 0) {

			for (int j = i * 2; j <= 100; j += i) {
				check[j] = 1;
			}
		}
	}

	for (int i = 1; i <= 100; i++) {
		if (check[i] == 0) { PRIME.push_back(i); }
	}
}

int alpha[100];

int N;

int main(void) {

	cin >> N;

	E();

	/*for (int i = 0; i < (int)PRIME.size(); i++) {
		cout << PRIME[i] << endl;
	}*/

	for (int i = 2; i <= N; i++) {
		
		int NUM = i;
		while (NUM > 1) {
			for (int j = 0; j < (int)PRIME.size(); j++) {
				if ((PRIME[j] <= NUM) && (NUM%PRIME[j] == 0)) { alpha[j]++; NUM /= PRIME[j]; }
			}
		}
	}

	/*for (int i = 0; i < (int)PRIME.size(); i++) {

		cout << PRIME[i] << " " << alpha[i] << endl;
	}*/

	int ans = 0;
	// 74
	for (int i = 0; i < 100; i++) {
		if (alpha[i] >= 74) { ans++; }
	}

	// (2, 24)
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (i == j) { continue; }
			if (alpha[i] >= 2 && alpha[j] >= 24) { ans++; }
		}
	}

	//(4, 14)
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (i == j) { continue; }
			if (alpha[i] >= 4 && alpha[j] >= 14) { ans++; }
		}
	}

	//(2,4,4)
	int temp = 0;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (i == j) { continue; }
			for (int k = 0; k < 100; k++) {
				if (i == k || j == k) { continue; }
				if (alpha[i] >= 2 && alpha[j] >= 4 && alpha[k] >= 4) { temp++; }
			}
		}
	}

	ans += temp / 2;

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;

vector<P> food;
int dp[3500][3500];
int b[3500];
signed main(){
    int n,t;
    cin >> n >> t;
    REP(i,n){
        int a1,b1;
        cin >> a1 >> b1;
        food.pb(P(a1,b1));
    }
    sort(food.begin(),food.end());
    REP(i,n+1){
        if(i==0) continue;
        REP(j,3010){
            if(j==0){
                dp[i-1][j];
            }
            else if(j-food[i-1].first<0){
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                dp[i][j] = max(dp[i][j],dp[i-1][j-food[i-1].first]+food[i-1].second);
            }            
        }
    }
    int ans = 0;
    REP(i,n+1){
        ans = max(ans,dp[i][t]);
    }
    for(int i=n-1;i>=0;i--){
        b[i] = max(b[i+1],food[i].second);
    }
    REP(i,n+1){
        ans = max(ans,dp[i][t-1]+b[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 84352
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int t=0;while(x){t+=BIT[x];x-=x&-x;}return t;}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)

LL z[N];
map<LL,int>mp;
void add(int x){
	while(x<=N){
		z[x]++;
		x+=x&-x;
	}
}
LL get(int x){
	int s=0;
	while(x)s+=z[x],x-=x&-x;
	return s;
		
}


LL n,k,a[N],s[N],d[N],p[N],b[N];
int main(){Accel
	cin>>n>>k;
	
	FOR(i,1,n){ 
		cin>>a[i];
		s[i]=s[i-1]+a[i];
		p[i]=d[i]=s[i]-k*i;
	}
	
	sort(p+1,p+n+1);
	FOR(i,1,n)
		mp[p[i]]=i;
	FOR(i,1,n)
		b[i]=mp[d[i]];

	//FOR(i,1,n)cout<<b[i]<<" ";cout<<endl;


	LL ans=0;
	FOR(i,1,n){
		ans+=get(b[i]);
		add(b[i]);
		ans+=p[i]>=0;
	}
	cout<<ans<<endl;
	

}

/*
4 6
1
1
2
3
*/




Measured memory_bytes: 36864
from itertools import zip_longest as Zip
s=input()
ans=0
g=len(s)
for i in range(2**(g-1)):
  d=s
  k=bin(i)[2:]
  k="0"*(g-len(k)-1)+k+"0"
  ans+=eval("".join([d[j]+ ("+" if k[j]=="1" else "") for j in range(g)]))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

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

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

int main(){

  int n = in();
  int k = in();
  vector<int> a(n);
  REP(i, n){
    a[i] = in();
  }
  vector<int> dp(k + 1, 0);
  FOR(i, 1, k + 1){
    set<int> ss;
    REP(j, n){
      if(i - a[j] >= 0){
        ss.insert(dp[i - a[j]]);
      }
    }
    REP(j, INF){
      if(ss.find(j) == ss.end()){
        dp[i] = j;
        break;
      }
    }
  }

  // cout << dp << endl;
  
  if(dp[k] == 0){
    puts("Second");
  } else {
    puts("First");
  }
  
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>

#define MAX_N (100000)

using namespace std;

typedef struct {
  long to;
  long cost;
} edge;

void add_edge(vector<vector<edge>> &adj_lists, long u, long v, long cost) {
  adj_lists[u].push_back({v, cost});
  adj_lists[v].push_back({u, cost});
}

long minimum_spanning_tree(vector<vector<edge>> &adj_lists) {
  const int N = adj_lists.size();
  vector<long> ds(N, -1);
  priority_queue<pair<long, long>, vector<pair<long, long>>,
                 greater<pair<long, long>>>
      que;
  que.push(pair<long, long>(0, 0));
  long ret = 0;
  while (!que.empty()) {
    const pair<long, long> p = que.top();
    const long u = p.second, d = p.first;
    que.pop();
    // printf("u = %ld, d = %ld\n", u, d);
    if (ds[u] < 0) {
      ds[u] = d;
      ret += d;
      for (edge &e : adj_lists[u]) {
        const long v = e.to, w = e.cost;
        if (ds[v] < 0) {
          que.push(pair<long, long>(w, v));
        }
      }
    }
  }
  return ret;
}

int main(int argc, char *argv[]) {
  // read inputs
  long N, xs[MAX_N], ys[MAX_N];
  scanf("%ld", &N);
  for (int i = 0; i < N; i++) {
    scanf("%ld %ld", &xs[i], &ys[i]);
  }

  // create sorted list of xs and ys
  vector<pair<long, long>> sorted_xs, sorted_ys;
  for (long i = 0; i < N; i++) {
    sorted_xs.push_back(pair<long, long>(xs[i], i));
    sorted_ys.push_back(pair<long, long>(ys[i], i));
  }
  sort(sorted_xs.begin(), sorted_xs.end());
  sort(sorted_ys.begin(), sorted_ys.end());

  // create graph where only nodes adjacent in the sorted lists are connected
  vector<vector<edge>> adj_lists(N, vector<edge>());
  for (long i = 1; i < N; i++) {
    const long u = sorted_xs[i - 1].second, v = sorted_xs[i].second;
    const long cost = min(abs(xs[u] - xs[v]), abs(ys[u] - ys[v]));
    add_edge(adj_lists, u, v, cost);
  }
  for (long i = 1; i < N; i++) {
    const long u = sorted_ys[i - 1].second, v = sorted_ys[i].second;
    const long cost = min(abs(xs[u] - xs[v]), abs(ys[u] - ys[v]));
    add_edge(adj_lists, u, v, cost);
  }

  // for (long i = 0; i < N; i++) {
  //   printf("%ld:  ", i);
  //   for (edge &e : adj_lists[i]) {
  //     const long j = e.to, w = e.cost;
  //     printf("(%ld, %ld) ", j, w);
  //   }
  //   printf("\n");
  // }

  // minimum spanning tree
  printf("%ld\n", minimum_spanning_tree(adj_lists));

  return 0;
}


Measured memory_bytes: 20580
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <utility>
#include <set>

using namespace std;

int main(){
    int N,M,K,t;
    cin >> N >> M;
    set<int> vi;
    set<int> V;
    set<int> VV;

    cin >> K;
    for(int j = 0; j < K; j++){
        cin >> t;
        vi.insert(t);       
    }

    for(int i = 1; i < N; i++){
        cin >> K;
        for(int j = 0; j < K; j++){
            cin >> t;
            if(vi.count(t)){
                V.insert(t);  
            }   
        }
        vi = V;
        V = VV;
    }
    cout << vi.size() << endl;

}

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

using namespace std;

int main()
{
    int N;
    int m=0;
    int sa;
    int maewa=0;
    int ushirowa=0;
    cin >> N;
    int W[100];
    for (int t = 0; t < N; t++) {
        cin>>W[t];
    }
    for (int i = 0; i < N-1; i++)
    {
        for (int j = 0; j < i+1; j++)
        {
            maewa=maewa+W[j];/* code */
        }
        for (int k = i+1; k < N; k++)
        {
            ushirowa=ushirowa+W[k];/* code */
        }
        if (i==0)
        {
            sa=abs(maewa-ushirowa);/* code */
          	maewa=0;
    	 	ushirowa=0;
        }else
        {
            if (sa>=abs(maewa-ushirowa))
            {
                sa=abs(maewa-ushirowa);/* code */
            }
           	maewa=0;
    	 	ushirowa=0;/* code */
        }   
        
    }
    cout << sa;
}

Measured memory_bytes: 256
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=41;

int main()
{
	int a,b;

	scn(a); scn(b);

	rep(i,1,10001)
	{
		int x=(i*8)/100,y=i/10;

		if(x==a and y==b)
		{
			pri(i); return 0;
		}
	}

	pri(-1);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

Bset = set()
Aset = set()
ans = 0
for i in range(n):
    if s[i][0] == "B":
        Bset.add(i)
    if s[i][-1] == "A":
        Aset.add(i)
    for j in range(1, len(s[i])):
        if s[i][j - 1] == "A" and s[i][j] == "B":
            ans += 1

Bli = list(Bset)
Ali = list(Aset)
ans += min(len(Bli), len(Ali))
if Bset == Aset and Bset != set():
    ans -= 1
print(ans)

Measured memory_bytes: 5100
#include<stdio.h>

int main(void)
{
  int n,T;
  scanf("%d%d",&n,&T);

  int i,c[n],t[n],min=1100;
  for(i=0;i<n;i++){
    scanf("%d%d",&c[i],&t[i]);
    if(t[i]<=T)
      if(c[i]<min)
        min = c[i];
  }

  if(min==1100)
    printf("TLE\n");
  else
    printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 1732
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


// AxxxB
// BxxxA
int main() {
	int N;
	cin >> N;
	int ans = 0;
	map<pair<int, int>,int> p;
	for (int i = 1; i <= N; i++) {
		auto s = to_string(i);
		p[{s[0] - '0', s.back() - '0'}]++;
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			ans += p[{i, j}] * p[{j, i}];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

S = str(input())
P = str(input())

for i in range(len(S)):
    FLG = True

    for k in range(len(P)):

        if S[(i+k)%(len(S))] != P[k]:
             FLG = False
             break
    if FLG == True:
        break

if FLG == True:
    print("Yes")

else :
    print("No")
   


        



Measured memory_bytes: 5568
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextLong()
  
  	var ans = N - 1
    
    for (x in 1..Math.sqrt(N.toDouble()).toLong()) {
        if (N % x == 0L) {
            ans = Math.min(ans, x + (N / x) - 2)
        }
    }
  
  	println(ans)
}


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

using namespace std;

int main()
{
	int n, p;
	string s;
	cin >> n;
	cin.get();
	while(n--) {
		getline(cin, s);
		while(p = s.find("Hoshino"), p != string::npos) {
			s.replace(p, 7, "Hoshina");
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 0
N = int(input())
CSF = [list(map(int,input().split())) for _ in range(N-1)]
result = [0]*N
for i in range(N-1):
    now = CSF[i][1] + CSF[i][0]
    for j in range(i+1,N-1):
        c,s,f = CSF[j]
        if s >= now:
            now = c + s 
        else:
            now = c + (now if now % f == 0 else (now // f+1)*f)
    result[i] = now
print(*result,sep='\n')


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



int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	vector<int> a(n);
	for(int i=0;i<n;i++){
		a[v[i]-1]=i+1;
	}
	for(int i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

char a[102][102];

int main(){
   int h,w;
   scanf("%d%d",&h,&w);
   int flag = 0;

   for(int i=1;i<=h;i++){
    scanf("%s",a[i]);
   }

   char c;
   for(int i=0;i<h+2;i++){
    if(i>=1 && i<=h){
        printf("#");
        printf("%s",a[i]);
        printf("#\n");
    }
    else if(i==0){
        for(int j=0;j<w+2;j++) printf("#");
        printf("\n");
    }
    else {
        for(int j=0;j<w+2;j++) printf("#");
    }

    }
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
import math
MOD = 1000000007  # type: int


def solve(N: int, M: int):
    if abs(N-M) >= 2:
        print(0)
        return 
    
    ## Nの並び替えパターン
    N_number = math.factorial(N)%MOD
    M_number = math.factorial(M)%MOD

    if N == M:
        print((N_number*M_number*2)%MOD)
    else:
        print((N_number*M_number)%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;
    vector<i64> h(N);
    rep(i,0,N) cin >> h[i];

    vector<i64> dp(N,inf64);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    rep(i,2,N){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[N-1] << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
    ll Q,H,S,D,N,ans=0;
    cin>>Q>>H>>S>>D>>N;
    ll q=Q*8,h=H*4,s=S*2,d=D,Min=min(min(q,h),min(s,d));
    if(Min==d){
        ans+=D*(N/2);
        
        N%=2;
        Min=min(min(q,s),h);}
    if(Min==s){ans+=S*N;}
    if(Min==h){ans+=H*N*2;}
    if(Min==q){ans+=Q*N*4;}
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,y) for(int i=(x);i<(y);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,k;
    cin>>n>>k;
    vi v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(rall(v));
    int ans=0;
    rep(i,k){
        ans+=v[i];
    }
    cout<<ans;


    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  a = 0;
  cin >> n;
  for (int i = 1; i < n+1; i *= 10) {
    a += n / i % 10;
  }
  if (n % a == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_083
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            var sequenceList = new List<int>();
            bool isZero = s[0] == '0';
            int nowCnt = 1;
            for (int i = 1; i < s.Length; i++)
            {
                if ((isZero && s[i] == '0')
                    || (!isZero && s[i] == '1'))
                {
                    nowCnt++;
                }
                else
                {
                    sequenceList.Add(nowCnt);
                    isZero = s[i] == '0';
                    nowCnt = 1;
                }
            }
            sequenceList.Add(nowCnt);
            for(int i = 0; i < sequenceList.Count; i++)
            {
                //Console.WriteLine(sequenceList[i]);
            }
            int first = 0;
            int last = sequenceList.Count - 1;
            int head = sequenceList[first];
            int tail = sequenceList[last];
            int min = int.MaxValue;
            while (head + tail < s.Length)
            {
                if (head < tail)
                {
                    min = Math.Min(min, s.Length - head);
                    first++;
                    head += sequenceList[first];
                }
                else
                {
                    min = Math.Min(min, s.Length - tail);
                    last--;
                    tail += sequenceList[last];
                }
                //Console.WriteLine(head + " " + tail);
            }
            Console.WriteLine(Math.Max(head, tail));
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13228
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <list>
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define pb push_back
 
int INF = INT_MAX / 10;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	vector<int> b(N);
	rep(i, N) b[a[i] - 1] = i;
	set<int> st;
	st.insert(-1);
	st.insert(N);
	ll ans = 0;
	rep(i, N) {
		int k = b[i];
		auto it = st.insert(k).first;
		it--;
		int l = *it;
		it++; it++;
		int r = *it;
		ans += (ll)(i + 1) * (k - l) * (r - k);
	}
	cout << ans << endl;
}


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

int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  string t;
  for (int i = 0; i < n; ++i) {
    if (i < (n - 1) && s[i] == 'B' && s[i + 1] == 'C') {
      t += 'D';
      ++i;
    } else {
      t += s[i];
    }
  }
  // cout << t << endl;

  n = t.size();
  int64_t answer = 0;
  int64_t count = 0;
  for (int i = 0; i < n; ++i) {
    if (t[i] == 'A') {
      count++;
    } else if (t[i] == 'D') {
      answer += count;
    } else {
      count = 0;
    }
  }
  cout << answer << endl;
  return 0;
}

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

int main()
{
    long N,K;
    cin >> N >> K;
    vector<ld> p;
    p.resize(N);
    rep(i,N)cin >> p[i];
    ld max=0;
    ld tmp=0;
    rep(i,K){
        tmp+=p[i];
    }
    max=tmp;
    rep(i,N-K){
        tmp=tmp-p[i]+p[K+i];
        if(tmp>max){
            max=tmp;
        }
    }
    max+=K;
    cout << setprecision(7) <<max/2 << endl;
}

Measured memory_bytes: 3328
// https://atcoder.jp/contests/abc163/submissions/12204917
use proconio::input;
use proconio::marker::Usize1;

// 頂点数 n のときのパスの和を返す (u -> v と v -> u を重複と見なす)
fn f(n: usize) -> usize {
    n * (n + 1) / 2
}

// 部分木のサイズを countv に設定する
fn g(countv: &mut Vec<usize>, evv: &Vec<Vec<usize>>, v: usize, p: usize) {
    let mut count = 1;
    for &u in evv[v].iter() {
        if u == p {
            continue;
        }
        g(countv, evv, u, v);
        count += countv[u];
    }
    countv[v] = count;
}

fn h(
    av: &mut Vec<usize>,
    ccv: &mut Vec<usize>,
    cpv: &mut Vec<usize>,
    stackv: &mut Vec<Vec<usize>>,
    countv: &Vec<usize>,
    cv: &Vec<usize>,
    evv: &Vec<Vec<usize>>,
    v: usize,
    p: usize,
) {
    let c_v = cv[v];
    stackv[c_v].push(v);
    for &u in evv[v].iter() {
        if u == p {
            continue;
        }
        ccv[v] = countv[u];
        h(av, ccv, cpv, stackv, countv, cv, evv, u, v);
        av[c_v] -= f(ccv[v]);
    }
    stackv[c_v].pop();
    if let Some(&i_pc) = stackv[c_v].last() {
        ccv[i_pc] -= countv[v];
    } else {
        cpv[c_v] -= countv[v];
    }
}

fn main() {
    input! {
        n: usize,
        cv: [Usize1; n],
        abv: [(Usize1, Usize1); n - 1],
    };
    let mut evv = vec![vec![]; n];
    for (a, b) in abv {
        evv[a].push(b);
        evv[b].push(a);
    }

    let mut countv = vec![0_usize; n];
    g(&mut countv, &evv, 0, 0);

    let mut av = vec![f(n); n];
    let mut ccv = vec![0_usize; n];
    let mut cpv = vec![n; n];
    let mut stackv = vec![vec![]; n];
    h(
        &mut av,
        &mut ccv,
        &mut cpv,
        &mut stackv,
        &countv,
        &cv,
        &evv,
        0,
        0,
    );

    for (i, &a) in av.iter().enumerate() {
        println!("{}", a - f(cpv[i]));
    }
}


Measured memory_bytes: 61576
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
//#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 4e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
bool prime(int n) {
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios;
    int a , b;
    cin >> a >> b;
    int ans = b*10;
    for(int i = 0; i < 9; i ++) {
        if( (int)((ans + i) * 0.08) == a) {
            cout << ans + i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k;
	int cnt=0;
  cin>>a>>b>>c>>k;
  while(a>=b)
  {
    cnt+=1;b*=2;
  }
  while(b>=c)
  {
    cnt+=1;c*=2;
  }
  if(cnt<=k)cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3604
// Try  AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let i = get!();
    
    let ans = n - i + 1;
    
    println!("{}", ans);
    
}

Measured memory_bytes: 4352
import math
a, b, x = map(int, input().split())
result = 0.0
if  a * b / 2 < x / a:
    h = 2 * (b - x / (a * a))
    result = math.degrees(math.atan2(h, a))
else:
    w = 2 * x / (a * b)
    result = math.degrees(math.atan2(b, w))
print(result)

Measured memory_bytes: 3060
table = [4, 1, 4, 1, 2, 1, 2, 1]

$<.readlines.map {|l| l.split.map(&:to_i)}.each do |persons|
  result = (0..7).map do |i|
    order = table.rotate(i)
    left = persons.map.with_index do |n, j|
      a = n - order[j]
      a < 0 ? 0 : a
    end.sum
    [left, order]
  end.sort_by {|d| d.first}
  min = result.first.first
  result = result.select {|d| d.first == min}.sort_by {|d| d.last.join.to_i}.first
  puts result.last.join(" ")
end


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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if ((W >= x + r && x - r >= 0) && (H >= y + r && y - r >= 0))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    if (N % 2 == 0) {
    	String str = sc.next();
    	String half = str.substring(0, N/2);
    	if(str.equals(half+half)) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
    } else {
    	System.out.println("No");
    }
  }
}

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

int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h,n,temp;
	long long int total = 0;
	cin>>h>>n;
	for (int i = 0; i < n; i++) {
		cin>>temp;
		total+=temp;
	}
	cout<< ((total >= h) ? "Yes" : "No") << '\n';
	return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(true){
    c-=b;
    if(c<=0){
      cout << "Yes";
      return 0;
    }
    a-=d;
    if(a<=0){
      cout << "No";
      return 0;
    }
  }
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int N;
  scanf("%d", &N);

  char S[N][11];
  for(int i = 0; i < N; i++){
    scanf("%s", S[i]);
  }

  int count = 1;

  qsort(S,N,11,strcmp);

  for(int i = 0; i < N-1; i++){
    if(strcmp(S[i], S[i+1]) != 0){
      count += 1;
    }
  }


  printf("%d\n", count);

  return 0;
  }


Measured memory_bytes: 5712
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_N 86401 //60*60*24
ll field[MAX_N];

void init(){
	rep(i,MAX_N){
		field[i] = 0;
	}
}

int stringToIntTime(string str){
	int hour,minutes,second;
	hour = stoi(str.substr(0,2));	//hh:mm:ss
	minutes = stoi(str.substr(3,2));
	second = stoi(str.substr(6,2));
	return 60*60*hour + 60*minutes + second;
}

int main()
{
	int n;
	cin>>n;
	while( n!=0){
		init();
		for(int i = 0; i < n; i++){
			string start,end;
			cin>>start>>end;
			field[stringToIntTime(start)]++;
			field[stringToIntTime(end)]--;
		}
		ll ans = 0;
		for(int i = 0; i < MAX_N-1; i++){
			field[i+1] += field[i];
			ans = max(ans,field[i+1]);
		}
		cout<<ans<<endl;
		cin>>n;
	}
	
	return 0;
}



Measured memory_bytes: 3820