akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

bool dfs(VVI& G, int u, VI& parity, PLL& res){
  if(parity[u] > 0) res.FF++;
  else res.SS++;

  for(int to: G[u]){
	if(parity[to]){
	  if(parity[to] == parity[u])
		return false;
	}
	else{
	  parity[to] = -parity[u];
	  if(!dfs(G, to, parity, res))
		return false;
	}
  }
  return true;
}

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

  int V, E; cin >> V >> E;
  VVI G(V);
  REP(i,E){
	int u, v; cin >> u >> v;
	--u;
	--v;
	G[u].PB(v);
	G[v].PB(u);
  }
  vector<PLL> xs;
  VI parity(V);
  REP(i,V){
	if(!parity[i]){
	  parity[i] = 1;
	  PLL res;
	  if(!dfs(G, i, parity, res)){
		cout << -1 << endl;
		return 0;
	  }
	  xs.EB(res);
	}
  }
  
  LL ans = 0;
  bitset<100001> bs;
  bs[0] = 1;
  for(auto& p: xs)
	bs = (bs << p.FF) | (bs << p.SS);

  REP(i,V+1)
	if(bs[i]){
	  maxi(ans, (LL)i * (V - i));
	}
  cout << ans - E << endl;

  return 0;
}

Measured memory_bytes: 9284
#include<bits/stdc++.h>
using namespace std;
int main(){

     long long int a,b,c,d,e,f,i,j,k,x,y,t=0;
     vector<int> v;
     vector<int> v1;
     vector<int> v2;
     vector<int>::iterator it;
     set<int> st;
     cin>>a>>b;
     for(i=0;i<a;i++){
        cin>>c;
        v.push_back(c);

     }
     sort(v.begin(),v.end());
 for(i=0;i<a-b;i++){
    t+=v[i];
 }
cout<<t<<endl;

    return 0;
}



Measured memory_bytes: 1400
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"Yes\n";
#define N cout<<"No\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
lli arr[1000001];
lli mpp[1000001];

int main()
{
    fast
    lli n,ans=0;
    cin>>n;
    vector<lli> v(n);
    for(lli i=0;i<n;i++)
    {
        cin>>v[i];
        mpp[v[i]]++;
    }
        
    for(lli i=0;i<n;i++)
    {
        lli ele=v[i];
        bool f=0;
        for(lli j=1;(j*j)<=ele;j++)
        {
            // er
            if(j==1)
            {
                if(ele==1)
                {
                    if(mpp[1]>=2)
                    {
                        f=1;
                        break;
                    }
                    
                }
                else
                {
                   if(mpp[1]>=1||mpp[ele]>=2) 
                   {
                       f=1;
                       break;
                   }
                }
               
               continue; 
            }
            if((ele%j)==0)
            {
                if(mpp[j])
                {
                    f=1;
                    break;
                }
                if(j*j!=ele)
                {
                    if(mpp[ele/j])
                    {
                        f=1;
                        break;
                    }
                }
                // print2(j,ele/j)
            }
        }
        if(f==0)
        {
            ans++;

        }
        
    }
    
    cout<<ans;
}
//a+b=a⊕b+2∗(a&b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";




Measured memory_bytes: 12536
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMaximalValue solver = new CMaximalValue();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMaximalValue {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            CMaximalValue.Pair[] a = new CMaximalValue.Pair[n - 1];
            for (int i = 0; i < n - 1; i++) {
                a[i] = new CMaximalValue.Pair(sc.nextInt(), i);
            }
            int[] ans = new int[n];
            Arrays.fill(ans, -1);
            Arrays.sort(a, Comparator.comparingInt(a2 -> a2.x));
            for (int i = 0; i < n - 1; i++) {
                if (ans[a[i].y] == -1) {
                    ans[a[i].y] = a[i].x;
                }
                if (ans[a[i].y + 1] == -1) {
                    ans[a[i].y + 1] = a[i].x;
                }
            }
            long sum = 0;
            for (int i = 0; i < n; i++) {
                sum += ans[i];
            }
            out.println(sum);
        }

        static class Pair {
            int x;
            int y;

            public Pair(int x, int y) {
                this.x = x;
                this.y = y;
            }

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
  int H , W ;
  string a ;
  cin >> H >> W ;
  for ( int i = 0 ; i < W + 2 ; i++ ){
    cout << '#' ;
  }
  cout << endl ;
  for ( int i = 0 ; i < H ; i++ ){
    cin >> a ;
    cout << '#' << a << '#' << endl ;
  }
  for ( int i = 0 ; i < W + 2 ; i++ ){
    cout << '#' ;
  }
  cout << endl ;
}


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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll N=2e5+1;

