akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf = (int) 2e18;
const int mod = (int) 998244353;

vector<int> fact, invfact;

// modulo x ^ y 
int modpow(int x, int y, int p = mod) 
{ 
	int res = 1;       
	x %= p;   
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res * x) % p; 
		y >>= 1;
		x = (x * x) % p;   
	} 
	return res; 
} 

// modulo x + y
int add(int x, int y) 
{
	x += y;
	if (x >= mod) return x - mod;
	return x;
}

// modulo x - y
int sub(int x, int y) 
{
	x -= y;
	if (x < 0) return x + mod;
	return x;
}

// modulo inv
int inv(int a, int m = mod)
{
	return modpow(a, m - 2, m);
}

// modulo x * y
int mul(int a, int b) 
{
	return (long long) ((a % mod) * (b % mod)) % mod;
}

void calc_fact(int n)
{
	fact.resize(n);
	invfact.resize(n);
	fact[0] = invfact[0] = 1;
	for(int i = 1; i < n; ++ i)
	{
		fact[i] = mul(fact[i - 1], i);
		invfact[i] = inv(fact[i]);
	}
}

int ncr(int n, int r)
{
	int ans = mul(fact[n], mul(invfact[n - r], invfact[r]));
	return ans;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	calc_fact(3e5);
	int n, m, k;
	cin >> n >> m >> k;
	int ans = 0;
	for(int i = 0; i <= k; ++ i)
	{
		int cur = ncr(n - 1, i);
		int is = mul(m, modpow(m - 1, n - i - 1));
		cur = mul(cur, is);
		ans = add(ans, cur);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 7856
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
b = np.sqrt(a)

lim = 10**9
lim_1 = 10**18
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
if ans > lim_1:
  ans = -1
elif ans < 0:
  ans = -1
  
print(ans)

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a,b,now,bn;
string s;

signed main() {
    cin >> n >> a >> b >> s;
    rep(i,n) {
        if (s[i] == 'a' && now < a+b) cout << "Yes" << endl,now++;
        else if (s[i] == 'b' && now < a+b && bn < b) cout << "Yes" << endl,now++,bn++;
        else cout << "No" << endl;
    }
}





Measured memory_bytes: 896
N=int (input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(N):
    if(A[i]>B[i]):
        ans+=B[i]
    else:
        ans+=A[i]
        x=B[i]-A[i]
        if(x>=A[i+1]):
            ans+=A[i+1]
            A[i+1]=0
        else:
            ans+=x
            A[i+1]-=x
print(ans)
        


Measured memory_bytes: 19156
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const s = stdin.split('\n')[0]

const ans = () => {
  let arr = [0]

  let rl = []

  for (let i = 1; i < s.length; i++) {
    if (s[i - 1] === 'R' && s[i] === 'L') {
      rl.push(i)
    }

    arr.push(0)
  }

  for (let i = 0; i < rl.length; i++) {
    const ls = countL(rl[i])
    const rs = countR(rl[i])

    const l = 1 + Math.floor(ls / 2) + Math.ceil(rs / 2)
    const r = 1 + Math.ceil(ls / 2) + Math.floor(rs / 2)

    const lIndex = rl[i]
    const rIndex = rl[i] - 1

    arr[lIndex] = l
    arr[rIndex] = r
  }

  console.log(arr.join(' '))
}

const countL = num => {
  let count = 0

  for (let i = num + 1; ; i++) {
    if (s[i] === 'L') {
      count++
    } else {
      return count
    }
  }
}

const countR = num => {
  let count = 0

  for (let i = num - 2; ; i--) {
    if (s[i] === 'R') {
      count++
    } else {
      return count
    }
  }
}

ans()


Measured memory_bytes: 16460
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[53]="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
int main(){
    char str[81];
    while(cin>>str[0]){
        for(int i=1;i<81;i++)str[i]=0;
        for(int i=1;i<80;i++){
            str[i]=getchar();
            if(str[i]==10){
                str[i]=0;
                break;
            }
        }
        int len=strlen(str);

        for(int i=0;i<26;i++){
            char cpy[81];
            strncpy(cpy,str,81);

            for(int j=0;j<len;j++){
                if(str[j]==' ' || str[j]=='.' || str[j]==10)continue;
                cpy[j]=a[cpy[j]-'a'+i];
            }
            bool f=false;
            for(int j=0;j<len-2;j++){
                if(!strncmp(cpy+j,"the",3))f=true;
                if(!strncmp(cpy+j,"this",4))f=true;
                if(!strncmp(cpy+j,"that",4))f=true;
            }
            if(f){
                cout<<cpy<<endl;
                break;
            }
        }
    }
    return 0;


}

Measured memory_bytes: 1148
#include<stdio.h>
#include<math.h>
int main (void) {

    int n;
    while (1)
    {
        scanf("%d",&n);
        if (n==0)break;
        double s[1001]={0},average = 0,a2 = 0;
        for (int i = 0; i < n; i++)scanf("%lf",&s[i]);
        for (int i = 0; i < n; i++)average+=s[i];
        average/=n;
        for (int i = 0; i < n; i++){
            a2+=((s[i]-average)*(s[i]-average));
        }
        
        printf("%lf\n",sqrt(a2/n));
    }
    

    return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define Mod 1000000007
using namespace std;
int fpow(int a,int b)
{
	int ans=1,t=a;
	while(b)
	{
		if(b&1)ans=(long long)ans*t%Mod;
		t=(long long)t*t%Mod;
		b>>=1;
	}
	return ans;
}
int n;
int f[1000010][3];
int fac[1000010],inv[1000010];
int C(int x,int y)
{
	return (long long)fac[x]*inv[y]%Mod*inv[x-y]%Mod;
}
int main()
{
	scanf("%d",&n);
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=(long long)fac[i-1]*i%Mod;
	inv[n]=fpow(fac[n],Mod-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=(long long)inv[i]*i%Mod;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		f[i][0]=(f[i-1][1]+f[i-1][2])%Mod;
		f[i][1]=(f[i-1][0]+f[i-1][2])%Mod;
		f[i][2]=(f[i-1][0]+f[i-1][1])%Mod;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=(ans+(long long)f[i][1]*C(n,i)%Mod*fpow((long long)n*i%Mod,Mod-2))%Mod;
	ans=(long long)ans*fpow(fpow(3,n),Mod-2)%Mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19712
from bisect import *

n = int(input())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i] = int(input())
for i in range(n):
    b[i] = int(input())

a.sort()
b.sort()

ans = 1
mod = 1000000007

for x,y in zip(a,b):
    if x > y:
        x, y = y, x
    ans *= (bisect_right(a, y)-bisect_left(a, x))
    ans %= mod

print(ans)


Measured memory_bytes: 11440
#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++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  int a[N];
  REP(i, N) cin >> a[i];

  // bool pushed[N];
  // => false初期化ではないので注意
  // https://cpplover.blogspot.jp/2010/09/blog-post_18.html
  int pushed[N] = {0};
  int ans = 0;
  int b = 0;
  // debug: 標準エラーへ
  REP(i, N) cerr << pushed[i] << endl;
  do {
    if (pushed[b] == 1) {
      ans = -1;
      break;
    }

    ans++;
    pushed[b] = 1;
    b = a[b] - 1;

  } while (b != 1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
let for_range s e step f =
  let rec loop i =
    if i > e then ()
    else
      begin f i;loop (i + step) end
  in loop s;;

let a =
  let num = 1000000 in
  let p = Array.init (num+1) (fun x -> 1) in
  let rec loop i =
    if i*i < num then
      begin
        for_range (i+i) num i (fun x -> p.(x) <- 0);
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0);
  for_range 4 num 2 (fun x -> p.(x) <- 0);
  loop 3;
  let rec read () =
    try let n = read_int () in
        Printf.printf "%d\n" (Array.fold_left (+) 0 (Array.sub p 0 (n+1)));
        read ()
    with End_of_file -> ()
  in read ();;

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

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n;
	long long int a,b;
	vector <long long int> v,v2;
	cin >> n;
 
	for(int i=0;i<n;i++)
	{
		cin >> a >> b;
		v.push_back(a);
		v2.push_back(b);
	}

	sort(v2.begin(),v2.end());
	sort(v.begin(),v.end());
 
	if(n%2==1)
	{
		cout << v2[n/2] - v[n/2] + 1 << '\n';
	}
	else
	{
		cout << (v2[n/2] + v2[(n/2)-1]) - (v[n/2] + v[(n/2)-1]) + 1 << '\n';
	}
 
    return 0;
}


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

using namespace std;

#define M 1000005

int k;
int vis[M];

deque< pair<int, int> > dq;
#define mp(x, y) make_pair(x, y)
#define pi pair<int, int>

void bfs()
{
	dq.push_back(mp(1, 1));
	while (!dq.empty())
	{
		pi x = dq.front(); dq.pop_front();
		if (vis[x.first]) continue; vis[x.first] = 1;
		if (!x.first) { cout << x.second; return; }
		dq.push_front(mp((x.first*10) % k, x.second));
		dq.push_back(mp((x.first+1) % k, x.second + 1));
	}
}

int main()
{
	cin >> k;
	bfs();
	return 0;
}

Measured memory_bytes: 1408
S = input() + "R" #以下ではRでってったときに値更新してるから最後にR加える
l = len(S)
ans = [0 for s in range(1, l)]
flag = 0
rcnt = 0
lcnt = 0
rpos = 0
lpos = 0
for i in range(l):
    if S[i] == "R":
        if flag == 1:#文字列がLRとなってるとき、直前のRLについて答える
            if rcnt % 2 == 0: #Rの個数が偶数
                ans[rpos] += rcnt // 2
                ans[lpos] += rcnt // 2
            else:
                ans[rpos] += rcnt// 2 + 1
                ans[lpos] += rcnt // 2
            if lcnt % 2 == 0:
                ans[rpos] += lcnt // 2
                ans[lpos] += lcnt // 2
            else:
                ans[rpos] += lcnt // 2
                ans[lpos] += lcnt // 2 + 1
            rcnt = 0
            lcnt = 0
        flag = 0
        rcnt += 1 #Rの個数求める
        rpos = i #右端のRの位置を求める
    elif S[i] == "L":
        if flag == 0:
            lpos = i #左端のRの位置を求める
        lcnt += 1 #Lの個数を求める
        flag = 1
print(*ans)

Measured memory_bytes: 10832
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int ones_place = N % 10;
    if(ones_place == 3) cout << "bon" << endl;
    else if(ones_place == 0 || ones_place == 1 || ones_place == 6 || ones_place == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
    
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
    
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


Node find(Node u,int k){
  while (u!=NIL && k!= u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if(com[0]=='f'){
      scanf("%d", &x);
      Node t= find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }  else  if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else break;
     
  }
    
    
    
  return 0;
}



Measured memory_bytes: 20456
a,b,c,x,y = map(int,input().split())
ans = 0
if 2*c <= a+b:
    m = min(x,y)
    x -= m
    y -= m
    ans += m*2*c
    ans += min(a,2*c)*x+min(b,2*c)*y
    print(ans)
else:
    print(a*x+b*y)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+10;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,m; cin >> n >> m;
  priority_queue<int> q[mx];
  rep(i,n){
    int a,b; cin >> a >> b;
    q[a].push(b);
  }
  ll ans=0;
  priority_queue<int> w;
  for(int i=1; i<=m; i++){
    while(!q[i].empty()){ w.push(q[i].top()); q[i].pop(); }
    if(!w.empty()){ ans += w.top(); w.pop();}
  }
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int a, b;
  char c;
  cin >> a >> c >> b;

  if(c == '+'){
    cout << a + b << endl;
  }

  else if(c == '-'){
    cout << a - b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y<=2019)
	{
		if(m<=4)
		{
			if(d<=30)
				printf("Heisei");
			else
				printf("TBD");		
		}	
		else
			printf("TBD");
	} 
	else
		printf("TBD");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split(' ')))
B = list(map(int,input().split(' ')))
C = list(map(int,input().split(' ')))
a = 0
a += sum(B)
for i in range(N-1):
  if A[i+1]-A[i] == 1:
    a += C[A[i]-1]
print(a)

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

template <typename T> ostream& operator<<(ostream& out, vector<T> &v){
  for (int i = 0; i < (int)v.size(); i++) {
    out<<v[i]<<' ';
  }
  return out;
}

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

  int m, d; cin >> m >> d;
  int ans= 0;
  for(int j = 1; j <= m; j++){
    for(int i = 10; i <= d; i++){
      int d_1 = i % 10, d_10 = i / 10;
      if(d_1 >= 2 && d_10 >= 2 && d_1 * d_10 == j){
        ans++;
        }
      }
    }
  cout << ans << endl;

  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        long n = long.Parse(Console.ReadLine());
        List<string> ss = new List<string>();
        for (int i = 0; i < n; i++)
        {
            ss.Add(Console.ReadLine());
        }
        Console.WriteLine("AC x " + ss.Count(s => s == "AC"));
        Console.WriteLine("WA x " + ss.Count(s => s == "WA"));
        Console.WriteLine("TLE x " + ss.Count(s => s == "TLE"));
        Console.WriteLine("RE x " + ss.Count(s => s == "RE"));
    }
}

Measured memory_bytes: 33168
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
    p[i]--;
  }

  int cnt=0;
  for(int i=0;i<N;i++){
    if(p[i]!=i) cnt++;
  }

  if(cnt<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
// ALDS1_7_A
#include <iostream>
#include <vector>
using namespace std;

struct Node {
	int parent;
	int depth;
	vector<int> children;
};

void cal_depth(vector<Node> &Tree, int p) {
	if (Tree[p].parent != -1)
		Tree[p].depth = Tree[Tree[p].parent].depth + 1;

	for (int i = 0; i < Tree[p].children.size(); i++)
		cal_depth(Tree, Tree[p].children[i]);
}

void printTree(vector<Node> Tree) {
	for (int i = 0; i < Tree.size(); i++) {
		cout <<"node "<< i << ": parent = " << Tree[i].parent << ", depth = " << Tree[i].depth << ", ";
		
		if (Tree[i].parent == -1)
			cout << "root, ";
		else if (Tree[i].children.size() == 0)
			cout << "leaf, ";
		else
			cout << "internal node, ";
		
		cout << "[";
		for (int j = 0; j < Tree[i].children.size(); j++) {
			cout << Tree[i].children[j];
			if (j != Tree[i].children.size() - 1)
				cout << ", ";
		}
		cout << "]" << endl;
	}
}

int main() {
	
	int n, id, c, k, root;
	cin >> n;

	vector<Node> Tree;

	for (int i = 0; i < n; i++) {
		Node node;
		node.parent = -1;
		node.depth = 0;
		Tree.push_back(node);
	}

	for (int i = 0; i < n; i++) {
		cin >> id >> k;
		
		for (int j = 0; j < k; j++) {
			cin >> c;
			Tree[c].parent = id;
			Tree[id].children.push_back(c);
		}
	}

	for (int i = 0; i < n; i++) {
		if (Tree[i].parent == -1)
			root = i;
	}

	cal_depth(Tree, root);

	printTree(Tree);

	return 0;
}



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

using namespace std;

typedef struct {
    char suit;
    char value;
} Card;

void bubbleSort(Card C[], int N)
{
    for(int i = 0; i < N; i++){
        for(int j = N - 1; j >= i; j--){
            if(C[j].value < C[j - 1].value){
                swap(C[j], C[j - 1]);
            }
        }    
    }
}

void selectionSort(Card C[], int N)
{
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(C[minj].value > C[j].value){
                minj = j;
            }
        }
        if(minj != i){
            swap(C[minj], C[i]);
        }
    }
}

