akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int N,A,B,C;
int bamboo[9];
int dfs(int n,int a,int b,int c){
    if (n == N){
        if (a > 0 && b > 0 && c > 0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
        else return INF;
    }
    int res1 = dfs(n+1,a,b,c);
    int res2 = dfs(n+1,a+bamboo[n],b,c)+10;
    int res3 = dfs(n+1,a,b+bamboo[n],c)+10;
    int res4 = dfs(n+1,a,b,c+bamboo[n])+10;
    return min({res1,res2,res3,res4});
}
int main(){
    cin >> N >> A >> B >> C;
    rep(i,N) cin >> bamboo[i];
    PRINT(dfs(0,0,0,0));
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 10e18+1000
#define INF 0x3f3f3f3f
#define MAR 10e5+100

LL a[100100];
LL b[100100],c[100100];
LL b1[100100],b2[100100];
void scan(int n){
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++)
        cin>>c[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    sort(c+1,c+n+1);
}

int main() {
    shutdown;
    mem(b1,0);mem(b2,0);
    int n,j,k,temp;
    ULL sum=0;
    cin>>n;
    scan(n);
    j=n;
    for(int i=n;i>0;i--){
        while(b[i]<=a[j]&&j>0) j--;
        if(j==0)
            break;
        b1[i]=j;
    }
    k=1;
    for(int i=1;i<=n;i++){
        while(b[i]>=c[k]&&k<=n) k++;
        if(k==n+1)
            break;
        b2[i]=n-k+1;
    }
    for(int i=1;i<=n;i++){
        sum+=b1[i]*b2[i];
    }
    cout<<sum<<endl;
    return 0;
}



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

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

    string target;
    vector<string> targets;

    for (int i = 0; i < n; ++i) {
        cin >> target;
        sort(target.begin(), target.end());
        targets.push_back(target);
    }

    sort(targets.begin(), targets.end());
    long long sum_count = 0;
    long long count = 1;
    for (int i = 1; i <= n; ++i) {
        if (i == n) {
            sum_count += count * (count - 1) / 2;
            break;
        }
        if (targets[i] == targets[i - 1]) {
            ++count;
            continue;
        }
        sum_count += count * (count - 1) / 2;
        count = 1;
    }

    cout << sum_count << endl;

    return 0;
}

Measured memory_bytes: 5748
#include<stdio.h>
int main(){
	int num;
	int i;
	char blood[3];
	int count[4]={0,0,0,0};
	
	while(~scanf("%d,%s",&num,&blood)){
		//puts(blood);
		//printf("%c\n",blood[0]);
		if(blood[0]=='A' && blood[1]=='\0') count[0]++;
		else if(blood[0]=='B') count[1]++;
		else if(blood[0]=='O') count[3]++;
		else if(blood[0]=='A' && blood[1]=='B') count[2]++;  
	}
	for(i=0;i<=3;printf("%d\n",count[i]),i++){}
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define INF (1<<28)
int n, p;
int pos[216000];
int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> p;
    pos[p-1] = i;
  }
  int ans = 0;
  for(int i = 0;i < n;i++){
    int r = i;
    while(r < n-1 && pos[r] < pos[r+1])r++;
    ans = max(ans, r - i + 1);
    i = r;
  }
  cout << n - ans << endl;

  return 0;
  
  
}

Measured memory_bytes: 1152
local mmi = math.min
local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local function upper_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if comp(x, ary[1]) then return 1 end
  if not comp(x, ary[num]) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if not comp(x, ary[mid]) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n = io.read("*n", "*l")
local s = ""


local function create()
  local struct = {}
  struct.xpy = {}
  struct.xmy = {}
  struct.x = {}
  struct.y = {}
  return struct
end
local toleft = create()
local toright = create()
local toup = create()
local todown = create()

local function ins(tbl, x, y)
  local xpy, xmy = x + y, x - y
  if not tbl.xpy[xpy] then tbl.xpy[xpy] = {} end
  table.insert(tbl.xpy[xpy], x)
  if not tbl.xmy[xmy] then tbl.xmy[xmy] = {} end
  table.insert(tbl.xmy[xmy], x)
  if not tbl.x[x] then tbl.x[x] = {} end
  table.insert(tbl.x[x], y)
  if not tbl.y[y] then tbl.y[y] = {} end
  table.insert(tbl.y[y], x)
end
local function sortall(tbl)
  local z = {tbl.xpy, tbl.xmy, tbl.x, tbl.y}
  for i = 1, 4 do
    for k, t in pairs(z[i]) do
      table.sort(t)
    end
  end
end

