akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t,tut[N];

bool check(ll x)
{
	for(int i=1;i<=m;i++)
	{
		tut[i]=0;
		if(ar[i]<=x)
			tut[i]=1;
	}

	if(tut[n]==tut[n-1] || tut[n]==tut[n+1])
	{
		return tut[n];
	}
	for(int i=1;i<n-1;i++)
	{
		if(tut[n-i]==tut[n-i-1])
			return tut[n-i];
		if(tut[n+i]==tut[n+i+1])
			return tut[n+i]; 
	}
	return tut[1];
}

ll bs()
{
	int l=1,r=m;
	while(l<r)
	{
		if(l==r-1)
		{
			if(check(l))
				r=l;

			break;
		}
		int mid=(l+r)/2;
		// cout<<mid<<sp<<check(mid)<<endl;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	return r;
}

int main()
{
	fast;
	cin>>n;
	m=n*2-1;
	fs(ar,m);
	cout<<bs();

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 5888
N,M,D = map(int,input().split())

B = list(map(int,input().split()))

ans = 0

for _ in range(N):
    tmp_math = D
    A = list(map(int,input().split()))
    for i in range(M):
        tmp_math += B[i]*A[i]
    if tmp_math > 0:
        ans += 1
print(ans)

Measured memory_bytes: 61820
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

const int mod=1000000007;
//const int mod=998244353;




int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d;
    cin>> a;
    cout<< (double)2*acos(-1)*a<<'\n';
    
}


Measured memory_bytes: 3820
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

double pr[128][101];
int board[101];

int main(){
    int n,t,l,b;

    while(cin >> n >> t >> l >> b){
        if((n|t|l|b) == 0) break;
        int tmp, nxt;
        memset(board, 0, sizeof(board));
        fill((double *)pr, (double *)pr+128*101, 0);


        for(int i=0;i<l;i++){
            cin >> tmp;
            board[tmp] = 1;
        }
        for(int i=0;i<b;i++){
            cin >> tmp;
            board[tmp] = 2;
        }

        pr[0][0] = 1.0;
        for(int i=1;i<=t;++i){
            for(int j=0;j<n;++j){
                for(int k=1;k<=6;++k){
                    if(j+k <= n){ //in board
                        nxt = j+k;
                    }else{
                        nxt = n - (j+k - n);
                    }
                    if(board[nxt] == 2){
                        nxt = 0;
                    }
                    if(board[nxt] == 1){
                        pr[i+1][nxt] += pr[i-1][j] / 6;
                    }else{
                        pr[i][nxt] += pr[i-1][j] / 6;
                    }
                }
            }
        }

        double ret = 0;
        for(int i=0;i<=t;i++){
            ret += pr[i][n];
        }

        printf("%f\n", ret);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<int> a(n), b(n), c(n);
  for(auto &e: a)cin>>e;
  for(auto &e: b)cin>>e;
  for(auto &e: c)cin>>e;
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  ll ans=0;
  for(int j=0;j<n;j++){
    ans += ll(lower_bound(a.begin(), a.end(), b[j])-a.begin()) *
           ll(c.end()-upper_bound(c.begin(), c.end(), b[j]));
  }
  cout<<ans<<endl;
}


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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> divide_des;

    for (int i=min(A, B); i>0; i--){
        if (A%i==0 && B%i==0) divide_des.push_back(i);
    }
    cout << divide_des.at(K-1) << endl;
    return 0;
}

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

using namespace std;

vector<int> uppers;
vector<int> lowers;
vector<int> uppers_acc;
vector<int> lowers_acc;
int N;

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

    cin >> N;

    uppers.resize(N);
    lowers.resize(N);
    uppers_acc.resize(N);
    lowers_acc.resize(N);

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

    uppers_acc[0] = uppers[0];
    for (int i = 1; i < N; i++) {
        uppers_acc[i] = uppers_acc[i-1] + uppers[i];
    }

    lowers_acc[N-1] = lowers[N-1];
    for (int i = N-2; i >= 0; i--) {
        lowers_acc[i] = lowers_acc[i+1] + lowers[i];
    }

    int max_val = 0;
    
    for (int i = 0; i < N; i++) {
        auto val = uppers_acc[i] + lowers_acc[i];
        if (val > max_val) max_val = val;
    }
    cout << max_val;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}



ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}


