akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


int p[1000][1000];

vector<vector<int>> v;

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

  int m = n - n % 2;
  int s = n * (n - 1) / 2;
  rep(i, m / 2) {
    p[i][m - 1 - i] = p[m - 1 - i][i] = 1;
    s --;
  }
  cout << s << endl;
  rep(i, n) {
    rep(j, i) {
      if (p[i][j] == 0) {
        cout << i + 1 << ' '  << j + 1 << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 640
let s = read_line () in
let t = read_line () in
let sa = Array.init (String.length s) (fun i -> s.[i]) in
let ta = Array.init (String.length t) (fun i -> t.[i]) in
let () = Array.sort (fun a b -> compare a b) sa in
let () = Array.sort (fun a b -> compare b a) ta in
let s = String.init (String.length s) (fun i -> sa.(i)) in
let t = String.init (String.length t) (fun i -> ta.(i)) in
print_endline @@ if s < t then "Yes" else "No"

Measured memory_bytes: 384
# AOJ ITP1_7_A

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        data = numinput()
        if data[0] < 0 and data[1] < 0 and data[2] < 0: break
        grade = ""
        if data[0] + data[1] >= 80: grade = "A"
        elif data[0] + data[1] >= 65: grade = "B"
        elif data[0] + data[1] >= 50: grade = "C"
        elif data[0] + data[1] >= 30:
            if data[2] >= 50: grade = "C"
            else: grade = "D"
        else:
            grade = "F"
        if data[0] < 0 or data[1] < 0: grade = "F"
        print(grade)

if __name__ == "__main__":
    main()



Measured memory_bytes: 5600
s = input()
n,m,m2 = len(s),1,2
if 1-int(s[0]) or int(s[-1]) or any(s[i]!=s[n-i-2] for i in range(n-1)): print(-1)
else:
	for i in range(n-1):
		print(m,m2)
		if int(s[i]): m = m2
		m2+=1

Measured memory_bytes: 4648
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

int main() {
  char ch;
  int alph[26] = {};

  while(cin >> ch){
    for (int i = 'a'; i <= 'z'; i++)
      if ( i == tolower(ch)) alph[i-'a']++;
  }

  for (int i = 0; i < 26; i++) {
    printf("%c : %d\n", ('a'+i), alph[i]);
  }
  return 0 ;
}

Measured memory_bytes: 3136
def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    PY = {}
    for i in range(1, M+1):
        p, y = map(int,input().split())
        if p not in PY.keys():
            PY[p] = []
        PY[p].append((y, i))
    numbers = [0] * (1+M)
    for p in PY.keys():
        PY[p].sort(reverse=True)
        rank = 1
        while PY[p]:
            year, i = PY[p].pop()
            num = str(p).zfill(6) + str(rank).zfill(6)
            rank += 1
            numbers[i] = num
            
    for i in range(1, M+1):
        print(numbers[i])


main()

Measured memory_bytes: 99052
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>
#include <bitset>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;

const long MOD = 998244353;

long pwr(long a, long b)
{
	if(b == 0) return 1;
	else if(b == 2) return (a*a)%MOD;
	else if(b&1) return (pwr(a,b-1)*a)%MOD;
	else return pwr(pwr(a,b/2),2);
}

long fac[300003], facm[300003];

void precompute()
{
	fac[0] = facm[0] = 1;
	for(int i = 1; i <= 300000; i++)
	{
		fac[i] = (i*fac[i-1])%MOD;
		facm[i] = pwr(fac[i],MOD-2);
	}
}

long C(long n, long k)
{
	if(k > n) return 0;
	else return ((fac[n]*facm[k])%MOD*facm[n-k])%MOD;
}

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("input.in", "r", stdin);
    
    precompute();
	long n, a, b, k;
	scanf("%lld %lld %lld %lld", &n, &a, &b, &k);

	long res = 0;
	for(long i = 0; i <= n; i++)
	{
		if(k-a*i >= 0 && (k-a*i)%b == 0)
		{
			// printf("%lld %lld\n", i, (k-a*i)/b);
			res += C(n,(k-a*i)/b)*C(n,i);
			res %= MOD;
		}
	}
	printf("%lld\n", res);
}	












Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<pair<string, pi>> s;
	rep(i, n){
		string a;
		int b;
		cin >> a >> b;
		s.pb(mp(a, mp(-b, i)));
	}
	sort(all(s));
	rep(i, n) cout << s[i].se.se + 1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        Integer a = scanner.nextInt();
        Integer b = scanner.nextInt();
        if(a + b < 10){
            System.out.println(a + b);
        }else{
            System.out.println("error");
        }
    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N,Q,i,l,r,counter;
	string S;
	cin >> N;
	cin >> Q;
	cin >> S;
	counter = 0;
	int ans[N];
	ans[0] = 0;
	for (i = 0;i < N-1; i++){
		if (S[i] == 'A' && S[i+1] == 'C'){
			counter++;
		}
		ans[i+1] = counter;

	}
	for (i = 0;i < Q; i++){
		cin >> l;
		cin >> r;
		cout << (ans[r-1] -ans[l-1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
import math
import copy

def condition(t, h, a, b):
    count = 0
    for i in range(len(h)):
        if h[i] > b*t:
            count += math.ceil((h[i]-b*t)/(a-b))
    # print("count:{} t:{} _h:{} a:{} b:{}".format(count, t, _h, a, b))
    if count > t:
        return False
    else:
        return True


class binarySearch:
    # 添え字による二分探索
    # 添え字「t」によってソート済みリストを二分探索
    def __init__(self, limit, target):
        self.limit = limit
        self.target = target

    def search(self, h, a, b):
        low = 0
        high = self.limit
        t = int((low + high) / 2)
        while high >= low:
            out = condition(t, h, a, b)
            # print("t:{} _out:{} limit:{}\n".format(t, out, self.limit))
            if not out:
                low = t + 1
            else:
                high = t - 1
            t = int((low + high) / 2)
        for i in range(3):
            if condition(low-i, h, a, b):
                return low-i
        # return low

def func(a, b, _h):
    _h.sort()
    _h.reverse()
    _sum = 0  # 現在何回以上爆発させることが確定しているか
    aMargin = 0  # _sum回のうちあと何回aを使うことができるか
    for h in _h:
        print("prev cost upper:{}".format(a * aMargin + b * (_sum - aMargin)))
        # まず_sum回で抑える場合にaがいくつ必要か算出
        if h <= a * aMargin + b * (_sum - aMargin):
            # そのうちどれだけaを使わないでいられるか
            h -= b * _sum  # まず必ず減る部分を計算
            if h > 0:
                aMargin -= math.ceil(h / (a - b))  # a が何回必要か
        else:
            # hを0にするのに必要最低限の回数をを算出
            tmpH = h
            tmpH -= a * aMargin + b * (_sum - aMargin)
            extra = math.ceil(tmpH / a)
            _sum += extra
            aMargin += extra
            print("aMargin:{}".format(aMargin))
            # 合計して「_sum」回が最小回数
            # ここで使えるaは「aMargin」回
            # そのうちどれだけaを使わないでいられるか
            h -= b * _sum  # まず必ず減る部分を計算
            aMargin -= math.ceil(h / (a - b))  # a が何回必要か
        print("_sum:{} margin:{}".format(_sum, aMargin))
    return str(_sum)


n, a, b = [int(i) for i in input().split()]
h = [0 for _ in range(n)]
for i in range(n):
    h[i] = int(input())
# print(func(a, b, h))
binary = binarySearch(target=math.ceil(max(h)/a), limit=math.ceil(max(h)/1))
print(binary.search(h, a, b))
# print("print(func({}, {}, {}))".format(a, b, h))
"""
print("2 vs " + func(5, 3, [8, 7, 4, 2]))
print("4 vs " + func(10, 4, [20, 20]))
print("800000000 vs " + func(2, 1, [900000000, 900000000, 1000000000, 1000000000, 1000000000]))
"""


Measured memory_bytes: 7632
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	vector<int> data;
	for(int i=0;i<10;++i){
		int a;
		scanf("%d",&a);
		data.push_back(a);
	}
	sort(data.begin(),data.end());
	vector<int>::iterator it = data.end();
	--it;
	for(int i=0; i < 3 ; --it, ++i)
		printf("%d\n",*it);
	return 0;
}

Measured memory_bytes: 0
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p = MOD) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

const lli N = 1e5 + 1;
lli n, a[N], sm = 0, b, c, q;

void solve(){
    cin >> n;
	map<lli,lli> mpp;
	NA(i,0,n) cin >> a[i], sm += a[i], mpp[a[i]]++;
	cin >> q;
	NA(i,0,q){
		cin >> b >> c;
		mpp[c] += mpp[b];
		sm += (mpp[b] * (c - b));
		mpp[b] = 0;
		cout << sm << '\n';
	}
    return;
}
        
int main(){
    fastIO;
    lli t = 1;
    // cin>>t;
    NA(i,0,t){
        solve();
    }
    return 0;
}


Measured memory_bytes: 10236
#include <iostream>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int64_t A, B, C, D;
unordered_map<int64_t, int64_t> memo;

int64_t solve(int64_t N) {
  if (N == 0)
    return 0;
  else if (N == 1)
    return D;
  if (memo.count(N)) return memo[N];

  int64_t ret = INT64_MAX;
  if (N < ret / D) ret = N * D;

  vector<int64_t> coin = {2, 3, 5};
  vector<int64_t> cost = {A, B, C};
  rep(i, 3) {
    int64_t m = coin[i];
    int64_t ln = N / m;
    int64_t rn = (N + m - 1) / m;
    ret = min(ret, abs(ln * m - N) * D + cost[i] + solve(ln));
    ret = min(ret, abs(rn * m - N) * D + cost[i] + solve(rn));
  }
  return memo[N] = ret;
}

int main(void) {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  vector<int64_t> answer(T);
  rep(i, T) {
    int64_t N;
    cin >> N >> A >> B >> C >> D;
    memo.clear();
    answer[i] = solve(N);
  }
  rep(i, T) { cout << answer[i] << endl; }
  return 0;
}

Measured memory_bytes: 4180
#include <cstdio>
int main()
{
    int a,b,n;
    scanf("%d%d%d",&n,&a,&b);
    if(n==1)
    {
        if(a==b)
            printf("1\n");
        else
            printf("0\n");

    }
    else
    {
        if(a>b) printf("0\n");
        else printf("%lld\n",(long long)(b-a)*(n-2)+1);
    }
    return 0;
}


Measured memory_bytes: 128
s=input()
bflag=0
wflag=0
if s[0]=="B":
    bflag=1
else:wflag=1
count=0
for i in s[1:]:
    if i=="B" and wflag==1:
        count+=1
        wflag=0
        bflag=1
    elif i=="W" and bflag==1:
        count+=1
        wflag=1
        bflag=0
print(count)

Measured memory_bytes: 3188
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

R = INT()
print(2 * R * pi)




Measured memory_bytes: 10460
#include<iostream>

using namespace std;
int main(){
    int n;
    cin >> n;
    int resultCount = 0;
    for(int i = 1; i<=n; i+=2){
        int count = 0;
        for(int j = 1; j<=i; j++){
            if( i % j == 0 ){
                count ++;
            }
        }
        if(count == 8){
            resultCount++;
        }
    }
    cout << resultCount << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            int[] data = cin.ReadIntArray(2);
            int n = data[0];
            int k = data[1];
            int[] max = cin.ReadIntArray(n);

            int maximum = 0;
            int maxStart = 0;
            int checkSum = 0;
            //最初の1箇所目
            for(int i = 0; i < k; i++)
            {
                maximum += max[i];
            }
            checkSum = maximum;
            for (int i = 1; i <= n - k; i++)
            {
                checkSum -= max[i - 1];
                checkSum += max[i + k - 1];
                if (maximum < checkSum)
                {
                    maximum = checkSum;
                    maxStart = i;
                }
            }

            double kitaichi = 0;
            for (int i = maxStart; i < k + maxStart; i++)
            {
                kitaichi += (max[i] + 1) / 2.0;
            }
            Console.WriteLine(kitaichi);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 32604
def solve():
    S = input()
    K = int(input())
    strlist = sorted(list(S))
    lis = set()
    p = 0
    while len(list(lis))<K:
        a = strlist[p]
        if len(S)>=5:
            for i,s in enumerate(S):
                if s==a:
                    for j in range(i+1,min(len(S)+1,i+K+1)):
                        lis.add(S[i:j])
        else:
            for i in range(len(S)):
                for j in range(i+1,len(S)+1):
                    lis.add(S[i:j])
        p += 1
    ans = sorted(list(lis))[K-1]
    return ans
print(solve())

Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
Ad = {}
for a in A:
    Ad[a] = Ad.get(a, 0) + 1
A, maxA, ans = sorted(Ad.keys()), max(Ad.keys()), 0

for a in A:
    if Ad[a] == 1:
        ans += 1
    if Ad[a] >= 1:
        if a == 1:
            break
        m = 2
        while a * m <= maxA:
            if a * m in Ad:
                Ad[a * m] = 0
            m += 1

print(ans)


Measured memory_bytes: 122240
n,m=map(int,input().split())
a=list(map(int,input().split()))
#bc=[]

import heapq  
heapq.heapify(a) 

bc=[]
for _ in range(m):
    b,c=map(int,input().split())
    bc.append((c,b))

bc.sort(reverse=True)
for item in bc:
    b=item[1]
    c=item[0]    
    for _ in range(b):
        temp=heapq.heappop(a)
        if temp<c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,temp)
            print(sum(list(a)))
            exit()
#print(a)
print(sum(list(a)))

Measured memory_bytes: 88856
#include <iostream>
#include <cstdio>
#include <algorithm> // sort
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <utility>

using namespace std;

typedef long long int lli;
typedef pair<lli,lli> p_ii;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl
int bug = 1;

int main(){
	IOS
	int x, a;

	cin >> x >> a;
	int ans = (x < a ? 0 : 10);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//AtCoder Beginner Contest 120
//A	Favorite Sound
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		sc.close();

		int times = B / A;

		System.out.print(Math.min(times, C));
	}
}


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

int main(){
  
  int n, q, command, t, x;
  
  cin >> n;
  priority_queue<int> Q[n];
  
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> command;
    
    if(command == 0){
      cin >> t >> x;
      Q[t].push(x);
    }else if(command == 1){
      cin >> t;
      if(Q[t].size()) cout << Q[t].top() << endl;
    }else if(command == 2){
      cin >> t;
      if(Q[t].size()) Q[t].pop();
    }
  }
  
  return 0;
}



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

int n;
long long a,b;

long long h[100005];
long long r[100006];

bool check(long long x)
{
    for(int i=1;i<=n;i++)
        r[i]=max(h[i]-b*x,0ll);
    for(int i=1;i<=n;i++)
    {
        x-=(r[i]+a-b-1)/(a-b);
    }
    if(x<0)return false;
    return true;
}

long long erfen(long long l,long long r)
{
    if(l==r)
        return l;
    int mid=(l+r)/2;
    if(check(mid))return erfen(l,mid);
    else return erfen(mid+1,r);
}

int main()
{
    scanf("%d%lld%lld",&n,&a,&b);
    for(int i=1;i<=n;i++)
        scanf("%lld",&h[i]);
    printf("%lld",erfen(0,1e9));
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 5000000
#define N -1
 
int key[MAX],n,count = 0;
 
int parent(int p){
  return p/2;
}
 
int right(int p){
  return 2*p+1;
}
 
int left(int p){
  return 2*p;
}
 
void maxHeapify(int p){
  int l,r,largest=N,temp;
  l = left(p);
  r = right(p);
 
  if(l <= count && key[l]>key[p]) largest = l;
  else largest = p;
  if(r<= count && key[r]>key[largest]) largest = r;
  if(largest != p){
    temp = key[p];
    key[p] = key[largest];
    key[largest] = temp;
    maxHeapify(largest);
  }
 
}
 
void buildMaxHeap(){
  int i;
  for(i = count/2; i > 0; i--){
    maxHeapify(i);
  }
}
 
void heapIncreaseKey(int p,int in){
  int temp,i;
 
  if(in < key[p]){
    exit(1);
  }
 
  key[p] = in;
 
  while(p > 1 && key[parent(p)] < key[p]){
    temp = key[p];
    key[p] = key[parent(p)];
    key[parent(p)] = temp;
 
    p = parent(p);
  } 
}
 
void maxHeapInsert(int in){
  int i;
  count++;
  key[count] = N;
  heapIncreaseKey(count,in);
}
 
 
int heapExtractMax(){
  int max;
  if(count < 1){
    exit(1);
  }
 
  max = key[1];
  key[1] = key[count];
  count--;
 
  maxHeapify(1);
 
  return max;
}
 
 
int main(){
  int i,v,max;
  char com[20];
 
 
  for ( i = 0; i < MAX; i++ ){
    key[i] = N;
  }
 
  while(strcmp(com,"end") != 0){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d" ,&v);
      maxHeapInsert(v);
    }
    else if(com[1] == 'x'){
      max = heapExtractMax();
      printf("%d\n",max);
    }
  }
  return 0;
}

Measured memory_bytes: 20132
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <string>


#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;


int main()
{
	ll X;
	cin >> X;
	ll N = X / 100;
//	print(N)
	ll K = 100 * N;
	if (X <= 105 * N)
	{
		cout << 1;
	}
	else cout << 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n;
void solve(int n,int a,int sel[],int cnt){
  if(n < 0 || a <= 0) return;
  if(n == 0 && a == 1) {
    int flg = 0;
    for(int i=0;i<cnt;i++){
      if(flg) cout << " ";
      cout << sel[i];
      flg = 1;
    }
    cout << endl;
    return;
  }
  sel[cnt] = a;
  solve(n-a,a,sel,cnt+1);
  solve(n,a-1,sel,cnt);
  return;
}
int main(){
  while(cin >> n , n){
    int sel[100]={0};
    solve(n,n,sel,0);
  } 
}

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


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int input[100000][2] = {};
	int memo = 0;

	for (int i = 0; i < 100000; ++i) {
		CI input[i][0];
		CI input[i][1];
		if (input[i][0] == 0) {
			memo = i;
			break;
		}
	}

	for (int i = 0; i < memo; ++i) {
		for (int k = 0; k < input[i][0]; ++k) {
				for (int j = 0; j < input[i][1]; ++j) {
					if (k % 2 == 0) {
						if (j % 2 == 0) {
							CO "#";
						}
						else {
							CO ".";
						}
					}
					else {
						if (j % 2 == 0) {
							CO ".";
						}
						else {
							CO "#";
						}
					}
				}
			CO "\n";
		}
		CO "\n";
	}
}

Measured memory_bytes: 1908
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, M, K, Q, W, H;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	string s, t, u;
	cin >> s >> t >> u;
	cout << s[0] << t[0] << u[0] << endl;
	return 0;
}

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

