akhauriyash/Code-Regression huggingface dataset:
using System;

namespace abc071_b
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] find = new bool[200];
            string s = Console.ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                find[s[i]] = true;
            }
            bool flag = false;
            for (int i = 'a'; i <= 'z' && !flag; i++)
            {
                if (!find[i])
                {
                    Console.WriteLine((char)i);
                    flag = true;
                }
            }
            if (!flag) Console.WriteLine("None");
        }
    }
}

Measured memory_bytes: 13116
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ee := make([][]Edge, n)
	for i := 0; i < n-1; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		ee[a] = append(ee[a], Edge{
			to: b,
			id: i,
		})
		ee[b] = append(ee[b], Edge{
			to: a,
			id: i,
		})
	}

	tree := make([]int, n)
	dfs(0, -1, 0, tree, ee)

	cnt := map[int]int{}
	for i := 0; i < n; i++ {
		cnt[tree[i]] = cnt[tree[i]] + 1
	}
	if cnt[1] < cnt[2] {
		for i := 0; i < n; i++ {
			tree[i] = 3 - tree[i]
		}
		cnt[1], cnt[2] = cnt[2], cnt[1]
	}

	cc := [3]int{
		0,
		0,
		0,
	}
	lm := make([]int, 3)
	lm[0] = n / 3
	lm[1] = n / 3
	if n%3 != 0 {
		lm[1]++
	}
	lm[2] = n - lm[0] - lm[1]

	ans := make([]int, n)
	if cnt[2]*3 <= n {
		for i := 0; i < n; i++ {
			if tree[i] == 2 {
				ans[i] = cc[0]*3 + 3
				cc[0]++
				continue
			}
			for j := 0; j < 3; j++ {
				if cc[(j+1)%3] < lm[(j+1)%3] {
					ans[i] = cc[(j+1)%3]*3 + (j + 1)
					cc[(j+1)%3]++
					break
				}
			}
		}
	} else {
		for i := 0; i < n; i++ {
			if cc[tree[i]] >= lm[tree[i]] {
				tree[i] = 3
			}
			ans[i] = cc[tree[i]%3]*3 + tree[i]
			cc[tree[i]%3]++
		}
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, ans[i])
	}
}

// Edge ...
type Edge struct {
	to, id int
}

func dfs(i, p, c int, tree []int, ee [][]Edge) {
	tree[i] = (c % 2) + 1
	for _, e := range ee[i] {
		if e.to == p {
			continue
		}
		dfs(e.to, i, c+1, tree, ee)
	}
}

func minint(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 73984
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int N,X,Y;
int main(void){
    cin>>N>>X>>Y;
    int dis[N];
    memset(dis,0,sizeof dis);
    for(int i=1;i<N;i++)for(int j=i+1;j<=N;j++)dis[min({j-i,abs(X-i)+abs(Y-j)+1})]++;
    for(int k=1;k<N;k++)cout<<dis[k]<<endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
		int N;
	cin >> N;
	ll ans = 0;
	vec(C);
	fx(N) {
		int A, B;
		cin >> A >> B;
		pb(C, A + B);
		ans += A;
	}
	sorts(C);
	reverses(C);
	for (int x = 1; x < N;x+=2) {
		ans -= C[x];
	}
	ce(ans)

    return 0;
}



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

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a=0,b,c,n,sum=0,ma=0;
    long long min=100000000000;
    cin >> n;
    if(n == 1){
         cout << "0" << endl;
         return 0;
    }
    int x[n];
    rep(i,n){
        cin >> x[i];
        ma = max(ma,x[i]);
    }
    rep(i,ma+1){
        a=0;
        rep(j,n){
            a += pow(x[j]-i,2);
        }
        if(a<min) min = a;
    }
    cout << min << endl;
    return 0;
}

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

#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)

using ll = long long;

int main() {
  // freopen("1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string S;
  cin >> S;
  if (S.back() == 's') {
    S += "es";
  } else {
    S += "s";
  }

  cout << S << '\n';

  return 0;
}


Measured memory_bytes: 3588
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define FIND(i, c) ((c).find(i) != (c).end())
#define SORT(c) sort((c).begin(), (c).end())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)

// constant
// const ll MOD = 1e9 + 7;
// const ll INF = 1e12;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define debug(x) cout << #x << " = " << x << endl

// --------------------------------------------------------