void output(Card C[], int N)
{
    for(int i = 0; i < N; i++){
        if(i > 0){
            cout << " ";
        }
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
}

bool isStableSort(Card C1[], Card C2[], int N)
{
    for(int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit){
            return false;
        }
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    Card C1[36], C2[36];
    for(int i = 0; i < N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i = 0; i < N; i++){
        C2[i] = C1[i];
    }
    bubbleSort(C1, N);
    output(C1, N);
    cout << "Stable" << endl;
    selectionSort(C2, N);
    output(C2, N);
    if(isStableSort(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

const int N = 310;
double memo[N][N][N];
int n;
double dp(int one, int two, int three) {
  double &res = memo[one][two][three];
  if (res == res) return res;
  if (one == 0 && two == 0 && three == 0) return res = 0;

  res = 1.0;
  if (one) res += (1. * one / n) * dp(one-1, two, three);
  if (two) res += (1. * two / n) * dp(one+1, two-1, three);
  if (three) res += (1. * three / n) * dp(one, two+1, three-1);
  double mul = 1. / (1. - (n - one - two - three) / (1. * n));
  res *= mul;
  return res;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < n; i++) {
      int t; cin >> t;
      if (t == 1) one++;
      if (t == 2) two++;
      if (t == 3) three++;
    }
    memset(memo, -1, sizeof memo);
    cout << fixed << setprecision(10) << dp(one, two, three) << endl;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

string C(string x);
string D(string x);
string S(string x);
string L(string x);

int main()
{
    string s;
    while(cin >>s,(s!="."))
    {
        string ans=C(s);

        rep(i,s.size())
        {
            if(ans[i]=='?') ans[i]='A';
        }

        cout << ans <<endl;
    }
    return 0;
}

string C(string x)
{
    if(x[0]=='[')
    {
        int br=0;
        int idx=0;
        while(idx<x.size())
        {
            if(x[idx]=='[') ++br;
            else if(x[idx]==']') --br;

            if(br==0) break;
            ++idx;
        }

        string a=S(x.substr(0,idx+1));

        string b="";
        if(idx+1!=x.size()) b=D(x.substr(idx+1));

        return a+b;
    }
    else
    {
        //Letter

        int idx=0;
        while(idx<x.size())
        {
            if(x[idx]=='?' || ('A'<=x[idx] && x[idx]<='Z')) break;
            ++idx;
        }

        string a=S(x.substr(0,idx+1));
        string b=D(x.substr(idx+1));

        return a+b;
    }
}

string D(string x)
{
    if(x=="") return x;
    return C(x);
}

string S(string x)
{
    if(x[0]=='[')
    {
        //reverse
        string r=C(x.substr(1,x.size()-2));
        reverse(all(r));

        return r;
    }
    else return L(x);
}

string L(string x)
{
    if(x[0]=='+')
    {
        string r=L(x.substr(1));

        if(r[0]!='?')
        {
            if(r[0]=='Z') r[0]='A';
            else ++r[0];
        }

        return r;
    }
    else if(x[0]=='-')
    {
        string r=L(x.substr(1));

        if(r[0]!='?')
        {
            if(r[0]=='A') r[0]='Z';
            else --r[0];
        }
        return r;

    }
    else return x;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std;
// numeric_limits<double>::epsilon()
 
#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define f(i,n) for(i =0 ; i< n ; i++)
#define ff first
#define ss second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
void solve();


int power(int a, int b)
{
    if(b==0) return 1;
    else if(b&1) return a*power(a*a,b/2);
    else return power(a*a, b/2);
}
 


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}
bool AreSame(double a, double b) {
    return std::fabs(a - b) < std::numeric_limits<double>::epsilon();
}
 
int  j=1, n, t, m=0, dot=0, i, k, q, a, x, y, n1, m1;

void extendGcd(int m, int n)
{
    if(n==0)
    {
        x=1;
        y=0;
        dot=m;
    }
    else
    {
        extendGcd(n,m%n);
        q = x;
        x = y;
        y = q - (m/n)*y;
    }
    

}

string s1, s2,s3;
void solve()
{
    // cin >> t;while(t--)
    {
        cin >> n;
        vi v(n), cp(n);
        f(i,n) {cin >> v[i];cp[i]=v[i];}
        sort(v.begin(), v.end());
        f(i,n){(cp[i]==v[n-1])?cout <<v[n-2]<<'\n':pr(v[n-1])}
    }
    
}

Measured memory_bytes: 4736
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

const ll p=1e9+7;

int main(){
  ll N;
  cin >> N;
  ll a=1,b=1,c=1;
  for(ll i=0;i<N;i++){
    a=a*10%p;
    b=b*9%p;
    c=c*8%p;
  }
  ll ans=a-2*b+c;
  if(ans<0){
    while(ans<0){
      ans+=p;
    }
  }
  cout << ans%p << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0)  // 引数チェック
    {
        fprintf(stderr, "引数エラーです。\n");
        return 0;
    }
    
    return (x * y / gcd(x, y));
}

using namespace std;

int main(int argc, char *argv[]) {
    ll result = 0;
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    
    ll x = B / C;
    ll y = (A - 1) / C;
    ll CC = x - y;
    
    x = B / D;
    y = (A-1) / D;
    ll DD = x - y;
    
    ll CD = lcm(C, D);
    x = B / CD;
    y = (A-1) / CD;
    ll CCDD = x - y;
    
    result = CC + DD - CCDD;
    result = B - A + 1 - result;
    cout << result << endl;
    return 0;
}



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

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

    int n,x;
    cin >> n >> x;

    int array[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> array[i];
    }
    sort(array, array+n);

    int max = abs(x-array[0]);

    for (int i = 1; i < n; i++)
    {
    	max = __gcd(max, abs(array[i] - array[i-1]));
    }

    cout << max;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;

void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

}

void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;

	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 

	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}


	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}

	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}


	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;

	if (right > left)
	{
		mid = (right + left) / 2;
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);

		merge(a, tmp, left, mid + 1, right);
	}
}