int main(){
  int n;cin >> n;
  int p[20], count = 0;
  for(int i = 0;i < n;i++) {
    cin >> p[i];
  }
  for(int i = 1;i < n - 1;i++)
    if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1]))
      count++;
  cout << count;
}


Measured memory_bytes: 256
#![allow(dead_code, unused_variables, unused_imports)]
use proconio::marker::Chars;
use proconio::{fastout, input};
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};

#[fastout]
fn main() {
    input!{
        n:usize,
        mut a:[usize;n],
    }
    
    let mut f = true;
    for i in 1..n{
        if a[i] < a[i-1]{
            f = false;
            break;
        }else if a[i] > a[i-1]{
            a[i] -= 1;
        }

    }
    if f{
        println!("Yes");
    }else{
        println!("No");
    }
}   


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

#define ALL(v) (v).begin(), (v).end()
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl;
#define DEBUG_VEC(v) cerr<<#v<<": ";for(auto x:v)cerr<<x<<" ";cerr<<endl

#define MOD 1000000007

int n;
ll xx;
ll x[252521];
ll sm[252521];

int main(){
	scanf("%d%lld",&n,&xx);
	REP(i,n)scanf("%lld",x+i);
	REP(i,n)sm[i+1] = sm[i] + x[i];
	ll ans = 1ll<<62;
	FOR(y,1,n+1){
		ll tmp = 5ll*sm[n] + (ll)xx*n;
		tmp += (ll)y*xx;
		int rgt = n-y;
		ll coe = 0;
		while(rgt>0){
			int nxt = max(rgt-y,0);
			__int128 add = 1;
			add *= coe;
			add *= sm[rgt]-sm[nxt];
			add += tmp;
			if(add > ans){
				tmp = ans;
				break;
			}
			tmp = add;
			rgt = nxt;
			coe += 2;
		}
		CHMIN(ans, tmp);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int t;
	int s, f;
	int total;
	
	while (scanf("%d", &t), t != 0){
		total = 0;
		scanf("%d", &n);
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &s, &f);
			total += f - s;
		}
		if (t <= total){
			printf("OK\n");
		}
		else {
			printf("%d\n", t - total);
		}
	}
	return (0);
}

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