int main()
{
    int N, K;
    cin >> N >> K;
    VI num(N + 1, 0);

    REP(i, N)
    {
        int A;
        cin >> A;
        num[A]++;
    }

    SORT(num);
    cout << accumulate(num.begin(), num.end() - K, 0LL) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define ll long long
#define INF (1<<30)
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<vector<int>> S(n, vector<int>(27, 0));
	vector<int> ans(27, INF);
	for (int i = 0; i < n;i++) {
		string s; cin >> s;
		for (auto c : s) {
			S[i][c - 'a']++;
		}
	}
	for (int i = 0; i < n;i++) {
		for (int j = 0; j < 27;j++) {
			ans[j] = min(S[i][j], ans[j]);
		}
	}
	string s_ans = "";
	for (int i = 0; i < 27;i++) {
		if(ans[i] !=0)
			s_ans += string(ans[i], 'a'+i);
	}
	cout << s_ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 10^^9 + 7;
alias Edge = Tuple!(int, "to", int, "cost");

void main() {
    int n, m, s;
    scan(n, m, s);

    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int a, b, c;
        scan(a, b, c);
        adj[a] ~= Edge(b, c);
    }

    auto d = dijkstra(adj, s);

    foreach (i ; 0 .. n) {
        if (d[i] == inf) writeln("INF");
        else writeln(d[i]);
    }
}

int[] dijkstra(Edge[][] adj, int s) {
    alias Node = Tuple!(int, "num", int, "dist");

    auto n = adj.length.to!int;
    auto minhp = new BinaryHeap!(Array!Node, "a.dist > b.dist")();
    auto d = new int[](n);
    d[] = inf;
    minhp.insert(Node(s, 0));

    int rep = n;

    while (rep && !minhp.empty) {
        auto v = minhp.front;
        minhp.popFront();

        if (d[v.num] <= v.dist) continue;
        d[v.num] = v.dist;
        rep--;

        foreach (e ; adj[v.num]) {
            if (d[v.num] + e.cost < d[e.to]) {
                minhp.insert(Node(e.to, d[v.num] + e.cost));
            }
        }
    }

    return d;
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 54108
# Digital Gifts
# settings
BIT_unit = 380000

# input
N = int(input())
total = 0
for i in range(N):
    x, u = input().split()
    if u == 'BTC':
        total += float(x) * BIT_unit
    else:
        total += float(x)

# output
print(total)


Measured memory_bytes: 2940
N,D=map(int,input().split())
X=[[int(i) for i in input().split()] for i in range(N)]
num=0
for i in range(N):
    for j in range(i+1,N):
        a=0
        for k in range(D):
            a+=(X[i][k]-X[j][k])**2
        #print(a)
        for x in range(201):
            if x**2==a:
                num+=1
                break
print(num)


Measured memory_bytes: 39408
import sys

N = int(sys.stdin.readline().rstrip())  # 節点数
_Pre = [int(x) for x in sys.stdin.readline().rstrip().split()]
_In = [int(x) for x in sys.stdin.readline().rstrip().split()]


def narabekae(pre_lists, in_lists):

    # 入ってきた順列から、（根／）左側／右側を作る
    rt = pre_lists[0]

    # print(rt, pre_lists, in_lists)

    rt_idx = in_lists.index(rt)

    left = pl_lf = pre_lists[1:rt_idx + 1]
    il_lf = in_lists[:rt_idx]
    right = pl_rg = pre_lists[rt_idx + 1:]
    il_rg = in_lists[rt_idx + 1:]

    if len(left) > 1:
        left = narabekae(pl_lf, il_lf)

    if len(right) > 1:
        right = narabekae(pl_rg, il_rg)

    new_list = []
    new_list.extend(left)
    new_list.extend(right)
    new_list.extend([rt])

    # print(rt, left, right)

    return new_list


def main():

    lst = narabekae(_Pre, _In)

    print(*lst)


main()



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

int main(){
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,3) rep(j,3) cin >> a[i][j];
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    vector<vector<int>> aa(3,vector<int>(3,0));


    rep(i,n){
        rep(j,3){
            rep(k,3){
                if (b[i] == a[j][k]) aa[j][k] = 1;
            }
        }
    }

    bool bingo = false;

    rep(i,3){
        if (aa[i][0]+aa[i][1]+aa[i][2] == 3) bingo = true;
        if (aa[0][i]+aa[1][i]+aa[2][i] == 3) bingo = true;
    }
    if (aa[0][0]+aa[1][1]+aa[2][2] == 3) bingo = true;
    if (aa[0][2]+aa[1][1]+aa[2][0] == 3) bingo = true;

    if (bingo) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef complex<double> P;

const double EPS = 1e-8;

double cross(P a, P b){
  return a.real() * b.imag() - a.imag() * b.real();
}

vector<P> convexCut(vector<P>& g, P p, P q){
  vector<P> res;
  int n = g.size();
  for(int i=0;i<n;i++){
    P A(g[i]), B(g[(i+1)%n]);
    double p1 = cross(q-p, A-p);
    double p2 = cross(q-p, B-p);
    if(p1 > -EPS) res.push_back(A);
    if(p1 * p2 < -EPS) res.push_back(A + cross(q-p, q-A) / cross(q-p, B-A) * (B-A));
  }
  return res;
}

double getArea(vector<P>& g){
  double res = 0.0;
  for(int i=0;i<g.size();i++) res += cross(g[i], g[(i+1)%g.size()]);
  return abs(res) * 0.5;
}

main(){
  int n, m;
  while(cin >> n >> m && (n|m)){
    vector<P> A, B;
    double a, b;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      A.push_back(P(a, b));
    }
    for(int i=0;i<m;i++){
      cin >> a >> b;
      B.push_back(P(a, b));
    }
    for(int i=0;i<m;i++){
      vector<P> tmp = A;
      for(int j=0;j<m;j++){
        if(i == j) continue;
        P mid = (B[i] + B[j]) / 2.0;
        P p = mid + (B[i] - B[j]) * P(0, 1);
        if(cross(p-mid, B[i]-mid) > EPS) swap(p, mid);
        tmp = convexCut(tmp, p, mid);
      }
      printf("%.5f\n", getArea(tmp));
    }
  }
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], s[maxn];
int n, top;
bool check(int k)
{
	top = 0;
	for(int i = 2; i <= n; ++i)
	{
		if(a[i - 1] < a[i]) continue;
		while(top && s[top] > a[i]) --top;
		s[++top] = a[i];
		while(top >= k && s[top - k + 1] == s[top])
		{
			int val = s[top];
			top -= k;
			s[++top] = val - 1;
			if(!s[top]) return 0;
		}
	}
	return 1;
}		
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	int l = 1, r = n;
	while(l <= r)
	{
		int mid = l + r >> 1;
		if(check(mid)) r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n", l);
	return 0;
}
/*
6
3 2 2 3 3 2
*/
	

