akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int t;
ll a, b, c, d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> t;
  FOR(i, 0, t){
    cin >> a >> b >> c >> d;
    if(a < b || b > d){
      cout << "No" << endl;
      continue;
    }
    if(c >= b){
      cout << "Yes" << endl;
      continue;
    }
    ll g = gcd(b, d);
    a %= g;
    if(a+b-g > c){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll H,W;
	while(1){
		cin >> H >> W;
		if(H==0&&W==0){break;}
		REP(i,H){
			REP(j,W){
				if(i==0 || i==H-1 || j==0 || j== W-1){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
	printf("\n");
	}
  return 0;
}


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

struct Sieve {
  ll n;
  vector<ll> f, primes;
  Sieve(ll n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(ll x) { return f[x] == x;}
  vector<ll> factorList(ll x) {
    vector<ll> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(ll x) {
    vector<ll> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (ll p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  ll n;
  cin >> n;

  ll n_max = 1e7;
  Sieve seive(n_max);

  auto get_num = [&](ll num) {
    // 1 の場合は 1のみ
    if(num == 1) {
      return ll(1);
    }
    auto ps = seive.factor(num);
    ll v = 1;
    for(auto p : ps) {
      v *= (p.second + 1);
    }
    return v;
  };

  ll ans = 0;
  for(ll i=1;i<=n;i++) {
    // printf("%lld: %lld\n", i, get_num(i));
    ans += i * get_num(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 89772
#include <bits/stdc++.h>
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;

#define M 100005
#define mod 1000000007
int n;
int a[M],sum[M],js[M],ni[M];

inline int qpow(int x,int ci) {
	int sum=1;
	for(;ci;ci>>=1,x=1ll*x*x%mod)
		if(ci&1) sum=1ll*x*sum%mod;
	return sum;
}

inline int get_c(int x,int y) {
	if(x<y) return 0;
	return 1ll*js[x]*ni[y]%mod*ni[x-y]%mod;
}

inline void inc(int &x,int y) {x+=y,x-=x>=mod?mod:0;}

int main () {
	//freopen("a.in","r",stdin);
	scanf("%d",&n);
	for1(1,n,i) scanf("%d",a+i);
	js[0]=1;
	for1(1,n,i) js[i]=1ll*js[i-1]*i%mod;
	ni[n]=qpow(js[n],mod-2);
	FOR2(n,1,i) ni[i-1]=1ll*ni[i]*i%mod;
	
	for1(2,n,i) inc(sum[i]=sum[i-1],1ll*js[i-1]*get_c(n,i)%mod*js[n-i]%mod);
	//cout<<sum[3]<<endl;
	int ans=0;
	for1(1,n,i) {
		int t=js[n];
		inc(t,(sum[i]-sum[1]+mod)%mod);
		inc(t,(sum[n-i+1]-sum[1]+mod)%mod);
		//cout<<t<<" ";
		inc(ans,1ll*t*a[i]%mod);
	}
//	cout<<endl;
	cout<<ans<<endl;
}

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

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(){
    string s; cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b, c, d, e, f;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();
        e = sc.nextInt();
        f = sc.nextInt();
        float bound = e * 1.f / (e + 100);
        float[][] dp = new float[f / 2 + 1][f + 1];
        dp[0][0] = 0.5f;
        float opt = -1.f;
        int sugar = -1;
        int total = -1;
        for (int i = 0; i <= f / 2; i++) {
            for (int j = i; j <= f; j++) {
                if(j >= 100 * b){
                    if(dp[i][j - 100 * b] > 0 || dp[i][j - 100 * a] > 0)
                        dp[i][j] = i * 1.f / j;
                    else if(i >= d && (dp[i - d][j - d] > 0 || dp[i - c][j - c] > 0))
                        dp[i][j] = i * 1.f / j;
                    else if(i >= c && dp[i - c][j - c] > 0)
                        dp[i][j] = i * 1.f / j;
                    if(bound >= dp[i][j] && dp[i][j] > opt){
                        opt = dp[i][j];
                        sugar = i;
                        total = j;
                    }
                }else if(j >= 100*a){
                    if(dp[i][j - 100 * a] > 0)
                        dp[i][j] = i * 1.f / j;
                    else if(i >= d && (dp[i - d][j - d] > 0 || dp[i - c][j - c] > 0))
                        dp[i][j] = i * 1.f / j;
                    else if(i >= c && dp[i - c][j - c] > 0)
                        dp[i][j] = i * 1.f / j;
                    if(bound >= dp[i][j] && dp[i][j] > opt){
                        opt = dp[i][j];
                        sugar = i;
                        total = j;
                    }
                }else if(j >= d){
                    if(i >= d && (dp[i - d][j - d] > 0 || dp[i - c][j - c] > 0))
                        dp[i][j] = i * 1.f / j;
                    else if(i >= c && dp[i - c][j - c] > 0)
                        dp[i][j] = i * 1.f / j;
                    if(bound >= dp[i][j] && dp[i][j] > opt){
                        opt = dp[i][j];
                        sugar = i;
                        total = j;
                    }
                }else if(j >= c){
                    if(i >= c && dp[i - c][j - c] > 0)
                        dp[i][j] = i * 1.f / j;
                    if(bound >= dp[i][j] && dp[i][j] > opt){
                        opt = dp[i][j];
                        sugar = i;
                        total = j;
                    }
                }
            }
        }
        if(sugar == 0)
            System.out.printf("%d %d\n", 100 * a, 0);
        else
            System.out.printf("%d %d\n", total, sugar);
    }
}

Measured memory_bytes: 52564
let k = Scanf.sscanf (read_line ()) "%d" @@ fun k -> k

let rec gcd x y = if y = 0 then x else gcd y (x mod y)

let () =
  let ans = ref 0 in
  for a = 1 to k do for b = 1 to k do for c = 1 to k do
    ans := !ans + gcd a (gcd b c)
  done done done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 3780
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N, A, B, C, D;
  scanf("%ld %ld %ld %ld %ld", &N, &A, &B, &C, &D);

  // solve
  const long diff = B - A, Nm1 = N - 1;
  if (C == 0) {
    if (diff <= D * Nm1 || diff >= -D * Nm1) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  } else {
    const long kl =
        max(0L, min(Nm1, (long)floor(0.5 * (Nm1 + (double)diff / C))));
    const long ku = max(0L, min(Nm1, kl + 1));
    const long lower = C * (2 * kl - Nm1);
    const long upper = C * (2 * ku - Nm1);
    // printf(
    //     "kl = %ld, lower = %ld, from_lower = %ld, ku = %ld, upper = %ld, "
    //     "from_upper = %ld\n",
    //     kl, lower, lower + kl * (D - C), ku, upper,
    //     upper - (Nm1 - ku) * (D - C));
    if ((ku != -Nm1 && lower + kl * (D - C) >= diff) ||
        (kl != Nm1 && upper - (Nm1 - ku) * (D - C) <= diff)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}


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

int n,m,a[330][330],p[330],used[330],cou[330];

int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++) cin>>a[i][j];
	}
	int l=1,r=n;
	while (l<r){
		int mid=(l+r)/2;
		//cout<<mid<<endl;
		memset(used,0,sizeof used);
		memset(cou,0,sizeof cou);
		for (int i=1;i<=n;i++) p[i]=1;
		queue<int> q;
		for (int i=1;i<=n;i++){
			used[a[i][p[i]]]++;
			if (used[a[i][p[i]]]>mid) q.push(a[i][p[i]]);
		}
		bool f=true;
		while (!q.empty() && f){
			int t=q.front();q.pop();
			if (!cou[t]){
				cou[t]=1;
				for (int i=1;i<=n;i++){
					if (a[i][p[i]]==t){
						while (cou[a[i][p[i]]]) p[i]++;
						if (p[i]>m) f=false;
						else{
							used[a[i][p[i]]]++;
							if (used[a[i][p[i]]]>mid) q.push(a[i][p[i]]);
						}
					}
				}
			}
		}
		if (f && q.empty()) r=mid;
		else l=mid+1;
	}
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int N;
long long unsigned int Y;

int main(){
    int x, y, z;
    x = y = z = 0;
    cin >> N >> Y;

    for(x = 0; x <= N; x++){
        for(y = 0; y + x <= N; y++){
            z = N - (x+y);
            if(z < 0) break;
            if(x + y + z == N && 10000*x + 5000*y + 1000*z == Y){
                cout << x << " " << y << " " << z;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";

    return 0;
}

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

using namespace std;

string s;

int main()
{
    cin >> s;
    int cnt1 = 0,cnt2 = 0;
    int n = s.size();
    char ch = s[0],ch1 = s[n - 1];
    for(int i = 1,j = n - 2; i < n; i++){
        if(ch != s[i]){
            cnt1++;
            ch = s[i];
        }
        if(ch1 != s[j]){
         cnt2++;
         ch1 = s[j];
        }
        j--;
    }
    cout << min(cnt1,cnt2) << endl;
    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

bool cmp(pair<int,int> a,pair<int,int> b)
{
	if(a.first==b.first)
	{
		return a.second<b.second;
	}
	return a.first>b.first;
}
int32_t main()
{
	fastio();
	int n;
	cin>>n;
	vector<pair<int,int>> tp1,tp2,tp3;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		int cur=0;
		int mi=inf;
		for(auto x: s)
		{
			if(x=='(')cur++;
			else cur--;
			mi=min(mi,cur);
		}
		if(cur==s.length())
		{
			tp1.push_back({cur,0});
		}
		else if(-cur==s.length())
		{
			tp3.push_back({cur,0});
		}
		else
		{
			tp2.push_back({cur,mi});
		}
	}
	sort(tp2.begin(),tp2.end(),cmp);
	int cur=0;
	for(auto x: tp1)
	{
		cur+=x.first;
	}
	for(auto x: tp2)
	{
		if(cur+x.second<0)
		{
			cout<<"No\n";
			return 0;
		}
		cur+=x.first;
	}
	for(auto x: tp3)
	{
		cur+=x.first;
	}
	if(cur==0)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}


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

using namespace std;

vector<vector<vector<int>>> graph;
vector<int> ret;

void dfs(int v, int prevColor) {
    int color = 1;
    for (auto nextEdge:graph[v]) {
        if (ret[nextEdge[1]] == 0) {
            if (color == prevColor)color++;
            ret[nextEdge[1]] = color;
            dfs(nextEdge[0], color);
            color++;
        }
    }
}

int main() {
    int n;
    cin >> n;
    graph = vector<vector<vector<int>>>(n);
    vector<vector<int>> edge(n);
    vector<int> count(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back({b, i});
        graph[b].push_back({a, i});
        count[a]++, count[b]++;
    }

    int maxCount = 0;
    int maxIndex = -1;
    for (int i = 0; i < n; i++) {
        if (maxCount < count[i]) {
            maxCount = count[i];
            maxIndex = i;
        }
    }

    cout << maxCount << endl;
    ret = vector<int>(n - 1);
    dfs(maxIndex, 0);
    for (auto x:ret)cout << x << endl;
    return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, comb = 0; cin >> N;
  vector<ll> A(N), kosuu(N, 0);
  for(ll i = 0; i < N; i++) {
  	cin >> A[i]; A[i]--;
  }
  for(ll i = 0; i < N; i++) {
  	kosuu[A[i]]++;
  }
  for(ll i = 0; i < N; i++) {
  	comb += kosuu[i] * (kosuu[i] - 1) / 2;
  }
  for(ll i = 0; i < N; i++) {
  	cout << comb - (kosuu[A[i]] - 1) << endl;
  }
}

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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

bool dfs(vector<int> A, ll K, ll C, int count, int index)
{
	if (K == 0)
	{
		return false;
	}

	if (K <= count)
	{
		return true;
	}

	if (A.empty())
	{
		return false;
	}

	if (A.size() - 1 <= index)
	{
		return false;
	}

	for (auto i = index + 1; i < A.size(); i++)
	{
		if(A[i] - A[index] >= C)
		{ }
		else
		{
			A.erase(A.begin() + i);
			return dfs(A, K - 1, C, count + 1, i - 1);
		}
	}
}

int main()
{
	ll N, K, interval;
	string shift_table;

	cin >> N >> K >> interval;
	cin >> shift_table;

	vector<int> fronts, backs;

	// 前から
	int index = 0;
	for (auto i = 0; i < N; i++)
	{
		if (shift_table[i] == 'o')
		{
			fronts.push_back(i);
			i += interval;
		}
	}

	// 後ろから
	index = 0;
	for (auto i = N - 1; i >= 0; i--)
	{
		if (shift_table[i] == 'o')
		{
			backs.push_back(i);
			i -= interval;
		}
	}

	// どちらにもあるものがans
	rep(i, K)
	{
		if (fronts[i] == backs[K - i - 1])
		{
			cout << fronts[i] + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
int n,ma[18][18],m,tot[1<<16],dp[1<<16][16],tt;
void getmax(int &x,int y)
{
	if(y>x)x=y;
}
int main()
{
	memset(ma,-0x3f3f3f,sizeof(ma));
	scanf("%d%d",&n,&m);tt=0;
	for(int i=1;i<=m;++i)
	{
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		ma[x][y]=ma[y][x]=z;tt+=z;
	}
	for(int i=1;i<(1<<n);++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(i&(1<<(j-1)))
			{
				tot[i]=tot[i^(1<<(j-1))];
				for(int k=j+1;k<=n;++k)
				{
					if((i&(1<<(k-1)))&&ma[j][k]>0)tot[i]+=ma[j][k];
				}
				break;
			}
		}
	}
	memset(dp,-0x3f3f3f,sizeof(dp));
	dp[1][1]=0;
	for(int i=1;i<(1<<n);++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(i&(1<<(j-1)))
			{
				int r=i;
				while(r)
				{
					if(r&(1<<(j-1)))
					{
						getmax(dp[i][j],dp[(i-r)|(1<<(j-1))][j]+tot[r]);
					}
					r=(r-1)&i;
				}
				for(int k=1;k<=n;++k)
				{
					if(!(i&(1<<(k-1))))
					{
						getmax(dp[i|(1<<(k-1))][k],dp[i][j]+ma[j][k]);
					}
				}
			}
		}
	}
	int res=0;
	for(int i=0;i<(1<<n);++i)
	{
		if(i&(1<<(n-1)))
		getmax(res,dp[i][n]);
	}
	cout<<tt-res<<endl;
  return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
set<char> st;
string s;
int main(int argc,char const* argv[])
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
    {
      cout << "Yes" << endl;
    }
    else
      {
	cout << "No" << endl;
      }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
	return 0;
}

Measured memory_bytes: 256
program ABC160E2
    implicit none
    integer(8)::X,Y,A,B,C,i,ans
    integer(8),allocatable,dimension(:)::P,Q,R
    read*,X,Y,A,B,C
    ans=0

    allocate(P(A))
    allocate(Q(B))
    allocate(R(C+X+Y))
    read*,P,Q,(R(i),i=1,C)
    call heapsort(A,P)
    call heapsort(B,Q)

    do i=0,X-1
        R(C+i+1)=P(A-i)
    end do

    do i=0,Y-1
        R(C+X+i+1)=Q(B-i)
    end do
    call heapsort(C+X+Y,R)

    do i=0,X+Y-1
        ans=ans+R(C+X+Y-i)
    end do

    print'(i0)',ans
end program ABC160E2

subroutine heapsort(n,array)
    implicit none
    integer(8),intent(in) :: n
    integer(8),intent(inout) :: array(1:n)
   
    integer(8) ::i,k,j,l
    integer(8) :: t
   
    if(n.eq.1)return
  
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       enddo
       array(i)=t
    enddo
  
    return
  end subroutine heapsort

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

using namespace std;
typedef long long ll;
struct town{
  int x, y, num;

  town(int xx, int yy, int nn) : x(xx), y(yy), num(nn) {}

  bool operator < (const town& oth) const {
  if(x != oth.x) return x < oth.x;
  else if(y != oth.y) return y < oth.y;
  return num < oth.num;
  }
};

struct edge{int from, to, cost;

  edge(int f, int t, int c) : from(f), to(t), cost(c) {}

  bool operator < (const edge& oth) const {
    if(cost != oth.cost) return cost < oth.cost;
    else if(from != oth.from) return from < oth.from;
    return to < oth.to;
  }

};

vector<town> g;
vector<edge> s;
int n;
int par[100005];
int Rank[100005];
ll ans;
void init(int n) {
  for(int i = 0; i < n; i++) {
    par[i] = i;
    Rank[i] = 0;
  }
}

int find(int x) {
  return x == par[x] ? x : par[x] = find(par[x]);
}

void Union(int x, int y) {
  int a = find(x);
  int b = find(y);
  if(a == b) return;

  if(Rank[a] > Rank[b]) par[b] = a;
  else {
    par[a] = b;
    if(Rank[a] == Rank[b]) Rank[b]++;
  }
}

int main() {
  cin >> n;
  init(n);
  for(int i = 0; i < n; i++) {
    int x,y;
    cin >> x >> y;
    g.push_back(town(x,y,i));
  }
  sort(g.begin(),g.end());

  for(int i = 1; i < n; i++) {
    int c = min(abs(g[i].x - g[i-1].x),abs(g[i].y - g[i-1].y));
    s.push_back(edge(g[i].num,g[i-1].num,c));
  }
  for(int i = 0; i < n; i++) swap(g[i].x,g[i].y);

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

   for(int i = 1; i < n; i++) {
    int c = min(abs(g[i].x - g[i-1].x),abs(g[i].y - g[i-1].y));
    s.push_back(edge(g[i].num,g[i-1].num,c));
  }
  
   sort(s.begin(),s.end());
  
   for(int i = 0; i < s.size(); i++) {
     
     int u = s[i].from;
     int v = s[i].to;
     int C = s[i].cost;
   
     if(find(u) != find(v)) {
       Union(u,v);
       ans += C;
     }
   }

   cout << ans << endl;
}
  /*for(int i = 0; i < n; i++) {
  cout << g[i].x <<"   "<<g[i].y<<"   "<<g[i].num<< endl;
 }
 }*/


Measured memory_bytes: 6644
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n; cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		if (s == "AC") ac++;
		else if (s == "WA") wa++;
		else if (s == "TLE") tle++;
		else re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000000000000
int main(){
	int n,k;string s;
	cin>>n>>k>>s;k--;

	if(s[k]=='A'){s[k]='a';}
	if(s[k]=='B'){s[k]='b';}
	if(s[k]=='C'){s[k]='c';}

	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int N; cin >> N;
    string s; cin >> s;
    int k; cin >> k;
    char b = s[k - 1];
    rep(i, N){
        if(s[i] != b) {
            s[i] = '*';
        }
    }
    COUT(s);
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#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 <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int extgcd(int a, int b, int& x, int& y) {
    int d = a;

    if (b == 0) {
        x = 1;
        y = 0;
    } else {
        d = extgcd(b, a % b, y, x);
        y -= (a/b) * x;
    }
    return d;
}

int main() {
    int a, b;
    int x, y;
    cin >> a >> b;
    bool flag = false;
    if (a < b) {
        swap(a, b);
        flag = true;
    }
    extgcd(a, b, x, y);
    if (flag) swap(x, y);
    printf("%d %d\n", x, y);
    return 0;
}

Measured memory_bytes: 1140
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k):
    b=[0]*(n+1)
    for i in range(n):
        b[max(i-a[i],0)]+=1
        b[min(i+a[i]+1,n)]-=1
    for i in range(n):
        b[i+1]+=b[i]
    f=1
    for j in range(n):
        if b[j]!=n:
            f=0
            break
    if f:
        print(*b[:n])
        exit()
    a=b[:]
print(*a[:n])

Measured memory_bytes: 168804
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int n;
  cin>>n;
  int old = 0;
  int mx = 0;
  int cnt = 0;
  for(int i:irange(0,n)){
    int h;
    cin>>h;
    if (old >= h) {
      ++cnt;
      mx = max(mx, cnt);
    } else {
      cnt = 0;
    }
    old = h;
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

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

    string t="";
    for(auto c : s)
        if(t.back() != c) t.push_back(c);
    int n=t.size();
    cout << n-1 << endl;
    return 0;
}

Measured memory_bytes: 704
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n!=0){
    int a;
    int q[10]={};
    for(int i=0;i<n;i++){
      cin>>a;
      q[a]++;
    }
    for(int i=0;i<10;i++){
      if(q[i]==0){
	cout<<'-'<<endl;
      }else{
	for(int l=0;l<q[i];l++){
	  cout<<'*';
	}
	cout<<endl;
      }
    }
    cin>>n;
  }
  return 0;
}



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

const int N = 200005;
const int MOD = 1000000007;

int solve() {
  int n, t, x;
  scanf("%d %d %d", &n, &x, &t);
  printf("%d\n", (n + x - 1) / x * t);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


Measured memory_bytes: 3824
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, k, n) for (int i = k; i < (int)(n); i++)
#define coyes cout << "Yes" << endl;
#define cono cout << "No" << endl;
#define coYes cout << "YES" << endl;
#define coNo cout << "NO" << endl;
using namespace std;
using ll = long long int;
string large_al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string small_al = "abcdefghijklmnopqrstuvwxyz";
using Graph = vector<vector<int>>;
using i64 = int64_t;

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  if (h > w) {
    if (n % h == 0) {
      cout << n / h << endl;
    }
    else {
      cout << n / h + 1 << endl;
    }
  }
  else {
    if (n % w == 0) {
      cout << n / w << endl;
    }
    else {
      cout << n / w + 1 << endl;
    }
  }
}



Measured memory_bytes: 256
n,m,q=map(int, input().split())
lr=[list(map(int,input().split())) for i in range(m)]
pq=[list(map(int,input().split())) for i in range(q)]

a=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
    a[lr[i][0]][lr[i][1]]+=1
for i in range(1,n+1):
    for j in range(1,n+1):
        a[i][j]+=a[i-1][j]
for i in range(1,n+1):
    for j in range(1,n+1):
        a[i][j]+=a[i][j-1]
for i in range(q):
    print(a[pq[i][1]][pq[i][1]]-a[pq[i][0]-1][pq[i][1]])

Measured memory_bytes: 77272
unittest
{
	assert( [ "a?c", "der", "cod" ].parse.expand.solve == 7 );
	assert( [ "atcoder", "atcoder", "???????" ].parse.expand.solve == 7 );
	
	assert( [ "tc", "atcoder", "de" ].parse.expand.solve == 7 );		// 追加ケース
	assert( [ "tc?", "atcoder", "?de" ].parse.expand.solve == 7 );		// 追加ケース
	assert( [ "tc?", "atcoder", "cde" ].parse.expand.solve == 10 );		// 追加ケース
	assert( [ "?".repeat( 2000 ).join( "" ), "?".repeat( 2000 ).join( "" ), "?".repeat( 2000 ).join( "" ) ].parse.expand.solve == 2000 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = new dchar[][ 3 ];
	foreach( ref x; abc )
	{
		x = input.front.to!( dchar[] );
		input.popFront;
	}
	return tuple( abc );
}

auto solve( dchar[][] abc )
{
	// msss[ 文字列X ][ 文字列Y ][ i文字目 ] = 文字列Xのi文字目以降と文字列Yを比較して不一致か
	auto msss = new bool[][][]( 3, 3, reduce!( ( x, y ) => x + y.length )( 1L, abc ) );
	foreach( i, ref mss; msss )
	{
		foreach( j, ref ms; mss )
		{
			if( i == j ) continue;
			foreach( k, ref m; ms )
			{
				if( abc[ i ].length <= k ) break;
				foreach( x, y; lockstep( abc[ i ][ k .. min( $, k + abc[ j ].length ) ], abc[ j ] ) )
				{
					if( x != '?' && y != '?' && x != y )
					{
						m = true;
						break;
					}
				}
			}
		}
	}
	
	// 文字列の順番を入れ替えながら全列挙
	auto ans = long.max;
	foreach( ps; iota( 3 ).permutations )
	{
		foreach( i; 0L .. abc[ ps[ 0 ] ].length + 1 )
		{
			foreach( j; 0L .. max( abc[ ps[ 0 ] ].length.signed - i, abc[ ps[ 1 ] ].length ) + 1 )
			{
				if( !msss[ ps[ 0 ] ][ ps[ 1 ] ][ i ] && !msss[ ps[ 1 ] ][ ps[ 2 ] ][ j ] && !msss[ ps[ 0 ] ][ ps[ 2 ] ][ i + j ] )
				{
					auto a = max( abc[ ps[ 0 ] ].length, i + abc[ ps[ 1 ] ].length, i + j + abc[ ps[ 2 ] ].length );
					ans = min( ans, a );
				}
			}
		}
	}
	return ans;
}


Measured memory_bytes: 380
s = input()

res = 0
for i in range(2**(len(s)-1)):
    pos = 0
    for j in range(len(s)-1):
        if (i >> j) & 1:
            res += int(s[pos:j+1])
            pos = j + 1
    res += int(s[pos:])

print(res)

Measured memory_bytes: 9012
#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<vector>
#include<unordered_set>
#include<algorithm>

using namespace std;

namespace
{

}

#if 1
int main()
{
	int n;
	cin >> n;

	std::vector<string> strs;
	strs.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> strs[i];
	}

	bool isSuccess = true;
	char last = ' ';
	std::unordered_set<string> sets;
	for (int i = 0; i < n; i++)
	{
		if (i != 0)
		{
			if (last != strs[i][0])
			{
				isSuccess = false;
				break;
			}
		}

		auto itr = sets.find(strs[i]);
		if (itr != sets.end())
		{
			isSuccess = false;
			break;
		}
		sets.insert(strs[i]);

		last = strs[i][strs[i].size() - 1];
	}



	if (isSuccess)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 256
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int A[N];
  int k = 0;

  for(int i = 0; i < N; i++){
    A[i] = 0;

  }
  for(int i = 0; i < N - 1 ; i++){
    cin >> k;
    A[k-1] = A[k-1] + 1;
    //cout << A[k] << endl;
  }

  for(int i = 0; i < N; i++){
    cout << A[i] << endl;
    //cout << "test";
  }

}


Measured memory_bytes: 4372
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static int N;
	static int M;
	static 		ArrayList<ArrayList<Integer>> map;
	static boolean[] used;
	static int f = 0;
	static int s = 0;

	static int mindis = 1000000000;
	static ArrayList<Integer> saitan;




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(b- a <= 0){
			System.out.println("delicious");
		}else if(b - a <= x ){
			System.out.println("safe");

		}else{
			System.out.println("dangerous");

		}
		
		
	}

}




Measured memory_bytes: 21972
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
    mn = int(1e10)


    for j in range(1,min(i,k)+1):
        if abs(h[i] - h[i-j]) + dp[i-j] < mn:
            mn = abs(h[i] - h[i-j]) + dp[i-j]
    dp[i] = mn
print(dp[n-1])

Measured memory_bytes: 52448
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){      
    string s;   
    cin >> s;
    if( s[0] != s[1] && s[1] != s[2] && s[2] != s[3]){
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }
}

Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end
s = gets.chomp
t = gets.chomp

sc = s.codepoints
tc = t.codepoints

dp = Array.new(s.size + 1) { Array.new(t.size + 1, 0) }
0.upto(s.length - 1) do |i|
  dpi1 = dp[i+1]
  dpi0 = dp[i]
  0.upto(t.length - 1) do |j|
    if (sc[i] == tc[j]) 
      dpi1[j+1] =  dpi0[j] + 1
    else
      dpi1[j+1] = dpi0[j+1]
      dpi1[j+1] = dpi1[j] if dpi1[j+1] < dpi1[j]
    end
  end
end

sl = s.length
tl = t.length

res = ""
while sl > 0 && tl > 0
  if dp[sl][tl] == dp[sl-1][tl]
    sl -= 1
  elsif dp[sl][tl] == dp[sl][tl-1]
    tl -= 1
  else
    res << s[sl-1]
    sl -= 1
    tl -= 1
  end
end

puts res.reverse

Measured memory_bytes: 72316
#include <iostream>
#include <map>
using namespace std;
int main(){
    long long n, k;
    cin >> n >> k;
    long long a, b, tmp=0;
    map<long long,long long>mp;
    for(int i=0; i<n; i++){
        cin >> a >> b;
        mp[a] += b;
    }
/*
for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first           // キーを表示
                << ", val = " << itr->second << "\n";    // 値を表示
    }
*/
    //for(auto p : mp) pair だよ~
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        tmp += itr->second;
        a = itr->first;
        if(tmp>=k) break;
    }
    cout << a << endl;
    return 0;
}

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

using namespace std;

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

    vector<long> A;
    vector<long> B;
    vector<long> a{0};
    vector<long> b{0};

    for(int i=0;i<N;i++){
        long a;
        cin>>a;
        A.push_back(a);
    }
    for(int i=0;i<M;i++){
        long b;
        cin>>b;
        B.push_back(b);
    }

    for(int i=0;i<N+1;i++){
        a.push_back(a[i]+A[i]);//calc a1=a[0]+A[0] := a1=a0 + A1
    }
    for(int i=0;i<M+1;i++){
        b.push_back(b[i]+B[i]);
    }

    long res=0;
    long j=M;

    for(int i=0;i<N+1;i++){
        if (a[i] > K){
            break;
        }
        while(b[j] > K-a[i]){
            j-=1;
        }
        res=max(i+j,res);
    }
    cout<<res;
}

Measured memory_bytes: 11032
#include<bits/stdc++.h>
#define y1 wzpakking
#define ll long long
#define pa pair<int,int>
#define mo 998244353
using namespace std;
const int N=300005;
int fac[N],inv[N];
int n,a,b,ans;
long long k;
int C(int x,int y){
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	fac[0]=inv[0]=inv[1]=1;
	for (int i=2;i<=n;i++)
		inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	for (int i=1;i<=n;i++){
		fac[i]=1ll*fac[i-1]*i%mo;
		inv[i]=1ll*inv[i-1]*inv[i]%mo;
	}
	for (int red=0;red<=n;red++){
		long long rest=k-1ll*red*a;
		if (rest<0||rest>1ll*b*n||rest%b) continue;
		int blue=rest/b;
		ans=(ans+1ll*C(n,red)*C(n,blue))%mo;
	}
	printf("%d",ans);
}

Measured memory_bytes: 2560
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int H,W;
    cin >> H >> W;
    string board[50];

    for (int i = 0; i < H; ++i)
        cin >> board[i];

    const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
    const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (board[i][j] == '#') continue;

            int num = 0;
            for (int d = 0; d < 8; ++ d) {
                const int ni = i + dy[d];
                const int nj = j + dx[d];
                if (ni < 0 || H <= ni) continue;
                if (nj < 0 || W <= nj) continue;
                if (board[ni][nj] == '#') num++;
            }

            board[i][j] = char(num + '0');

        }
    }

    for(int i = 0; i < H; ++i) 
        cout << board[i] << endl;
    
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int cnt=0;
  for(int i=0;;i++){
    if(a>=b){
      b*=2;
      cnt++;
    }
    else break;
  }
  for(int i=0;;i++){
    if(b>=c){
      c*=2;
      cnt++;
    }
    else break;
  }
  if(cnt<=k) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#define MAX 2000000

void Counts(int *,int *,int);
int C[MAX];
int n;

int main() {

  int num[MAX],ans[MAX];
  int i;

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&num[i]);
  
  int max = 0;
  for(i=1;i<=n;i++) if(max<=num[i]) max=num[i];

  Counts(num,ans,max);

  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",ans[i]);
  }
  printf("\n");

  return 0;

}