#define int long long

using namespace std;

int a[10010];

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

    vector <int> ans;

    for(int i=1;i<=n;i++)
    {
        cin >> a[i];

        if(ans.size() < a[i]-1)
        {
            cout << -1 << endl;
            return 0;
        }

        ans.insert(ans.begin()+a[i]-1,a[i]);
    }

    for(int i:ans)
        cout << i << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

# 0-indexでやる

D = int(readline())

C = list(map(int,readline().split())) # 満足度の下がりやすさ

last_submit = [-26] * 26

for i in range(D):
  S = list(map(int,readline().split()))
  
  # 52回以上提出がないものがあれば、42回を超えたもののうちCの値が高いものを提出
  if i - min(last_submit) >= 52:
    ind = -1
    for j in range(len(last_submit)):
      if i - last_submit[j] >= 42:
        if ind == -1:
          ind = j
        else:
          if C[ind] < C[j]:
            ind = j
    print(ind + 1)
    last_submit[ind] = i
    continue
    
  for j in range(len(S)):
    S[j] = (S[j],j)
  S = sorted(S, key = lambda x:x[0], reverse = True)
  topval = S[0][0]
  for j in range(len(S)):
    val = S[j][0]
    if val < topval // 2:
      continue # 最高値の半分になるのであればやめよう
    index = S[j][1]
    if i - last_submit[index] < 26:
      continue
    print(index + 1)
    last_submit[index] = i
    break
  else:
    print(S[0][1] + 1)