Measured memory_bytes: 5252
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int temp;
	int a[1000];
	int cnt = 0;
	while (cin >> n){
		if (n == -1) break;
		while (n > 0){
			temp = n % 4;
			a[cnt] = temp;
			n /= 4;
			cnt++;
		}
		if (cnt == 0) cout << "0" << endl;
		for (int i = cnt - 1; i >= 0; i--) {
			cout << a[i];
			if (i == 0) cout << endl;
		}
		cnt = 0;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    int x = 0;
    int y = 0;
	for(int i = 0; i<s.length ; i++){
		if(s[i] == 'A'){
			x = i;
			break;
		}
	}
	for(int i = s.length-1; i>=0 ; i--){
		if(s[i] == 'Z'){
			y = i;
			break;
		}
	}
	System.out.print(y-x+1);
  }
}

Measured memory_bytes: 14668
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes\n";
  else
    cout << "No\n";
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

int bit[26][(1 << 19) + 1];
int n;
int _n;
int sum(int i,int j) {
  int s = 0;
  while(j > 0) {
    s += bit[i][j];
    j -= j & -j;
  }
  return s;
}

void add(int i,int j, int x) {
  while(j <= _n) {
    bit[i][j] += x;
    j += j & -j;
  }
  return;
}

int main() {

  int q;
  string s;
  cin >> n >> s >> q;
  _n = 1;
  while(_n < n) _n *= 2;
  
  for(int i = 0; i < n; i++) {
    add(s[i]-'a',i+1,1);
  }
  for(int i = 0; i < q; i++) {
    int qu;
    cin >> qu;
    if(qu == 1) {
      int iq;
      char cq;
      cin >> iq >> cq;
     add(cq-'a',iq,1);
     add(s[iq-1]-'a',iq,-1);
     s[iq-1] = cq;
    }
    else {
      int l,r;
      cin >> l >> r;
      int tmp = 0;
      for(int j = 0; j < 26; j++) {
	  if(sum(j,r)-sum(j,l-1)) tmp++;
      }   
      cout << tmp << endl;
    }
  }
    
}