long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

int N, M,F,K, W,L,sa,X[2000000], Y[2000000], Z[2000000], ans, k[5],B,C,n[2];
string s, t[100];
bool a, b, c;
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		Z[i] = X[i];
	}
	mergeSort(X, Y, N);
	if (X[N - 1] % 2 == 0) {
		M = X[N - 1] / 2;
	}
	else {
		M = (X[N - 1] + 1) / 2;
	}
	sa = INF;
	for (int i = N-2; i>=0; i--) {
		if (sa > abs(X[i] - M)) {
			sa = abs(X[i] - M);
			ans = X[i];
		}
	}
			cout << X[N-1]<<" "<<ans << endl;

	
	return 0;
}




Measured memory_bytes: 6784
// https://atcoder.jp/contests/abc103/tasks/abc103_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  string s, t;

  cin >> s >> t;

  string tt = t + t;

  string r = tt.find(s) != string::npos ? "Yes" : "No";

  cout << r << '\n';

  return 0;
}


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

using ll = long long int;

const int MOD = 1e9 + 7;

#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

template <class T>
class my_array{
  private:
    int n;
    vector<T> A;
  public:
    my_array(int k){n = k; A.resize(n);}
    ~my_array(void){};
    // input a_0, a_1, ..., a_(n-1)
    void get(void){
      for(int i = 0; i < n; i++) cin >> A.at(i);
    }
    // sort A
    void sorted(bool flag = true){
      if(flag) sort(A.begin(), A.end());
      else sort(A.begin(), A.end(), greater<T>());
    }
    // print : a_0, a_1, ... a_(n-1)
    void show(void){
      for(int i = 0; i < n - 1; i++) cout << A.at(i) << " ";
      cout << A.at(n - 1) << "\n";
    }
    int solve(int a, int b){
      if(a >= b) return 0;
      int mn_idx = 0, min = 1e9;
      for(int i = a; i < b; i++) if(min > A.at(i)){
        min = A.at(i);
        mn_idx = i;
      }
      for(int i = a; i < b; i++) A.at(i) -= min;
      return solve(a, mn_idx) + min + solve(mn_idx + 1, b);
    }
};

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