local raw_x, raw_y, raw_d = {}, {}, {}
for i = 1, n do
  s = io.read()
  local x, y, d = s:match("(%d+) (%d+) (%w)")
  x, y = tonumber(x), tonumber(y)
  raw_x[i], raw_y[i], raw_d[i] = x, y, d
  if d == "L" then
    ins(toleft, x, y)
  elseif d == "R" then
    ins(toright, x, y)
  elseif d == "U" then
    ins(toup, x, y)
  else
    ins(todown, x, y)
  end
end
sortall(toleft)
sortall(toright)
sortall(toup)
sortall(todown)

local ans = false
local function solvelb(tbl, z, mul)
  if tbl then
    local p = lower_bound(tbl, z) - 1
    if 0 < p then
      local v = (z - tbl[p]) * mul
      if not ans or v < ans then
        ans = v
      end
    end
  end
end

for i = 1, n do
  local x, y, d = raw_x[i], raw_y[i], raw_d[i]
  local xpy, xmy = x + y, x - y
  if d == "L" then
    --toLeft vs toRight
    solvelb(toright.y[y], x, 5)
    --toLeft vs toUp
    solvelb(toup.xmy[xmy], x, 10)
    --toLeft vs toDown
    solvelb(todown.xpy[xpy], x, 10)
  elseif d == "R" then
  elseif d == "U" then
    -- toUp vs toRight
    solvelb(toright.xpy[xpy], x, 10)
  else
    -- toDown vs toRight
    solvelb(toright.xmy[xmy], x, 10)
    -- toDown vs toUp
    solvelb(toup.x[x], y, 5)
  end
end
print(ans and ans or "SAFE")


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

int main() {
	int height[10];
	for (int i = 0; i < 10; i++) {
		cin >> height[i];
	}
	sort(height,height+10);
	for (int i = 9; i > 6; i--) {
		cout << height[i] << endl;
	}
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define MAX 305
using namespace std;
 
int main(){
  int n, a[MAX][MAX], i, j, k;
  bool t;
  long long ans = 0;
  scanf("%d", &n);
  for(i = 0; i < n; i++) for(j = 0; j < n; j++)
    scanf("%d", &a[i][j]);
  for(i = 0; i < n; i++){
    for(j = i+1; j < n; j++){
      t = true;
      for(k = 0; k < n; k++){
        if(a[i][j] > a[i][k] + a[k][j]){
          printf("%d\n", -1);
          return 0;
        }
        if(a[i][j] == a[i][k] + a[k][j] && i != k && j != k) t = false;
      }
      if(t) ans += a[i][j];
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b[100],d[100],c=0;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  for(int i=0;i<a-2;i++){
    for(int j=0;j<a;j++){
      d[j]=b[j];
    }
    sort(d+i,d+(i+3));
    if(d[i+1]==b[i+1]){
      c++;
    }
  }
  
  cout<<c<<"\n";

  return(0);
}


Measured memory_bytes: 256
i = [p+2 for p in range(12)]
i.append(1)
x, y = map(int, input().split())
if i.index(x) == i.index(y):
    print("Draw")
if i.index(x) > i.index(y):
    print("Alice")
if i.index(x) < i.index(y):
    print("Bob")


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A + B == 15) {
			System.out.println("+");
		} else if (A * B == 15) {
			System.out.println("*");
		} else {
			System.out.println("x");
		}
	}
}

Measured memory_bytes: 21844
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
	return a.second<b.second;
}