ll x, y;



int main(void){
	cin >> x >> y;
	if ((x + y) % 3) {cout << 0 << endl; return 0;}
	ll a = x - (x + y) / 3;
	ll b = y - (x + y) / 3;
	if (a < 0 || b < 0) {cout << 0 << endl; return 0;}
	cout << comb<llm>(a+b, a) << endl;

	


    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

  constexpr auto M = 1000000007L;
  bitset<64> bs(n);
  int64_t dp[64][2][2][2] = {};
  dp[63][0][0][0] = 1;
  for (auto i : irange(0L, 63L) | reversed) {
    if (bs[i]) {
      dp[i][0][0][1] = dp[i + 1][0][0][0] + dp[i + 1][0][0][1] +
                       dp[i + 1][0][1][0] + dp[i + 1][0][1][1];
      dp[i][0][1][1] = dp[i + 1][0][0][0] + dp[i + 1][0][1][1];

      dp[i][1][0][0] = dp[i + 1][0][0][0] + dp[i + 1][0][0][1] +
                       dp[i + 1][0][1][0] + dp[i + 1][0][1][1] +
                       dp[i + 1][1][0][0] + dp[i + 1][1][0][1] +
                       dp[i + 1][1][1][0] + dp[i + 1][1][1][1];
      dp[i][1][0][1] = dp[i + 1][1][0][0] + dp[i + 1][1][0][1] +
                       dp[i + 1][1][1][0] + dp[i + 1][1][1][1];
      dp[i][1][1][0] = dp[i + 1][0][0][1] + dp[i + 1][0][1][0] +
                       dp[i + 1][1][0][1] + dp[i + 1][1][1][0];
      dp[i][1][1][1] = dp[i + 1][1][0][0] + dp[i + 1][1][1][1];
    } else {
      dp[i][0][0][0] = dp[i + 1][0][0][0] + dp[i + 1][0][0][1] +
                       dp[i + 1][0][1][0] + dp[i + 1][0][1][1];
      dp[i][0][1][0] = dp[i + 1][0][0][1] + dp[i + 1][0][1][0];

      dp[i][1][0][0] = dp[i + 1][1][0][0] + dp[i + 1][1][0][1] +
                       dp[i + 1][1][1][0] + dp[i + 1][1][1][1];
      dp[i][1][0][1] = dp[i + 1][1][0][0] + dp[i + 1][1][0][1] +
                       dp[i + 1][1][1][0] + dp[i + 1][1][1][1];
      dp[i][1][1][0] = dp[i + 1][1][0][1] + dp[i + 1][1][1][0];
      dp[i][1][1][1] = dp[i + 1][1][0][0] + dp[i + 1][1][1][1];
    }

    for (auto j : irange(0L, 2L)) {
      for (auto k : irange(0L, 2L)) {
        for (auto l : irange(0L, 2L)) {
          dp[i][j][k][l] %= M;
          // cerr << i << ":" << j << "," << k << "," << l << ":" <<
          // dp[i][j][k][l]
          //      << endl;
        }
      }
    }
  }

  cout << (dp[0][0][0][0] + dp[0][0][1][1] + dp[0][1][0][0] + dp[0][1][1][1]) %
              M
       << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    string s;
    cin >> N >> s;
    vector<int> le(N);
    vector<int> ri(N);
    rep(i, 0, N) {
        if(i != 0) {
            le[i] = le[i - 1];
            ri[i] = ri[i - 1];
        }
        if(s[i] == 'E') {
            le[i]++;
        } else {
            ri[i]++;
        }

        // cout << ri[i] << "," << le[i] << endl;
    }
    int cost = 1000000;
    rep(i, 0, N) {
        int tcost = 0;
        if(i != 0) {
            tcost += ri[i - 1];
        }
        if(i != N - 1) {
            tcost += le[N - 1] - le[i];
        }
        chmin(cost, tcost);
    }
    cout << cost << endl;
}


