akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;


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

	vector<pair<int, int>> P(N);
	int X, L;
	rep(i, N) {
		cin >> X >> L;
		P[i].first = X + L;
		P[i].second = X - L;
	}

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

	ll head = -1e10;
	rep(i, N) {
		if (P[i].second >= head) {
			head = P[i].first;
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

  int main(void)
{
  int h, m, s, S;

  scanf("%d", &S);
  h = S/3600;
  m = (S-h*3600)/60;
  s = S - h*3600 - m*60;

  printf("%d:%d:%d\n", h, m, s);
  
  
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int ans = 0;
    rep(i, 5) {
        int a;
        cin >> a;
        if (a == 0) {
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	string s, t;
	bool ans = true;
	cin >> s >> t;
	map<char, char> trans;
	set<char> ch;
	rep(i, s.size()) { trans[s[i]] = t[i]; }
	rep(i, s.size()) { 
		ans &= (trans[s[i]] == t[i]);
		ch.insert(trans[s[i]]);
	}
	ans &= (ch.size() == trans.size());
	cout << solve(ans) << endl;
}

Measured memory_bytes: 3892
L, R = gets.chomp.split.map(&:to_i)
ans = Array.new
if R - L < 2019
  (L..R-1).each do |i|
    (i+1..R).each do |j|
      ans.push(i * j % 2019)
    end
  end
else
  puts 0
end
puts ans.min


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

int main()
{
  int a,b;
  while(cin>>a>>b)
  {
	  a+=b;
	  int count = 0;
	  while(a!=0)
	  {
		  a /= 10;
		  count++;
	  }
	  cout<<count<<endl;
  } 
	return 0;
}

Measured memory_bytes: 1160
/* include */
#include <stdio.h>
#include <stdlib.h>
/* define */
#define MAX 1000
#define INFTY 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2
/* global */
int n, MATRIX[MAX][MAX]; //0??§??????????????????
/* prototype */
int prim();

int prim(){
  int from, to, min, i, j, sum;
  int PATH[MAX], PARENT[MAX], COLOR[MAX]; //????°??????????, ?????????, ?¨??????¶???
  
  /* create matrix */
  for(i=0;i<n;i++){
    PATH[i] = INFTY;
    PARENT[i] = -1;
    COLOR[i] = WHITE;
  }
  PATH[0] = 0;

  /* ??????????¨???? */
  while(1){
    min = INFTY;
    from = -1;
    for(i=0;i<n;i++){
      if(min>PATH[i] && COLOR[i]!=BLACK){
        from = i;
        min = PATH[i];
      }
    }
    if(from==-1) {
      break;
    }
    COLOR[from] = BLACK;
    for(to=0;to<n;to++){
      if(COLOR[to]!=BLACK && MATRIX[from][to]!=INFTY) {
        if(PATH[to]>MATRIX[from][to]){
          PATH[to] = MATRIX[from][to];
          PARENT[to] = from;
          COLOR[to] = GRAY;
        }
      }
    }
    sum = 0;
    for(i=0;i<n;i++){
      if(PARENT[i]!=-1){
        sum += MATRIX[i][PARENT[i]];
      }
    }
  }
  return sum;
}
  
  
int main() {
  int i, j, path;
  /* number of size */
  scanf("%d", &n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d", &path);
      if(path==-1){
        MATRIX[i][j] = INFTY;
      }else{
        MATRIX[i][j] = path;
      }
    }
  }
  
  printf("%d\n", prim());
  
  return 0;
}

Measured memory_bytes: 992
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}


double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	ll ans = 0;
	vector<ll> a(n);
	rep(i, n) scanf("%lld", &a[i]);
	rep(i, n - 1) {
		ans += max(0ll, a[i] - a[i + 1]);
		a[i + 1] = max(a[i], a[i + 1]);
	}
	printf("%lld\n", ans);

	Please AC;
}


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

using namespace std;

int main() {
	int K, S, X, Y, Z, cnt = 0;
	cin >> K >> S;
	for (auto i = 0; i <= K; i++) {
		for (auto j = 0; j <= K; j++) {
			if (i + j <= S && S <= i + j + K)
				cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
	long long a1;
	cin>>a>>b>>c;
	a1=a+b+c;
	if(a1>=22)
	cout<<"bust";
	else
	cout<<"win";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/

void go(){
    vi a;
    rep(i,1,5){
        int x;
        R(x);
        a.pb(x);
    }
    int ans=0;
    int mx=0;
    for(auto x:a){
        ans+=x;
        int w=x%10;
        if(w!=0){
            ans+=10-w;
            mx=max(mx,10-w);
        }
    }
    ans-=mx;
    W(ans);
}


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

int x[200005];
 

int main(){
    int N, K, a, ans=0;
    cin >> N >> K;

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

    sort(x, x+200005, std::greater<int>());
    
    for(int i =K; i < 200005; i++){
        if(x[i]==0) break;

        ans += x[i];

    }
    
    cout << ans << endl;

return 0;
}

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

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
    B.at(A.at(i)-1) = i+1;
  }
  
  for( int i = 0; i < N; i++ ){
    cout << B.at(i) << " ";
  }
  cout << " " << endl;
 
}

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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    if(t%1000==0)
    cout<<"0"<<"\n";
    else
    cout<<1000-(t%1000)<<"\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int X; cin  >> X;
int Xsuff = X%10 + (X/10)%10 * 10;// 下二桁
int Xpre = X / 100; //上2桁
int cnt = 0;
for (int i = 5; Xsuff > 0; --i){
    cnt += Xsuff /i;
    Xsuff %= i;
}
if (Xpre >= cnt) cout << "1\n";
else cout << "0\n";

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var a []int

	sc.Split(bufio.ScanWords)
	n := nextInt()

	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}

	var ans = -1

	for i := 0; ; i++ {
		for j := 0; j < len(a); j++ {
			if a[j]%2 == 1 {
				ans = i
				break
			}
			a[j] = a[j] / 2
		}
		if ans != -1 {
			break
		}
		// fmt.Printf("%v %v\n", i, a)
	}
	fmt.Printf("%v\n", ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
//#include <cassert>
//#include <array>
//#include <queue>
//#include <stack>
#include <vector>
//#include <map>
//#include <set>
#include <unordered_map>
//#include <unordered_set>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)

std::vector<int> sieve_of_eratosthenes(int n) {
	std::vector<int> primes(n + 1);
	for (int i = 2; i <= n; ++i)
		primes[i] = i;
	for (int i = 2; i*i <= n; ++i)
		if (primes[i])
			for (int j = i * i; j <= n; j += i)
				primes[j] = 0;
	return primes;
}

unsigned int pow_mod(unsigned long long x, unsigned int k, unsigned int mod) { //x^k (mod mod) 
	if (k == 0)     return 1;
	if (k % 2 == 0) return pow_mod(x*x % mod, k / 2, mod);
	else            return x * pow_mod(x, k - 1, mod) % mod;
}

unsigned int combination_mod_straightforward(unsigned int n, unsigned int r, unsigned int mod_prime) {
	if (r * 2 > n) r = n - r;
	unsigned long long numerator = 1;
	unsigned long long denominator = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		numerator *= n - i + 1;
		numerator %= mod_prime;
		denominator *= i;
		denominator %= mod_prime;
	}
	return (unsigned int)((numerator * pow_mod(denominator, mod_prime - 2, mod_prime)) % mod_prime);
}

#define MOD 1000000007
#define M_MAX 1000000000

using namespace std;

int N, M;
unordered_map<int, int> um;

void solve() {
	cin >> N >> M;

	vector<int> primes = sieve_of_eratosthenes((int)sqrt(M));
	for (int factor = 2; factor*factor <= M; factor++)
	{
		if (primes[factor] == 0) {
			continue;
		}
		if (M%factor == 0) {
			um[factor]++;
			M /= factor;
			if (M == 1) {
				break;
			}
			else {
				factor--;
			}
		}
	}
	if (M != 1) {
		um[M]++;
	}

	unsigned long long ans = 1;
	for (const auto &e : um) {
		ans *= combination_mod_straightforward(N - 1 + e.second, e.second, MOD);
		ans %= MOD;
	}

	cout << ans << endl;

	return;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)


int a, b;

int main() {
	cin >> a >> b;
	if (a > 8 || b > 8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}

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

int main(){
	int N;
  cin>>N;
  if(N<105)
    cout<<0<<endl;
  else if(N<135)
    cout<<1<<endl;
  else if(N<165)
    cout<<2<<endl;
  else if(N<189)
    cout<<3<<endl;
  else if(N<195)
    cout<<4<<endl;
  else
    cout<<5<<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main() {
    val n = readLine()!!.toInt()
    var count = 0
    for( i in 1..n) {
        for(j in 1..n){
            if(i * j <= n -1){
                count += 1
            }else{
                break
            }
        }
    }
    println(count)
}

Measured memory_bytes: 34652
from collections import deque
N = int(input())
A = list(map(int, input().split()))
d = deque()
for i in range(N):
  if N % 2 == 0:
    if i % 2 == 0: d.append(A[i])
    else: d.appendleft(A[i])
  else:
    if i % 2 == 0: d.appendleft(A[i])
    else: d.append(A[i])
print(*d)

Measured memory_bytes: 25532
/*
title:D - Good Grid

url:https://abc099.contest.atcoder.jp/tasks/abc099_d

問題がややこしいだけの問題
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int N, C;
    cin >> N >> C;
    int d[C][C];
    int c[N][N];

    for (int i = 0; i < C; i++)
        for (int j = 0; j < C; j++)
            cin >> d[i][j];

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cin >> c[i][j];
    //すべてC色に染めた時の、mod i の座標の違和感の合計を格納する
    int data[3][C];
    memset(data, 0, sizeof(data));
    for (int i = 0; i < C; i++)
    {
        for (int j = 0; j < N; j++)
        {
            for (int k = 0; k < N; k++)
            {
                data[(j + k) % 3][i] += d[c[j][k] - 1][i];
            }
        }
    }

    int ans = INF;
    for (int i = 0; i < C; i++)
    {
        for (int j = 0; j < C; j++)
        {
            for (int k = 0; k < C; k++)
            {
                if (i != j && j != k && k != i)
                    ans = min(ans, data[0][i] + data[1][j] + data[2][k]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include <stdio.h>
#define N 500000

int data[N+1], n;

void swap(int* i, int* b){
  int tmp = *i;
  *i = *b;
  *b = tmp;
}

void maxHeapify(a){
  int l = 2*a;
  int r = 2*a+1;
  int valM;
  
  if(l <= n && data[l] > data[a]) valM = l;
  else valM = a;
  
  if(r<=n && data[r] > data[valM]) valM = r;
  if(valM != a){
    swap(&data[a], &data[valM]);
    maxHeapify(valM);
  }
}

void buildMaxheap(){
  int a;
  
  for(a=n/2;a>0;a--) maxHeapify(a);
}

main(){
  int a;
  
  scanf("%d", &n);
  
  for(a=1;a<=n;a++) scanf("%d", &data[a]);
  
  buildMaxheap();
  for(a=1;a<=n;a++) printf(" %d", data[a]);
  printf("\n");
  
  return 0;
}



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

using namespace std;

int main()
{
    long long n;
    cin>>n;
    vector <long long> a(n);
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long q;
    cin>>q;
    for(long long i=0;i<q;i++)
    {
        long long k;
        cin>>k;
        cout<<lower_bound(a.begin(),a.end(),k)-a.begin()<<endl;
    }
    return 0;
}




Measured memory_bytes: 3548
use std::io::Write;
use std::cmp::*;

fn query(a: &[char]) -> usize {
    static mut CNT: usize = 0;
    unsafe {
        assert!(CNT < 850);
        CNT += 1;
    }
    let ask: String = a.iter().cloned().collect();
    println!("? {}", ask);
    std::io::stdout().flush().ok();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().unwrap()
}

fn run() {
    let op: Vec<char> = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890".chars().collect();
    let len = 128;
    assert!(op.len() == 26 + 26 + 10);
    let mut h = std::collections::BinaryHeap::new();
    let mut sum = 0;
    for c in op.iter().cloned() {
        let a = vec![c; len];
        let x = query(&a);
        if x < len {
            h.push(Reverse((len - x, vec![c; len - x])));
            sum += len - x;
        }
    }
    let sum = sum;
    while h.len() > 1 {
        let Reverse((x, a)) = h.pop().unwrap();
        let Reverse((y, mut s)) = h.pop().unwrap();
        let mut pos = 0;
        for (i, a) in a.into_iter().enumerate() {
            loop {
                s.insert(pos, a);
                if query(&s) == sum - i - 1 - y {
                    pos += 1;
                    break;
                } else {
                    s.remove(pos);
                    pos += 1;
                }
            }
        }
        h.push(Reverse((x + y, s)));
    }
    let Reverse((_, a)) = h.pop().unwrap();
    let ans: String = a.into_iter().collect();
    println!("! {}", ans);
}

fn main() {
    run();
}


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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

long N;

long count(int od, int n, vector<int> v, int flag){
  if( n < 0 ){
    if( flag != 7 ) return 0;
    long num = 0;
    long p = 1;
    for( int i=0; i<od; i++ ){
      num += v[i] * p;
      p *= 10;
    }
    if( N < num ) return 0;
    else return 1;
  }
  int ret = 0;
  v[n] = 3;
  ret += count(od, n-1, v, flag | 1);
  v[n] = 5;
  ret += count(od, n-1, v, flag | 2);
  v[n] = 7;
  ret += count(od, n-1, v, flag | 4);
  return ret;
}

int main()
{
  cin >> N;

  // 桁数
  int od = 0;
  for( long n=N; n != 0; ){
    n /= 10;
    od++;
  }

  long ret = 0;
  vi v(od);
  for( int i=3; i<=od; i++ ){
    ret += count(i, i-1, v, 0);
  }
  cout << ret << endl;

  return 0;
}



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

int main() {
  string s,t;
  string ans = "No";

  cin >> s >> t;

  if(s==t.erase(s.length())) {ans="Yes";}

  //cout << s << t.erase(s.length()) << endl;

  cout << ans <<endl;

  return 0;
}


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

int main()
{
	int n;
	char c;
	bool f = 0;

	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> c;
		if (c == 'Y')
			f = 1;
	}

	if (f)
		cout << "Four" << endl;
	else
		cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())

l = []
k = 0
for i in range(2**n):
	j = int(input())
	if i % 2 !=  0:
		l.append(max(k,j) - min(k,j))
	else:
		k = j

while len(l) != 1:
	ll = []
	for i in range(len(l)):
		j = l[i]
		if i % 2 != 0:
			ll.append(max(k,j) - min(k,j))
		else:
			k = j
	l = ll[:]
print(l[0])

Measured memory_bytes: 11360
# -*- coding: utf-8 -*-
N, M = map(int, input().split(' '))

p_ys = []
for _ in range(M):
    p, y = map(int, input().split(' '))
    p -= 1
    p_ys.append([p, y])

counts = [1 for _ in range(N)]
order_dicts = [{} for _ in range(N)]
for p, y in sorted(p_ys, key=lambda x: x[1]):
    order_dicts[p][y] = counts[p]
    counts[p] += 1

for p, y in p_ys:
    print('%06d%06d' % (p+1, order_dicts[p][y]))


Measured memory_bytes: 97496
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   int n;
   cin>>n;
   vector<int>a(n);
   map<int,int>ans;
   for(int i=0;i<n;i++)cin>>a[i];
   sort(a.begin(),a.end());
   int a_max=a[n-1];
   int a_min=a[0];
   for(int i=0;i<n;i++){
      if(a[i]==a_min){
         ans[i]=upper_bound(a.begin(),a.end(),a[i]+1)-lower_bound(a.begin(),a.end(),a[i]);
      }
      else if(a[i]==a_max){
         ans[i]=upper_bound(a.begin(),a.end(),a[i])-lower_bound(a.begin(),a.end(),a[i]-1);
      }
      else ans[i]=upper_bound(a.begin(),a.end(),a[i]+1)-lower_bound(a.begin(),a.end(),a[i]-1);
   }
   int ans_max=0;
   for(int i=0;i<n;i++){
      ans_max=max(ans_max,ans[i]);
   }
   cout<<ans_max<<endl;
   
   
}

Measured memory_bytes: 5376
#include<stdio.h>
int main()
{
	char s[3];
  	int c=0;
    int exit=0;
  	for(int i=0;i<3;i++){
    	scanf("%c",&s[i]);
    }
  
  	for(int i=0;i<3;i++)
    {
    	if(s[i]=='R')
      {   
        	for(int j=i;j<3;j++)
            {
            	if(s[j]=='R')
                  c=c+1;
              	else
                {
                	exit=1;
                    break;
                }
            }
            break;
        }
      	if(exit==1)	
          break;
    }
 printf("%d",c);
}


Measured memory_bytes: 1632
using System;
using System.Linq;

namespace Abc170
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] inputIntArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            for (int i = 0; i < inputIntArray.Length; i++)
            {
                if (inputIntArray[i] == 0)
                {
                    Console.WriteLine(i + 1);
                }
            }
        }
    }
}

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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int nxt[21][100000];

int f(int x, int s)
{
  int cur = s;
  for(int k = 20; k >= 0; k--){
    if(x & 1<<k){
      cur = nxt[k][cur]; 
    }
  }

  return cur;
}

signed main()
{
  int n, L, Q;
  cin >> n;

  vi x(n);
  rep(i, n) cin >> x[i];
  cin >> L >> Q;

  rep(i, n){
    nxt[0][i] = (upper_bound(all(x), x[i]+L)-x.begin())-1;
  }

  rep(i, 20) rep(j, n){
    nxt[i+1][j] = nxt[i][nxt[i][j]];
  }

  while(Q--){
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    a--; b--;

    int l = 0, r = 1<<20;
    while(r-l > 1){
      int m = (l+r)/2;
      if(f(m, a) >= b) r = m;
      else l = m;
    }

    cout << r << endl;
  }

  return 0;
}


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

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

using namespace std;

int main() {
  while(1){
    string a,b,c;
    cin>>a;
    if(a=="0")break;
    cin>>b>>c;
    reverse(begin(a),end(a));
    reverse(begin(b),end(b));
    reverse(begin(c),end(c));
    int n=a.size();
    vector<vector<int>> dp(n+1,vector<int>(2,0));
    dp[0][0] = 1;
    REP(i,n) {
      int m[10][10];
      REP(j,10)REP(k,10)m[j][k]=1;
      if(i==n-1)
        REP(j,10)
          m[0][j]=m[j][0]=0;
      if(a[i] != '?'){
        int ai= a[i]-'0';
        REP(j,10)REP(k,10) {
          if(j==ai)continue;
          m[j][k]=0;
        }
      }
      if(b[i] != '?'){
        int bi= b[i]-'0';
        REP(j,10)REP(k,10) {
          if(j==bi)continue;
          m[k][j]=0;
        }
      }
      vector<int> cv;
      if(c[i]!='?') {
        cv.push_back(c[i]-'0');
      } else {
        REP(j,10) cv.push_back(j);
      }
      for(int ci:cv){
        REP(j,10)REP(k,10){
          if(m[j][k]){
            if (j+k==ci) dp[i+1][0] += dp[i][0];
            dp[i+1][0] %= 1000000007;
            if (j+k+1==ci) dp[i+1][0] += dp[i][1];
            dp[i+1][0] %= 1000000007;
            if (j+k==ci+10) dp[i+1][1] += dp[i][0];
            dp[i+1][1] %= 1000000007;
            if (j+k+1==ci+10) dp[i+1][1] += dp[i][1];
            dp[i+1][1] %= 1000000007;
          }
        }
      }
    }
    cout<<dp[n][0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
N = int(input())
S = list(str(input()))

Alpha = ['A', 'B','C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
         'A', 'B','C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

S_index = []
for i in S:
    S_index.append(Alpha.index(i))
    
S_plus = map(lambda x: x + N, S_index)

output_w = []
for j in S_plus:
    output_w.append(Alpha[j])
    
answer = ''.join(output_w)
print(answer)

Measured memory_bytes: 3316
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if (l[i]+l[j]>l[k]) and (l[i]+l[k]>l[j]) and (l[j]+l[k]>l[i]) and (l[i]!=l[j]) and (l[j]!=l[k]) and (l[i]!=l[k]):
        ans+=1
print(ans)

Measured memory_bytes: 9212
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int main() {
  int n;
  while (scanf("%d", &n), n) {
    ll ans = -(1LL << 60);
    ll sum = 0;
    REP(i, n) {
      int v;
      scanf("%d", &v);
      ans = max(ans, (ll)v);
      sum += v;
      if (sum < 0) { sum = 0; }
      else { ans = max(ans, sum); }
    }
    printf("%lld\n", ans);
  }
}

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

vector<int> to[100005];
int n;

vector<int> dist;
void dfs(int v, int d=0, int p=-1) {
  dist[v] = d;
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u,d+1,v);
  }
}
vector<int> calcDist(int s) {
  dist = vector<int>(n);
  dfs(s);
  return dist;
}

int main() {
  cin >> n;
  int s, t;
  cin >> s >> t;
  --s; --t;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<int> distS = calcDist(s);
  vector<int> distT = calcDist(t);

  int mx = 0;
  rep(i,n) {
    if (distS[i] < distT[i]) {
      mx = max(mx, distT[i]);
    }
  }
  int ans = mx-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1e9 + 7;
constexpr int MAX = 510000;
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;
}
int main()
{
    COMinit();
    Int N, M, K; cin >> N >> M >> K;
    Int ans = 0;
    Int com = COM(N*M-2, K-2);
    for (int i = 1; i < N; i++) {
        ans = (ans + (N - i) * i * M % MOD * M % MOD * com) % MOD;
    }
    for (int i = 1; i < M; i++) {
        ans = (ans + (M - i) * i * N % MOD * N % MOD * com) % MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 12160
#include<iostream>
#include<cmath>
using namespace std;
int dp[100001]={-1};
int a[100001];
int n;
int f(int p)
{
	if(p==n-1)
		return 0;
	if(dp[p]!=-1)
		return dp[p];
	dp[p]=abs(a[p]-a[p+1])+f(p+1);
	if(p+2 < n)
		dp[p]=min(dp[p], abs(a[p]-a[p+2])+f(p+2));
	return dp[p];
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		dp[i] = -1;
	cout << f(0) << '\n';
}

Measured memory_bytes: 4224
#include <stdio.h>
#define ll long long
ll int GCD(ll int x, ll int y) {
	if (y == 0) return x;
	return GCD(y, x % y);
}

int factorize(ll int n) {
	ll int i;
	int cnt = 0;
	for (i = 2; i * i <= n; i++) {
		if (n % i != 0) {
			continue;
		}
		cnt++;
		while (n % i == 0) {
			n /= i;
		}
	}
	if (n != 1) cnt++;
	return cnt;
}

int main() {
	ll int A, B;
	ll int g;

	scanf("%lld %lld", &A, &B);

	g = GCD(A, B);
	printf("%lld", factorize(g) + 1);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 999999999999

int main(){
  string S;
  cin>>S;
  rep(i,S.size()){
    cout<<"x";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		System.out.println((x - a) % b);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#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,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,t;
    cin >> n >> t;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll mx = 0;
    ll nmx = a[n-1];
    rrep(i,n-1) {
        chmax(mx,nmx-a[i]);
        chmax(nmx,a[i]);
    }
    set<ll> se;
    int ans = 0;
    rrep(i,n) {
        if(se.count(a[i]+mx)) {
            ans++;
        }
        se.insert(a[i]);
    }
    set<ll> nse;
    int nans = 0;
    rep(i,n) {
        if(nse.count(a[i]-mx)) {
            nans++;
        }
        nse.insert(a[i]);
    }
    cout << min(ans,nans) << endl;
}


Measured memory_bytes: 10368
r,c=input().split()
r,c=[int(r),int(c)]
A=[0]*r
for i in range(r):
    A[i]=list(map(int, input().split()))
for i in range(r):
    sum1=0
    for j in range(c):
        sum1+=A[i][j]
    A[i].append(sum1)
b=[]
for i in range(c+1):
    sum2=0
    for j in range(r):
        sum2+=A[j][i]
    b.append(sum2)
for i in range(r):
    results=" ".join([str(m) for m in A[i]])
    print(results)
results2=" ".join([str(m) for m in b])
print(results2)


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

int main(int argc, char const *argv[])
{
	int m,k;
	cin>>m>>k;
	int n=1;
	for (int i = 0; i < m; ++i)
	{
		n*=2;
	}
	if (m==0)
	{
		if (k==0)
		{
			cout<<"0 0\n";
		}
		else
		{
			cout<<"-1\n";
		}
	}
	else if (m==1)
	{
		if (k==0)
		{
			cout<<"0 0 1 1\n";
		}
		else
		{
			cout<<"-1\n";
		}
	}
	else
	{
		if (k>=n)
		{
			cout<<"-1\n";
			return 0;
		}
		if (k==0)
		{
			cout<<1;
		}
		else if (k==1)
		{
			cout<<0;
		}
		else
		{
			cout<<"0 1";
		}
		for (int i = 2; i < n; ++i)
		{
			if (i!=k)
			{
				cout<<" "<<i;
			}
		}
		cout<<" "<<k;
		for (int i = n-1; i >= 0; --i)
		{
			if (i!=k)
			{
				cout<<" "<<i;
			}
		}
		cout<<" "<<k<<endl;
	}
	return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x = 0;
  int ans = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S.at(i) == 'I') {
      ++x;
    }
    if (S.at(i) == 'D') {
      --x;
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    static Scanner scanner;

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

        int N=gi();
        boolean[] f=new boolean[N];
        int[] A=new int[N];
        int[] B=new int[N];
        List<Pair<Integer, Integer>> tl=new ArrayList<Pair<Integer, Integer>>();

        long ans=0;
        for (int i=0; i<N;i++) {
            int a=gi();
            int b=gi();
            A[i]=a;
            B[i]=b;
            tl.add(new Pair<Integer, Integer>(a+b, i));
        }
        Collections.sort(tl, Collections.reverseOrder());

        long tv=0;
        long av=0;
        boolean tf=true;
        for (int i=0; i<N;i++) {
            if(tf) {
                tv+=A[tl.get(i).getValue()];
            	tf=false;
            } else {
            	av+=B[tl.get(i).getValue()];
            	tf=true;
            }
        }


        ans=tv-av;
        System.out.println(ans);
    }

    public static class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> implements Comparable<Pair<K, V>> {
        /** serialVersionUID. */
        private static final long serialVersionUID = 6411527075103472113L;

        public Pair(final K key, final V value) {
            super(key, value);
        }

        @Override
        public int compareTo(Pair<K, V> o) {

            Comparable key = (Comparable)this.getKey();
            Comparable key2 = (Comparable)o.getKey();

            return key.compareTo(key2);
        }

    }

    // 文字列として入力を取得
    public static String gs() {
         return scanner.next();
    }

    // intとして入力を取得
    public static int gi() {
         return Integer.parseInt(scanner.next());
    }

    // longとして入力を取得
    public static long gl() {
         return Long.parseLong(scanner.next());
    }

    // doubleとして入力を取得
    public static double gd() {
         return Double.parseDouble(scanner.next());
    }
}

Measured memory_bytes: 68164
#include<iostream>
using namespace std;
int main(){
  int n;  
  while(1){
    cin>>n;
    if(n==0)break;
    int a,c[100001];
    for(int i=0;i<n;i++){
      cin>>a;
      c[i]=a;
      int j=i-1;
      if(i%2==1)while(c[j]!=a&&j>=0)c[j]=a,j--;
      }
    a=0;
    for(int i=0;i<n;i++)if(c[i]==0)a++;
    cout<<a<<endl;  
  }
  return 0;
} 

Measured memory_bytes: 1548
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#define X first
#define Y second
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

const int N=1000010,mod=1e9+7;

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

int n,m;
LL ans;

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

	cin>>n>>m;
	
	ans+=n*(n-1)/2;
	ans+=m*(m-1)/2;
	
	cout<<ans<<endl;



















	return 0;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'a' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n, a, b, c;
int l[10];
int ans = INF;

int calc(string s) {
    int mp = 0;
    int cnt[3] = {};
    int suml[3] = {};
    rep(i, 0, s.size()) {
        int c = s[i] - '0';
        if (c == 3) continue;
        cnt[c]++;
        suml[c] += l[i];
    }
    rep(i, 0, 3) mp += (cnt[i] - 1) * 10;
    mp += abs(suml[0] - a) + abs(suml[1] - b) + abs(suml[2] - c);
    return mp;
}

bool is_ok(string s) {
    bool a, b, c;
    a = b = c = false;
    for (auto i : s) {
        if (i == '0') a = true;
        if (i == '1') b = true;
        if (i == '2') c = true;
    }
    return a && b && c;
}

void dfs(string s) {
    if ((int)s.size() == n) {
        if (is_ok(s)) {
            ans = min(ans, calc(s));
        }
        return;
    }
    rep(i, 0, 4) dfs(s + char(i + '0'));
}

int main() {
    cin >> n >> a >> b >> c;
    rep(i, 0, n) cin >> l[i];
    dfs("");
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

struct edge{int s,t,n;}e[4010];
int n,k,h[2010],siz[2010],dep[2010],f[2010][2010],ans;

void upd(int &x,int y){if (x<y)  x=y;}

void dfs(int x,int fa)
{
	siz[x]=1,dep[x]=0,f[x][0]=1;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=fa)
			{
				dfs(y,x);
				for (int j=dep[x]; j>=0; j--)
					{
						int _=f[x][j];
						for (int l=dep[y]; l>=0; l--)
							if (j+l<k)  upd(f[x][max(j,l+1)],_+f[y][l]);
					}
				siz[x]+=siz[y],dep[x]=max(dep[x],dep[y]+1);
			}
	for (int i=0; i<=dep[x]; i++)  upd(ans,f[x][i]);
}

void work()
{
	scanf("%d %d",&n,&k);
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v);
			e[++tot]=(edge){u,v,h[u]},h[u]=tot;
			e[++tot]=(edge){v,u,h[v]},h[v]=tot;
		}
	dfs(1,0);
	printf("%d",n-ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c[10];
  cin>>a>>b;
  c[0]=a*b;
  c[1]=a+b;
  c[2]=a-b;
  sort(c,c+3);
  cout<<c[2]<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

const int N = 2e5+5;

int a[N];

int n,k;

bool check(int mid){
    int need = 0;
    rep(i,1,n){
        need += (a[i] - 1) / mid;
    }
    return need <= k;
}

int main()
{
   IOS;
   cin >> n >> k;
   rep(i,1,n) cin >> a[i];
   //二分答案//
   int l = 1, r = 1e9;
   while(r - l > 1){
       int mid = (l + r) >> 1;
       if(check(mid)) r = mid;//mid越短  切的刀数🔪应该越多  我们想要mid越短越好
       else l = mid;
   }
   cout << (check(l) ? l : r);
}


Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,ans=0;cin>>n;
	for(ll i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0)continue;
		ans+=i;
	}
	
	cout<<ans;
}