Measured memory_bytes: 9304
# FOrbidden List
def nearest(x, arr):
    if x not in arr:
        return x
    lower = x - 1
    higher = x + 1
    while True:
        if lower not in arr:
            return lower
        if higher not in arr:
            return higher
        lower -= 1
        higher += 1

        


x = list(map(int, input().rstrip().split()))
a = list(map(int, input().rstrip().split()))
print(nearest(x[0], a))

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

int main() {
  int N,M;
  cin >> N;
  vector <string> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i); 
  }  
  cin >> M;
  vector <string> b(M);
  for(int i=0;i<M;i++){
    cin >> b.at(i);
  }  
   
  int res=0;
  for(int i=0;i<N;i++){
  int r=0;  
    for(int j=0;j<N;j++){
      if(a.at(i)==a.at(j))r++;
    } 
    for(int k=0;k<M;k++){
      if(a.at(i)==b.at(k))r--;
    }  
  res=max(res,r);  
  }  
     cout << res;
  
}  


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
	int i, n;
	int a, b;
	int num;
	scanf("%d %d",&a,&b);
	if(b < 10)
	{
		a = a * 10;
	}
	if(b >= 10 && b < 100)
	{
		a = a * 100;
	}
	if(b == 100)
	{
		a = a * 1000;
	}
	num = a + b;
	int haha = sqrt(num);
	if(haha * haha != num)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}

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


