akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y,z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endlhttps:  // stopwatch.onl.jp/#
#endif
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(c-a+b,0);
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		int dist[][] = new int[h][w];
		boolean visit[][] = new boolean[h][w];

		char[][] board = new char[h][w];
		Deque<Point> queue = new ArrayDeque<Point>();
		for(int i = 0; i < h; i++){
			char[] input = sc.next().toCharArray();
			for(int j = 0; j < w; j++){
				board[i][j] = input[j];

				if(input[j] == '#'){
					queue.add(new Point(j, i));
					visit[i][j] = true;
					dist[i][j] = 0;
				}
			}
		}

		int dx[] = {0,1,0,-1};
		int dy[] = {1,0,-1,0};
		while(!queue.isEmpty()){
			Point p = queue.removeFirst();

			for(int i = 0; i < 4; i++){
				int tmpX = p.x + dx[i];
				int tmpY = p.y + dy[i];

				if(tmpX >= 0 && tmpX < w && tmpY >= 0 && tmpY < h && !visit[tmpY][tmpX]){
					visit[tmpY][tmpX] = true;
					dist[tmpY][tmpX] = dist[p.y][p.x] + 1;
					queue.add(new Point(tmpX, tmpY));
				}
			}
		}

		int result = 0;

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				result = Math.max(result, dist[i][j]);
			}
		}

		System.out.println(result);

	}
}

class Point {
	int x, y;

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

Measured memory_bytes: 73696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+7;
int a1[N],a2[N],a3[N];
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	for(int i=0;i<a;i++){
		cin>>a1[i];
	}
	for(int i=0;i<b;i++){
		cin>>a2[i];
	}
	for(int i=0;i<c;i++){
		cin>>a3[i];
	}
	ll sum = 0;
	sort(a1,a1+a,greater<int>()); sort(a2,a2+b,greater<int>() ); sort(a3,a3+c,greater<int>() );
	for(int i=0;i<x;i++){
		sum += a1[i];
	}
	for(int i=0;i<y;i++){
		sum += a2[i];
	}
	int i=x-1,j=y-1,k = 0;
	while(1){
		int t = k;
		if(i<0&&j<0||k>=c) break;
		if(i<0){ 
			if(a2[j]<a3[k]){
				sum = sum + a3[k] - a2[j];
				j--; k++;
			}		
		}
		else if(j<0){
			if(a1[i]<a3[k]){
				sum = sum + a3[k] - a1[i];
				i--; k++;
			}
		}
		else{
			if(a1[i] <= a2[j]&&a1[i]<a3[k]){
				sum = sum + a3[k] - a1[i];
				i--; k++;
			}
			else if(a2[j] <= a1[i]&&a2[j]<a3[k]){
				sum = sum + a3[k] - a2[j];
				j--; k++;
			}
		}
		if(t==k) break;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 4832
//
//  select_half.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;


int main(int argc, const char* argv[]) {

  int n;
  std::cin >> n;
  ll a[n];
  ll dp[n][2]; // 0: n/2, 1: n/2+1
  for (int i=0; i<n; i++) {
    std::cin >> a[i];
  }
  dp[2][0] = max(a[0], a[1]);

  if (n > 2) {
    dp[3][0] = max(dp[2][0], a[2]);
    dp[3][1] = a[0] + a[2];
    for (int i=4; i<=n; i++) {
      if (i%2 == 0) {
        dp[i][0] = max(dp[i-1][1], a[i-1] + dp[i-2][0]);
      }
      else {
        dp[i][0] = max(dp[i-1][0], a[i-1] + dp[i-2][0]);
      }
      if (i%2 == 1) {
        dp[i][1] = a[i-1] + dp[i-2][1];
      }
    }
  }
  // std::cout << dp[3][1] << std::endl;
  std::cout << dp[n][0] << std::endl;

  return 0;
}


Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin >> n;
		int a[n+1];
		rep(i,1,n+1) cin >> a[i];
		int dp[n+1][n+1];
		rep(i,0,n+1){
			rep(j,0,n+1) dp[i][j] = INF;
		}
		int cum[n+1];
		cum[0]=0;
		rep(i,1,n+1) cum[i] = cum[i-1]+a[i];
		rep(i,1,n+1) dp[i][i] =0;
		rep(i,1,n) dp[i][i+1] = a[i]+a[i+1];
		rep(gap,1,n){
			rep(i,1,n-gap+1){
				int j = i+gap;
				rep(k,i,j) dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]+cum[j]-cum[i-1]);
			}
		}
		// trace(dp[1][2],dp[3][4],dp[1][3]);
		cout<<dp[1][n];
	}
}

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