string s1, s2, s3;

int mx_same(char p, char q, char r){
  if(p == q){
    if(q == r) return 3;
    else return 2;
  }
  else{
    if(p == r || q == r) return 2;
    else return 1;
  }
}

int main(void){
  int n, res = 0; cin >> n;
  cin >> s1 >> s2 >> s3;
  for(int i = 0; i < n; i++){
    res += 3 - mx_same(s1.at(i), s2.at(i), s3.at(i));
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private long MOD = 1_000_000_000 + 7;

	// 二分累乗法を用いた指数の計算
	long my_pow(long x, long n) {
		if (n == 0) {
			return 1;
		}
		if (n == 1) {
			return x;
		}

		long tmp = my_pow(x, n / 2) % MOD;
		if (n % 2 == 0) {
			return (tmp * tmp) % MOD;
		} else {
			return ((tmp * tmp) % MOD) * x % MOD;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		int a = sc.nextInt();
		int b = sc.nextInt();

		// 階乗数
		long[] x = new long[h + w - 1];
		long[] y = new long[h + w - 1];
		x[0] = 1;
		y[0] = 1;
		for (int i = 1; i < h + w - 1; i++) {
			x[i] = (i * x[i - 1]) % MOD;
			y[i] = my_pow(x[i], MOD - 2) % MOD;
		}

		long ans = 0;

		for (int j = b; j < w; j++) {
			int h1 = h - a - 1;
			int w1 = j;
			long tmp = (((x[h1 + w1] * y[h1]) % MOD) * y[w1]) % MOD;

			int h2 = a - 1;
			int w2 = w - j - 1;
			long tmp1 = (((x[h2 + w2] * y[h2]) % MOD) * y[w2]) % MOD;

			ans += tmp * tmp1 % MOD;
			ans %= MOD;
		}

		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 12884
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

struct UnionFind {
  vector<int> par; // par[i]が親を表す
  vector<int> _size; // _size[i]でそのノードの属しているサイズを返す

  // コンストラクタ
  UnionFind(int n) {
    _size = vector<int>(n);
    par = vector<int>(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
      _size[i] = 1;
    }
  }

  // データxの根を求める
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]); // 木構造の縮約を行っている
  }

  // xとyの親が違うとき、マージする。そのときyの根がxの根の子になる
  void merge(int x, int y) {
    int rootx = root(x);
    int rooty = root(y);
    if (rootx == rooty)
      return;
    par[rooty] = rootx;
    int s = _size[rooty] + _size[rootx];
    _size[rooty] = s;
    _size[rootx] = s;
  }

  // xの属している集団のサイズ
  int size(int x) { return _size[x]; }

  // 同じグループに属しているか
  bool isSame(int x, int y) { return root(x) == root(y); }
};

int main() {
  int n, k, l;
  cin >> n >> k >> l;
  UnionFind road(n), ans(n);
  REP(i, k) {
    int p, q;
    cin >> p >> q;
    p--;
    q--;
    road.merge(p, q);
  }

  REP(i, l) {
    int r, s;
    cin >> r >> s;
    r--;
    s--;
    ans.merge(r, s);
  }

  map<pair<int, int>, int> m;
  REP(i, n) {
    auto p = make_pair(road.root(i), ans.root(i));
    m[p]++;
  }

  REP(i, n) {
    cout << m[make_pair(road.root(i), ans.root(i))];
    if (i != n - 1)
      cout << " ";
    else
      cout << endl;
  }
}


Measured memory_bytes: 15104
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
count = 0
for i in range(N):
  A = list(map(int, input().split()))
  ans = C
  for j in range(M):
    ans += A[j]*B[j]
  if ans > 0:
    count += 1
print(count)
  

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

int main(){
    int n,m, count = 0;
    cin >> n;

    for(int i = 1; i <=9; i++){
        for(int j = 1; j <= 9; j++)
            if(j * i == n) count++;
    }

    if(count > 0)  cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
    int N, ans;
    ans = 0;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < d.size(); i++)
    {
        cin >> d.at(i);
    }
    for (int i = 0; i < d.size() - 1; i++)
    {
        int sum = 0;
        for (int j = i + 1; j < d.size(); j++)
        {
            sum += (d.at(i) * d.at(j));
        }
        ans += sum;
    }
    cout << ans << endl;
}


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