using namespace std;


const int maxi=1e6+2;
pair<int,int> a[maxi];

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

    swap(m,n);

    for (int i=1;i<=n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        a[i]={y-1,x};
    }

    sort(a+1,a+n+1);

    int last=0;
    int ans=0;
    for (int i=1;i<=n;i++)
        if (a[i].second>last)
    {
        ans++;
        last=a[i].first;
    }

  cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100005
#define INF 1000000000000000000
using Graph=vector<vector<int>>;

int main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<int> L(M),R(M),p(Q),q(Q);
  for(int i=0;i<M;i++){
    cin>>L.at(i)>>R.at(i);
    L.at(i)--;
    R.at(i)--;
  }
  for(int i=0;i<Q;i++){
    cin>>p.at(i)>>q.at(i);
    p.at(i)--;
    q.at(i)--;
  }

  vector<vector<int>> query(N,vector<int>(N,0));
  for(int i=0;i<M;i++){
    query.at(L.at(i)).at(R.at(i))++;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N-1;j++){
      query.at(i).at(j+1)+=query.at(i).at(j);
    }
  }
  for(int i=N-1;i>0;i--){
    for(int j=0;j<N;j++){
      query.at(i-1).at(j)+=query.at(i).at(j);
    }
  }

  for(int i=0;i<Q;i++){
    cout<<query.at(p.at(i)).at(q.at(i))<<endl;
  }
}


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