int main()
{
	speed;
	
	ll n,m,a,b;
	cin>>n>>m;
	vector<pair<ll,ll> > v;
	for(ll i=0;i<m;i++)
	{
		cin>>a>>b;
		v.pb(mp(a,b));

	}
	sort(v.begin(),v.end(),comp);
	ll ans=0;
	ll temp=0;
	for(ll i=0;i<m;i++){
		if(v[i].first<temp)
			continue;
		ans++;
		temp=v[i].second;
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;
 
    int n = s.length();
    int p = 2019;

    ll ans = 0;
    if (p == 2 || p == 5) {
        rep(i, n) {
            if ((s[n-i-1]-'0')%p == 0) ans += n-i;
        }
    }
    else {
        vll num(p, 0);
        ll digit = 1;
        ll cur = 0;
        num[cur]++;
        rep(i, n) {
            cur = (cur+(s[n-i-1]-'0')*digit)%p;
            digit *= 10;
            digit %= p;
            num[cur]++;
        }
        rep(i, p) ans += num[i]*(num[i]-1)/2;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


string ans;

int main(){
	string s;
    cin >> s;
  ll size = s.length();
  
  bool b = true;
    REP(i,0,size){
      if(s[i]=='R' && i%2==1){
        b = false;
      }else if(s[i]=='L' && i%2==0){
        b = false;
      }else{
        b = true;
      }
      if(b==false) break;
    }
    
   ans = b ? "Yes":"No";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#define mod 1000000007;
using namespace std;
using ll = long long;
using ld = long double;
long double pi = 2 * acos(0.0);

void solve() {
    ll a;
    ld b;
    cin >> a >> b;
    cout << (ll)(a * b);
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3748
def f(x):
    return x-1
import itertools
import math
N = int(input())
P = list(map(int, input().split()))
P = list(map(f, P))
Q = list(map(int, input().split()))
Q = list(map(f, Q))
S = list(range(N))
permutation = list(itertools.permutations(S))
a,b = 0,0
for i in range(len(permutation)):
    if P == list(permutation[i]):
        a = i
    if Q == list(permutation[i]):
        b = i
print(int(math.fabs(a-b)))

Measured memory_bytes: 7972
n,p = map(int,input().split())
a = list(map(int,input().split()))
from collections import Counter

import itertools
ad = [a[i]%2 for i in range(n)]

b = Counter(ad)
ama = 1
pet = p

zero = [1] * (b[0]+1)
one = [1] * (b[1]+1)
ze = [0]*2
on = [0]*2

ze[0] = 1
on[0] = 1
for i in range(1,b[0]+1):
    zero[i] = zero[i-1] * (b[0]+1-i) // i
    ze[i%2] += zero[i]
for i in range(1,b[1]+1):
    one[i] = one[i-1] * (b[1]+1-i) // i
    on[i%2] += one[i]
    
if p == 0:
    ans = (ze[0]*on[0] + ze[1]*on[1])
else:
    ans = (ze[0]*on[1] + ze[1]*on[0])
if p == 1 and b[1] == 0:
    ans = 0
if p == 0 and b[1] == 0:
    ans *= 2
    
print(ans)

Measured memory_bytes: 38256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int T = sc.nextInt();

		int[] K = new int[N];
		for(int i = 0 ; i < N ; i++){
			K[i] = sc.nextInt();
		}

		sc.close();
		long ans = 0;
		for(int i = 0 ; i < N-1 ; i++){
			if(K[i+1]-K[i] >= T){
				ans += T;
			}
			else{
				ans += K[i+1]-K[i];
			}
		}

		System.out.println(ans+T);
	}
}


Measured memory_bytes: 63552
#include <string>
#include <iostream>

using namespace std;

int main()
{
	long long ans=2, i, j, k=0, l=0, m, n, N, M, cnt=0;
	string s;

	cin >> s;
	j = s.length();

	for (i = 0; i < j; i++) {
		if (s[i] == 'A') {
			k = i;
			break;
		}
	}
	for (i = j - 1; i >= 0; i--) {
		if (s[i] == 'Z') {
			l = i;
			break;
		}
	}

	cout << l-k+1 << endl;

	return 0;
}

Measured memory_bytes: 640
use std::str::FromStr;
use std::io::{stdin, BufRead};

fn read<T: FromStr>() -> T {
    let mut s = String::new();
    let stdin = stdin();
    let mut input = stdin.lock();
    input.read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub struct Foo {
    ch: char
}

pub struct ParseCharError {
    kind: CharErrorKind,
}

impl ParseCharError {
    pub fn __description(&self) -> &str {
        match self.kind {
            CharErrorKind::EmptyString => "cannot parse char from empty string",
            CharErrorKind::TooManyChars => "too many characters in string",
        }
    }
}

enum CharErrorKind {
    EmptyString,
    TooManyChars,
}

impl FromStr for Foo {
    type Err = ParseCharError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let mut chars = s.chars();
        match (chars.next(), chars.next()) {
            (None, _) => Err(ParseCharError { kind: CharErrorKind::EmptyString }),
            (Some(c), None) => Ok(Foo { ch: c }),
            _ => Err(ParseCharError { kind: CharErrorKind::TooManyChars }),
        }
    }
}

fn main() {
    let s: String = read();
    let n: u32 = read();
    let q: Vec<Vec<Foo>> = read_vec2(n);
    let mut ans = s.chars().collect::<Vec<char>>();
    let mut head:Vec<char> = Vec::new();
    let mut tail:Vec<char> = Vec::new();
    let mut is_reverse = false;
    for query in q {
        if query[0].ch == '1' {
            is_reverse = if is_reverse { false } else { true };
        } else {
            if query[1].ch == '1' {
                if is_reverse {
                    tail.push(query[2].ch);
                } else {
                    head.push(query[2].ch);
                }
            } else {
                if is_reverse {
                    head.push(query[2].ch);
                } else {
                    tail.push(query[2].ch);
                }
            }
        }
    }
    head.reverse();
    head.append(&mut ans);
    head.append(&mut tail);

    if is_reverse {head.reverse()}
    println!("{}", head.into_iter().collect::<String>())
}


Measured memory_bytes: 14588
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin >> n;
	int c = n%10;
	if(c == 3)
	{
		cout << "bon";
	}
	else if(c ==0 || c== 1 || c== 6 || c==8)
		cout << "pon";
	else
	{
		cout << "hon";
	}
	
	

    return 0;
}


Measured memory_bytes: 3648
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

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

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CPoll {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        map<string, int> counter;
        int maxi = 0;
        FOR(i, 0, n) {
            string str;
            in >> str;
            ckmax(maxi, ++counter[str]);
        }
        for (auto &[s, c]: counter) {
            if (c == maxi) {
                out << s << '\n';
            }
        }
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CPoll solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 19256
//
//  main.cpp
//  ATcode131
//
//  Created by didi on 2020/1/16.
//  Copyright © 2020年 didi. All rights reserved.
//

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cassert>
#include <queue>
#include <list>
using namespace std;

#define ll long long

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    int cnt = 0;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    int a = A[(N-1)/2], b = A[(N-1)/2 + 1];
    if (a == b) {
        cout << "0";
        return 0;
    }
    cout << b - a;
    return 0;
}



Measured memory_bytes: 640
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = new int[n];
        for (int i = 0; i < n; i++)
            d[i] = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                if (d[i] == d[j]) d[j] = 0;
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (d[i] != 0) ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t;
int main(){
    cin >> s >> t;
    int len1 = s.size();
    int len2 = t.size();
    int ans = 0;
    for(int i = len1 - len2;i>=0;i--){
        int cnt = 0;
        for(int j = 0;j<len2;j++){
            if(s[i + j] == t[j]) {
                cnt++;
            }
            ans = max(ans,cnt);
        }
    }
    cout << len2 - ans << endl;

    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int get_rand(int a, int b) {  // [a, b]
    return uniform_int_distribution<int>(a, b)(rng);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, n = 26;
    cin >> d;
    // d = 365;
    vector<int> c(n);
    vector<vector<int>> s(d, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        // c[i] = get_rand(0, 100);
    }
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < n; j++) {
            cin >> s[i][j];
            // s[i][j] = get_rand(0, 20000);
        }
    }
    vector<int> t(d);
    for (int i = 0; i < d; i++) {
        t[i] = get_rand(0, n - 1);
    }
    auto get = [&]() {
        int res = 0;
        vector<int> last(n, -1);
        for (int i = 0; i < d; i++) {
            res += s[i][t[i]];
            int x = i - last[t[i]] - 1;
            res -= c[t[i]] * x * (x + 1) / 2;
            last[t[i]] = i;
        }
        for (int i = 0; i < n; i++) {
            int x = d - last[i] - 1;
            res -= c[i] * x * (x + 1) / 2;
        }
        return res;
    };
    auto beg = clock();
    int cnt = 0;
    while (true) {
        cnt++;
        if (clock() - beg > 1900000) {
            break;
        }
        int q = get_rand(0, d - 1);
        int sc = -1e9;
        int best = -1;
        for (int i = 0; i < n; i++) {
            t[q] = i;
            int p = get();
            if (p > sc) {
                sc = p;
                best = i;
            }
        }
        t[q] = best;
    }
    for (int i = 0; i < d; i++) {
        cout << t[i] + 1 << '\n';
    }
    debug(get());
    return 0;
}

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


using namespace std;

typedef long long ll;

const int N = 1000000;
bool isprime[N+1];
#define eps 1e-9
void sieve()
{
    memset(isprime,true,sizeof(isprime));
    isprime[0]=isprime[1]=false;

    for(ll i=2; i*i<=N; i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i; j<=N; j+=i)
            {
                isprime[j]=false;
            }
        }
    }
}