Measured memory_bytes: 54148
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s[3];
  cin >> s[0] >> s[1] >> s[2];

  cout << "A" << s[1][0] << "C" << endl;
  return 0;
}


Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception, std.typecons;
  
  int n, m; rd(n, m);
  auto a=readln.split.to!(long[]);
  auto g=new int[][](n);
  foreach(i; 0..m){
    int x, y; rd(x, y);
    g[x]~=y; g[y]~=x;
  }

  if(m==n-1){writeln(0); return;}
  if((n-m-1)*2>n){writeln("Impossible"); return;}

  auto vis=new bool[](n);
  long dfs(int i, int p=-1){
    vis[i]=true;
    auto ret=a[i];
    foreach(j; g[i])if(j!=p){
      ret=min(ret, dfs(j, i));
    }
    return ret;
  }
  auto used=new bool[](n);
  bool search(long mn, int i, int p=-1){
    if(a[i]==mn){used[i]=true; return true;}
    auto ret=false;
    foreach(j; g[i])if(j!=p){
      ret|=search(mn, j, i);
      if(ret) return true;
    }
    return ret;
  }

  long c=0;
  foreach(i; 0..n)if(vis[i]==false){
    auto cost=dfs(i), found=search(cost, i);
    enforce(found);
    c+=cost;
  }
  alias T=Tuple!(long, "a", int, "i");
  auto as=new T[](n);
  foreach(i; 0..n) as[i]=T(a[i], i);
  sort!((l, r)=>(l.a==r.a ? l.i<r.i : l.a<r.a))(as);
  int tot=n-m, j=0;
  while(tot<(n-m-1)*2){
    auto e=as[j++];
    if(used[e.i]) continue;
    c+=e.a; tot++;
  }

  writeln(c);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


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

struct data
{
  ll x, y;
};

data ar[100005];

bool compare(data a, data b)
{
  return a.x<b.x;
}


int main()
{
  ll t, a, b, i, l, r, sum, c=0, d, mx=-1e9;

  cin>>t;

  for(i=1; i<=t; i++)
  {
    cin>>a>>b;
    ar[i].x=a+b;
    ar[i].y=(a-b);
  }

  sort(ar,ar+t+1,compare);
  for(i=1; i<=t; i++)
  {
    if(ar[i].y>=mx)
    {
      c++;
      mx=ar[i].x;
    }
    
  }

  cout<<c<<endl;
}

Measured memory_bytes: 1792
MOD = 10**9+7

n = int(input())
a = list(map(int, input().split()))

arr = [a[-1]]
for i in range(len(a)-2,-1,-1):
    arr += [arr[-1] + a[i]]

arr.reverse()
ans = 0
for i in range(len(a)-1):
    
    ans += (a[i] * (arr[i]-a[i]))%MOD
   
print(ans%MOD)

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


int main(){
  int a[10] = {0,0,0,0,0,0,1,1,1,2};
  int b[10] = {1,1,1,2,2,3,2,2,3,3};
  int c[10] = {2,3,4,3,4,4,3,4,4,4};
  
  int n; cin >> n;
  vector<long long> ini(5,0);
  long long ans = 0LL;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    if(s[0] == 'M') ini[0]++;
    if(s[0] == 'A') ini[1]++;
    if(s[0] == 'R') ini[2]++;
    if(s[0] == 'C') ini[3]++;
    if(s[0] == 'H') ini[4]++;
  }
  
  for(int i = 0; i < 10; i++){
    ans += ini[a[i]]*ini[b[i]]*ini[c[i]];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)

while A.length > 2 && A[-1] < A[-2] do
    A.pop
end

money = 1000
stock = 0

(A.length - 1).times do |i|
    if A[i] == A[i+1]
        next
    elsif A[i] > A[i+1]
        money += A[i] * stock
        stock = 0
    elsif stock == 0
        stock = money / A[i]
        money -= A[i] * stock
    end
end

puts money + (stock * A[-1])

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL INF=0x7FFFFFFFFFFFFFFF;
map <LL,LL> M;
int G,A,B,C,D;
LL n;
LL calc(LL,int,int);
LL finds(LL num)
{
	if (M[num]) return M[num];
	LL res=INF;
	if (log10(num)+log10(D)<=18) res=num*D;
	if (num>=2) res=min(res,calc(num,2,A)); 
	if (num>=3) res=min(res,calc(num,3,B)); 
	if (num>=5) res=min(res,calc(num,5,C));
	return M[num]=res;
}
LL calc(LL num,int k,int cost)
{
	LL L=num/k*k,R=L+k,res=finds(L/k)+abs(num-L)*D+cost;
	if (L!=k) res=min(res,finds(R/k)+abs(num-R)*D+cost);
	return res;
}
int main()
{
	scanf("%d",&G);
	while (G--)
	{
		scanf("%lld%d%d%d%d",&n,&A,&B,&C,&D);
		M.clear();
		printf("%lld\n",finds(n));
	}
	return 0;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	std::string s; cin >> s;
	
	int A = 0, B = 0;
	for(auto v: s) {
		A += (v == 'R');
		B += (v == 'B');
	}
	
	if(A > B) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
# https://abc070.contest.atcoder.jp/tasks/abc070_c

import itertools
import collections
from bisect import bisect


def lcm(a, b):
    return a * b // gcd(a, b)


def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)