Measured memory_bytes: 3076
/*Alohomora*/
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define mod1        987654319 
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll fact(ll n){ if(n==0){return 1;}return (n*fact(n-1))%mod1;}
ll power(ll x, ll y,ll mod){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod1-2,mod1);}
ll gcd(ll a,ll b){if(b==0){return a;}gcd(b,a%b);}
ll a[2000000];
void sieve(){ll i,j;fli(i,2,1000001){if(a[i]==0){for(j=i*i;j<1000001;j+=i){a[j]=1;}}}}
map<ll,vector<ll> >m1;
vector<ll>v1;
bool compar(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second);
} 
ll level[1000000];
vector<ll>root;
set<ll>s1;
void factorise(long long n) 
{ 
    while (!(n%2)) 
    { 
        n >>= 1; 
        s1.insert(2);
    } 
    for (long long i=3; i<=sqrt(n); i+=2) 
    { 
        while (n%i==0) 
        { 
        	s1.insert(i);
            n=n/i; 
        } 
    } 
  	if (n>2) 
  	{
       s1.insert(n);
	}
} 
void comp()
{
	ll l,i,j,k,q,n,d,m,temp=0,sum,count=0;
	cin>>n;
	vector<ll>v1;
	fl(i,n)
	{
		cin>>j;
		v1.pb(j);
	}
	int arr[n+1];
	int arr1[n+1];
	arr[n-1]=v1[0];
	ll curr=n-1;
	ll low,high,mid,ans;
	fli(i,1,n)
	{
		low=curr;
		high=n-1;
		ans=-1;
		while(low<=high)
		{
			mid=(low+high)/2;
			if(v1[i]>arr[mid])
			{
				ans=mid;
				low=mid+1;
			}
			else
			{
				high=mid-1;
			}
		}
		if(ans==-1)
		{
			arr[curr-1]=v1[i];
			curr--;
		}	
		else
		{
			arr[ans]=v1[i];
		}
	}
	cout<<n-curr<<"\n";
} 
int main()
{
	speedup;
	ll i=0,t;
	ll n;
	//cin>>t;
	t=1;
	while(t--)
	{
	 comp();
	}
}

Measured memory_bytes: 3572
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
sumA = sum(A)

cumevA = list(accumulate(A[::2]))
cumodA = list(accumulate(A[1::2]))