Measured memory_bytes: 3620
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main
{
	public static void main (String[] arg)throws IOException
	{
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String line;
		while ((line = input.readLine()) != null && !line.isEmpty()) {
			double v1= Double.parseDouble(line);
			double v2=0;
			double y;
			int k=0;
			while(v2 < v1){
				k++;
				y=5*k-5;
				v2=9.8*Math.sqrt(y/4.9);
			}
			System.out.println(k);
		}
	}
}	
		

Measured memory_bytes: 16904
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import scipy as scp

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,x,y = map(int,input().split())

ans = [0 for _ in range(n)]

for i in range(1,n):
    for j in range(i+1,n+1):
        kyori = min(j-i,abs(x-i)+1+abs(y-j),abs(i-y)+1+abs(x-j))
        ans[kyori] +=1

print(*ans[1:],sep="\n")
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 12768
#include"bits/stdc++.h"
#define ll long long
#define inf 1e9
using namespace  std;

int main(){

	ll n,k;
	cin>>n>>k;

	ll h[n];

	for(ll i=0;i<n;i++){
		cin>>h[i];
	}	

	

	vector<ll> dp(n,inf);

	dp[0]=0;

	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<=i+k;j++){
			if(j<n){
				dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}

	cout<<dp[n-1]<<endl;

	return 0;
}

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