namespace cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var pg = new Program();
            pg.Execute();

        }

        private void Execute()
        {
            var input = ReadLineNTimesString();
            OutputResult(input.Distinct().Count());

           // var (A, B) = ReadLinesLongList2<long>();

        }

        private void OutputResult<T>(T result)
        {
            Console.WriteLine(result);
        }

        static long ReadLineLong => long.Parse(Console.ReadLine());
        static string ReadLineString => Console.ReadLine();
        static IEnumerable<long> ReadLinesLongList => Console.ReadLine().Split(' ').Select(i => long.Parse(i));
        static IEnumerable<string> ReadLinesStringList => Console.ReadLine().Split(' ');

        public static (T, T) ReadLinesLongList2<T>()
        {
            var input = Console.ReadLine().Split(' ');
            return ((T)Convert.ChangeType(input.ElementAt(0), typeof(T)), (T)Convert.ChangeType(input.ElementAt(1), typeof(T)));
        }

        public static List<long> ReadLineNTimes(){
            var input = new List<long>();
             var N = long.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                input.Add(long.Parse(Console.ReadLine()));
            }
            return input;
        }
        public static List<string> ReadLineNTimesString(){
            var input = new List<string>();
            var N = long.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                input.Add(Console.ReadLine());
            }
            return input;
        }

        private int SolveDynamicProgramming(int n)
        {
            var inputList = new List<int>(){7,-6,9};
            var dpList = new List<int>(){0};
            for (int i = 0; i < n; ++i)
            {
                dpList.Add(Math.Max(dpList[i], dpList[i] + inputList[i]));
            }

            return dpList[n];
        }

        private int SolveDynamicProgrammingForKnapsack(int n, int weight,List<int> valueList ,List<int> weightList)
        {
            var dpList = new List<List<int>>();
            
            for (int i = 0; i < n + 1; ++i){
                dpList.Add(Enumerable.Repeat(0, weight + 1).ToList());
            }

            for (int i = 0; i < n; ++i)
            {
                for (int w = 0; w <= weight; ++w)
                {
                    if (w >= weightList[i])
                    { 
                        dpList[i + 1][w] = Math.Max(dpList[i][w - weightList[i]] + valueList[i], dpList[i][w]);
                    }
                    else 
                    {
                        dpList[i + 1][w] = dpList[i][w];
                    }
                }
            }

            return dpList[n][weight];
        }

        public static int Gcd(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }

    }
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int K;
string S;