ans = [None] * N
for i in range(N):
    if i == 0:
        ans[i] = str(sumA - 2 * cumodA[-1])
    elif i == 1:
        ans[i] = str(sumA - 2 * (cumevA[-1] - cumevA[0]))
    elif i == N-1:
        ans[i] = str(sumA - 2 * (cumevA[-2]))
    else:
        if i % 2 == 0:
            ans[i] = str(sumA - 2 * (cumodA[-1] - cumodA[i // 2 - 1] + cumevA[i // 2 - 1]))
        else:
            ans[i] = str(sumA - 2 * (cumevA[-1] - cumevA[(i - 1) // 2] + cumodA[(i - 3) // 2]))

print(" ".join(ans))

Measured memory_bytes: 83940
import sys
from collections import defaultdict

read = sys.stdin.read


# 最小素因数を求める（エラトステネスの篩の亜種？）
def min_factor(n):
    sieve = list(range(n + 1))
    sieve[2::2] = [2] * (n // 2)
    for i in range(3, int(n ** 0.5) + 2, 2):
        if sieve[i] == i:
            sieve[i * i::2 * i] = [i] * ((n - i * i - 1) // (2 * i) + 1)
    return sieve


# 素因数分解
def prime_factorize(n):
    a = defaultdict(int)
    while n != 1:
        b = table[n]
        a[b] += 1
        n //= b
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

table = min_factor(10 ** 6)
dic = defaultdict(int)

for i in A:
    for key, value in prime_factorize(i).items():
        dic[key] = max(dic[key], value)


lcm = 1
for i, j in dic.items():
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = sum(lcm * pow(i, mod - 2, mod) for i in A) % mod
print(answer)


Measured memory_bytes: 52068
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

q, h, s, d = map(int, input().split())
n = int(input())

print((n // 2) * min(8 * q, 4 * h, 2 * s, d) + (n % 2) * min(4 * q, 2 * h, s))


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

int main()
{
	int N;
	scanf("%d", &N);
	int count{}, max{};
	for (int i{}; i < N; i++)
	{
		int H;
		scanf("%d", &H);
		if (max <= H) count++;
		max = std::max(max, H);
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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; }

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }

};

const int MOD = 1000000007;
using mint = Fp<MOD>;

int main(){
    ll n,k;cin>>n>>k;
    mint min=0;
    mint max=0;
    mint count = 0;
    for(ll i =1;i<=n+1;++i){
        min += i-1;
        max += n-i+1;
        if(k<=i){
            count+=(max-min+1);
        }
    }
    cout<<count<<endl;

}

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

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}



struct vert
{
    int nxt[26];
    vert()
    {
        for(int j=0;j<26;j++)
            nxt[j]=-1;
    }
};

vector<vert>tr(1);
int mm[1000005][26];

void add(string a)
{
    int n=a.length();
    int ver=0;
    vector<int>lol;
    lol.push_back(0);
    for(auto i:a)
    {
        if(tr[ver].nxt[i-'a']==-1)
        {
            tr[ver].nxt[i-'a']=tr.size();
            tr.emplace_back();
        }
        ver=tr[ver].nxt[i-'a'];
        lol.push_back(ver);
    }
    bool ch[26]={0};
    for(int i=n-1;i>=0;i--)
    {
        ch[a[i]-'a']|=1;
        for(int j=0;j<26;j++)
        {
            if(ch[j]==1)
            {
                mm[lol[i]][j]++;
            }
        }
    }    
}

int get(string a)
{
    int n=a.length();
    int ver=0;
    bool flag=true;
    for(int i=0;i<n-1;i++)
    {
        if(tr[ver].nxt[a[i]-'a']!=-1)
        {
            ver=tr[ver].nxt[a[i]-'a'];
        }
        else
        {
            flag=false;
            break;
        }        
    }
    if(flag)
    {
        return mm[ver][a[n-1]-'a'];
    }
    else
    {
        return 0;
    }    
}

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n;
    cin>>n;
    string a[n];
    map<string,int>lol;

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        reverse(a[i].begin(),a[i].end());
        add(a[i]);
        lol[a[i]]++;
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=get(a[i]);
    }
    for(auto i:lol)
    {
        ans-=((i.second)*(i.second-1))/2;  
    }
    cout<<ans-n;


}

Measured memory_bytes: 422580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   if(b-a==c-b)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    
 }

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

#define int       long long
#define nn        301
#define FAST      ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int n;
int x=0, y=0, z=0;
double dp[nn][nn][nn];

double solve(int x,int y,int z){
    if(x<0 || y<0 || z<0)
        return 0;

    if(x == 0 && y == 0 && z == 0)
        return 0;
    
    if(dp[x][y][z] > -0.9)
        return dp[x][y][z];

    double exp = n + x*solve(x-1,y,z) + y*solve(x+1,y-1,z) + z*solve(x,y+1,z-1);
    return dp[x][y][z] = exp/(x+y+z);
    
}

int32_t main(){
    FAST;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
        int val; cin>>val;
        if(val == 1) x++;
        else if(val == 2) y++;
        else z++;
    }
    cout<<fixed<<setprecision(10);
    cout<<solve(x,y,z);
}


Measured memory_bytes: 213376
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end


def max(a,b)
    return a>b ? a : b
end
N=gets.to_i
a=array(2)
2.times do|i|
    a[i]=get_i
end
dp=array(N,0,2)
dp[0][0]=a[0][0]
2.times do|i|
    N.times do|j|
        next if i.zero? and j.zero?
        if i-1>=0
            dp[i][j]=max(dp[i][j],dp[i-1][j]+a[i][j])
        end
        if j-1>=0
            dp[i][j]=max(dp[i][j],dp[i][j-1]+a[i][j])
        end
    end
end
puts dp[1][N-1]

Measured memory_bytes: 3836
import sys
from scipy.sparse.csgraph import floyd_warshall as f
def main():
  n,m,l,*t=map(int,sys.stdin.buffer.read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  print('\n'.join(map(str,map(int,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)]))))
main()

Measured memory_bytes: 36264
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    int X,Y;
    cin>>X>>Y;

    if(Y>=2*X&&Y<=4*X&&Y%2==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

#define endl '\n'
#define MAX

typedef long long ll;
typedef pair<int,int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;


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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int x;
	cin >> x;
	if(x == 7 || x == 5 || x == 3)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}



Measured memory_bytes: 256
# frozen_string_literal: false

s = gets.chomp
q = gets.to_i
queries = q.times.map { gets.split }

f1s = ''
f2s = s
reversed = false
queries.each do |t, f, c|
  if t.to_i == 1
    reversed = !reversed
    next
  end

  if f.to_i == 1
    if !reversed
      f1s << c
    else
      f2s << c
    end
  elsif f.to_i == 2
    if !reversed
      f2s << c
    else
      f1s << c
    end
  end
end

if reversed
  puts f2s.reverse! << f1s
else
  puts f1s.reverse! << f2s
end

Measured memory_bytes: 43132
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    sc.close();

    StringBuilder buf = new StringBuilder();
    for (int i = 0; i < S.length(); i++) buf.append("x");

    System.out.println(buf.toString());
  }
}


Measured memory_bytes: 23380
#include <stdio.h>
 
int main()
{
    int i, j, k;

    int n, m, l;
    scanf("%d%d%d", &n, &m, &l);
    int A[n][m], B[m][l];
    for( i = 0; i < n; ++i )
        for( j = 0; j < m; ++j )
            scanf("%d", &A[i][j]);
    for( i = 0; i < m; ++i )
        for( j = 0; j < l; ++j )
            scanf("%d", &B[i][j]);
    long int C[n][l];
    for( i = 0; i < n; ++i )
        for( j = 0; j < l; ++j )
            C[i][j] = 0;
    for( i = 0; i < n; ++i )
        for( j = 0; j < l; ++j )
            for( k = 0; k < m; ++k )
                C[i][j] += A[i][k] * B[k][j];
    for( i = 0; i < n; ++i ){
        for( j = 0; j < l; ++j ){
            printf("%ld", C[i][j]);
            if( j != l-1 ) printf(" ");
        }
        printf("\n");
    }
 
    return 0;
}

Measured memory_bytes: 760
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

void bfs(unordered_map<int, vint>& graph, unordered_map<int, ll>& query,
    vll& ans) {

    deque<int> q;
    q.push_back(1);
    unordered_set<int> visited;
    visited.insert(1);
    ans[1] = query[1];

    while (1) {
        if (q.size() <= 0) break;
        int nd = q.front();
        q.pop_front();
        for (auto &adj : graph[nd]) {
            if (visited.find(adj) == visited.end()) {
                visited.insert(adj);
                ans[adj] = ans[nd] + query[adj];
                q.push_back(adj);
            }
        }
    }

}

int main() {
    int N, Q;
    cin >> N >> Q;
    unordered_map<int, vint> graph;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    unordered_map<int, ll> query;
    rep(i, Q) {
        int p, x;
        cin >> p >> x;
        query[p] += ll(x);
    }

    vll ans(N + 1);
    bfs(graph, query, ans);
    REP(i, 1, N + 1) {
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}

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

int main() {
	string s;
	int count=0;
	cin>>s;
	for(int i=0;i<3;i++)
	{
	    if(s[i]=='A')
	    count++;
	}
	if(count<=2 && count>0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100002
#define NIL -1

struct Node { int p, l, r; };
Node T[MAX];
int n;

void Preorder(int u){
    if(u==NIL) return;
    cout << " " << u;
    Preorder(T[u].l);
    Preorder(T[u].r);
}

void Inorder(int u){
    if(u==NIL) return;
    Inorder(T[u].l);
    cout << " " << u;
    Inorder(T[u].r);
}

void Postorder(int u){
    if(u==NIL) return;
    Postorder(T[u].l);
    Postorder(T[u].r);
    cout << " " << u;
}


int main(){
    int id,left,right,root;
    cin >> n;
    
    for(int i=0;i<n;i++){
        T[i].p=NIL;
    }
    
    for(int i=0;i<n;i++){
        cin >> id >> left >> right;
        T[id].l=left;
        T[id].r=right;
        if(left!=NIL) T[left].p=id;
        if(right!=NIL) T[right].p=id;
    }
    
    for(int i=0;i<n;i++) if(T[i].p==NIL) root=i;
    
    cout << "Preorder" << endl;
    Preorder(root);
    cout << endl;
    
    cout << "Inorder" << endl;
    Inorder(root);
    cout << endl;
    
    cout << "Postorder" << endl;
    Postorder(root);
    cout << endl;
    
    return 0;
}    


Measured memory_bytes: 3116
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}
template<typename T, int Begin, int End>
T& OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}
template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}

LL N, K, A[100001];
int main() {
	cin >> N >> K;
	REP(i, 0, N) {
		cin >> A[i];
	}
	LL sum = 0;
	REP(i, 0, N) {
		if (A[i] > 0) sum += A[i];
	}

	// 黒でマイナス
	LL MINUS = 0;
	LL MINUS_MIN = 0;
	REP(i, 0, K) {
		if (A[i] < 0) MINUS += abs(A[i]);
	}
	MINUS_MIN = MINUS;
	REP(i, 0, N - K) {
		MINUS += (A[i] < 0 ? A[i] : 0) + (A[K + i] < 0 ? -A[K + i] : 0);
		MINUS_MIN = min(MINUS_MIN, MINUS);
	}

	// 白でプラス
	LL PLUS = 0;
	LL PLUS_MIN = 0;
	REP(i, 0, K) {
		if (A[i] > 0) PLUS += abs(A[i]);
	}
	PLUS_MIN = PLUS;
	REP(i, 0, N - K) {
		PLUS += (A[i] > 0 ? -A[i] : 0) + (A[K + i] > 0 ? A[K + i] : 0);
		PLUS_MIN = min(PLUS_MIN, PLUS);
	}

	cout << sum - min(MINUS_MIN, PLUS_MIN) << endl;
	return 0;
}


Measured memory_bytes: 1024
import Data.List

main = do
    getLine
    as <- map read . words <$> getContents
    print . fst $ foldl f (0,0) as

f (p,0) k = let (d,m) = k `divMod` 2 in (p+d,m)
f (p,1) 0 = (p,0)
f (p,1) k = let (d,m) = (k-1) `divMod` 2 in (p+d+1,m)

Measured memory_bytes: 54652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,x,y;
	scanf("%d%d%d%d",&n,&m,&x,&y);
	int Max=INT_MIN,Min=INT_MAX;
	int z;
	for(int i=0;i<n;i++){
		scanf("%d",&z);
		Max=max(Max,z);
	}
	for(int i=0;i<m;i++){
		scanf("%d",&z);
		Min=min(Min,z);
	}
	bool Y=false;
	for(int i=x+1;i<y;i++){
		if(i>Max&&Min>=i){
			Y=true;
			break;
		}
	}
	printf("%s\n",Y?"No War":"War");
	return 0;
} 

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	int out=0;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,in.size()){
		out+=in[i]-1;
	}
	cout<<out<<endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m, visitt[N];