int main() {

	string p;

	cin >> p;

	if (p=="a"||p=="i"||p=="u"||p=="e"||p=="o") {
		cout << "vowel" << endl;
	}

	else{
		cout << "consonant" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
d_l = []
for i in range(len(x)-1):
    dif=x[i+1] - x[i]
    d_l.append(dif)
d_l.sort()
if n==1:
    print(sum(d_l))
else:
    print(sum(d_l[:-(n-1)]))

Measured memory_bytes: 56744
#include<iostream>
#include<string>
using namespace std;
int main(){
  bool flag = false;
  string s;
  cin >> s;
  for(int i = 0; i< 3; i++){
    if(s[i] == s[i+1]){
      flag = true;
      break;
    } 
  }
  if(flag){
    cout << "Bad";
  }else{
    cout << "Good";
  }
  return 0;
}  


Measured memory_bytes: 256
import itertools
if __name__ == '__main__':
  
  N = input()
  n = int(N)
  count = 0
  for i in range(0, len(N)):

    temp = itertools.product(["3", "5", "7"], repeat=i+1)
    for j in temp:
      s = "".join(j)
      
      if ("3" in s and "5" in s and "7" in s and int(s) <= n):
        count += 1
  
  print(count)

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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;

void partiu() {
    cout << "No" << endl;
    exit(0);
}
 
int main() {
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    s = "1" + s;
    for(int i = 1; i < s.size(); i++) {
        if(i&1) { if(s[i] != 'R' and s[i] != 'U' and s[i] != 'D') partiu(); }
        else if(s[i] != 'L' and s[i] != 'U' and s[i] != 'D') partiu();
    }
    cout << "Yes" << endl;
    return 0;
}



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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合.
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

signed main() {
    int a;
    cin >> a;
    cout << a + (a*a)+ (a*a*a) << endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	int N,K,X,Y;
	cin >> N >> K >> X >> Y;

	int ans;
	if (N >= K) ans = X * K + Y * (N-K);
	else ans = X* N;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256