void Counts(int A[n],int B[n],int k) {

  int i,j;
  
  for(i=0;i<=k;i++) C[i]=0;

  for(j=1;j<=n;j++) C[A[j]]++;

  for(i=1;i<=k;i++) C[i] = C[i] + C[i-1];

  for(j=n;j>=1;j--) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}


Measured memory_bytes: 17352
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*/
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin >> s;
  if(s.at(0)-'0'==7)cout << "Yes"<<endl;
  else if(s.at(1)-'0'==7)cout << "Yes"<<endl;
  else if(s.at(2)-'0'==7)cout << "Yes"<<endl;
  else  cout << "No"<<endl;
} 

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <string>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0;i < N;i ++){
        cin >> A.at(i);
    }
    int count,sum = 1;
    for(count = 0;sum < N;count ++){
        sum -= (count -1) * (K -1); 
        sum += count * (K -1);
    }
    cout << count << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
vector<int>x;
vector<int>y;
map<char,int>a;
map<char,int>b;

int main(){
  string s,t;
  cin>>s>>t;
  int cnt=0;
  int na=0,nb=0;
  for(int i=0;i<s.size();i++){
    if(a.count(s[i])==0){
      a[s[i]]=na;
      na++;
    }
    x.push_back(a[s[i]]);
  }
  for(int i=0;i<t.size();i++){
    if(b.count(t[i])==0){
      b[t[i]]=nb;
      nb++;
    }
    y.push_back(b[t[i]]);
  }
  if(equal(x.begin(),x.end(),y.begin()))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}


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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b,k;
  cin >> a >> b;
  if (a < b){
    swap(a,b);
  }
  if ((a - b) % 2 == 0){
    cout << (a - b) / 2 + b<< '\n';
  }
  else{
    cout << "IMPOSSIBLE\n";
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    int a[n],mx = 0;
    rep(i,n){
        cin >> a[i];
        mx = max(mx,a[i]);
    }
    
    bool check = true;
    
    vector<int> v(mx+1,0),s(mx+1,0);
    for(itn i = 0;i <= mx;i++)s[i] = 0;
    for(int i = 0;i < n;i++)s[a[i]]++;
    
    for(int i = 2;i <= mx;i++){
        if(v[i] != 0)continue;
        v[i]++;
        
        int cnt = 0;
        cnt += s[i];
        for(int j = 2*i;j <= mx;j += i){
            v[i]++;
            cnt += s[j];
        }
        if(cnt >= 2)check = false;
        if(cnt == n){
            cout << "not coprime" << endl;
            return 0;
        }
    }
    
    if(check)cout << "pairwise coprime" << endl;
    else cout << "setwise coprime" << endl;
}

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