int main(void)
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    string s;
    cin>>s;
    n = s.size();
    ll ans = 0;
    for(int i=0;i<(1<<(n-1));i++)
    {
        ll res = 0;
        for(int j=0;j<n-1;j++)
        {
            res = res*10 + s[j]-'0';
            if(i & (1<<j))
            {
                ans+=res;

                res = 0;
            }
        }

        ans += res*10 + s[n-1]-'0';

    }
    cout<<ans<<endl;


}



Measured memory_bytes: 3532
N = int(input())
d = dict()
for i in range(N):
    s = input()
    if s in d:
        d[s]+= 1
    else:
        d[s]=1

d = sorted(d.items(), key = lambda x:x[1])
if len(d) <= 1:
    print(d[0][0])
    exit()

tmp, max_value = d.pop()
res = [tmp]
#print(d)
for i in range(len(d)):
    temp_name,temp_value = d.pop()
    if max_value == temp_value:
        res.append(temp_name)
    else:
        break

res.sort()
for i in res:
    print(i)
#print(res)


Measured memory_bytes: 43228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        boolean yes = false;
        if(n%2 != 0) {
            yes = false;
        }
        else {
            String s2 = s.substring(0, n/2);
            if(s.equals(s2 + s2)) {
                yes = true;
            }
        }
        System.out.println(yes ? "Yes" : "No");
    }
}