signed main()
{
  cin >> S;
  int win = 0;
  for(char c : S) {
    if(c == 'o') {
      win++;
    }
  }

  cout << (win + (15-S.size()) >= 8 ? "YES" : "NO") << endl;

  return 0;
}

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

using namespace std;

int main() {
	string x, u;
	int N;
	string gifts = "";
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> x >> u;
		if (u == "BTC") {
			gifts = to_string(atof(gifts.c_str()) + atof(x.c_str()) * 380000.0);
		}
		else if (u == "JPY") {
			gifts = to_string(atof(gifts.c_str()) + atoi(x.c_str()));
		}
	}
	cout << gifts << endl;

	return 0;
}

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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int n, v[55];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    sort(v, v+n);
    double atual=v[0];
    for(int i=1; i<n; i++){
        atual+=v[i];
        atual/=2;
    }
    cout << atual << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> cnt(26,99);
	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		vector<int> c(26,0);
		for(int j=0; j<s.length(); j++){
			c[s[j]-'a']++;
		}
		for(int j=0; j<26; j++) cnt[j]=min(cnt[j], c[j]);
	}
	for(int i=0; i<26; i++){
		for(int j=0; j<cnt[i]; j++){
			printf("%c", 'a'+i);
		}
	}
	cout << endl;
	return 0;
}

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