def main():
    N = int(input())

    ans = int(input())
    for _ in range(N-1):
        ans = lcm(ans, int(input()))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>

main(){
  char data[101];
  int i, count=0, h, t;

  while(1){
    if(scanf("%s", &data)==EOF) break;

    for(i=0;;i++){
      if(data[i]=='\0'){
	t=i-1;
	break;
      }
    }
    h=0;
   
    while(1){
      if(data[h]!=data[t]) break;
      h++;
      t--;
      if(h>t){
	count++;
	break;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a<b){
cout<<"a < b"<<endl;
}
else if(a>b){
cout<<"a > b"<<endl;
}
else if(a==b){
cout<<"a == b"<<endl;
}
         return 0;
      }

Measured memory_bytes: 1156
using System;

namespace ConsoleApplication31
{
    class Program
    {
        static void Main(string[] args)
        {
            string anser = "123";
            string stranser = "";
            //入力A
            string A =(Console.ReadLine());
            
            //入力B
            string B = (Console.ReadLine());

            stranser = anser.Replace(A, "");
            stranser = stranser.Replace(B, "");

            //出力
            Console.WriteLine(stranser);

        }
    }
}


Measured memory_bytes: 13140
(let ((n (read))
      (m (read))
      (ans 0))
  (cond ((and (= 1 n) (= 1 m)) (setf ans 1))
        ((= 1 n) (setf ans (- m 2)))
        ((= 1 m) (setf ans (- n 2)))
        (t (setf ans (* (- n 2) (- m 2)))))
  (format t "~a~%" ans))


Measured memory_bytes: 11872
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		String st="";

		if(N==0){
			System.out.println(0);
		}else{

			while(N!=0){
				if(Math.abs(N)%2==1){
					st += "1";
					N--;
				}else{
					st += "0";
				}

				N /= -2;
			}

			StringBuffer sb = new StringBuffer(st);
			System.out.println(sb.reverse().toString());
		}

	}
}

Measured memory_bytes: 23764
N, K = map(int, input().split())

probs = []
for i in range(1, N+1):
    
    a = i
    n = 0
    while a < K:
        a *= 2
        n += 1

    p = (1/N) * (1/2)**n
    probs.append(p)

print(sum(probs))

Measured memory_bytes: 6296
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define int long long int