Measured memory_bytes: 23892
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] likes = new int[N];
        int[] alsoLikes = new int[N];

        for(int i=0; i<N; i++)
        {
            likes[i] = scanner.nextInt();
        }
        int c = 0;
        for(int i=0; i<N; i++)
        {
            int i_like = likes[i];
            int he_like = likes[i_like-1];
            if(i == he_like-1)
                c++;
        }
        System.out.println(c / 2);
    }
}

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

#ifdef YUCHIKIDEBUG
  #define dump(x)  cerr << #x << " = " << (x) << endl;
  #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#else
  #define dump(x) ;
  #define debug(x) ;
#endif // YUCHIKIDEBUG

#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _repr(i,n) repir(i,n,0)
#define repir(i,a,b) for(int i=int(a);i>=int(b);--i)
#define repr(...) _overload3(__VA_ARGS__,repir,_repr,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define CINV(x,n) rep(i,n){int x##temp; cin >> x##temp; x.push_back(x##temp);}
#define REV(x) reverse(all(x))
#define SORT(x) sort(all(x))
#define PUTS(x) cout<<(x)<<endl;

inline int sqr(int x) { return x * x; }
inline int sqrti(int x) {return (int)sqrt(x); }

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

#define put PUTS

signed main(){
    string s1, s2;
    cin >> s1 >> s2;
    REV(s1);
    put(s1 == s2 ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    string s,t;
    cin >> s >> t;
    if(t.size()-s.size()!=1){
        cout << "No" << endl;
        return 0;
    }
    REP(i,s.size()){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
//agc007_b.cpp
//Sun Jul 28 21:30:18 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n],b[n];
	for (int i=0;i<n;i++){
		a[i] = 1+40000*i;
		b[i] = 40000*(n-1)+1-40000*i;
	}

	int rank = 1;
	for (int i=0;i<n;i++){
		int p;
		cin >> p;
		p--;
		a[p] += rank;
		rank++;
	}

	for (int i=0;i<n;i++){
		cout << a[i] << " ";
	}
	printf("\n");
	for (int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	printf("\n");
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():

        N = int(input())
        B = list(map(int, input().split()))
        ans = []

        while len(B) > 0:
            flag = False

            for i in reversed(range(len(B))):
                if B[i] == i+1:
                    ans.append(B[i])
                    B.pop(i)
                    flag = True
                    break
            if not flag:
                return None

        return ans


    ans=main()
    if ans:
        for i in reversed(ans):
            print(i)
    else:
        print(-1)

resolve()

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

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

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, c;
    string s;
    cin >> n >> k >> c;
    cin >> s;
    n++;
    s = "x" + s;
    vector<int> dpL(n + 3, 0), dpR(n + 3, 0);
    vector<int> lastOLeft(n + 3, -10000000), lastORight(n + 3, 10000000);
    for (int i = 1; i <= n; i++) {
        lastOLeft[i] = (s[i] == 'o' ? i : lastOLeft[i - 1]);
        if (s[i] == 'x') dpL[i] = dpL[i - 1];
        if (s[i] == 'o') dpL[i] = 1 + (i - c - 1 >= 0 ? dpL[i - c - 1] : 0);
    }
    for (int i = n; i >= 1; i--) {
        lastORight[i] = (s[i] == 'o' ? i : lastORight[i + 1]);
        if (s[i] == 'x') dpR[i] = dpR[i + 1];
        if (s[i] == 'o') dpR[i] = 1 + (i + c + 1 <= n ? dpR[i + c + 1] : 0);
    }

    for (int i = 1; i <= n; i++) {
        if (s[i] == 'x') continue;
        int lastRight = lastORight[i + 1];
        int lastLeft = lastOLeft[i - 1];

        int right = dpR[i + 1] + (lastRight - c - 1 >= i ? dpL[i - 1] : ((lastRight - c - 1 < n) && (lastRight - c - 1 >= 0) ? dpL[lastRight - c - 1] : 0));
        int left = dpL[i - 1] + (lastLeft + c + 1 <= i ? dpR[i + 1] : ((lastLeft + c + 1 < n) && (lastLeft + c + 1 >= 0) ? dpR[lastLeft + c + 1] : 0));
        int takeIt = 1 + (i - c - 1 >= 1 ? dpL[i - c - 1] : 0) + (i + 1 + c <= n ? dpR[i + 1 + c] : 0);
        if (max(left, right) < k && takeIt == k) {
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4944
from heapq import heapify, heappop
def main():
    card_num = int(input())
    cards = list(map(lambda x: -int(x), input().split()))
    heapify(cards)

    A_score = 0
    B_score = 0
    As_turn = True

    for i in range(card_num):
        card = - heappop(cards)
        if As_turn:
            A_score += card
        else:
            B_score += card
        As_turn = not As_turn

    diff = A_score - B_score
    print(diff)

main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const ll INF = 1e18;
const int MAXN = (int) 2e5;

int x[MAXN + 1];
ll sp[MAXN + 1];;

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, X;
    ios::sync_with_stdio(false);
    cin >> n >> X;
    for(i = 1; i <= n; i++) {
        cin >> x[i];
        sp[i] = sp[i - 1] + x[i];
    }
    ll ans = INF;
    for(int k = 1; k <= n; k++) {
        ll cur = (sp[n] - sp[max(0, n - 2 * k)]) * 5LL;
        int coef = 7;
        for(i = n - 2 * k; i >= 0; i -= k) {
            ll val = 1LL * coef * (sp[i] - sp[max(0, i - k)]);
            if(INF - cur <= val) {
                cur = INF;
                break;
            }
            cur += val;
            coef += 2;
        }
        if(INF - cur >= 1LL * X * k) {
            cur += 1LL * X * k;
            ans = min(ans, cur);
        }
    }
    cout << ans + 1LL * n * X;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	static class FenwickTree {
	    int n;
	    long x[];
	    public FenwickTree(int N) {
	    	this.n = N;
	    	x = new long[N + 1] ;
		}
	    int size()  { return n; }
	    long sum(int i) {
	    	long ret = 0;
	        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
	            ret = (ret + x[idx]) % MOD;
	        }
	        return ret % MOD;
	    }
	    long sum(int l, int r)  { return (sum(r) - sum(l) + MOD) % MOD; }
	    void add(int i, long v) {
	        for (int idx = i; idx <= n; idx += (idx & -idx)) {
	            x[idx] = (x[idx] + v) % MOD;
	        }
	    }
	};
	static class FT2{
		FenwickTree bit0;
		FenwickTree bit1;
		public FT2(int N) {
			bit0 = new FenwickTree(N);
			bit1 = new FenwickTree(N);
		}		
		void add(int l , int r, long x){
			bit0.add(l, - x * (l - 1));
			bit1.add(l, x);
			bit0.add(r + 1, x * r);
			bit1.add(r + 1, -x);
		}
		long sum(int i){
			return bit0.sum(i) + bit1.sum(i) * i;
		}
	}

	final static long MOD = 998244353L;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int L[] = new int[K];
		int R[] = new int[K];
		for(int i = 0 ; i < K ; ++i){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		FenwickTree ft = new FenwickTree(N + 1);
		ft.add(1, 1);
		ft.add(2, -1);
//		long dp[] = new long[N];		
//		dp[0] = 1;
		for(int i = 0 ; i < N ; ++i){
			long cur = ft.sum(i + 1);
			for(int k = 0 ; k < K ; ++k){
				int nl = i + L[k];
				int nr = i + R[k];
				if(nl >= N){
					continue;
				}
				nr = Math.min(N - 1, nr);
				ft.add(nl + 1, cur);
				ft.add(nr + 2, MOD - cur);
//				for(int next = nl ; next <= nr ; ++next){
//					dp[next] = (dp[next] + cur) % MOD;
//				}
			}
		}
		System.out.println(ft.sum(N));
//		System.out.println(dp[N - 1]);
	}
}


Measured memory_bytes: 37968
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	long long sumA = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sumA = (sumA + A[i]) % MOD;
	}
	sumA -= A[0];
	if (sumA < 0) sumA += MOD;

	long long ans = 0;
	for (int i = 0; i < N - 1; ++i) {
		ans = (ans + sumA * A[i] % MOD) % MOD;
		sumA -= A[i + 1];
		if (sumA < 0) sumA += MOD;
	}

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

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

const int N = 1e5 + 5;

int n;
string s[N];
map<char, int> mp;
char ans[N];

signed main() {
	cin >> n >> mp['A'] >> mp['B'] >> mp['C'];
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= n; i++) {
		if (mp[s[i][0]] == 0 && mp[s[i][1]] == 0) {
			cout << "No" << endl;
			return 0;
		}
		if (mp[s[i][0]] > mp[s[i][1]]) {
			mp[s[i][0]]--;
			mp[s[i][1]]++;
			ans[i] = s[i][1];
		} else if (mp[s[i][0]] < mp[s[i][1]]) {
			mp[s[i][0]]++;
			mp[s[i][1]]--;
			ans[i] = s[i][0];
		} else if (mp[s[i][0]] == mp[s[i][1]]) {
			if (i == n || (s[i + 1][0] != s[i][0] && s[i + 1][1] != s[i][0])) {
				mp[s[i][0]]--;
			   mp[s[i][1]]++;
			   ans[i] = s[i][1];
			} else {
				mp[s[i][0]]++;
			   mp[s[i][1]]--;
			   ans[i] = s[i][0];
			}
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 6864
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


int main(){

    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int cnt[100001];
    rep(i, 100001) cnt[i] = 0;

    rep(i, n) cnt[a[i]]++;

    int max = 0;
    for (int i=1; i < 100000; i++){
        int sum = cnt[i-1] + cnt[i] + cnt[i+1];
        if (max < sum) max = sum;
    }

    cout << max << endl;


    return 0;
}





//              g++ -std=c++1z

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define cc(a) cout << a << endl;
#define msg(a,b) cout << a << " : " << b << endl;
#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;
#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;



int main(){
    long long int counter, mainCount ,n;
    cin >> n;
    mainCount  =0;
    for(int k=1;k<=n;k++){
        counter = 0;
        for(int i=1;i<=k;i++){
            if(k%i == 0){
                counter++;
            }
        }
        if(counter == 8 && k%2 == 1){
            mainCount++;
            //msg2(counter, k,mainCount)
        }
    }
    cout << mainCount << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
int main(){

  int Num,Inp;
  double Rev;
  //int A[100]={};
  double Sum=0;
  double Res=0;
  std::cin >> Num;
  for(int i=0;i<Num;i++){
    std::cin >> Inp;
    Rev = 1.0 / Inp;
    Sum += Rev;
  }
  Res = 1.00 /Sum; 
  //std::cout << Res << std::endl;
  if( Sum !=0)
    std::cout << std::setprecision(10) << Res;
  else std::cout << 0;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>

using namespace std;
typedef long long ll;


int main(){
        ll N, H, Count=0;
        cin >> N >> H;
        vector<ll> A(N), B(N);

        for(ll i=0; i<N; i++){
                cin >> A[i];
                cin >> B[i];
        }
        sort(A.rbegin(), A.rend());
        sort(B.begin(), B.end());
        auto iter = lower_bound(B.begin(), B.end(), A[0]);
        int index = iter - B.begin();
        for(ll i=0; i<N-index; i++){
                H -= B[N-1-i];
                Count++;
                if(H<=0) break;
        }
        if(H <= 0) cout << Count;
        else if(H%A[0]==0) cout << Count + H/A[0];
        else if(H%A[0]!=0) cout << Count + H/A[0]+1;

}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll INF=1e18;
const ll mod=1e9+7;
const double eps=0.000000001;

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> dp1(n+1),dp2(n+1);
    for(ll i=1;i<=n;i++){
        if(s[i-1]=='#') dp1[i]=dp1[i-1]+1;
        else dp1[i]=dp1[i-1];
    }
    for(ll i=n;i>=1;i--){
        if(s[i-1]=='#') dp2[i-1]=dp2[i]+1;
        else dp2[i-1]=dp2[i];
    }
    for(ll i=0;i<=n;i++){
        //cout << dp1[i] << " " << dp2[i] << endl;
    }
    ll ans=INF;
    for(ll i=0;i<=n;i++){
        ans=min(ans,dp1[i]+min(dp2[i],n-i-dp2[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6804
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  ll ans = 0;
  rep(i, n) rep(j, i)
    ans += d[i]*d[j];
  cout << ans << endl;
  return 0;
}

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

int main(){

    vector<int> a(5);
    rep(i,5)cin >> a[i];

    int t=0;
    int ans=0;
    rep(i,5){
        if(a[i]%10!=0){
            t=max(t,10-a[i]%10);
            ans+=(a[i]/10+1)*10;
        }else{
            ans+=a[i];
        }
    }

    cout << ans-t << endl;

    return 0;
}

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

using namespace std;

long long H[200005];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long n, k;
	cin >> n >> k;
	for (long long i = 0; i < n; ++i) {
		cin >> H[i];
	}
	sort(H, H + n);
	long long cnt = 0;
	for (long long i = 0; i < n - k; ++i) {
		cnt += H[i];
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 1792
n, m = gets.split.map(&:to_i)
s = Array.new(m)
c = Array.new(m)
for i in 0..(m-1)
  s[i], c[i] = gets.split.map(&:to_i)
end

num = Array.new(n,-1)
flag = 1
for i in 0..(m-1)
  if n != 1 && s[i]+c[i] == 1
    flag = 0
    break
  end
  if num[s[i]-1] == -1
    num[s[i]-1] = c[i]
  elsif num[s[i]-1] != c[i]
    flag = 0
    break
  end
end

if flag == 1
  if n+m == 1 && num[0] == -1
    puts 0
  else
    for i in 0..(n-1)
      num[i] = 1 if i == 0 && num[i] == -1
      num[i] = 0 if i > 0 && num[i] == -1
    end
    puts num.join
  end
else
  puts -1
end

Measured memory_bytes: 1788
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int[][] cost, time;
	int n, m, k;

	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			if((n|m)==0){
				break;
			}
			cost=new int[m][m];
			time=new int[m][m];
			for(int j=0; j<m; j++){
				fill(cost[j], INF);
				fill(time[j], INF);
			}
			for(int i=0; i<n; i++){
				int a=sc.nextInt()-1;
				int b=sc.nextInt()-1;
				int c=sc.nextInt();
				int t=sc.nextInt();
				cost[a][b]=cost[b][a]=c;
				time[a][b]=time[b][a]=t;
			}
			for(int k=0; k<m; k++){
				for(int i=0; i<m; i++){
					for(int j=0; j<m; j++){
						cost[i][j]=min(cost[i][j], cost[i][k]+cost[k][j]);
						time[i][j]=min(time[i][j], time[i][k]+time[k][j]);
					}
				}
			}
			k=sc.nextInt();
			for(int i=0; i<k; i++){
				int p=sc.nextInt()-1;
				int q=sc.nextInt()-1;
				int r=sc.nextInt();
				if(r==0){
					println(cost[p][q]+"");
				}else{
					println(time[p][q]+"");
				}
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

#define reps(i,j,n) for(int i = (j) ; i < (int)(n) ; ++i)    
#define rep(i,n) reps(i,0,n)  
#define each(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)  
  
#define all(v) (v).begin(), (v).end()  
#define pb(x) push_back(x)  
#define sz(x) (int)((x).size())  
#define UNQ(s) {sort(ALL(s));(s).erase(unique(ALL(s)),(s).end());}   
#define fr first  
#define sc second  
  
typedef pair< int , int > Pi;  
typedef pair< int , Pi > Pii;

  
typedef long long int64;  
const int INF = 1 << 30;  
  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is>>a.first>>a.second; }  
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os<<a.first<<" "<<a.second; }  
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ rep(i,sz(vc)) is >> vc[i]; return is;}  
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ rep(i,sz(vc)) os << vc[i] << endl; return os; }  

int main(){
  int N;
  while(cin >> N, N){
    vector< int > a(N), b(N), cnt(N, 0);
    cin >> a;
    cin >> b;
    sort( a.rbegin(), a.rend());
    sort( b.rbegin(), b.rend());

    int s = 0, t = 0;
    while(t < a.size() && s < b.size()){
      while( a[t] > b[s] && t < a.size()) t++;
      if( t < N && b[s] >= a[t]){
        cnt[t]++;
        t++, s++;
      }
    }

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

    int ret = -1;
    for(int i = 1; i < N; i++){
      if(i - cnt[i - 1] >= (i + 2) / 2){
        ret = i;
        break;
      }
    }
    if(~ret) cout << ret << endl;
    else cout << "NA" << endl;
  }
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    if(s.size() % 2 != 0){ cout << "No" << endl; return 0; }
    for(size_t i=0;i<s.size();i+=2) if(s[i] != 'h'){ cout << "No" << endl; return 0; }
    for(size_t i=1;i<s.size();i+=2) if(s[i] != 'i'){ cout << "No" << endl; return 0; }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256