void solve(long long int N,std::vector<long long int> enemy,std::vector<long long int> grad){
    long long int kill=0,b=0;
    for(long long int i=0;i<N;i++){
        b=std::min(enemy[i],grad[i]);
        grad[i]-=b;
        kill+=b;;
        b=std::min(enemy[i+1],grad[i]);
        enemy[i+1]-=b;
        kill+=b;
    }
    printf("%lld",kill);
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    long long int N=0;
    std::cin>>N;
    std::vector<long long int> A(N+1),B(N);
    for(long long int i=0;i<N+1;i++)std::cin>>A[i];
    for(long long int i=0;i<N;i++)std::cin>>B[i];
    solve(N,A,B);
    return 0;
}


Measured memory_bytes: 3456
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] d = new int[n];
		for(int i = 0; i < n; i++){
		    d[i] = sc.nextInt();
		}

		// 計算
	    int result = 0;
	    for(int i = 0; i < n; i++){
		    for(int j = i + 1; j < n; j++){
		        result += d[i]*d[j];
		    }
		}

		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <bits/stdc++.h>
using namespace  std;
const int N=200005;
long long arr[N];
int main() {
 
 
 
 long long n;
 int maxi=0;
 int index;
 vector<int>vc;
 cin>>n;
multiset<int>ls;
 for(int i=0;i<n;i++) {
     cin >> arr[i];
    vc.push_back(arr[i]);
 }
 sort(vc.begin(),vc.end());
 int k=vc[vc.size()-1];
 int k2=vc[vc.size()-2];
 
 
for(int i=0;i<n;i++) {
 
if(arr[i]==k)cout<<k2<<endl;
else cout<<k<<endl;
 
 
 
 
}
 
 
 
 
    return 0;
}

Measured memory_bytes: 4084
import sys
import math
import numpy as np
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = list(s())
print(S.count('1'))

Measured memory_bytes: 26956
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int N;
  int a[100001];
  cin >> N;
  Rep(i, N) {
    cin >> a[i]; a[i]--;
  }

  int cnt = 0;
  Rep(i, N) {
    if( i == a[a[i]] ) cnt++;
  }

  cout << cnt / 2 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  string s;
  cin>>s;
  ll sum=0,w=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='W'){
      sum+=i;
      w++;
    }
  }
  cout<<sum-w*(w-1)/2<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long ans;