int main()
{
  ll V, E;
  cin >> V >> E;
  vector<vector<pair<ll, ll>>> edge(V);// to, cost
  ll s, t, d;
  for (ll i = 0; i < E; ++i)
  {
    cin >> s >> t >> d;
    edge.at(s).push_back({t, d});
  }
  ll p2v = pow(2, V);
  vector<vector<ll>> dp(p2v, vector<ll>(V, INF));// went, last
  dp.at(1).at(0) = 0;
  for (ll i = 1; i < p2v; ++i)
  {
    bitset<15> bs(i);
    for (ll j = 0; j < V; ++j)
    {
      if (bs[j])
      {
        for (ll k = 0; k < edge.at(j).size(); ++k)
        {
          pair<ll, ll> next = edge.at(j).at(k);
          if (bs[next.first])
          {
            continue;
          }
          ll ipow = i + pow(2, next.first);
          dp.at(ipow).at(next.first) = min(dp.at(ipow).at(next.first), dp.at(i).at(j) + next.second);
        }
      }
    }
  }

  ll ans = INF;
  for (ll i = 0; i < V; ++i)
  {
    for (ll j = 0; j < edge.at(i).size(); ++j)
    {
      if (edge.at(i).at(j).first == 0)
      {
        ans = min(ans, dp.at(p2v - 1).at(i) + edge.at(i).at(j).second);
      }
    }
  }
  if (ans == INF)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << ans << endl;
  }
}



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