ll solve(ll t,vector<ll>& a,ll n)
{
  ll ans=0;
  for(int i=1;i<=n;i++)
    ans+=(a[i]-t)*(a[i]-t);

  return ans;

}


ll bx(ll n)
{
  ll temp=10;
  while(n)
  {
    temp=min(temp,n%10);
    n/=10;
  }
  return temp;
}

ll ax(ll n)
{
  ll temp=0;
  while(n)
  {
    temp=max(temp,n%10);
    n/=10;
  }
  return temp;
}



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


ll n;cin>>n;
set<pair<ll,ll>>s;
vl a(n+1);

for(int i=1;i<=n;i++)
{
  cin>>a[i];
 // s.insert({a[i],i});
}

for(int i=1;i<=n;i++)
{
  s.insert({a[i],-i});
  auto it=s.find({a[i],-i});

  if(it!=s.begin())
  {
    advance(it,-1);
// cout<<"hi"<<" "<<(*it).first<<"\n";
    s.erase(it);
  }
}

//for(auto x:s)cout<<x.first<<" "<<x.second<<"\n";


cout<<s.size()<<"\n";

return 0;

}

Measured memory_bytes: 7296
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        mut a: u128,
        b: Chars,
    };

    let mut d = vec![];
    for &c_i in b.iter() {
        if c_i.is_digit(10) {
            d.push(c_i.to_digit(10).unwrap() as u128);
        }
    }
    let mut ans = 0;
    for &d_i in d.iter() {
        ans *= 10;
        ans += a * d_i;
    }
    ans *= 10;
    ans /= 10_u128.pow(d.len() as u32);
    println!("{}", ans);
}


Measured memory_bytes: 2188
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	int A, B;
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}


Measured memory_bytes: 256
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

h = Hash.new(0)
ans = 0

a.each do |num|
  h[num] += 1
end

h.each do |key, value|
  if key > value
    ans += value unless key == value
  else
    ans += value - key
  end
end

p ans


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