int n,fa[100003],r[100003];
pair<int,int> a[100003],x[100003],y[100003];
priority_queue <pair<int,pair<int,int> > > q;
int find_fa(int x){
	if(fa[x]==x) return x;
	return fa[x]=find_fa(fa[x]);
}
void uni(int x,int y){
	x=find_fa(x);
	y=find_fa(y);
	if (r[x]<r[y]) fa[x]=y;
	else{
		fa[y]=x;
		if(r[x]==r[y]) r[x]++;
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++) fa[i]=i;
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
		x[i]={a[i].first,i};
		y[i]={a[i].second,i};
	}
	sort(x,x+n);
	sort(y,y+n);
	for(int i=0;i<n-1;i++){
		q.push({-(x[i+1].first-x[i].first),{x[i].second,x[i+1].second}});
		q.push({-(y[i+1].first-y[i].first),{y[i].second,y[i+1].second}});
	}
	while(q.size()){
		int c=-q.top().first,p1=q.top().second.first,p2=q.top().second.second;
		if(find_fa(p1)!=find_fa(p2)){
			uni(p1,p2);
			ans+=c;
		}
		q.pop();
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7540
def change(s):
    ans = []
    for i in s:
        if i== "0":
            ans.append("1")
        else:
            ans.append("0")
    return "".join(ans)

n = int(input())
s = input()
MOD = 998244353

# 重複込みで数える
a = [0] * (n+1)
for i in range(1, n + 1):
    if n % i == 0:
        a[i] += int(s[0:i], 2)
        a[i] %= MOD
        si = int(s[0:i])
        change_si = int(change(s[0:i]))
        for j in range(n // i):
            if j % 2 == 0:
                if si < int(s[j*i:(j+1)*i]):
                    a[i] += 1
                    break
                if si > int(s[j*i:(j+1)*i]):
                    break
            else:
                if change_si < int(s[j*i:(j+1)*i]):
                    a[i] += 1
                    break      
                if change_si > int(s[j*i:(j+1)*i]):
                    break 
        else:
            a[i] += 1

# 約数包除で重複を除く
for i in range(1, n + 1):
    for j in range(2*i, n + 1, i):
        if n % j == 0:
            a[j] -= a[i]

# b:有効周期
b = []
ans = 0
for i in range(1, n+1):
    if n % i == 0:
        if (n // i) % 2 == 1: 
                b.append(i)

#周期の重みを足し合わせる
for i in range(1, n+1):
    if n % i == 0:
        for tmp in b:
            if tmp % i == 0:
                ans += a[i] * 2*tmp
                ans %= MOD
                break
          
print(ans % MOD)



Measured memory_bytes: 80668
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H, W;
    scanf("%d %d",&H,&W);
    
    int i,j;
    while (1)
    {
        if (H == 0 && W == 0) {
            break;
        }
        else
        {
            for (i=1; i<H+1; i++)
            {
                for (j=1; j<W+1; j++) {
                    if (i%2 == 1 && j%2 == 0) {
                        printf(".");
                    }
                  
                   else if (i%2 == 0 && j%2 == 1) {
                        printf(".");
                   }
                   else {
                       printf("#");
                   }
                }
                printf("\n");
            }
            printf("\n");
            scanf("%d %d",&H,&W);
        }
    }
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define fr(a, b, c) for(int a = b, __ = c; a < __; a++)
#define dbg(x) cerr << ">>>>> " << x << endl;
#define _ << " , " <<

using namespace std;

typedef long long ll;

const ll mod = ll(1e9) + 7;

int main(){
	ios::sync_with_stdio(0);
	ll a, b;
	cin >> a >> b;
	ll ma, mb;
	ma = min(a, b), mb = max(a, b);
	if(mb - ma > 1){
		cout << 0 << endl;
		return 0;
	}
	else{
		ll ans = 1;
		fr(i, 0, ma){
			ans = (ans * (i+1))%mod;
		}
		fr(i, 0, mb){
			ans = (ans * (i+1))%mod;
		}
		if(ma == mb){
			ans = (ans*2)%mod;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    int N, L, S = 0;
    int maxL = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> L;
        S += L;
        if (maxL < L) maxL = L;
    }

    if (maxL < S - maxL) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

	ll t, i, x, j, y, 	z, k, n;
	cin >> n >> k;
	z = 0;

	rep(i, 0, n, 1) {
		cin >> x >> y;
		t = x * x + y * y;
		t = ceil(sqrt(t));
		if (t <= k)z++;
	}


	debug(z);
	ce(z);
}



Measured memory_bytes: 3728
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import qualified Data.Vector as V
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x
--------------------------------------------------------------
tsort xs = reverse $ map reverse $ sort  $ map (reverse) xs
alt :: Int -> [Int] -> Bool
alt k an = if k <= (head an) then True else False
bgt k an = if (an !! 1) >= k then True else False
ans :: [[Int]] -> [[Int]] -> Int
ans xn [] = 0
ans [] yn = 0
ans (x:xn) (y:yn) = if a >= c
                    then ans xn (y:yn)
                    else if null mn == False
                         then 1 + ans xn (reverse (sort ( (y:yn) \\ [head mn]) ))
                         else ans xn (y:yn)
                           where a = x !! 0
                                 b = x !! 1
                                 c = y !! 0
                                 d = y !! 1
                                 mn = reverse $ tsort $ filter (bgt b) $ filter (alt a) (y:yn)

main = do
    n <- readLn :: IO Int
    ab <- map ((map bsreadInt . BC.words)) <$> replicateM n BC.getLine
    cd <- map ((map bsreadInt . BC.words)) <$> replicateM n BC.getLine
    
    print $ ans (reverse (sort ab)) (reverse (sort cd))
    

Measured memory_bytes: 1020
import java.util.*;

public class Main {
    static long MOD = 1000000007;

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

        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Map<Integer, Integer> numCount = new HashMap<>();
        Set<Integer> potentialX = new HashSet<>();

        for(int ai: a) {
            int count = numCount.getOrDefault(ai, 0) + 1;
            numCount.put(ai, count);
            potentialX.add(ai - 1);
            potentialX.add(ai);
            potentialX.add(ai + 1);
        }

        int maxCount = -1;
        for(int x: potentialX) {
            int count = numCount.getOrDefault(x - 1, 0)
                    + numCount.getOrDefault(x, 0)
                    + numCount.getOrDefault(x + 1, 0);
            maxCount = Math.max(maxCount, count);
        }

        System.out.println(maxCount);
    }
}

Measured memory_bytes: 68768
#include <iostream>

using namespace std;
#define h 100100

int t[h];

int main()
{
    int n;
    cin >> n;
    int i = 1;
    while(n --)
    {
        cin >> t[i];
        i ++;
    }
    int m;
    cin >> m;
    while(m --)
    {
        int p, x;
        cin >> p >> x;
        int c;
        c = t[p];
        t[p] = x;
        int sum = 0;
        for(int j = 1; j < i; j ++)
        {
            sum += t[j];
        }
        cout << sum <<endl;
        t[p] = c;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> //tuple<ll,ll,ll>
#define pr(x) cout << x << endl;
using namespace std;

int main(){
  int n; cin >> n;
  vector<vector<int> > f(n);
  rep(i,n)rep(j,10){
    int tmp; cin >> tmp;
    f[i].push_back(tmp);
  }
  vector<vector<int> > p(n);
  rep(i,n)rep(j,11){
    int tmp; cin >> tmp;
    p[i].push_back(tmp);
  }

  int ans=-INF;

  int ma=pow(2,10);
  for(int i=1; i<ma; i++){
    int ti=i;
    vector<int> eigyou(10,0);
    rep(j,10){
      if(ti%2==1) eigyou[j]++;
      ti/=2;
    }
    int bnf=0;
    rep(j,n){
      int cnt=0;
      rep(k,10){
        if(f[j][k]==1 && eigyou[k]==1) cnt++;
      }
      bnf+=p[j][cnt];
    }
    ans=max(ans,bnf);
  }

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


Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	if(y>x) swap(x,y);
	if(z>x) swap(x,z);
	if(z>y) swap(y,z);
	int ans=(x-y);
	z+=(x-y);
	y=x;
	ans+=(x-z)/2;
	if((x-z)%2==1) ans+=2;
	printf("%d",ans);
	return 0;
}

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

int N, Q, s[1000000];
vector< int > Student;
multiset< int > Leader;

char Query[10];
int a;

main()
{
  scanf("%d %d", &N, &Q);
  Student.resize(N);
  for(int i = 0; i < N; ++i) {
    scanf("%d", &Student[i]);
    s[i] = Student[i];
  }
  sort(Student.begin(), Student.end());
  while(Q--) {
    scanf("%s %d", Query, &a);
    if(Query[0] == 'A') { // "ADD"
      Leader.insert(s[--a]);
    } else if(Query[0] == 'R') { // "REMOVE"
      Leader.erase(Leader.find(s[--a]));
    } else { // "CHECK"
      int Lower = 0, Upper = 1 << 30;
      while(Lower < Upper) {
        int Mid = Lower + Upper >> 1, Lost = 0;
        vector< int >::iterator last = Student.begin();
        for(multiset< int >::iterator it = Leader.begin(); it != Leader.end() && last != Student.end(); ++it) {
          Lost += lower_bound(last, Student.end(), *it - Mid) - last;
          last = upper_bound(last, Student.end(), *it);
        }
        Lost += Student.end() - last;
        if(Lost <= a) Upper = Mid;
        else Lower = Mid + 1;
      }
      if(Lower == 1 << 30) cout << "NA" << endl;
      else cout << Lower << endl;
    }
  }
}

Measured memory_bytes: 8860
/*author @dhanush*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first
ll MOD = 1e9 + 7;
vector<ll>adj[100005];
ll col[100005];
ll vis[100005];
ll temp;
void dfs(ll n)
{
  vis[n] = 1;
  temp = min(col[n], temp);
  for (auto x : adj[n])
  {
    if (!vis[x])
    {
      dfs(x);
    }
  }
}
void icchhipadey()
{

  ll n;
  cin >> n;
  ll cnt = 0;
  bool ok = 0;
  for (int i = 0; i < n; i++)
  {
    ll a, b;
    cin >> a >> b;
    if (a == b)
    {
      cnt++;
    }
    else
    {
      cnt = 0;
    }
    if (cnt >= 3)
    {
      ok = 1;
    }
  }
  if (ok)cout << "Yes" << endl;

  else
    cout << "No" << endl;

}


int main()
{


  icchhipadey();
}









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

int main(void){
    int N,L;
    cin >> N >> L;
    string S[N];
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    sort(S,S+N);
    for(int i=0;i<N;i++){
        cout << S[i];
    }
    cout << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,c,k;
    IN(n,c,k);
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    sort(all(t));
    ll ans = 0;
    // 乗せる人の添字の範囲
    ll left = 0;
    ll right = 0;
    while(right < n){
        while(right-left+1<c && right < n-1 && t[right+1] <= t[left]+k) right++;
        ans++;
        left = right+1;
        right++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
#define house 4
#define floor 3
#define room 10
 
int main()
{
  short people[house][floor][room] = {{{0}}};
  short n;
 
  fscanf(stdin, "%hd", &n);
 
  short i, b, f, r, v;
  for (i = 0; i < n; i++) {
    fscanf(stdin, "%hd %hd %hd %hd", &b, &f, &r, &v);
    people[b - 1][f - 1][r - 1] += v;
  }
     
  short j, k;
  for (i = 0; i < house; i++) {
    for (j = 0; j < floor; j++) {
      for (k = 0; k < room; k++) {
    if (k < room) {
      putchar(' ');
    }
    fprintf(stdout, "%hd", people[i][j][k]);
      }
      putchar('\n');
    }
    if (i < house - 1) {
      fprintf(stdout, "####################\n");
    }
  }
     
  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  vector<int> sum(N),ans(N);
  if(S.at(0)=='W')
    sum.at(0)=1;
  else
    sum.at(0)=0;
  for(int i=1;i<N;i++){
    if(S.at(i)=='W')
      sum.at(i)=sum.at(i-1)+1;
    else
      sum.at(i)=sum.at(i-1);
  }
  ans.at(0)=(N-1)-(sum.at(N-1)-sum.at(0));
  ans.at(N-1)=sum.at(N-2);
  for(int i=1;i<N-1;i++){
    ans.at(i)=sum.at(i-1)+(N-i-1)-(sum.at(N-1)-sum.at(i));
  }
  sort(ans.begin(),ans.end());
  cout<<ans.at(0)<<endl;
}


Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


ll cal(int a, int b, int x, int y){
  int res = 0, w = x - a, h = y - b;
  if(w * h > 0)return max(abs(w), abs(h));
  return abs(w) + abs(h);
}

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int3(w, h, n);
    int res = 0;
    int a, b, x, y;
    scanf("%d %d", &a, &b); --n;
    for(;n--;){
      scanf("%d %d", &x, &y);
      res += cal(a, b, x, y);
      a = x; b = y;
    }
    pri(res);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3152
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int l[9];
int how[9];
int how2[9];

int main(){
    int n,aa,bb,cc;
    cin >>n>>aa>>bb>>cc;
    rep(i,n){
        cin >> l[i];
    }
    ll ANS=INF;
    
    rep(i,1<<(2*n+1)){
        ll ans=0;
        vector<int> a,b,c,d;
        rep(j,n){
            how[j]=(i>>(2*j))&1;
            how2[j]=(i>>(2*j+1))&1;
            //cerr<<how2[j]<<how[j]<<endl;
            if(how[j]==0&&how2[j]==0){
                continue;
            }else if(how[j]==1&&how2[j]==0){
                a.push_back(j);
            }else if(how[j]==0&&how2[j]==1){
                b.push_back(j);
            }else if(how[j]==1&&how2[j]==1){
                c.push_back(j);
            }
        }
        int A=a.size();
        int B=b.size();
        int C=c.size();
        //cerr<<A<<' '<<B<<' '<<C<<endl;
        if(A==0||B==0||C==0){
            continue;
        }
        ans+=10*(A+B+C-3);
        int tempa=0;
        int tempb=0;
        int tempc=0;
        rep(j,A){
            tempa+=l[a[j]];
        }
        rep(j,B){
            tempb+=l[b[j]];
        }
        rep(j,C){
            tempc+=l[c[j]];
        }
        ans+=abs(tempa-aa);
        ans+=abs(tempb-bb);
        ans+=abs(tempc-cc);
        cerr<<i<<' '<<ans<<endl;
        ANS=min(ANS,ans);
    }
    cout<<ANS<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
    int main()
    {
        int a,b,c;
        // 整数の入力
        scanf("%d", &a);
        b=0;
        c=a;
        while(a!=0){
        b= b+ a%10;
        a = a/10;
        }
        c=  c % b;
        if(c==0){
        printf("Yes\n");
        }else{
        printf("No\n");
        }
        // 出力
        return 0;
    
    }

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        print(0)
    else:
        l = sorted([A, B, C])
        print(l[0] * l[1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
//#define inf 1000000000000000000
using namespace std;
ll mod=1000000000000000001;
bool check(string a){
    if(a.size()>19) {
        //cout<<'t';
        return true;
    }
    else if(a.size()<19)return  false;
    else{
        for(int i=0; i<a.size(); i++){
            if(i==0){
                if(a[i]>'1'){
                    //cout<<'y';
                    return true;
                }
            }
            else if(a[i]>'0'){
                //cout<<'n';
                return true;
            }
        }
    }
    return false;
}
string multiply(string num1, string num2) 
{ 
    int len1 = num1.size(); 
    int len2 = num2.size(); 
    if (len1 == 0 || len2 == 0) 
    return "0"; 
  
    // will keep the result number in vector 
    // in reverse order 
    vector<int> result(len1 + len2, 0); 
  
    // Below two indexes are used to find positions 
    // in result.  
    int i_n1 = 0;  
    int i_n2 = 0;  
      
    // Go from right to left in num1 
    for (int i=len1-1; i>=0; i--) 
    { 
        int carry = 0; 
        int n1 = num1[i] - '0'; 
  
        // To shift position to left after every 
        // multiplication of a digit in num2 
        i_n2 = 0;  
          
        // Go from right to left in num2              
        for (int j=len2-1; j>=0; j--) 
        { 
            // Take current digit of second number 
            int n2 = num2[j] - '0'; 
  
            // Multiply with current digit of first number 
            // and add result to previously stored result 
            // at current position.  
            int sum = n1*n2 + result[i_n1 + i_n2] + carry; 
  
            // Carry for next iteration 
            carry = sum/10; 
  
            // Store result 
            result[i_n1 + i_n2] = sum % 10; 
  
            i_n2++; 
        } 
  
        // store carry in next cell 
        if (carry > 0) 
            result[i_n1 + i_n2] += carry; 
  
        // To shift position to left after every 
        // multiplication of a digit in num1. 
        i_n1++; 
    } 
  
    // ignore '0's from the right 
    int i = result.size() - 1; 
    while (i>=0 && result[i] == 0) 
    i--; 
  
    // If all were '0's - means either both or 
    // one of num1 or num2 were '0' 
    if (i == -1) 
    return "0"; 
  
    // generate the result string 
    string s = ""; 
      
    while (i >= 0) 
        s += std::to_string(result[i--]); 
  
    return s; 
} 
 string numtostr(ll n){
     string ans="";
     while(n>0){
         ll rem=n%10;
         ans+=(char)(rem+'0');
         n/=10;
     }
     reverse(ans.begin(),ans.end());
     return ans;
 }

int main(){
    int n;
    cin>>n;
    ll arr[n];
    string mul="1";
    for(int i=0; i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0; i<n;i++){
        string tmp=numtostr(arr[i]);
        //cout<<tmp<<endl;
        mul=multiply(mul,tmp);
        if(check(mul)==true){
            //cout<<mul<<endl;
            cout<<-1<<endl;
            return 0;
        }
    }
   // cout<<mul<<" "<<mul2<<endl;
    cout<<mul<<endl;
    return 0;
}

Measured memory_bytes: 4480
n,m=map(int,input().split())
nl=[list(map(int,input().split())) for _ in range(n)]
ml=[list(map(int,input().split())) for _ in range(m)]
ans=[]

for nll in nl:
  c=0
  ii=1
  for i,mll in enumerate(ml):
    cc = abs(nll[0]-mll[0])+abs(nll[1]-mll[1])
    if i == 0:
      c = cc
      continue
    
    if c > cc:
      ii = i+1
      c = cc
    
  ans.append(ii)
  
[print(x) for x in ans]

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string s, t;
    cin >> s >> t;
    int  r = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]){
            r++;
        }
    }
    cout << r;
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int tar = in.nextInt();
		int cnt = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					int tot = 500 * i + 100 * j + 50 * k;
					if(tot == tar)
						cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 21716
// ALDS 1_9_B
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;

void maxHeapify(vector<int> &btree, int i){
	int largest = i;

	if(2*i < btree.size())
		if(btree[2*i] > btree[i])
			largest = 2*i;

	if(2*i+1 < btree.size())
		if(btree[2*i+1] > btree[largest])
			largest = 2*i+1;

	if(largest != i){
		int temp = btree[i];
		btree[i] = btree[largest];
		btree[largest] = temp;

		maxHeapify(btree, largest);
	}
}

void buildMaxHeap(vector<int> &btree){
	for(int i=(btree.size()-1)/2;i>=1;i--)
		maxHeapify(btree, i);
}

int main(){
	int H;
	vector<int> btree;

	cin>>H;
	btree.resize(H+1);

	for(int i=1;i<=H;i++)
		cin>>btree[i];

	buildMaxHeap(btree);
	
	for(int i=1;i<btree.size();i++)
		cout<<" "<<btree[i];
	cout<<endl;

	return 0;
}

Measured memory_bytes: 3116
import sys
input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def main():
    n, m = map(int, input().split())
    bridges = list(readlines(m))

    tree = list(range(n+1))
    rank = [1] * (n+1)

    def root(v):
        while tree[v] != v:
            tree[v] = tree[tree[v]]
            v = tree[v]
        return v

    fuben = n*(n-1)//2

    for a, b in bridges[::-1]:
        x = root(a)
        y = root(b)

        if x == y:
            yield str(fuben)
            continue
        
        yield str(fuben)
        fuben -= rank[x]*rank[y]

        if rank[x] < rank[y]:
            tree[x] = y
            rank[y] += rank[x]
        else:
            tree[y] = x
            rank[x] += rank[y]

print("\n".join(reversed(list(main()))))


Measured memory_bytes: 29228
import itertools
import math
N = int(input())
A = []
ans = 0
t = 0
for _ in range(N):
  a = list(map(int,input().split()))
  A.append(a)
def D(x0,y0,x1,y1):
  d = math.sqrt((x1-x0)**2+(y1-y0)**2)
  return d

r = []
for i in range(N):
  r.append(i)

for row in itertools.permutations(r,N):
  t += 1
  for i in range(N-1):
    p = row[i]
    q = row[i+1]
    x0,y0 = A[p]
    x1,y1 = A[q]
    ans += D(x0,y0,x1,y1)

print(ans/t)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size

int main(void){
	int i;
	string s[5];
	for(i=0; i<3; ++i){
		cin >> s[i];
		cout << s[i][i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
for i in range(3500):
    for j in range(3500):
        if 4*i*j-n*(i+j)>0 and n*i*j%(4*i*j-n*(i+j))==0:
            print(i,j,n*i*j//(4*i*j-n*(i+j)))
            exit()

Measured memory_bytes: 9144
from collections import deque
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H,W = map(int,readline().split())
maze = []
for _ in range(H):
    maze += [list(readline().rstrip().decode())]

visited = [[-1]*W for _ in range(H)]
def bfs():
    queue = deque([[0,0]])
    visited[0][0] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [H-1, W-1]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <= new_y < H and \
                0 <= new_x < W and\
                maze[new_y][new_x] == "." and \
                visited[new_y][new_x] == -1: #通ったことがないかどうかの判定
                
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    return -1 #ゴールにたどり着けない場合、-1を返す






res = bfs()
if res == -1:
    print(-1)
else:
    count = 0
    for i in range(H):
        for j in range(W):
            if maze[i][j] == ".":
                count += 1

    print(count-res-1)

Measured memory_bytes: 40304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;
const int MOD = INF + 7;

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

    vector<ll> cnt(N + 2);
    cnt[0] = 1;
    ll ans = 0;
    for (int i = 1; i <= N + 1; ++i) {
        cnt[i] = cnt[i - 1] - (i - 1) + (N - i + 1);
    }

    for (int i = K; i <= N + 1;++i){
        ans += cnt[i];
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//示例：#define ll long long
//unsigned long long ;
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int k, a, b, x;
	cin >> k >> a >> b;
	x=k;
	while(k<=b){
		if(k>=a && k<=b){
			cout<<"OK"<<endl;
			return 0;
		}
		k+=x;
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin, a, b;
    cout << a * (a - 1) / 2 + b * (b - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAXN = 500005;
using pi = pair<int, lint>;

int n, a, b;

vector<int> gray(int n){
	if(n == 0) return {0};
	auto x = gray(n - 1);
	for(auto &i : x) i <<= 1;
	vector<int> ret = x;
	for(int i=0; i<x.size(); i++){
		ret.push_back(x[x.size() - i - 1] ^ 1);
	}
	return ret;
}

int main(){
	cin >> n >> a >> b;
	int dst = (a ^ b);
	vector<int> v;
	for(int i=0; i<n; i++){
		if((a ^ b) & (1 << i)){
			v.push_back(i);
		}
	}
	if(v.size() % 2 == 0){
		puts("NO");
		return 0;
	}
	auto ans = gray(n - v.size() + 1);
	for(int i=0; i<(v.size() - 1) / 2; i++){
		vector<int> nxt;
		for(auto &j : ans) j <<= 2;
		nxt.push_back(ans[0]);
		nxt.push_back(ans[0] ^ 1);
		nxt.push_back(ans[0] ^ 3);
		nxt.push_back(ans[0] ^ 2);
		for(int j=1; j<ans.size()/2; j++){
			nxt.push_back(ans[2*j-1] ^ 2);
			nxt.push_back(ans[2*j-1] ^ 3);
			nxt.push_back(ans[2*j-1] ^ 1);
			nxt.push_back(ans[2*j-1]);
			nxt.push_back(ans[2*j]);
			nxt.push_back(ans[2*j] ^ 1);
			nxt.push_back(ans[2*j] ^ 3);
			nxt.push_back(ans[2*j] ^ 2);
		}
		nxt.push_back(ans.back() ^ 2);
		nxt.push_back(ans.back());
		nxt.push_back(ans.back() ^ 1);
		nxt.push_back(ans.back() ^ 3);
		ans = nxt;
	}
	// first v.size() bits are flip, other stay
	for(int j=v.size()-1; j>=0; j--){
		int cur = v[j], nxt = j;
		for(auto &k : ans){
			int bit1 = (k >> cur) & 1;
			int bit2 = (k >> nxt) & 1;
			k ^= (bit1 << cur);
			k ^= (bit2 << nxt);
			k ^= (bit1 << nxt);
			k ^= (bit2 << cur);
		}
	}
	for(auto &i : ans) i ^= a;
	puts("YES");
	for(auto &i : ans) printf("%d ", i);
}


Measured memory_bytes: 1732
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        S: String,
        T: String,
    }

    println!("{}{}", T, S);
}


Measured memory_bytes: 2116
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class Dijkstra{
	using Point = pair<ll,ll>;
	vector<ll> dist;
public:
	void CalcShortestPath(int start,ConnectNodeInfo& connect){
		dist.resize(connect.size(),1LL<<60);
		dist[start] = 0;

		priority_queue<Point,vector<Point>,greater<Point>> Q;
		Q.emplace(0,start);
		while(!Q.empty()){
			auto p = Q.top();
			Q.pop();
			int v = p.second;
			if(dist[v]<p.first){
				continue;
			}
			for(auto e:connect[v]){
				if(dist[e.first]>dist[v]+e.second){
					dist[e.first] = dist[v]+e.second;
					Q.emplace(dist[e.first],e.first);
				}
			}
		}
	}
	ll GetDistance(int i){
		return dist[i];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	ConnectNodeInfo connect(N);

	REP(i,N-1){
		int a=in()-1,b=in()-1,c=in();
		connect.AddNonDirectionalConnection(a,b,c);
	}
	int Q=in(),K=in()-1;
	Dijkstra Dij;
	Dij.CalcShortestPath(K,connect);
	LOOP(Q){
		int x=in()-1,y=in()-1;
		out(Dij.GetDistance(x)+Dij.GetDistance(y));
	}
	return 0;
}


Measured memory_bytes: 11120
// #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
//#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

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

  int N, K, Q, temp;
  cin >> N >> K >> Q;

  vector<int> point(N, K - Q);
  for (int i = 0; i < Q; i++) {
    cin >> temp;
    point[--temp]++;
  }

  for (int i = 0; i < N; i++) {
    if (point[i] <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int mx = 0;
    ll ans = 0;
    rep(i, n) {
        if (a[i]>=mx) mx = a[i];
        else {
            ans += mx-a[i];
            debug(i, mx-a[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3948
s = gets.chomp
t = gets.chomp
n = s.length
a = []
key = 0
(0..(n-1)).each do |i|
  if s[i] != t[i]
    if a.include?(s[i]) || a.include?(t[i])
      key = 1
      break
    else
      s = s.gsub(s[i], "1").gsub(t[i], s[i]).gsub("1", t[i])
      a.push(s[i])
    end
  end
end
puts key == 0 ? "Yes" : "No"



Measured memory_bytes: 8000
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

S = F.readline().rstrip()
N = int(len(S) - 1)
sum = 0
l = [0]

# pdb.set_trace()
for bit in range(1<<N):
    for i in range(N):
        if bit & (1<<i):
            l.append(i+1)

    l.append(int(N+1))
    l_length = len(l)
    for j in range(l_length):
        if j == 0:
            continue
        ss = S[(l[j-1]):(l[j])]

        sum += int(ss)

    l = [0]


print(sum)


Measured memory_bytes: 52336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
vector<ll> memo;
int main() {
  int n;
  cin >> n;
  memo.resize(n + 40, 0);

  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      memo[j]++;
    }
  }

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (ll)i * memo[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 81276