#define ipair pair<int,int>
#define rep(I,N) for(int I=0; I<N; I++)
#define repj(i,j,n) for(int i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

int graph[10][10];

int dfs(int v, int N, bool visited[10])
{
  bool is_all_visited = true;
  rep(i, N) {
    if (visited[i] == false) {
      is_all_visited = false;
      break;
    }
  }

  if (is_all_visited) return 1;

  int ret = 0;
  rep(i, N) {
    if (graph[v][i] && visited[i] == false) {
      visited[i] = true;
      ret += dfs(i, N, visited);
      visited[i] = false;
    }
  }
  return ret;
}

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

  rep(i, 10) {
    rep(j, 10) {
      graph[i][j] = 0;
    }
  }

  rep(i, M) {
    int j, k;
    cin >> j >> k;
    j--;
    k--;
    graph[j][k] = graph[k][j] = 1;
  }

  bool visited[10] = {false};
  visited[0] = true;

  cout << dfs(0, N, visited) << '\n';

  return 0;

}


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

typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;
typedef vector<pll> vPL;


void solve() {
	lli n, m;
	cin >> n >> m;
	cout << (n-1) * (m-1) << '\n';
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_i

#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n;
  cin >> n;
  double phead;
  vector<double> dp(n + 1); // dp[i] - probability that there are i heads so far
  dp[0]=1;
  for (int i = 0; i < n; i++) {
    cin >> phead;
    for (int j = i + 1; j >= 0; j--) {
      dp[j] = (j == 0 ? 0 : dp[j - 1] * phead) + dp[j] * (1 - phead);
    }
  }
 double ans = 0;
 for (int heads = 0; heads <= n; ++heads) {
   int tails = n - heads;
   if (heads > tails) {
     ans += dp[heads];
   }
 }
 printf("%.9lf\n", ans);
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 256