int H, W;
int cnt[30];

int Func4(int h, int w){
    if(h <= 1 || w <= 1) return 0;
    int ret = 1;
    ret += (w - 2) / 2;
    ret += (h - 2) / 2;
    return ret + Func4(h - 2, w - 2);
}

int Func2(int h, int w){
    if(h <= 0 || w <= 0) return 0;
    if(h == 1 && w == 1) return 0;
    if(h == 1) return w / 2;
    if(w == 1) return h / 2;
    int ret = 0;
    ret += w % 2;
    ret += h % 2;
    return ret + Func2(h - 2, w - 2);
}

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

    cin >> H >> W;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            char input;
            cin >> input;
            cnt[int(input - 'a')]++;
        }
    }
    int cnt4 = Func4(H, W);
    int cnt2 = Func2(H, W);
/*
    cout << cnt4 << endl;
    cout << cnt2 << endl;

    for(int i = 0; i < 27; ++i){
        cout << cnt[i] << " ";
    }
    cout << endl;
*/
    int now = 0;
    bool check = false;
    while(now < 27){
        if(cnt4 > cnt[now] / 4){
            cnt4 -= cnt[now] / 4;
            cnt[now] %= 4;
        }
        else {
            cnt[now] -= cnt4 * 4;
            cnt4 = 0;
            check = true;
        }
        ++now;
    }
    if(!check){
        cout << "No" << endl;
        return 0;
    }
/*
    for(int i = 0; i < 27; ++i){
        cout << cnt[i] << " ";
    }
    cout << endl;
*/
    check = false;
    now = 0;
    while(now < 27){
        if(cnt2 > cnt[now] / 2){
            cnt2 -= cnt[now] / 2;
            cnt[now] %= 2;
        }
        else {
            cnt[now] -= cnt2 * 2;
            cnt2 = 0;
            check = true;
        }
        ++now;
    }
