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

int main(){
    int n,tmp=0;
    bool ok=true;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h.at(i);
    }
    reverse(h.begin(),h.end());
    for(int i=0;i<n;i++){
        if(i==0)tmp=h.at(i);
        else{
            if(tmp+1<h.at(i)){ok=false;break;}
            else{
                tmp=min(tmp,h.at(i));
            }
        }
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3772
h, w = map(int, input().split())

while not (h == 0 and w == 0):
    for i in range(h):
        if i == 0 or i == h - 1:
            print("".join(['#' for _ in range(w)]))
        else:
            a = ['.' for _ in range(w)]
            a[0] = a[-1] = '#'
            print("".join(a))

    print("")
    
    h, w = map(int, input().split())


Measured memory_bytes: 5624
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,child,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  ll K, A, B;
  cin >> K >> A >> B;
  if(B - A <= 2 || K - A <= 0){
    ll ans = K + 1;
    cout << ans << endl;
    return 0;
  }
  ll ans = 0;
  K -= A - 1;
  ans = A;
  if(K % 2){
    ans++;
    K--;
  }
  ans += (B - A) * (K / 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#単一始点最短経路問題
#負の辺があっても動作する

#最短経路を求める
#計算量O(N * M)

INF = 10 ** 15
#入力
N, M = map(int, input().split())

# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
    l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
    G += [[l-1, r-1, -s]] #有向グラフのときはここだけ


#メイン文
d = [INF] * N #最短距離を記録しておくリスト
# prev = [-1] * N
negative = [False] * N
#最短経路復元
def restore(g): #gまでの最短経路を復元
    path = []
    g -= 1 #0-indexに直す
    path.append(g)
    g = prev[g]
    count = 0
    while g != -1:
        # print ('C')
        path.append(g)
        g = prev[g]
        count += 1
        if count == N + 2:
            break
    path.reverse()
    return path

def shortest_path(s): #S番目の頂点から各頂点への最短距離を求める
    s -= 1
    for i in range(N):
        d[i] = INF
    d[s] = 0
    count = 0
    while count < N -1:
        count += 1
        # print ('A')
        # update = False
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                # update = True
                # prev[e[1]] = e[0]
        # if not update:
        #     return True

    count = 0
    while count < N:
        count += 1
        # print ('A')
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] == INF:
                continue
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                negative[e[1]] = True
            if negative[e[0]]:
                negative[e[1]] = True


#呼び出しスタート地点を入れる
shortest_path(1)
if not negative[N - 1]:
    print (-d[N - 1])
else:
    print ('inf')

# print (d)

Measured memory_bytes: 45292
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <vector>
const int inf=2147483647;
const int mo=1e9+7;
const int N=2005;
using namespace std;
int h[N],nex[N*2],to[N*2],dep[N],fa[N],fav[N],M;
void add(int a,int b){
    M++;
    to[M]=b;
    nex[M]=h[a];
    h[a]=M;
}
void dfs(int x){
    dep[x]=dep[fa[x]]+1;
    for(int i=h[x];i;i=nex[i]){
        if(to[i]!=fa[x]){
            fa[to[i]]=x;
            dfs(to[i]);
        }
    }
}
void col(int x,int y){
    if(dep[x]<dep[y])swap(x,y);
    while(dep[x]>dep[y]){
        fav[x]++;
        x=fa[x];
    }
    while(x!=y){
        fav[x]++;
        fav[y]++;
        x=fa[x];
        y=fa[y];
    }
}
struct rt{
    int x,y;
    rt(int a=0,int b=0){x=a;y=b;}
};
bool operator==(rt a,rt b){return a.x==b.x&&a.y==b.y;}
int d[2010],n;
vector<rt>solve(vector<rt>v){
    if(v.size()==0)return v;
    int x,u,i;
    for(x=1;x<=n;x++){
        if(d[x]==1)break;
    }
    if(x>n)return v;
    for(i=h[x];i;i=nex[i]){
        if(d[to[i]]){
            u=to[i];
            break;
        }
    }
    d[x]--;
    d[u]--;
    vector<rt>lx,nv;
    vector<int>id;
    int pos[2010];
    memset(pos,-1,sizeof(pos));
    for(i=0;i<(int)v.size();i++){
        if(v[i].x==x||v[i].y==x){
            lx.push_back(v[i]);
            id.push_back(i);
        }else{
            nv.push_back(v[i]);
            pos[i]=nv.size()-1;
        }
    }
    if(lx.size()==0)return solve(v);
    for(i=0;i+1<(int)lx.size();i+=2){
        if(lx[i].y==x)swap(lx[i].x,lx[i].y);
        if(lx[i+1].y==x)swap(lx[i+1].x,lx[i+1].y);
        if(lx[i]==lx[i+1]){
            if(v[id[i]]==v[id[i+1]])swap(v[id[i]].x,v[id[i]].y);
            continue;
        }
        nv.push_back(rt(lx[i].y,lx[i+1].y));
        pos[id[i]]=pos[id[i+1]]=nv.size()-1;
    }
    if(lx.size()&1){
        if(lx[lx.size()-1].y==x)swap(lx[lx.size()-1].x,lx[lx.size()-1].y);
        if(lx[lx.size()-1].y!=u){
            nv.push_back(rt(u,lx[lx.size()-1].y));
            pos[id[lx.size()-1]]=nv.size()-1;
        }
    }
    nv=solve(nv);
    for(i=0;i<(int)v.size();i++){
        if(pos[i]!=-1&&!(v[i].x==nv[pos[i]].x||v[i].y==nv[pos[i]].y))swap(v[i].x,v[i].y);
    }
    return v;
}
vector<rt>v;
int main(){
	//freopen("agc025e.in","r",stdin);
	//freopen("agc025e.out","w",stdout);
    int m,i,x,y,ans;
    scanf("%d%d",&n,&m);
    for(i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
        d[x]++;
        d[y]++;
    }
    dfs(1);
    for(i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        v.push_back(rt(x,y));
        col(x,y);
    }
    v=solve(v);
    ans=0;
    for(i=2;i<=n;i++)ans+=min(2,fav[i]);
    printf("%d\n",ans);
    for(rt t:v)printf("%d %d\n",t.x,t.y);
}

Measured memory_bytes: 56064
/*input
3
101 9901 999999000001
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+5;
ll arr[maxn];
int main(){
    int n;
    cin>>n;
    ll tot=1;
    REP(i,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    REP(i,n){
        ll x=arr[i];
        if(x==0){
            cout<<0;
            return 0;
        }
        if(tot>(INF64)/x){
            cout<<-1;
            return 0;
        }
        tot*=x;
    }
    if(tot>INF64){
        cout<<-1;
        return 0;
    }
    cout<<tot;
}


Measured memory_bytes: 4404
# -*- coding: utf-8 -*-
n = int(input())
p_list = list(map(int, input().split()))
counter = 0
for i in range(n-2):
    if p_list[i] < p_list[i+1] and p_list[i+1] < p_list[i+2]:
        counter += 1
    elif p_list[i] > p_list[i+1] and p_list[i+1] > p_list[i+2]:
        counter += 1

print(counter)

Measured memory_bytes: 3060
import math
a,b,x=map(int,input().split())

if x>a*a*b/2:
    h=(2*a*a*b-2*x)/(a*a)
    print(math.atan(h/a)*(180/math.pi))
else:
    h=2*x/(a*b)
    print(math.atan(b/h)*(180/math.pi))

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include<cstdio>
#include <iostream>
using namespace std;
int main() {
  int flag = 1;
  int flag2 = 1;
  int ans = 0;
  int c;
  int n;
  while ((c = getchar_unlocked()) >= '0') {
    n = c - '0';
    flag2 = flag;
    int n = c - '0';
    if (n < 4) {
      if (flag == -1) {
        ans += n + 1;
        flag = 1;
        continue;
      } else {
        ans += n;
        flag = 1;
        continue;
      }
    }
    else if (n > 5) {
      if (flag == 1) {
        ans += 10 - n;
        flag = -1;
        continue;
      }
      else {
        ans += 9 - n;
        flag = -1;
        continue;
      }
    } else if(n == 4) {
      if (flag == -1) {
        ans += 5;
        flag = 0;
        continue;
      }
      else {
        ans += 4;
        flag = 1;
        continue;
      }
    } else if (n == 5) {
      if (flag == 1) {
        ans += 5;
        flag = 0;
        continue;
      } else {
        ans += 4;
        flag = -1;
        continue;
      }
    }
  }
  if (n > 5 || (n == 5 && flag2 != 1)){
    ++ans;
  }
  printf("%d\n", ans);
  return 0;
}



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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        cout << "Possible" << '\n';
    else
        cout << "Impossible" << '\n';
}

Measured memory_bytes: 256
module Main where
import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
-- import qualified Data.Map as M
import Data.Ord
import Control.Monad


solve :: Int -> Int -> [(String, Int)] -> [(String, Int)]
solve n qt l = sim 0 initialQueue where
    sim ct qu = case S.viewl qu of
        S.EmptyL -> []
        ((name, run) S.:< ps) -> if run > qt
                                    then sim (ct + qt) (ps S.|> (name, run - qt))
                                    else (name, ct + run):sim (ct + run) ps
    initialQueue = S.fromList l

readLine :: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [(String, Int)]
readLines n = replicateM n readTupple where
    readTupple = do 
        [name, stRun] <- fmap words getLine
        return (name, read stRun)

print' :: [(String, Int)] -> IO ()
print' [] = return ()
print' ((n, t):xs) = do
    putStrLn $ n ++ ' ':show t
    print' xs

main :: IO() 
main = do
    [n, q] <- readLine
    l <- readLines n
    print' $ solve n q l



Measured memory_bytes: 26584
L, R = gets.chop.split.map(&:to_i)
 
min_mod = 2019
 
for i in L..R-1
  for j in i+1..R
    if min_mod > i*j % 2019
      min_mod = i*j % 2019
    end
    if min_mod == 0
      puts 0
      exit
    end
  end
end
 
puts min_mod

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e8
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')	c=getchar();}
	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();
	return t*f;
}
int n,x,four,two,odd;
int main()
{
	n=read();
	For(i,1,n)
	{
		x=read();
		if(x%4==0)	four++;
		if(x%4==2)	two++;
		if((x%4)&1)	odd++;
	}
	if(odd<=four||(odd<=four+1&&(!two)))	puts("Yes");	else	puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() 
{
	fastio
	//t_case
	{
		int n,m,q,ans=0,f=1,d,k,x,y,sum=0,h,w,black=0 ;
		cin>>h>>w>>k   ;
		string s[h]; take(s,h);
		fr(i,0,h) fr(j,0,w) if (s[i][j]=='#') black++;
		fr(i,0,pow(2,h)){
			int has[h][w],bit=0,cnt=0;
			memset(has,0,sizeof(has));
			while (bit<h){
				if ((i>>bit)&1)
					for (int j=0;j<w;j++){
						if (s[bit][j]=='#'){
						 	cnt++; has[bit][j]=1;
						}
					}
				bit++;
			}
			fr(j,0,pow(2,w)){
				bit=0; int cnt1=0;
				while(bit<w){
					if ((j>>bit)&1){
						for(int I=0;I<h;I++)
							if (s[I][bit]=='#' && !has[I][bit]){ 
								cnt1++;
							}
					}
					bit++;
				}
				if(black-cnt-cnt1==k) ans++;
			}
		} 
		cout<<ans;
		//cout<<endl;
	}
	return 0;
}



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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int d;
    cin >> d;
    if (d == 25)
        cout << "Christmas" << endl;
    else if (d == 24)
        cout << "Christmas Eve" << endl;
    else if (d == 23)
        cout << "Christmas Eve Eve" << endl;
    else if (d == 22)
        cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 3524
#include<iostream>

using namespace	std;

int main(void)
{
  int x,y; cin>>x>>y;
  int g[]={1,3,1,2,1,2,1,1,2,1,2,1};

  cout<<(g[x-1]==g[y-1]?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        Console.WriteLine(B * 2 - A);
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

long dp[1005][1005];
char charmap[1005][1005];
long MOD = 1000000007;

int main() {
    for(int i=0;i<1005;i++)for(int j=0;j<1005;j++)charmap[i][j]='.';

    int h,w;
    cin >> h >> w;
    
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        for(int j=0;j<w;j++){
            charmap[i+1][j+1]=s[j];
        }
    }

    for(int i=1;i<h+1;i++)for(int j=1;j<w+1;j++){
        if(i==1&&j==1)dp[i][j]=1;
        else if(charmap[i][j]!='#')dp[i][j]=dp[i-1][j]+dp[i][j-1];
        dp[i][j]=dp[i][j]%MOD;
    }

    cout << dp[h][w] << endl;

}


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


int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    REP(i, h){
        REP(j, w){
            cin >> a[i][j];
        }
    }
    
    vector<int> s(h), t(w);
    REP(i, h){
        int x = 0; int y = 0;
        REP(j, w){
            if (a[i][j] == '.') x++;
            //else if(a[i][j] == '#') y++;
        }
        if(x == w || y == w) s[i] = 0;
        else s[i] = 1;
    }

    REP(i, w){
        int x = 0; int y = 0;
        REP(j, h){
            if (a[j][i] == '.') x++;
            //else if(a[j][i] == '#') y++;
        }
        if(x == h || y == h) t[i] = 0;
        else t[i] = 1;
    }

    int c = 0; int d = 0;
    REP(i, h){
        if(s[i] == 1) c++;
    }
    REP(i, w){
        if(t[i] == 1) d++;
    }

    if(c + d == 0){
        cout << "\n";
    }else {       
        REP(i, h){
            bool skip = false;
            REP(j, w){
                if(s[i] != 0 && t[j] != 0){
                    cout << a[i][j];
                }else if (s[i] == 0){
                    skip = true;
                }
            }

            if (skip){
                skip = false;
            }else {
                cout << "\n";
            }
        }
    }
    
}


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

import heapq

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, m = rli()
    ll = []
    for _ in range(n):
        a, b = rli()
        ll.append((a, b))
    ll.sort()
    pq = []
    l = 0
    ans = 0
    for i in range(1, m+1):
        while l < len(ll) and ll[l][0] <= i:
            heapq.heappush(pq, -ll[l][1])
            l += 1
        if len(pq) > 0:
            ans -= heapq.heappop(pq)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprev(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    int n, q, q1, q2, q3;
    string s;
    cin >> s;

    if (s[0] == s[1] && s[1] == s[2])
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

    // compute
    int ans = 1;
    int tmp = 0;
    vector<int> l(N);
    for (int i = 1; i <= N; i++){
        int t = i;
        int cnt = 0;
        while(1){
            if (t%2 == 0) {
                cnt++;
                t = t / 2;
            }
            else{
                break;
            } 
        }
        l.push_back(cnt);
        int max = *max_element(l.begin(), l.end());
        if (max > tmp) {
            tmp = max;
            ans = i;
        }
    }
    
    // output
    cout << ans << endl;
    
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
int tenp[]={1,10,100,1000,10000,100000,1000000};
int digit(int n){
    int cnt=0;
    while(n){
        n/=10;
        cnt++;
    }
    return cnt;
}
int n;
int c[10][10];
int ans=0;
signed main(){
    cin>>n;
    REP(i,1,n+1){
        int a=i/(tenp[digit(i)-1]),b=i%10;
        c[a][b]++;
    }
    
    REP(i,1,10){
        REP(j,1,10){
            ans+=c[i][j]*c[j][i];
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
program ABC122B
    implicit none
    integer i,j,ans,Slen,flg
    character(10)::S
    read*,S
    Slen=len_trim(S)
    ans=0
    do i=1,Slen
        if(S(i:i)=="A".or.S(i:i)=="C".or.S(i:i)=="G".or.S(i:i)=="T")then
            flg=0
            do j=i+1,Slen
                if(S(j:j)/="A".and.S(j:j)/="C".and.S(j:j)/="G".and.S(j:j)/="T")then
                    !if(j-i>ans)print'(i0,1x,i0)',i,j
                    flg=1
                    ans=max(ans,j-i)
                    exit
                end if
            end do
            if(flg==0)ans=max(ans,Slen-i+1)
        end if
    end do
    print'(i0)',ans
end program ABC122B

Measured memory_bytes: 2896
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI=3.14159265358979323846;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  sort(A.begin(),A.end());
  rep(i,N-1){
    if(A[i+1]-A[i]==0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(b - a == c - b) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
    int i=1;
    while(i<10)
    {
        for(int a=1;a<10;a++)
        {    
            
        cout<<i<<"x"<<a<<"="<<i*a<<endl;
            
        }
    i=i+1;
    }
}

Measured memory_bytes: 3044
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

//最大公約数
template<class T>
T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}



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

	vector<int> dp(n, 0);
	dp[0] = 0; dp[1] = abs(h[1] - h[0]);

	for (int i = 2; i < n; i++)
	{
		dp[i] = min(abs(h[i - 1] - h[i]) + dp[i-1], abs(h[i - 2] - h[i]) + dp[i-2]);
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{

//整数値の入力
int n,m;
cin >> n>>m;
int honsu[10]={-1,2,5,5,4,5,6,3,7,6};
int table[m]={};
for (int i = 0; i < m; ++i) {
    cin >> table[i];
}
vector<int> dp(n+10,-100000);
dp[0]=0;
sort(table,table+m);
for (int i = 0; i < n; ++i) {
for (int j = m-1; j >-1; --j) {
    dp[i+honsu[table[j]]]=max(dp[i]+1,dp[i+honsu[table[j]]]);
}
}

//cout << dp[n];
int use=0;
while(use<n){
   // cout << use;
for(int j = m-1; j >-1; --j) {
    if(dp[n-use-honsu[table[j]]]==dp[n-use]-1&&n-use-honsu[table[j]]>-1){
        use=use+honsu[table[j]];
        cout << table[j];
        break;
        }
}
}



return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000007
using namespace std;

int main()
{ 
  fast;
  string s;
  cin>>s;
  ll n=s.size();
    ll dp[n+1][13];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;

    for(ll i=1;i<=n;i++)
      {
        if(s[i-1]=='?')
       {
         for(ll j=0;j<13;j++)
          for(ll k=0;k<10;k++)
            dp[i][(10*j+k)%13]=(dp[i][(10*j+k)%13]+dp[i-1][j])%mod;
       }
      else 
      {
        ll val=s[i-1]-48;
        for(ll j=0;j<13;j++)
            dp[i][(10*j+val)%13]=( dp[i][(10*j+val)%13]+ dp[i-1][j])%mod;
      }
      }

     cout<<dp[n][5]<<endl;

  }

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

int main(){
      int n;cin >> n;
      int t, a;cin >> t >> a;
      int curr = 0;
      int minn = INT_MAX;
      for(int i = 0;i < n;i++){
            int k;cin >> k;
            if(abs((t * 1000 - k * 6) - a * 1000) < abs(minn - a)){
                  curr = i + 1;
                  minn = abs((t*1000 - k * 6) - a * 1000);
            }
      }
      cout << curr;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

n,x0=map(int,input().split())
x=list(map(int,input().split()))

if n==1:
    print(abs(x[0]-x0))
    exit()

x.append(x0)
x.sort()
dis=[]
for i in range(1,n+1):
    dis.append(x[i]-x[i-1])

def gcd(number_list):
    return reduce(fractions.gcd, number_list)

print(gcd(dis))


Measured memory_bytes: 16276
#include<bits/stdc++.h>
using namespace std;
double c(int i){return double(i+1)/2;}

int main(){
  int n,k; cin >>n >>k;
  vector<int>a(n);
  for(int i=0; i<n; i++) cin >>a[i];
  vector<double>b(n+1,0); b[0]=a[0];
  for(int i=0; i<n; i++) b[i+1]=b[i]+c(a[i]);
  double ans=0;
  for(int i=0; i<n-k+1; i++) ans=max(b[i+k]-b[i],ans);
  cout <<fixed<<setprecision(10)<<ans;
return 0;}

Measured memory_bytes: 2560
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0

ans = "No"
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0:
    ans = "Yes"
print(ans)

Measured memory_bytes: 3192
from collections import deque

N = int(input())
edges = [[] for _ in range(N)]
edge_index = {}
ab = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(N-1)]
for i, (a, b) in enumerate(ab):
    edges[a].append(b)
    edges[b].append(a)
    edge_index[(a, b)] = edge_index[(b, a)] = i
# print(edges)

max_degree = 0
root = 0
for i in range(N):
    if len(edges[i]) > max_degree:
        max_degree = len(edges[i])
        root = i

color = [-1]*(N-1)
visited = [False]*N
visited[root] = True

stack = deque()  # (vertex, color_index)
for i, to in enumerate(edges[root]):
    color[edge_index[(root, to)]] = i+1
    visited[to] = True
    stack.append((to, i+1))

while stack:
    v, v_col = stack.pop()
    color_condidate = 0
    for to in edges[v]:
        assert color_condidate <= max_degree, "hello"
        if visited[to]:
            continue
        visited[to] = True
        color_condidate += 1
        if color_condidate == v_col:
            color_condidate += 1
        idx = edge_index[(v, to)]
        color[idx] = color_condidate
        stack.append((to, color_condidate))

print(max_degree)
print(*color, sep='\n')


Measured memory_bytes: 60972
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){
  ll int N;
  string S;
  char a;
  cin >> N >> S;

  ll int len;
  len = (ll int)(S.size());
  for(int i=0;i<len;i++){
        S[i]= (S[i]+N);
	if (S[i]>'Z'){
		S[i]=S[i]-26;
	}
	  cout << S[i];
  }












	return 0;

}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()


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

		int operand[4];
		for (int i = 0; i < s.size(); i++) {
				operand[i] = s[i] - '0';
		}

		for (int p_or_m = 0; p_or_m < (1<<3); p_or_m++) {
				int t = operand[0];
				char op[3];
				for (int i = 0; i < 3; i++) {
						if (p_or_m & (1<<i)) {
								t += operand[i+1];
								op[i] = '+';
						} else {
								t -= operand[i+1];
								op[i] = '-';
						}
				}
				if (t == 7) {
						for (int i = 0; i < 3; i++) {
								cout << operand[i] << op[i];
						}
						cout << operand[3] << "=7" << endl;
						return 0;
				}
		}
		
		return 0;
}


Measured memory_bytes: 256
def MI(): return map(int, input().split())
H,W,K=MI()
Map=[input() for _ in range(H)]
ans=0
from itertools import product
for gyou in list(product([0,1],repeat=H)):
  for retsu in list(product([0,1],repeat=W)):
    cnt=0
    for i in range(H):
      for j in range(W):
        if gyou[i]==1 and retsu[j]==1:
          if Map[i][j]=='#':
            cnt+=1
    if cnt==K:
      ans+=1
print(ans) 

Measured memory_bytes: 9208
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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


int main() {
    int a, b;
    
    cin >> a >> b;
    a--;b--;
    
    string s[105];
    REP(i, 100){
        if(i % 2 == 0){
            REP(j, 99){
                s[i] += '.';
            }
            s[i] += '#';
        }
        else{
            s[i] += '.';
            for(int j = 1; j < 100; j++){
                s[i] += '#';
            }
        }
    }
    
    for(int i = 0; i < 100; i += 2){
        for(int j = 1; j < 98; j += 2){
            if(a > 0){
                s[i][j] = '#';
                a--;
            }
            else{
                break;
            }
        }
        if(a == 0)break;
    }
    
    for(int i = 99; i >= 0; i -= 2){
        for(int j = 98; j > 1; j -= 2){
            if(b > 0){
                s[i][j] = '.';
                b--;
            }
            else{
                break;
            }
        }
        if(b == 0)break;
    }
    
    cout << 100 << ' ' << 100 << endl;
    REP(i, 100){
        REP(j, 100){
            cout << s[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k;
	cin>>n>>k;
	ll a[1001];
	ll s[1001];
	s[0]=0;
	for(int i=1; i<=n; i++){
		cin>>a[i];
		s[i]=s[i-1]+a[i];
	}
	vector<ll> v;
	for(int i=1; i<=n; i++){
		for(int j=0; j<i; j++){
			v.push_back(s[i]-s[j]);
		}
	}
	bool nuee[600000]={};
	ll ans=0;
	for(int i=41; i>=0; i--){
		int c=0;
		for(int j=0; j<v.size(); j++){
			if(nuee[j]) continue;
			if((v[j]&(1ll<<i))!=0){
				c++;
			}
		}
		if(c<k) continue;
		ans+=(1ll<<i);
		for(int j=0; j<v.size(); j++){
			if((v[j]&(1ll<<i))==0){
				nuee[j]=1;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

int n,a,b;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> a >> b;
    if((a-b)%2) cout << "Borys";
    else cout << "Alice";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>

#include<stdio.h>
#include<stdlib.h>

#define ll long long

using namespace std;

int main(){
    string S;
    cin >> S;
    for(int i=0;i<S.size();i+=2){
        cout << S[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
use proconio::{
    input,
    marker::{Chars, Usize1},
};

fn main() {
    input! {
        n: usize,
        k: Usize1,
        mut s: Chars,
    }
    match s[k] {
        'A' => s[k] = 'a',
        'B' => s[k] = 'b',
        'C' => s[k] = 'c',
        _ => println!("Input Error"),
    }
    println!("{}", s.into_iter().collect::<String>());
}

Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    int thp, tatk, ahp, aatk;
    scan4Int(thp, tatk, ahp, aatk);
    bool flag = false;
    while(thp > 0 && ahp > 0) {
        flag = !flag;
        if (flag) {
            ahp -= tatk;
        } else {
            thp -= aatk;
        }
    }
    if (thp <= 0) 
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 3696
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;


int main(){
    int n;
    scanf("%d", &n);
    vector<pair<int, int> > v;
    for(int i = 1 ; i <= n ; ++i){
        int x;
        scanf("%d", &x);
        v.emplace_back(x, i);
    }
    sort(v.begin(), v.end());
    for(auto i : v)printf("%d ", i.second);
}

Measured memory_bytes: 1780
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d,n,lank=1;
  cin >> n;

  int p[n],P[n],number[n];
  for(int i=0;i<n;i++){
    p[i]=0;
    number[i]=i+1;
  }

  for(int i=0;i<n*(n-1)/2;i++){
    cin >> a >> b >> c >> d;
    if(c>d){
      p[a-1]+=3;
    }
    else if(d>c){
      p[b-1]+=3;
    }
    else{
      p[a-1]++;
      p[b-1]++;
    }
  }


  //順位付け
  for(int i = 0 ; i < n-1 ; i++ ){
    for(int j = n - 1 ; j > i ; j-- ){
      if(p[j] > p[j-1]){
	swap(p[j],p[j-1]);
	swap(number[j],number[j-1]);
      }
    }
  }

    //cout << lank << endl;
  int tmp = 0;
  for(int i=0;i<n;i++,lank++){
    if(i && p[i-1] == p[i]) tmp++;
    else tmp = 0 , lank = i + 1 ;
    //cout << lank - tmp << endl;
    P[i]=lank-tmp;
  }

  for(int i = 0 ; i < n-1 ; i++ ){
    for(int j = n - 1 ; j > i ; j-- ){
      if(number[j] < number[j-1]){
	swap(number[j],number[j-1]);
	swap(P[j],P[j-1]);
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << P[i] << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string n;
  cin >> n;
  long long sum = 0;
  
  for(long long i = 0; i<(long long)n.length(); i++){
    sum += (int)(n[i] - '0');
  }
  
  if(sum%9==0){
	  cout << "Yes" << endl;
  }else{
	  cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3728
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    map<string, ll> m;

    REP(i, N) {
        string s; cin >> s;
        sort(ALL(s));

        m[s]++;
    }

    ll ans = 0;
    for(auto &p: m) {
        ans += p.se * (p.se - 1) / 2;
    }

    print(ans);
    
}


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

using namespace std;

int main(){
    int N,M;
    int Aij,K;

    cin>>N>>M;
    M++;
    int A[M]={0};

    for(int i=0;i<N;i++){
        cin>>K;
        for(int i=0;i<K;i++){
            cin>>Aij;
            A[Aij]++;
        }
    }

    int count =0;
    for(int i=1;i<=M;i++){
        if(A[i]==N)count++;
    }

    cout<<count;

}

Measured memory_bytes: 256
import math

def InputData():
    
    sequence_len = int(input())
    sequence = list(map(int, input().split(" ")))

    return sequence_len, sequence

def merge(sequence, left, mid, right):
    global merge_cnt
    n1 = mid - left
    n2 = right - mid
    sequence_left = sequence[left:left + n1]
    sequence_right = sequence[mid:mid + n2]
    sequence_left.append(float('inf'))
    sequence_right.append(float('inf'))

    left_cnt = 0
    right_cnt = 0
    for i in range(left, right):
        merge_cnt += 1
        if sequence_left[left_cnt] <= sequence_right[right_cnt]:
            # print(sequence_left[left_cnt])
            sequence[i] = sequence_left[left_cnt]
            left_cnt += 1
        else:
            # print(sequence_right[right_cnt])
            sequence[i] = sequence_right[right_cnt]
            right_cnt += 1

def mergeSort(sequence, left, right):
    if left + 1 < right:
        # print(merge_cnt)
        mid = (left + right) // 2
        mergeSort(sequence, left, mid)
        mergeSort(sequence, mid, right)
        merge(sequence, left, mid, right)

def PrintOut(sequence, merge_cnt):
    print(' '.join( map(str, sequence)))
    print(merge_cnt)

def main():
    global merge_cnt
    [sequence_len, sequence] = InputData()
    merge_cnt = 0
    mergeSort(sequence, 0, sequence_len)
    PrintOut(sequence, merge_cnt)

if __name__=="__main__":
    main()




Measured memory_bytes: 70500
def main():
    n = int(input())
    hs = list(map(int, input().split()))

    for i in range(n - 1):
        if hs[i] < hs[i + 1]:
            hs[i + 1] -= 1

    answer = 'Yes'
    for i in range(n - 1):
        if hs[i] > hs[i + 1]:
            answer = 'No'
            break

    print(answer)


main()

Measured memory_bytes: 14396
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<string>
#include<deque>
typedef long long ll;
#define PB	push_back
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define print(mes)		cout << mes << endl
const double PI	 = 3.141592;
const int	 MOD = 1e9 + 7;
using namespace std;

void solve() {
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for(int i = 1; i < n; ++i) ans += i;
	for(int i = 1; i < m; ++i) ans += i;
	cout << ans << endl;
}

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

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,x,l;
    in>>n;
    vector<pair<int,int>> p(n);
    for(auto&c:p){
        in>>x>>l;
        c=make_pair(x+l,x-l);
    }
    sort(p.begin(),p.end());
    int cnt=0,nw=-1e9-1;
    fr(i,n){
        if(nw<=p[i].second){
            ++cnt;
            nw=p[i].first;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
int n,j,tmp,flag=1;
int count=0;

scanf("%d",&n);
int A[n];

for(j=0; j<n; j++){
  scanf("%d",&A[j]);
}

while(flag){
  flag=0;
for(j=n-1; j>=1; j--){
  if(A[j]<A[j-1]){
    tmp=A[j];
    A[j]=A[j-1];
    A[j-1]=tmp;
    flag=1;
    count++;
  }
}

}

for(j=0; j<n; j++){
if(j!=n-1) printf("%d ",A[j]);
else {
  printf("%d",A[j]);
}
}
printf("\n");
printf("%d\n",count);

return 0;
}



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

int i1,i2;char ch;
inline int read()
{
	i1=i2=ch=0;
	while(!isdigit(ch))	i1|=ch=='-',ch=getchar();
	while(isdigit(ch))	i2=(i2<<1)+(i2<<3)+(ch^48),ch=getchar();
	return i1? -i2:i2;
}

int main()
{
	int n=read(),t=read(),a=read();
	
	double minn=0x3f3f3f3f;
	int minid;
	
	int h;
	for(int i=1;i<=n;i++)
	{
		h=read();
		if(fabs(1.000*t-0.006*h-1.000*a)<minn)
		minn=fabs(1.000*t-0.006*h-1.000*a),minid=i;
//		cerr<<minn<<endl;
	}
	
	printf("%d\n",minid);
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
B - *e**** ********e* *e****e* ****e**
https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_b

"""
import sys


def solve(N, S, K):
    ch = S[K-1]
    ans = [['*', s][ch==s] for s in S]
    return ''.join(ans)


def main(args):
    N = int(input())
    S = input()
    K = int(input())
    ans = solve(N, S, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main(){
    long long a, b;
    cin >> a >> b;

    if (a*b <= 0){
        cout << "Zero" << endl;
        return 0;
    }

    if(a > 0 && b > 0){
        cout << "Positive" << endl;
        return 0;
    }

    if(a < 0 && b < 0){
        if((b-a+1)%2 == 0){
            cout << "Positive" << endl;
            return 0;
        }else{
            cout << "Negative" << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
	int a, b, c;

	std::cin >> a >> b >> c;

	if (a != b || b != c || a != c) {
		std::cout << "No" << std::endl;
		return 0;
	}

	std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;


int main() {
	char a;
	cin >> a;
	if (0 <= a - 'a' && a - 'a' < 26) {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}

	
}


Measured memory_bytes: 3560
N,M = map(int,input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

check = False

for i in range(N-M+1):
  for j in range(N-M+1):
    if A[i][j:j+M] == B[0]:
      flag = True
      for k in range(1,M):
        if A[i+k][j:j+M] != B[k]:
          flag = False
      if flag:
        check = True

print("Yes" if check else "No")

Measured memory_bytes: 9224
a=list(map(int,input().split()))
i,j=a[2]-a[0],a[3]-a[1]
i,j=-j,i
x3,y3=a[2]+i,a[3]+j
i,j=-j,i
x4,y4=x3+i,y3+j
print(x3,y3,x4,y4)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
bool is_prime(int n){
    bool flag=true;
    if(n==1)flag=false;
    else if(n==2)flag=true;
    else{
      FOR(i,2,sqrt(n)+1){
        if(n%i==0)flag=false;
      }
    }
    return flag;
}
int main(){
  int n;cin>>n;
  vector<pair<int,int>> v;
  rep(i,n){
    int a,b;cin>>a>>b;
    v.push_back(make_pair(a,b));
  } 
  vector<int> che(100001);
  che[0]=0;
  rep(i,100000){
    if(is_prime(i+1)&&is_prime((i+2)/2))che[i+1]=che[i]+1;
    else che[i+1]=che[i];
  }
  //rep(i,100)cout<<che[i]<<endl;
  rep(i,n){
    cout<<che[v[i].S]-che[v[i].F-1]<<endl;
  }
}

Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  in(s);
  rep(i, s.size() - 1){
    if(s[i] == s[i + 1]){
      out(i + 1);
      hina;
      out(i + 2);
      memi;
      return 0;
    }
  }
  rep(i, s.size() - 2){
    if(s[i] == s[i + 2]){
      out(i + 1);
      hina;
      out(i + 3);
      memi;
      return 0;
    }
  }
  out(-1);
  hina;
  out(-1);
  memi;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
  ans+=min(a[i],b[i])
  if b[i]-a[i]>0:
    ans+=min(b[i]-a[i],a[i+1])
    a[i+1]-=min(b[i]-a[i],a[i+1])
print(ans)

Measured memory_bytes: 97560