vector<vector<int> > v(N);
int dfs(int n){
    visitt[n] = 1;
    int cnt = 1;
    for(int value: v[n])
        if(!visitt[value])
            cnt += dfs(value);
    return cnt;
}
int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int mx = 0;
    for(int i = 1; i <= n; i++){
        if(!visitt[i]){
            mx = max(mx, dfs(i));
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 24280
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#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 n;
int a, b, c;
vector<int> l;
int ans = 2e9;

void dfs(int cost, int depth, int a_, int b_, int c_)
{
    if (depth == n)
    {
        if (a_ == 0 || b_ == 0 || c_ == 0) return;
        cost += abs(a - a_) + abs(b - b_) + abs(c - c_) - 30;
        ans = min(ans, cost);
        return;
    }
    dfs(cost + 10, depth + 1, a_ + l[depth], b_, c_);
    dfs(cost + 10, depth + 1, a_ , b_ + l[depth], c_);
    dfs(cost + 10, depth + 1, a_, b_, c_ + l[depth]);
    dfs(cost + 0, depth + 1, a_, b_, c_);
}

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    cin >> n >> a >> b >> c;
    l.resize(n);
    rep(i, n) cin >> l[i];
    
    dfs(0, 0, 0, 0, 0);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
from heapq import *

# Aの中でxの根を求める
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a

# Aのリストでxとyの属する集合の併合
def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

N = int(input())
X = [(0,0)] * N
Y = [(0,0)] * N
E = [(0,0)] * N

for i in range(N):
    x, y = map(int, input().split())
    X[i] = (x, i)
    Y[i] = (y, i)
    E[i] = (x, y)

X.sort()
Y.sort()
H = []
heapify(H)

for i in range(N - 1):
    x1, j1 = X[i]
    x2, j2 = X[i + 1]
    y1, k1 = Y[i]
    y2, k2 = Y[i + 1]
    heappush(H, (x2 - x1, j1, j2))
    heappush(H, (y2 - y1, k1, k2))

answer = 0
V = [i for i in range(N)]

while H:
    w, s, t = heappop(H)
    if find(V, s) != find(V, t):
        union(V, s, t)
        answer += w

print(answer)


Measured memory_bytes: 61224
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll gcd(ll a, ll b){
    if(a < b)  swap(a,b);
    if(a%b==0) return b;
    else return gcd(b,a%b);
}
ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
ll nlcm(vector<ll> numbers) {
    ll res;
    res = numbers[0];
    for (ll i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    cout << nlcm(v) << endl;   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i,floor(sqrt(n))+1){
    if(pow(i,2) <=n){
      ans = pow(i,2);
    }
    else{
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0430_atcoder問題03
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split('/');
            int year = Convert.ToInt32(input[0]);
            int month = Convert.ToInt32(input[1]);
            int day = Convert.ToInt32(input[2]);
            if (year < 2019)
            {
                Console.WriteLine("Heisei");
            }
            else if (year == 2019 && month < 5)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }
        }
    }
}

Measured memory_bytes: 11220
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

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

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<string> field(n);
  REP(i, n) cin >> field[i];

  int ans = INF;
  REPS(i, 1, n - 1){
    int cnt = 0;
    REP(j, i){
      //cout << "line1: " << i << endl;
      REP(k, m){
        if (field[j][k] != 'W') cnt++;
      }
    }
    //print("-------");
    int tmp = cnt;
    REPS(j, i + 1, n){
      REPS(k, i, j){
        //cout << "line2: " << j << endl;
        REP(l, m){
          if (field[k][l] != 'B') cnt++;
        }
        //print("-------");
      }
      REPS(k, j, n){
        //cout << "line3: " << k << endl;
        REP(l, m){
          if (field[k][l] != 'R')  cnt++;
        }
        //print(cnt);
      }
      ans = min(ans, cnt);
      cnt = tmp;
    }
  }

  print(ans);

  return (0);
}

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