using namespace std;

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

Measured memory_bytes: 4836
N,C=map(int,input().split())
from collections import defaultdict
Cbef=defaultdict(int)
time=defaultdict(int)
TV=[tuple(map(int,input().split())) for i in range(N)]
TV.sort(key=lambda x:x[0])
for s,t,c in TV:
    if Cbef[c]==s:
        time[s]+=1
        time[t]-=1
        Cbef[c]=t
    else:
        time[s-1]+=1
        time[t]-=1
        Cbef[c]=t
ans=0
now=time[0]
ans=now
for i in range(1,10**5+1):
    now+=time[i]
    ans=max(ans,now)
print(ans)

Measured memory_bytes: 27708
m,a[9][2],S[2500];
D(d,s){int i=0;if(d==m)S[s]++;else for(;i<=a[d][1];i++)D(d+1,s+i**a[d]);}
main(i){for(;scanf("%d",&m),m;){
for(i=0;i<m;i++)scanf("%d%d",a[i],a[i]+1);
memset(S,0,sizeof(S));D(0,0);
for(scanf("%d",&i);i;i--)scanf("%d",&m),printf("%d\n",S[m]);
}exit(0);}

Measured memory_bytes: 616
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var set = new HashSet<char>();
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            set.Add(s[i][0]);
        }
        Console.WriteLine(set.Count == 3 ? "Three" : "Four");
    }
}