/*
    for(int i = 0; i < 27; ++i){
        cout << cnt[i] << " ";
    }
    cout << endl;
*/
    if(!check){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

map<int, int> mp;

int f(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  mp.clear();
  FOR(i, 1, 99) {
    FOR(j, 1, 99) {
      FOR(k, 1, 99) {
        mp[f(i, j, k)]++;
      }
    }
  }
  FOR(i, 1, n) {
    cout << mp[i] << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 5396
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cosÆ
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sinÆ
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
};

const double EPS = 1.0e-10;

vector<Point> circlesIntersection(const Point& p1, double r1, const Point& p2, double r2)
{
    double y = p2.y - p1.y;
    double x = p2.x - p1.x;
    double a = (y*y + x*x + r1*r1 - r2*r2) / 2;
    double b = (y*y + x*x) * r1*r1 - a*a;

    if(y*y + x*x < EPS || b < -EPS)
        return vector<Point>(0);
    if(b < EPS)
        return vector<Point>(1, Point(y, x) * (a / (y*y + x*x)) + p1);

    vector<Point> ret(2, Point(x * sqrt(b), - y * sqrt(b)));
    ret[1] = ret[1] * -1;
    for(int i=0; i<2; ++i)
        ret[i] = (ret[i] + Point(y, x) * a) / (y*y + x*x) + p1;
    return ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<Point> p(n);
        for(int i=0; i<n; ++i){
            char c;
            cin >> p[i].x >> c >> p[i].y;
        }

        int ret = 1;
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                vector<Point> p2 = circlesIntersection(p[i], 1, p[j], 1);
                for(unsigned k=0; k<p2.size(); ++k){
                    int tmp = 0;
                    for(int l=0; l<n; ++l){
                        if(pow(p[l].y - p2[k].y, 2) + pow(p[l].x - p2[k].x, 2) <= 1 + EPS)
                            ++ tmp;
                    }
                    ret = max(ret, tmp);
                }
            }
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;

bool find_torio(int* ary, int rest){
  if(rest==0) return true;
  for(int i=0;i<7;i++){
    if(ary[i]>0&&ary[i+1]&&ary[i+2]>0){
      int ary2[9]; copy(ary,ary+9,ary2);
      ary2[i]--; ary2[i+1]--; ary2[i+2]--;
      if(find_torio(ary2,rest-1)) return true;
    }
  }
  for(int i=0;i<9;i++){
    if(ary[i]>=3){
      int ary2[9]; copy(ary,ary+9,ary2);
      ary2[i]-=3;
      if(find_torio(ary2,rest-1)) return true;
    }
  }
  return false;
}

int main(){
  char s[16];
  while(scanf("%s",s)>0){
    int a[9]{0};
    set<int> atari;
    for(char c:s)
      a[(int)(c-'1')]++;
    for(int i=0;i<9;i++){//当たり牌
      if(a[i]==4) continue;
      int b[9]; copy(a,a+9,b);
      b[i]++;
      for(int j=0;j<9;j++){//頭
	if(b[j]<2) continue;
	int c[9]; copy(b,b+9,c);
	c[j]-=2;
	if(find_torio(c,4))
	  atari.insert(i);
      }
    }
    int count=0;
    for(int i:atari){
      if(++count==atari.size())
	printf("%d\n",i+1);
      else
	printf("%d ",i+1);
    }
    if(count==0) printf("0\n");
  }
}

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

using namespace std;

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

	int pre = s / 100;
	int post = s % 100;

	bool preYear = true, preMonth = false, postYear = true, postMonth = false;

	if (1 <= pre && pre <= 12) preMonth = true;
	if (1 <= post && post <= 12) postMonth = true;

	bool yymmFormat = preYear && postMonth;
	bool mmyyFormat = preMonth && postYear;
	if (yymmFormat && mmyyFormat) cout << "AMBIGUOUS" << endl;
	else if (yymmFormat) cout << "YYMM" << endl;
	else if (mmyyFormat) cout << "MMYY" << endl;
	else cout << "NA" << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    int n, p;
    int[] xs;

    void Read()
    {
        var line = ReadLine(int.Parse);
        n = line[0];
        p = line[1];

        xs = ReadLine(int.Parse);
    }

    long Solve()
    {
        var dp = new long[2, n + 1];
        dp[0, 0] = 1;

        for (var i = 0; i < n; i++)
        {
            for (var p = 0; p < 2; p++)
            {
                var q = p == (xs[i] % 2) ? 0 : 1;
                dp[p, i + 1] = dp[p, i] + dp[q, i];
            }
        }

        return dp[p, n];
    }

    public void Run()
    {
        Read();
        WriteLineOne(Solve());
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  string T; cin >> T;

  vector<pair<char, char>> sp(S.size());
  vector<pair<char, char>> tp(S.size());
  REP(i, S.size()) {
    sp[i] = make_pair(S[i], T[i]);
    tp[i] = make_pair(T[i], S[i]);
  }
  sort(all(sp));
  sort(all(tp));

  string ans = "Yes";
  for(int i = 0; i < S.size() - 1; ++i) {
    if(sp[i].first == sp[i + 1].first) {
      if(sp[i].second != sp[i + 1].second) {
        ans = "No";
      }
    }

    if(tp[i].first == tp[i + 1].first) {
      if(tp[i].second != tp[i + 1].second) {
        ans = "No";
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1544
#include <stdio.h>

#define N 1000000
int n;
int S[N];

int partition(int n){
	int x = S[n];
	int i,p=0;
	int tmp;
	int j;
	for(i = 0;i < n;i++){
		//printf("%d\n",i);
		if(S[i] <= x){
			tmp  = S[i];
			S[i] = S[p];
			S[p] = tmp;
			p++;
		}
		/*
		for(j=0;j<n+1;j++){
			printf("%d ",S[j]);
		}
		printf("\n");
		printf("p = %d\n",p);*/
	}
	tmp = S[p] ;
	S[p] = S[n];
	S[n] = tmp;
	return p;
}

int main(){
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}
	int m = partition(n-1);
	for(i = 0;i< n;i++){
		if(m == i){
			printf("[%d] ",S[i]);
		}
		else if(i == n-1)printf("%d\n",S[i]);
		else printf("%d ",S[i]);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

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

  int N, K;
  cin >> N >> K;
 
  unordered_set<size_t> remained_man;
  for (auto i = 1; i <= N; ++i) {
    remained_man.insert(i);
  }
 
  for (auto i = 0; i < K; ++i) {
    size_t d;
    READ(d);

    for (auto j = 0; j < d; ++j) {
      size_t a;
      READ(a);

      remained_man.erase(a);
    }
  }
  WRITE_N(remained_man.size());

  return 0;
}


Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
v=list(map(int,input().split()))
v1=[]
v2=[]
for i in range(n):
    if i%2==1:
        v2.append(v[i])
    else:
        v1.append(v[i])
c1=collections.Counter(v1)
c2=collections.Counter(v2)
c1[0]=0;c2[0]=0
c1 = sorted(c1.items(), key=lambda tup: -tup[1])
c2 = sorted(c2.items(), key=lambda tup: -tup[1])
# print(c1,c2)
if not c1[0][0]==c2[0][0]:
    print(n-c1[0][1]-c2[0][1])
    # print(0)
else:
    # print(c1,c2)
    print(min(n-c1[0][1]-c2[1][1],n-c1[1][1]-c2[0][1]))



Measured memory_bytes: 62808
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

// http://drken1215.hatenablog.com/entry/2018/06/08/210000
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

LL Sub1(LL N, LL K, VEC<LL> &A) {
  // return comb(N, K)*E(minX) mod 1e9+7
  //   or   comb(N, K)*E(maxX) mod 1e9+7

  // DUMP("Sub1", N, K, A);
  LL sum = 0;
  REP(i, 1, N - K + 1 + 1) {
    sum = (sum + (COM(N - i, K - 1) * (MOD+A[i - 1])%MOD) % MOD) % MOD;
    // DUMP("i, sum, COM(N-i,K-1), A[i-1]", i, sum, COM(N - i, K - 1), A[i -
    // 1]);
  }
  return sum;
}
int main() {
  LL N, K;
  cin >> N >> K;
  VEC<LL> A(N);
  REP(i, 0, N) cin >> A[i];
  sort(ALL(A));
  COMinit();
  LL mi = Sub1(N, K, A);
  reverse(ALL(A));
  LL ma = Sub1(N, K, A);
  // DUMP(ma, mi);
  // DUMP("COM(N,K)", COM(N, K));
  // DUMP("E(minX)", (double)mi / COM(N, K), "E(maxX)", (double)ma / COM(N, K));
  cout << (MOD - mi + ma) % MOD << endl;

  return 0;
}


Measured memory_bytes: 12928
use std::io;
use std::f64::consts::PI;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    let r = input.trim().parse::<f64>().unwrap();

    let area = PI * r * r;
    let circumference = 2. * PI * r;
    println!("{} {}", area, circumference);
}



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

bool mada (string a, string b) {
	int aux = 0;
	while (aux < min(a.size(), b.size()) && a[aux] == b[aux]) aux++;
	if (aux == min(a.size(), b.size())) aux--;
	return a[aux] < b[aux];
}

int main() { 
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	string s;
	cin >> n;
	map <string, int> h;
	for (int i=1; i<=n; i++) {
		cin >> s;
		h[s]++;
	}
	int mx = 0;
	for (auto it : h) {
		mx = max(mx, it.second);
	}
	vector <string> ans;
	for (auto it : h) {
		if (it.second == mx) {
			ans.push_back(it.first);
		}
	}
	sort(ans.begin(), ans.end());
	for (int i=0; i<ans.size(); i++) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 27208
import sys
import numpy as np
from collections import defaultdict



input = sys.stdin.readline

def main():

    N = int(input())
    A = list(map(int,input().split()))


    wa = defaultdict(int)
    sa = defaultdict(int)

    for i in range(1,N+1):
        wa[i+A[i-1]] +=1
        sa[i-A[i-1]]+=1

    ans = 0
    for j in range(N):
        ans += wa[j] *sa[j]

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 77688
m,d = map(int,input().split())
cnt = 0
for i in range(1,m + 1):
  for j in range(1,d+1):
    d1 = j % 10
    d10 = j // 10
    if d1 >= 2 and d10 >= 2 and d1 * d10 == i:
      cnt += 1
print(cnt)

Measured memory_bytes: 3060