int main(){
    int n;cin>>n;
    int M[n+1][n+1]={};//index 0 is not used.
    for(int i=1;i<n+1;i++){
        int target,degree;
        cin>>target>>degree;
        for(int j=0;j<degree;j++){
            int in;
            cin>>in;M[target][in]=1;
        }
    }
    for(int i=1;i<n+1;i++){
        for(int j=1;j<n+1;j++){
            cout<<M[i][j];
            if(j != n)cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}


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

int main(){
  string s;
  while(getline(cin,s)){
    if(s[0]=='.'&&s.size()==1)break;
    stack<char> st;
    int flag=1;
    for(int i=0;i<s.size();i++){
      if(s[i]=='(')st.push('(');
      if(s[i]=='[')st.push('[');
      if(s[i]==')'){
        if(st.empty()!=true&&st.top()=='('){
          st.pop();
        }else{
          flag=0;
          break;
        }
      }
      if(s[i]==']'){
        if(st.empty()!=true&&st.top()=='['){
          st.pop();
        }else{
          flag=0;
          break;
        }
      }
    }
    if(flag==1&&st.empty()){
      cout<<"yes"<<endl;
    }else{
      cout<<"no"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3124
#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;
  cin >> a >> b;

  cout << (a%3 * b%3 * (a+b)%3 == 0 ? "Possible" : "Impossible") << endl;

  return 0;
}


Measured memory_bytes: 256
x,k,d = map(int,input().split())
an = x

if x < 0:
    x = -x

if k <= x/d:
    an = x-d*k
else:
    if (k-x//d)%2==0:
        an = x-d*(x//d)
    else:
        an = x-d*(x//d)-d
        
print(abs(an))

Measured memory_bytes: 9172
void main() {
	auto S = rs;
	writefln("A%sC", S[8]);
	
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

#define int long long

using namespace std;

typedef pair<int, int> pp;

int getBest(vector<pp> &p) {
    int n = p.size();


    vector<pp> v;

    for (int i = 0; i < p.size(); ++i) {
        v.emplace_back(p[i].first, i);
        v.emplace_back(p[i].second, i);
    }

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

    vector<vector<int>> pos(n);
    for (int i = 0; i < v.size(); ++i) {
        pos[v[i].second].push_back(i);
    }

    int sum = 0;
    for (int i = 0; i < n - 2; ++i) {
        sum += v[i].first;
    }

    int best = numeric_limits<int>::max();
    for (int i = 0; i < p.size(); ++i) {
        int sum2 = sum;
        if (pos[i][0] < n - 2) {
            sum2 += v[n - 2].first;

            if (pos[i][1] < n - 1) {
                sum2 += v[n - 1].first;
            } else {
                sum2 += v[pos[i][1]].first;
            }
        } else {
            sum2 += v[pos[i][0]].first;
            sum2 += v[pos[i][1]].first;
        }

        best = min(best, sum2);
    }

    return best;
}

main() {
    int n;
    scanf("%lld", &n);

    vector<pp> p(n);

    for (int i = 0; i < n; ++i) {
        scanf("%lld%lld", &p[i].first, &p[i].second);
    }

    int best = numeric_limits<int>::max();

    int sum;

    sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += p[i].first;
    }
    best = min(best, sum);

    sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += p[i].second;
    }
    best = min(best, sum);

    best = min(best, getBest(p));
    printf("%lld\n", best);
}


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

int main(){
    int n;
    std::cin >> n;
    bool result = true;
    std::vector<std::string> vec;
    char last;
    std::string s;
    std::cin >> s;
    vec.push_back(s);
    last = s[s.length()-1];
    for(int i = 0; i < n-1; i++){
        std::cin >> s;
        result &= (s[0] == last);
        bool flag = std::find(vec.begin(), vec.end(), s) == vec.end();
        result &= flag;
        vec.push_back(s);
        last = s[s.length()-1];

    }
    std::cout << (result ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int c;
int t;

int main()
{
    int n,T;
    int i;
    int ans = 1001;

    scanf("%d%d",&n,&T);
    for(i = 0;i < n;i++)
    {
        scanf("%d%d",&c,&t);
        if(t <= T && c < ans) ans = c;
    }
    if(ans == 1001) printf("TLE\n");
    else printf("%d\n",ans);

    return 0;
}


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

#define INF 1e18
#define PI 3.141592653589793238
typedef long long ll;
#define N 200010

int main() {
    double l;cin>>l;
    double x=l/3;
    printf("%.7lf\n", x*x*(l-2*x));


    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
bool f [100001];
int c [100002];
int N,L,R ;
int main ()
{
    for (int i =2; i<=100000; i++)
        if (!f[i])
        for (int j = i+i ;j<=100000; j+=i )
                f[j]= true ;

    for (int i =3; i<=100000; i+=2)
        if (!f[i] && !f[(i+1)/2])
            c[i]++;

    for (int i =3; i <=100000; i ++)
            c[i]+=c[i-1];

    scanf ("%d",&N);
    while (N--)
    {
        scanf ("%d%d" ,&L ,&R );
        printf ("%d\n" , c[R] - c[L-1]);
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    vector<P> vec(N);
    rep(i,0,N)vec[i] = P(V[i], i);
    sort(vec.begin(), vec.end());

    int cnt = 0;
    rep(i,0,N)if(i % 2 == 0){
        if(vec[i].second % 2)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

bool comp(pii a, pii b){
  if(a.first == b.first) return a.second > b.second;
  return a.first > b.first;
}


bool comp2(pii a, pii b){
  return a.second > b.second;
}

void Main() {
  int N, H; cin >> N >> H;
  vector<pii> S(N);
  rep(i, 0, N){
    int a, b; cin >> a >> b;
    S[i] = make_pair(a, b);
  }
  sort(all(S), comp);
  pii yuusha = S[0];
  vector<pii> T(N);
  copy(S.begin() + 1, S.end(), back_inserter(T));
  sort(all(T), comp2);
  int res = 0;
  int n = 0;
  while(H > 0){
    if(H <= yuusha.second){
      H -= yuusha.second;
    }else if(T[n].second > yuusha.first){
      H -= T[n].second;
      n++;
    }else{
      H -= yuusha.first;
    }
    res++;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 10480
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
    int a[5],k,ans=0;
    for(int i=0;i<5;i++)    cin >> a[i];
    cin >> k;
    ans = a[4]-a[0];
    if(ans>k)  cout << ":(";
    else    cout << "Yay!";
    return 0;
}

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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

int main() {

    int n;
    set<string> st;

    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        st.insert(s);
    }

    cout << sz(st) << endl;

    return 0;
}


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

int main(void){

    int n;
    long long sum_A = 0;
    cin >> n;
    vector<int> B(n,100000);
    for(int i = 0; i < n-1; i++){
        cin >> B.at(i);
    }
    
    sum_A = B.at(0);
    for(int i = 0; i < n-1; i++){
        sum_A += min(B.at(i), B.at(i+1));
        //cout << "sum_A = " << B.at(i) << " " << B.at(i+1) << endl;
    }
    
    cout << sum_A << endl;
    

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int sum=0,i,ansm,anss;
  int time[4];

  for(i=0;i<4;i++){
    scanf("%d", &time[i]);
    sum=sum+time[i];
  }
  anss=sum%60;
  ansm=(sum-anss)/60;

  printf("%d\n", ansm);
  printf("%d\n", anss);

  return 0;
}


Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << a << endl;}
template<class T> void writes(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
void write(double a){cout << fixed << setprecision(12) << a << endl;}
void write(long double a){cout << fixed << setprecision(12) << a << endl;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
	int n,k;
    bool b[10]={0};
    cin>>n>>k;
    rep(i,k){
        b[read<int>()]=true;
    }
    int res=n;
    while(true){
        int tr=res;
        while(tr>0){
            if(b[tr%10])break;
            tr/=10;
        }
        if(tr==0)
            break;
        res++;
    }
    write(res);
    return 0;
}

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

int n;
ll a[401];
ll dp[401][401]={0};

ll helper(){
    for(int x=1; x<n; x++){
        int i=0, j=x;
        while(j<n){
            ll ans = LLONG_MAX;
            for(int k=i; k<j; k++){
                ans = min(ans, dp[i][k]+dp[k+1][j]+(a[j]-(i>0?a[i-1]:0)));
            }
            dp[i][j]=ans;
            i++;
            j++;
        }
    }
    return dp[0][n-1];
}

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

Measured memory_bytes: 1536
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;
int mod;

int add(int a, int b)
{
	int c = a + b;
	if (c >= mod)c -= mod;
	return c;
}

int dif(int a, int b)
{
	int c = a - b;
	if (c < 0)c += mod;
	return c;
}

int mlt(int a, int b)
{
	long long c = a * 1LL * b;
	return c % mod;
}

int bp(int a, int b)
{
	if (b == 0)return 1;
	if (b % 2 == 0)
	{
		int val = bp(a, b / 2);
		return mlt(val, val);
	}
	if (b % 2 == 1)
	{
		int val = bp(a, b - 1);
		return mlt(val, a);
	}
}

int inv(int a)
{
	return bp(a, mod - 2);
}

int ibit(int mask, int i)
{
	return (mask >> i) % 2;
}

void outp(vector<vector<int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		for (int j = 0; j < v[i].size(); j++)cout << v[i][j] << ' ';
		cout << endl;
	}
	cout << endl;
}
vector<int>fact, ofact;
int c(int a, int b)
{
	if(b<a) return 0;
	if(a<0)return 0;
	int val=fact[b];
	val=mlt(val, ofact[a]);
	val=mlt(val, ofact[b-a]);
	return val;
}
int pth(int st, int fn, int len)
{
	return c((len+fn-st)/2, len);
}
int hg(int st, int fn, int len)
{
   if(st<0)return 0;
   if(fn<0)return 0;
   if((st+fn)%2!=len%2)return 0;
   return dif(pth(st, fn, len), pth(st, -fn-2, len));
}
int f(int st, int fn, int b1, int b2, int len)
{
	//cout<<st<<' '<<fn<<' '<<b1<<' '<<b2<<' '<<len<<endl;
	if(b1!=0)
	{
		return f(st-b1, fn-b1, 0, b2-b1, len);
	}
	if(st<0)return 0;
	if(st>b2)return 0;
	if(fn<0)return 0;
	if(fn>b2)return 0;
	if(b2>2*len)
	{
		int bv=0;
		if (st > b2 / 2)
			  bv=f(b2 - st, b2 - fn, b1, b2, len);
		 else bv=hg(st, fn, len);
	//	cout<<st<<' '<<fn<<' '<<b1<<' '<<b2<<' '<<len<<' '<<bv<<endl;
		return bv;
	}
	int pq=dif(f(st, fn, -b2-2, b2, len),
	           f(st, -fn-2, -b2-2, b2, len));
//	cout<<st<<' '<<fn<<' '<<b1<<' '<<b2<<' '<<len<<' '<<pq<<endl;
	return pq;


}
int solve(int n, int k)
{
	if(k<0)return 0;
	if(n==1)return 1;
	if(n==2)return 0;
	int ans=fact[n-1], cr=0;
	for(int mn=0; mn<n-1; mn++)
	{
		int pl=n-1-mn;
		cr=add(cr, f(pl, mn, max(n-1-k,1), k+1,  n-1));
	}
	//cout<<n<<' '<<k<<' '<<cr<<endl;
	return mlt(ans,cr);
}
int main()
{
	int n, k;
	cin>>n>>k>>mod;
	fact.resize(300);
	ofact.resize(300);
	fact[0]=1;
	ofact[0]=1;
	for(int i=1; i<300; i++)
	{
		fact[i]=mlt(fact[i-1], i);
		ofact[i]=inv(fact[i]);
	}
	int ans=0;
	for(int low=1; low<=n; low++)
	{
		int val=solve(low, k-n+low);
		val=mlt(val, c(low,n));
		val=mlt(val, fact[n-low]);
		ans=add(ans, val);
	}
    cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
ll p = 1e9+7;

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

	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans=1;
	ll n=N, m=M;

	for (ll i = N; i > 0; i--) {
		ans *= i; ans %= p;
	}
	for (ll i = M; i > 0; i--) {
		ans *= i; ans %= p;
	}

	if (n != m) {
		cout << ans << endl;
	}
	else {
		ans *= 2; ans %= p;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

double dist(double x1, double y1, double x2, double y2){
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main() {
    double x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    double d1 = dist(x1, y1, x2, y2);
    double d2 = dist(x3, y3, x2, y2);
    double d3 = dist(x1, y1, x3, y3);

    double p = (d1 + d2 + d3) / 2.0;
    double s = sqrt(p * (p - d1) * (p - d2) * (p - d3));
    double r = 2 * s / (d1 + d2 + d3);
    double d = fmax(d1, fmax(d2, d3));

    double ans = d / (2 + d / r);
    printf("%.10f\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int dis(int x1, int y1, int x2, int y2) {
		return (x1 == x2) ? Math.abs(y1-y2) : Math.abs(x1-x2);
	}
	
	
	void calc(int m, int[] dis, boolean[] dir) {
		int prex = sc.nextInt(), prey = sc.nextInt();
		int nextx = sc.nextInt(), nexty = sc.nextInt();
		dis[0] = dis(prex, prey, nextx, nexty);
		int vorh;
		if (prex == nextx) {
			if (prey < nexty) vorh = 1; //↑
			else vorh = 2;              //↓
		} else {
			if (prex < nextx) vorh = 3; //→
			else vorh = 4;              //←
		}
		prex = nextx;
		prey = nexty;
		
		
		for (int i = 2; i < m; i++) {
			nextx = sc.nextInt();
			nexty = sc.nextInt();
			dis[i-1] = dis(prex, prey, nextx, nexty);
			switch (vorh) {
			case 1: if (prex < nextx) { dir[i-2] = true; vorh = 3; break;}
					else { dir[i-2] = false; vorh = 4; break;}
			case 2: if (prex < nextx) { dir[i-2] = false; vorh = 3; break;} 
					else { dir[i-2] = true; vorh = 4; break;}
			case 3: if (prey < nexty) { dir[i-2] = false; vorh = 1; break;} 
					else { dir[i-2] = true; vorh = 2; break;}
			case 4: if (prey < nexty) { dir[i-2] = true; vorh = 1; break;} 
					else { dir[i-2] = false; vorh = 2; break;}
			}
			prex = nextx;
			prey = nexty;
		}
	}
	
	void run() {
		int n ;
		while (true) {
			n = sc.nextInt();
			if (n == 0) break;
			int m0 = sc.nextInt();
			int[] dis0 = new int[m0-1];
			boolean[] dir0 = new boolean[m0-2]; // true:right   left:false
			calc(m0, dis0, dir0);
			
			
			for (int i = 1; i <= n; i++) {
				int m = sc.nextInt();
				int[] dis = new int[m-1];
				boolean[] dir = new boolean[m-2]; // true:right   left:false
				calc(m, dis, dir);
				if (m0 == m) {
					boolean flag = true;
					for (int j = 0; j < m-1; j++) {
						if (dis0[j] != dis[j]) {
							flag = false;
							break;
						}
					}
					for (int j = 0; j < m-2; j++) {
						if (dir0[j] != dir[j]) {
							flag = false;
							break;
						}
					}
					boolean rflag = true;
					for (int j = 0; j < m-1; j++) {
						if (dis0[j] != dis[m-j-2]) {
							rflag = false;
							break;
						}
					}
					for (int j = 0; j < m-2; j++) {
						if (dir0[j] == dir[m-j-3]) {
							rflag = false;
							break;
						}
					}
					if (flag || rflag)
						out.println(i);
				}
			}
			
			out.println("+++++");
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 29288
H, W, M = map(int, input().split())
h_dic, w_dic = {}, {}
m = set()
for i in range(M):
    h_i, w_i = map(int, input().split())
    m.add((h_i, w_i))
    if h_i in h_dic:
        h_dic[h_i] += 1
    else:
        h_dic[h_i] = 1
    if w_i in w_dic:
        w_dic[w_i] += 1
    else:
        w_dic[w_i] = 1
        
max_h_items = [[0,0]]
max_w_items = [[0,0]]

for key, value in h_dic.items():
    if value > max_h_items[0][1]:
        max_h_items = [[key, value]]
    elif value == max_h_items[0][1]:
        max_h_items.append([key, value])
for key, value in w_dic.items():
    if value > max_w_items[0][1]:
        max_w_items = [[key, value]]
    elif value == max_w_items[0][1]:
        max_w_items.append([key, value])
s = max_h_items[0][1] + max_w_items[0][1] - 1
for mh in max_h_items:
    for mw in max_w_items:
        if (mh[0], mw[0]) not in m:
            s = mh[1]+mw[1]
            print(s)
            break
    if s == max_h_items[0][1] + max_w_items[0][1]:
        break
if s == max_h_items[0][1] + max_w_items[0][1] - 1:
    print(s)

Measured memory_bytes: 240588
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[510][510];
long long f[510][510],sum[510][510],cnt[510][510];
inline long long mymin(long long a,long long b)
{
	if(a>b)swap(a,b);
	if(a==0)return b;
	else return a;
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read();
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=n;j++)if(i!=j)a[i][j]=read();
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=n;j++)sum[i][j]=sum[i][j-1]+a[i][j];
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=n;j++)cnt[i][j]=cnt[i][j-1]+sum[j][i]-sum[j][j-1];
    }
    for(int i=n-1;i>=1;i--)
    {
    	for(int j=i+1;j<=n;j++)
    	{
    		f[i][j]=cnt[j-1][j-1]-cnt[j-1][i-1];
    		long long tot=0,mn=0,uf=0;
    		for(int k=n;k>=j;k--)
    		{
    			tot+=sum[k][j-1]-sum[k][i-1];
    			uf+=sum[k][n]-sum[k][k-1];
    			if(k==j)mn=mymin(mn,uf);
    			else mn=mymin(mn,f[j][k]+tot);
    		}f[i][j]+=mn;
    	}
    }long long ans=f[1][2];
    for(int i=3;i<=n;i++)ans=min(ans,f[1][i]);
    printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7168
n, d = [int(i) for i in input().split()]
xy = [[int(i) for i in input().split()] for j in range(n)]

count = 0

for i in range(n):
    if(xy[i][0] ** 2 + xy[i][1] ** 2 <= d ** 2):
        count += 1

print(count)

Measured memory_bytes: 106880
#include<stdio.h>
 
int main(){
  int a,b,sum,counter,i;
  while(scanf("%d %d",&a,&b)!=-1){
    sum = a + b;
    for(i=0;sum!=0;i++)
      sum = sum / 10;
    printf("%d\n",i);
  }
  return 0;
}

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

using namespace std;


bool comp(pair<int,int> a, pair<int,int> b)
{
    if (a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}

int main()
{
    int ans = 0, n, m;
    cin>>n>>m;
    vector<pair<int,int>> V(m);
    for (int i=0; i< m; i++)
        cin>>V[i].first>>V[i].second;
    
    sort(V.begin(), V.end(), comp);
    int fin = 0;
    for (int i=0; i<m; i++)
    {
    	if(fin <= V[i].first){
    		ans++;
    		fin = V[i].second;
    	}
    }
    cout<< ans;
    return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return a % 1000000007;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n; vl num(n+1);
  for(ll i=1; i <= n-1; i++){ ll x; cin >> x; num[x]++; }
  
  for(ll i=1; i <= n; i++){ cout << num[i] << endl; }
}


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


int main() {


    string s,t;
    cin >> s >>t;

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

    sort(t.rbegin(),t.rend());

    if (s < t) {
        cout  << "Yes" << "\n";
    } else {
        cout  << "No" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

template<class T>
class FenwickTree {
public:
    FenwickTree(int n):
        tree(n + 1, 0) {}

    void update(int pos, T value) {
        for (++pos; pos < SZ(tree); pos += pos & -pos) {
            tree[pos] += value;
        }
    }
    T query(int pos) {
        T ret = 0;
        for (++pos; pos > 0; pos -= pos & -pos) {
            ret += tree[pos];
        }
        return ret;
    }
    T query(int left, int right) {
        return query(right) - query(left - 1);
    }
private:
    vector<T> tree;
};

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> A(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
    }
    vector<int> all = A;
    sort(all.begin(), all.end());
    all.erase(unique(all.begin(), all.end()), all.end());
    vector<int> lmax(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        lmax[i] = max(lmax[i - 1], A[i]);
    }

    vector<int64_t> fans(n + 1, 0);
    FenwickTree<int> count(n + 1);
    FenwickTree<int64_t> sum(n + 1);
    int64_t totalSum = 0;
    int totalCount = 0;
    for (int i = n; i > 0; --i) {
        int ind = lower_bound(all.begin(), all.end(), A[i]) - all.begin();
        totalCount++;
        totalSum += A[i];
        count.update(ind, 1);
        sum.update(ind, A[i]);
        if (lmax[i - 1] >= A[i]) {
            fans[i] = 0;
        } else {
            int ccount = totalCount - count.query(ind);
            int xind = lower_bound(all.begin(), all.end(), lmax[i - 1]) 
                - all.begin();
            fans[i] = (int64_t) ccount * (A[i] - lmax[i - 1]);
            ccount = count.query(xind, ind);
            int64_t csum = sum.query(xind, ind);
            fans[i] += csum - (int64_t) ccount * lmax[i - 1];
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << fans[i] << '\n';
    }
}


Measured memory_bytes: 4224
n = int(input())
a = int(str(n)[0])
b = int(str(n)[-1])

l = [[-1]*9 for _ in range(9)]

c = len(str(n))-2

for i in range(1, 10):
    for j in range(1, 10):
        cnt = 0
        if c >= 1:
            a_b = int(str(n)[1:-1])
            for k in range(1, c+1):
                if k == c:
                    if a > i:
                        cnt += 10**k
                    elif a == i:
                        if b >= j:
                            cnt += a_b + 1
                        else:
                            cnt += a_b
                else:
                    cnt += 10**k

        if int(str(i)+str(j)) <= n:
            cnt += 1

        if i == j and i <=n:
            cnt += 1

        l[i-1][j-1] = cnt

ans = 0

for i in range(9):
    for j in range(9):
        ans  += l[i][j] * l[j][i]

print(ans)

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

int main() {
  string S;
  cin >> S;
  
  if(S.at(5) != '1' && (S.at(6) == '1' || S.at(6) == '2' || S.at(6) == '3' || (S.at(6) == '4' && !(S.at(8) =='3' && S.at(9) == '1')))){
  	cout << "Heisei" << endl;  
  }else cout << "TBD" << endl;
}


Measured memory_bytes: 256
package main

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

type Node struct {
	key                 int
	parent, left, right *Node
}

type BinarySearchTree struct {
	root *Node
	n    int
}

func (bst *BinarySearchTree) insert(x int) bool {
	p := bst.findLast(x)
	u := &Node{key: x}
	return bst.addChild(p, u)
}

func (bst *BinarySearchTree) findLast(x int) *Node {
	w := bst.root
	var prev *Node

	for w != nil {
		prev = w
		if x < w.key {
			w = w.left
		} else {
			w = w.right
		}
	}
	return prev
}

func (bst *BinarySearchTree) addChild(p, u *Node) bool {
	if p == nil {
		bst.root = u
	} else {
		if u.key < p.key {
			p.left = u
		} else {
			p.right = u
		}
		u.parent = p
	}
	bst.n++
	return true
}

func (bst *BinarySearchTree) find(x int) *Node {
	u := bst.root

	for u != nil && x != u.key {
		if x < u.key {
			u = u.left
		} else {
			u = u.right
		}
	}
	return u
}

func (bst *BinarySearchTree) Splice(u *Node) {
	var s, p *Node

	if u.left != nil {
		s = u.left
	} else {
		s = u.right
	}

	if u == bst.root {
		bst.root = s
		p = nil
	} else {
		p = u.parent
		if p.left == u {
			p.left = s
		} else {
			p.right = s
		}
	}
	if s != nil {
		s.parent = p
	}
	bst.n--
}

func (bst *BinarySearchTree) Remove(u *Node) {
	if u.left == nil || u.right == nil {
		//削除対象に片方の枝しかないまたは枝がない場合は、parentとその枝のノードをつなげば完了
		bst.Splice(u)
		u = nil
	} else {
		//両方枝がある場合は、自分より大きい値の中の最小値のノードで置き換える
		w := u.right
		for w.left != nil {
			w = w.left
		}
		u.key = w.key //削除対象だったノードの値を置き換える
		bst.Splice(w) //置き換えたノードを削除する
		w = nil
	}
}

func preorder(u *Node, keys []int) []int {
	if u != nil {
		keys = append(keys, u.key)
		keys = preorder(u.left, keys)
		keys = preorder(u.right, keys)
	}
	return keys
}

func inorder(u *Node, keys []int) []int {
	if u != nil {
		keys = inorder(u.left, keys)
		keys = append(keys, u.key)
		keys = inorder(u.right, keys)
	}
	return keys
}

func print(keys []int) {
	w := bufio.NewWriter(os.Stdout)
	for _, key := range keys {
		w.Write([]byte(fmt.Sprintf(" %d", key)))
	}
	w.Write([]byte("\n"))
	w.Flush()
}

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

	bst := new(BinarySearchTree)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := 0; i < n; i++ {
		sc.Scan()
		command := sc.Text()

		if command == "insert" {
			sc.Scan()
			x, _ := strconv.Atoi(sc.Text())
			//insert
			bst.insert(x)
		} else if command == "print" {
			//print
			print(inorder(bst.root, []int{}))
			print(preorder(bst.root, []int{}))
		} else if command == "find" {
			sc.Scan()
			x, _ := strconv.Atoi(sc.Text())
			//find
			u := bst.find(x)
			if u != nil {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		} else if command == "delete" {
			sc.Scan()
			x, _ := strconv.Atoi(sc.Text())
			//delete
			u := bst.find(x)
			if u != nil {
				bst.Remove(u)
			}

		}
	}

	return
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll K;
ll i, j, k;
char ansS[101010];
ll ans = 0;

bool calc(ll ii,ll a,ll& ct){
    if(a<0||9<a)
        return false;
    if(ii==0){
        ++ct;
        if(ct==K){
            ansS[ii] = a+'0';
            return true;
        }
        return false;
    }
    ll i,ret=0;

    fornum(i,-1,2){
        if(calc(ii - 1, a + i,ct)){
            ansS[ii] = a+'0';
            return true;
        }
    }
    return false;
}

int main(){
    scanf("%lld", &K);
    
    j = 0;
    k = 0;
    while(true){
        fornum(i,1,10){
            if(calc(j,i,k)){
                reverse(ansS, ansS + (j+1));
                printf("%s\n", ansS);
                return 0;
            }
        }
        ++j;
    }
    return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    # AがBCを乗り越えて右に進むイメージ
    # それぞれのAに対して右側に連続したBCがいくつあるか
    ans = 0
    len_s = len(s)
    cnt = 0
    i = 0
    while i < len_s:
        if s[i] == 'A':
            cnt += 1
            i += 1
        elif i + 1 < len_s and s[i] == 'B' and s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
            
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

int main() {

	int N;
	cin >> N;

	int a[51] = {};
	int saidai = -10000000, saishou = 10000000;
	int saidaii, saishoui;

	rep1(i, N) {
		cin >> a[i];
		if (saidai < a[i]) {
			saidai = a[i];
			saidaii = i;
		}
		if (saishou > a[i]) {
			saishou = a[i];
			saishoui = i;
		}
	}
	vector<pair<int, int>> kotae;
	
	if (saidai + saishou >= 0) {

		rep1(i, N) kotae.push_back(make_pair(saidaii, i));
		rep1(i, N - 1) kotae.push_back(make_pair(i, i + 1));

	}
	else {

		rep1(i, N) kotae.push_back(make_pair(saishoui, i));
		rep(i, N - 1) kotae.push_back(make_pair(N - i, N - 1 - i));

	}

	co(2 * N - 1);
	rep(i, kotae.size()) {
		cosp(kotae[i].first);
		co(kotae[i].second);
	}
	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, x;
  cin >> a >> b;
  x = (a + b) / 2;
  c = (a + b) % 2;
  // cout << a << endl; //
  // cout << a + b << endl; //
  cout << x + c << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 36

typedef struct{
  char a;
  int b;
}tt;

int main(){
  int n,min;
  int i,j;
  tt H[N],x[N],y;

  scanf("%d" , &n);
  for(i = 0; i < n;i++){
    scanf(" %c%d",&H[i].a,&H[i].b);
    x[i] = H[i];
  }
  for(i = 0;i<n;i++){
    for(j = n-1;j>i;j--){
      if(H[j].b <H[j-1].b){
	y = H[j];
	H[j]=H[j-1];
	H[j-1]=y;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%c%d ",H[i].a,H[i].b);
  }
  printf("%c%d\n",H[n-1].a,H[n-1].b);
  printf("Stable\n");

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){

      if(x[j].b<x[min].b)min = j;
    }
    if(i != min){
      y = x[i];
      x[i] = x[min];
      x[min] = y;
    }
  }

  for(i=0;i<n-1;i++){
    printf("%c%d ", x[i].a,x[i].b);
  }
  printf("%c%d\n", x[n-1].a,x[n-1].b);


  for(i=0;i<n;i++){
    if(H[i].a != x[i].a){
      j=0;
      break;
    }
    else if(H[i].a == x[i].a){
      j=1;
    }
  }

  if(j==0)printf("Not stable\n");
  else if(j ==1)printf("Stable\n");
  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PB push_back

int main()
{
    ll N; cin >> N;
    map<ll, ll> value_count;
    vector<ll> A(N);
    rep(i, N){
        cin >> A.at(i);
        if(value_count.count(A.at(i))){
            value_count[A.at(i)]++;
        }
        else{
            value_count[A.at(i)]=1;
        }
    }
    ll all_conbination=0;
    for(auto i=value_count.begin(); i!=value_count.end(); i++){
        all_conbination+=i->S*(i->S-1)/2;
    }
    rep(i,N)
        cout << all_conbination-value_count[A.at(i)]+1 << endl;
}

Measured memory_bytes: 11008