Measured memory_bytes: 13396
fun main(args:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toLong() }
    var ans = n*m;
    if(n == 1L && m == 1L) {
        ans = 1
    } else if(n == 1L && m == 2L) {
        ans = 0
    } else if(n == 2L && m == 1L) {
        ans = 0
    } else if(n == 1L && m == 3L) {
        ans = 1
    } else if(n == 3L && m == 1L) {
        ans = 1
    } else if(n == 2L && m == 3L) {
        ans = 0
    } else if(n == 3L && m == 2L) {
        ans = 0
    } else if(n == 1L || m == 1L) {
        ans = n * m
        ans -= 2
    } else if(n == 2L || m == 2L) {
        ans = 0
    } else {
        ans = n*m
        ans -= 4
        ans -= (n-2)*2
        ans -= (m-2)*2
    }
    println(ans)
}


Measured memory_bytes: 37940
from collections import defaultdict
n,m = map(int, input().split())
d = defaultdict(int)

for i in range(m):
  a,b = map(int, input().split())
  d[a]+=1
  d[b]+=1

for i in d:
  if d[i]%2 ==1:
    print ('NO')
    exit()
print('YES')

Measured memory_bytes: 14580
#include<iostream>
using namespace std;
int main(void){
  int a,b,c;
  string s,t,u;
 cin >> s;
  t = s.erase(4,1);
  u = t.erase(6,1);
  if(stoi(u) <= 20190430){
    cout << "Heisei";
  }else{
    cout << "TBD";
  }
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;

struct res {
  string name;
  int score;
  int index;

  int opCmp(const res s) const {
    if (name == s.name) {
      return score > s.score ? -1 : 1;
    } else {
      return name < s.name ? -1 : 1;
    }
  }
}

void main()
{
  auto n = readln.chomp.to!int;
  auto sp = new res[](n);
  foreach (i; 0..n) {
    auto x = readln.chomp.split;
    sp[i].name = x[0];
    sp[i].score = x[1].to!int;
    sp[i].index = i + 1;
  }

  sp = sort(sp).array;
  
  foreach(i; 0..n) {
    sp[i].index.writeln;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

string s;
int k;
set<string> dict;

signed main() {
	int i, j, m;
	
	cin >> s >> k;
	for (i = 0; i < s.length(); i++) {
		for (j = i; j < min(i + k, (int)s.length()); j++) {
			string t;
			for (m = i; m <= j; m++) {
				t += s[m];
			}
			dict.insert(t);
		}
	}
	
	i = 0;
	for (set<string>::iterator it = dict.begin(); it != dict.end(); it++) {
		i++;
		if (i == k) { cout << (*it) << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  int c;
  cin >>a >> b>> c;
  cout << (a<=c&&c<=b ? "Yes" : "No" ) fin;
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
/*
 * FileName:     C
 * CreatedDate:  2020-03-14 21:12:09 +0900
 * LastModified: 2020-03-16 13:07:08 +0900
 */

#include <stdio.h>
#include"math.h"
int main(void){
    long double a,b,c;
    scanf("%Lf %Lf %Lf",&a,&b,&c);
    if(4*a*b<(c-a-b)*(c-a-b) && c-a-b>0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)

	s := strconv.Itoa(N)

	l := len(s)

	if l == 1 {
		fmt.Println(N)
		return
	}

	if l == 2{
		fmt.Println(9)
		return
	}

	if l == 3 {
		fmt.Println(9 + N - 99)
		return
	}

	if l == 4 {
		fmt.Println(9 + 900)
		return
	}

	if l == 5 {
		fmt.Println(9 + 900 + N - 9999)
		return
	}

	if l == 6 {
		fmt.Println(9 + 900 + 90000)
		return
	}

	if l == 7 {
		fmt.Println(9 + 900 + 90000)
		return
	}
}


Measured memory_bytes: 512