int main()
{
    int y, x;
    cin >> y >> x;
    char arr[y][x];
    char c;
    rep(i, y)
    {
        rep(j, x)
        {
            cin >> arr[i][j];
        }
    }
    rep(i, y)
    {
        rep(j, x)
        {
            int cou = 0;
            c = arr[i][j];
            if (c == '#')
                continue;
            if (j != 0 && arr[i][j - 1] == '#')
                cou++;
            if (j != 0 && i != 0 && arr[i - 1][j - 1] == '#')
                cou++;
            if (j != 0 && i != y - 1 && arr[i + 1][j - 1] == '#')
                cou++;
            if (j != x - 1 && arr[i][j + 1] == '#')
                cou++;
            if (j != x - 1 && i != 0 && arr[i - 1][j + 1] == '#')
                cou++;
            if (j != x - 1 && i != y - 1 && arr[i + 1][j + 1] == '#')
                cou++;
            if (i != 0 && arr[i - 1][j] == '#')
                cou++;
            if (i != y - 1 && arr[i + 1][j] == '#')
                cou++;
            arr[i][j] = '0' + cou;
        }
    }
    rep(i, y)
    {
        rep(j, x)
        {
            cout << arr[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using lint = long long;
vector<vector<int> > G;
vector<int> field;
vector<bool> visited;
int n,m;

void bfs()
{
	queue<int> que;
	que.push(0);
	visited[0] = true;
	while(!que.empty()){
		int now = que.front();
		que.pop();
		for(auto next : G[now])
            {
			if(!visited[next])
			{
				que.push(next);
				field[next] = now;
				visited[next] = true;
			}
		}
	}
}

void addEdge(vector <int> edges[], int u, int v)
{
   edges[u].push_back(v);
   edges[v].push_back(u);
}

int main()
{
    cin >> n >> m;
	vector<lint> a(m), b(m);
	G.resize(n);
    field.resize(n);
    visited.resize(n, false);

    vector<int> v;

    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }

    bfs();
    cout << "Yes" << endl;
	for(int i = 1; i < n; i++)
        cout << field[i] + 1 << endl;

    return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

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

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	vector<ll> cnt(3, 0);
	ll N, A, B; cin >> N >> A >> B;
	vector<ll> P(N); REP(i, N) cin >> P[i];

	REP(i, N)
	{
		ll t = P[i];

		if (t <= A) cnt[0]++;
		else if (t <= B) cnt[1]++;
		else cnt[2]++;
	}

	std::cout << *min_element(ALL(cnt)) << std::endl;
	
	return 0;
}


Measured memory_bytes: 3660
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


void solv() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll v[55];
	map<ll, int> m;
	for (size_t i = 0; i < n; i++)
	{
		cin >> v[i];
		m[v[i]]++;
	}

	sort(v, v + n);
	reverse(v, v + n);
	map<ll, int> mp;
	ll ta[51][51];
	memset(ta, 0, sizeof(ta));
	ta[0][0] = 1;
	for (size_t i = 1; i < 51; i++)
	{
		ta[i][0] = 1;
		for (size_t j = 1; j < 51; j++)
		{
			ta[i][j] = ta[i - 1][j] + ta[i - 1][j - 1];
		}
	}
	ll res = 0;
	ll sum = 0;
	ll den = 1;
	ll me = 0;

	for (ll i = 0; i < n; i++)
	{
		sum += v[i];
		mp[v[i]]++;

		if (i + 1 < a) continue;
		if (i + 1 > b) continue;
		if (me * (i + 1) < den * sum) {
			den = (i + 1);
			me = sum;
			res = 0;
		}
		if (me * (i + 1) > den * sum) { 
			continue; 
		}
		res += ta[m[v[i]]][mp[v[i]]];
	}

	cout << setprecision(20) << ((double)me / (double)den) << endl;
	cout << res << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 256