signed main(){
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    int hei = sum / n;
    if(sum % n > n / 2){hei++;}
    int result = 0;
    for(int i=0;i<n;i++){
        result += (a[i] - hei) * (a[i] - hei);
    }
    cout << result << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m,q;
    cin>>n>>m>>q;
    vl a(n+2);
    vl b(m+2);
    a[0]=-LINF;
    REP(i,n){
        cin>>a[i+1];
    }
    a[n+1]=LINF;
    b[0]=-LINF;
    REP(i,m){
        cin>>b[i+1];
    }
    b[m+1]=LINF;
    REP(i,q){
        ll now;
        cin>>now;
        ll ans=LINF;
        REP(j,2){
            REP(k,2){
                ll x,y;
                if(j%2){
                    x=now-*lower_bound(all(a),now);
                }else{
                    x=now-*(--upper_bound(all(a),now));
                }
                if(k%2){
                    y=now-*lower_bound(all(b),now);
                }else{
                    y=now-*(--upper_bound(all(b),now));
                }
                if((x/abs(x))*(y/abs(y))>=0){
                    x=abs(x);
                    y=abs(y);
                    chmin(ans,max(x,y));
                }else{
                    x=abs(x);
                    y=abs(y);
                    chmin(ans,max(x,y)+min(x,y)*2);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

const int md = (int) 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int sm = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    (sm += a[i]) %= md;
    (res += 1ll * a[i] * a[i] % md) %= md;
  }
  res = (1ll * sm * sm % md - res) % md;
  (res += md) %= md;
  res = (1ll * res * (md + 1) / 2) % md;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3964
import sys

n = int(raw_input())
a = list(map(int, raw_input().split()))

def no():
	print "No"
	exit(0)

def yes():
	print 'Yes'
	exit(0)

a = list(sorted(a))
if a[0] == a[-1] and a[0] == n - 1:
	yes()

X = max(a)
alone = 0
many = 0

for e in a:
	if e != X and e != X - 1:
		no()
	if e == X - 1:
		alone += 1
	else:
		many += 1

rest = X - alone

if rest < 0:
	no()

if rest == 0 and many > 0:
	no()

if rest * 2 > many:
	no()

yes()


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

int main(){
    int N;
    string s;
    cin  >> N >> s;
    vector<int> bit(N+1);
    for(int i = 0;i < N;i++){
        if(s[i] == 'o') bit[i] = 0;
        else    bit[i] = 1;
    }
    bit[N] = bit[0];
    vector<vector<int>> a(4, vector<int>(N+2, 0));
    for(int i = 0;i < 4;i++){
        a[i][0] = i>>1;
        a[i][1] = i&1;
        for(int j = 1;j <= N;j++){
            if(a[i][j]^bit[j])  a[i][j+1] = a[i][j-1];
            else    a[i][j+1] = !a[i][j-1];
        }
        if(a[i][N] == a[i][0] && a[i][N+1] == a[i][1]){
            for(int j = 0;j < N;j++){
                if(a[i][j]) cout << 'S';
                else    cout << 'W';
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 2816
n=int(input())
if n==1:
  print(1)
  exit()
mod=10**9+7
dp=[0]*(n+1)
S=[0]*(n+1)
dp[0]=1
dp[1]=1
dp[2]=1
S[0]=1
for i in range(n):
  if i+1>=3:
    dp[i+1]=2*dp[i]-dp[i-1]+dp[i-2]
  dp[i+1]%=mod
  S[i+1]=S[i]+(n-1)*dp[i]
  S[i+1]%=mod
ans=S[n]
for i in range(1,n):
  ans+=((n-1)**2)*dp[i-1]
  ans%=mod
print(ans)
#print(S)
#print(dp)

Measured memory_bytes: 56044
#include<iostream>

using namespace std;

int C[100005];

int N;
int A[100005];

int main(void) {

	cin >> N;

	int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp; A[i] = tmp;
	}


	for (int i = 1; i <= N; i++) {
		C[A[i]]++;
	}

	int count = 0;

	int R = 0;

	for (int i = 1; i <= 100000; i++) {
		if (C[i] > 0) { count++; }
		if (C[i] > 1) { R += C[i] - 1; }
	}

	//cout << "count= " << count << endl;
	//cout << "R= " << R << endl;

	if (R % 2 == 0) { cout << count << endl; }
	else { cout << count - 1 << endl; }

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

Measured memory_bytes: 1024
Module Atcorder1

        Sub Main(ByVal args() As String)

            Dim intFirst As Integer = 0
            Dim intSecond As Integer = 0
            Dim arr(2) As String
            Dim intMod As Integer = 0

            arr = Split(Console.ReadLine())
            intFirst = CInt(arr(0))
            intSecond = CInt(arr(1))

            intMod = ((intFirst * intSecond) Mod 2)

            If intMod > 0 Then
                Console.WriteLine("Odd")
            Else
                Console.WriteLine("Even")
            End If

        End Sub

    End Module

Measured memory_bytes: 11476
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007
#define NMAX 200000

signed main(){   
    int N,K,A[NMAX];
    int a[NMAX];

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

    for(int i=0;i<N;i++){
        a[i]=A[i];
    }
    for(int i=0;i<K;i++){
        int n[NMAX]={0};
        int sp=0;
        for(int j=0;j<N;j++){
            if(j-a[j]<0) sp++;
            else n[j-a[j]]++;
            if(j+a[j]+1<N) n[j+a[j]+1]--;
        }
        for(int j=0;j<N;j++){
            sp+=n[j];
            n[j]=sp;
        }
        bool mf=true;
        for(int j=0;j<N;j++){
            a[j]=n[j];
            if(a[j]!=N) mf=false;
        }
        if(mf) break;
    }
    for(int j=0;j<N;j++){
        cout<<a[j]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 7884
//
// main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> As(N);
	rep(i,0,N) {
		cin >> As[i];
	}
	unordered_set<ll> now;
	now.insert(0);
	vector<unordered_set<ll>> dpr(N);
	rrep(i,N,0) {
		unordered_set<ll> now0;
		for (ll x : now) {
			ll next = x + As[i];
			if (next < K && now.find(next) == now.end()) {
				dpr[i].insert(next);
				now0.insert(next);
			}
		}
		if (now0.size() > now.size()) {
			swap(now, now0);
		}
		for (ll x : now0) {
			now.insert(x);
		}
	}
	set<ll> right(now.begin(), now.end());
	unordered_set<ll> left;
	left.insert(0);
	ll need = 0;
	rep(i,0,N) {
		for (ll x : dpr[i]) {
			right.erase(x);
		}
		if (As[i] >= K) {
			need++;
		} else {
			for(ll l : left) {
				if (right.lower_bound(K-As[i]-l) != right.lower_bound(K-l)) {
					need++;
					break;
				}
			}
		}
		unordered_set<ll> left0;
		for (ll x : left) {
			ll next = x + As[i];
			if (next < K) {
				left0.insert(next);
			}
		}
		if (left0.size() > left.size()) {
			swap(left0, left);
		}
		for (ll x : left0) {
			left.insert(x);
		}
	}
	cout << N - need << endl;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <stack>
#include <sstream>

using namespace std;

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


typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;


const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}


int main(){
  ll n,ans=0;
  cin>>n;
  vector<ll> a(n+1),b(n+1),c(n+1);
  rep(i,n+1) cin>>a[i];
  rep(i,n+1){
	cin>>b[i];
    c[i]=b[i];
  }
   

  
  rep(i,n+1){
     if(a[i]>=b[i]){
       ans+=b[i];
     }else{
       ans+=a[i];
       if(i!=n){
          b[i+1]+=min(c[i],b[i]-a[i]);
       }
     }
  }

  cout<<ans<<endl;
}
  
  
  
  

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

void solve(){
    int n;
    string s;
    set<string> S;
    cin >> n;
    for(int i=0; i<n; ++i){
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 19080
#include<stdio.h>

int main(){
	
	int n;
	double w,m,BMI;
	
	while( scanf("%d,",&n) != EOF ){
		scanf("%lf,%lf",&w ,&m);
		
		BMI=w/(m*m);
		
		if(BMI>=25) printf("%d\n",n);
	}
	
return 0;
}

Measured memory_bytes: 636
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int h=0;
		int count=0;
		
		for(int i=0;i<N;i++) {
			h=sc.nextInt();
			if(h>=K) {
				count++;
			}
		}
		
		System.out.println(count);
	}
}


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

int main(void){
    int x = 0, a = 0, b = 0;

    scanf("%d%d%d", &x, &a, &b);
    x -= a;

    while(x - b >= 0){
        x -= b;
    }

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

} 


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss, ts; scan(ss, ts);
      std::sort(ss.begin(), ss.end());
      std::sort(ts.begin(), ts.end());
      std::reverse(ts.begin(), ts.end());
      puts(ss<ts?"Yes":"No");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




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

struct UnionFind {
	vector<int> d;

	UnionFind(int N=0) : d(N, -1){} 

	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}

	bool unite(int x, int y) {
		x = find(x); 
		y = find(y); 
		if (x == y) return false;
		if (d[x] > d[y]) swap(x,y);
		d[x] += d[y];
		d[y] = x; 
		return true;
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	int size(int x){
		return -d[find(x)];
	}
};

int main(){

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N,M; cin >> N >> M;


	UnionFind uf(N);
	rep(i,M){
		int a, b; cin >> a >> b;
		a--;
		b--;
		uf.unite(a,b);
	}	

	int ans = 0;
	rep(i,N){
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

ll g(ll x) {
  ll ans = 0;
  if (x % 2 == 0) ans = x;
  ans +=  ((x+1) / 2) % 2;

  return ans;
}

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

  ll y = stoll(s.substr(0, 4));
  ll m = stoll(s.substr(5, 2));
  string ans = "Heisei";
  if (y > 2019) {
    ans = "TBD";
  } else if (y == 2019 && m > 4) {
    ans = "TBD";
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   map<string, int> m;
   m["AC"] = 0;
   m["WA"] = 0;
   m["TLE"] = 0;
   m["RE"] = 0;
   int n; cin >> n;
   while(n--) {
      string s; cin >> s;
      m[s]++;
   }  
   cout << "AC x " << m["AC"] << "\n" << 
            "WA x " << m["WA"] << "\n" << 
            "TLE x " << m["TLE"] << "\n" << 
            "RE x " << m["RE"] << "\n";
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    std::vector<ll> A(N);
    REP(i, N) {
        std::cin >> A[i];
    }

    std::vector<ll> accsum(N + 1, 0);
    REP(acc_i, N) {
        accsum[acc_i + 1] = accsum[acc_i] + A[acc_i];
    }

    double h   = accsum.back() / 2.0;
    ll     ans = LINF;
    REP(i, N + 1) {
        chmin(ans, ll(abs(h - accsum[i]) * 2));
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;

  ll ans = 0;
  for(ll i = 1; i <= n; i++){
    ll cnt = 0;
    ll num = i;
    while(num){
      num /= 10;
      cnt++;
    }

    if(cnt % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define MAXN 0x7fffffff
#define ll long long


int m,n,i,j,k,p,q,l,flag=0;

int main(){
	int a,b;
	char num[4];
	scanf("%d",&a);
	for(i=3;i>=0;i--){
		b=a%10; a/=10;
		num[i]=b+48;
	}
	if((num[0]==num[1] && num[1]==num[2]) || (num[1]==num[2] && num[2]==num[3])) printf("Yes");
	else printf("No");
	return 0;
}

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

int solve500(int n)
{

	if (n > 500)
	{
		return solve500(n - 500);
	}
	else {
		return n;
	}
	return 0;
}
int main()
{
	int n, a;

	cin >> n >> a;
	int t = solve500(n);
	if (n % 500 == 0)
	{
		cout << "Yes" << endl;
	}
	else if (t > 0)
	{
		if (t <= a)
		{
			cout << "Yes" << endl;

		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
	
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
		int n; cin>>n;
		int arr[n] = {};
		int k,q; cin>>k>>q;
		int Q = q;;
		while (q--)
		{
			int a; cin>>a;
			arr[a - 1] += 1; 
		}
		for (int i = 0; i < n; i++)
		{
			if (arr[i] + k > Q)
			{
				cout<<"Yes";
			}
			else
			{
				cout<<"No";
			}
			cout<<endl;
		}
		
		
    }
    return 0;

}


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

int main(){
  int h, w;
  h = 100; w = 100;
  int a, b;
  int map[100][100];
  cin >> a >> b;

  for (int i = 0; i < 100; i++){
    for (int j = 0; j < 100; j++){
        map[i][j] = 0;
    }
  }

  int t = a - 1;
  if (t > 0){
    int u = (t-1) / 50 + 1;
    for (int i = 1; i <= u; i++){
      for (int j = 0; j < 100; j++){
        map[i*2-1][j] = 1;
      }
    }
    for (int i = 1; i <= u; i++){
      for (int j = 0; j < 100; j += 2){
        if (t == 0) break;
        map[i*2-2][j] = 1;
        t--;
      }
    }
  }
  int tt = b - 1;
  if (tt > 0){
    for (int i = 99; i > 30; i -= 2){
      for (int j = 0; j < 100; j+= 2){
        if (tt == 0) break;
        map[i][j] = 1;
        tt--;
      }
    }
  }
  if (t == 0){
    map[0][0] = 1;
  }


  printf("%d %d\n", h, w);
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if (map[i][j] == 1) printf("#");
      else printf(".");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

const unsigned long long MAX = 1e18;

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

	int N;
	cin >> N;

	vector<unsigned long long> A(N, 0);

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

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

	if (A.front() == 0)
	{
		cout << 0;
		return 0;
	}

	unsigned long long result = 1;
	for (int i = N - 1; i >= 0; i--)
	{
		if (A[i] <= MAX / result)
		{
			result *= A[i];
		}
		else
		{
			cout << -1;
			return 0;
		}
	}

	cout << result;

	return 0;
}

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

Measured memory_bytes: 3064
# AOJ 0058 Orthogonal

E = 1e-10
while line = gets
  xA, yA, xB, yB, xC, yC, xD, yD = line.split.map {|v| v.to_f}
  puts ((xB - xA) * (xD - xC) + (yB - yA) * (yD - yC)).abs < E ? "YES" : "NO"
end

Measured memory_bytes: 6120
#include<stdio.h>

int main(void) {
	int w, n, i, gl[50], cha1[50],cha2[50];
	scanf("%d", &w);
	for (i = 1; i <= w; i++) {
		gl[i] = i;
	}
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d,%d", &cha1[i],&cha2[i]);
		int t;
		t = gl[cha1[i]];
		gl[cha1[i]] = gl[cha2[i]];
		gl[cha2[i]] = t;

	}
	for (i = 1; i <= w; i++) {
		printf("%d\n", gl[i]);
	}
	return 0;
}

Measured memory_bytes: 596
package main
import (
  "fmt"
)
func main() {
  var s string
  fmt.Scan(&s)
  gCnt, pCnt := 0, 0 
  for _, char := range s {
    if char == 'g' {
      gCnt++
    } else {
      pCnt++
    }
  }
  result := (gCnt-pCnt)/2
  fmt.Println(result)
}

Measured memory_bytes: 1280