akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<int> v(in());
	for (int &x: v)
		x = in();
	auto s = v.begin();
	for (int q = in(); q; q--) {
		int b = in(), m = in();
		rotate(s + b, s + m, s + in());
	}
	out(v);
}


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

using namespace std;
typedef long long ll;
const int MAXN = 1000100;

int N, M;
int nd[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (x > y) swap (x, y);
        if (x == 0)
            nd[y]++;
        if (y == N - 1)
            nd[x]++;
    }

    int win = 0;
    for (int i = 0; i < N; i++)
        if (nd[i] == 2) win++;
    if (win) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){   
        IsPrime.resize(max+1,true);
    }
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i)
        if(IsPrime[i])
            for(size_t j=2; i*j<=max; ++j)
                IsPrime[i*j] = false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N=101000;
    vi v;
    sieve(101000);
    rep(i,N){
        if(IsPrime[i]) v.eb(i);
    }
    int K; cin >> K;
    cout << *lower_bound(all(v),K) << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

        long n = in.nextLong();
        if (n == 1) {
            System.out.println(0);
            return;
        }
        if (n == 2) {
            System.out.println(1);
            return;
        }

        System.out.println((n * (n-1)) / 2L);
    }
}


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

typedef pair<int,int> PII;
const int M=1e6+5;
char s[M];

struct Node
{
	int r,sum;
	Node(int r=0,int sum=0)
		:r(r),sum(sum){}
	bool operator<(const Node &B) const
	{
		return r<B.r;
	}
};
vector<Node> vec1,vec2;

void check()
{
	int m=strlen(s);
	int r=0,sum=0;
	for(int i=0;i<m;i++)
	{
		if(s[i]=='(') sum++;
		else
		{
			if(sum) sum--;
			else r++;
		}
	}
	sum-=r;
	if(sum>=0)
	{
		vec1.push_back(Node(r,sum));
		return;
	}
	r=0;sum=0;
	for(int i=m-1;i>=0;i--)
	{
		if(s[i]==')') sum++;
		else
		{
			if(sum) sum--;
			else r++;
		}
	}
	sum-=r;
	vec2.push_back(Node(r,sum));
}

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",s);
		check();
	}
	sort(vec1.begin(),vec1.end());
	sort(vec2.begin(),vec2.end());
	int suml=0,sumr=0,f=1;
	for(auto p:vec1)
	{
		if(suml<p.r)
		{
			f=0;
			break;
		}
		suml+=p.sum;
	}
	for(auto p:vec2)
	{
		if(sumr<p.r)
		{
			f=0;
			break;
		}
		sumr+=p.sum;
	}
	if(suml!=sumr) f=0;
	printf("%s\n",f?"Yes":"No");
	return 0;
}

Measured memory_bytes: 11256
#include <stdio.h>
#include <algorithm>

int main() {
	int n, nums[26];
	char S[51];
	scanf("%d", &n);
	for (int i = 0; i < 26; i++)
		nums[i] = 50;
	for (int i = 0; i < n; i++) {
		int alphabets[26] = { 0 };
		scanf("%s", S);
		for (int j = 0; S[j] != '\0'; j++)
			alphabets[S[j] - 'a']++;
		for (int j = 0; j < 26; j++)
			nums[j] = std::min(nums[j], alphabets[j]);
	}
	for (int i = 0; i < 26; i++)
		for (int j = 0; j < nums[i]; j++)
			printf("%c", 'a' + i);
	printf("\n");
}

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

string s;
int ind = 0;

struct E {
  int type;
  int op;
  E *l, *r;
  int index;
};

E *parse() {
  E *p = new E();
  if (s[ind] == '[') {
    p->type = 0;
    ind++;
    p->op = s[ind];
    ind++;
    p->l = parse();
    p->r = parse();
    ind++;
  } else {
    p->type = 1;
    p->index = s[ind] - 'a';
    ind++;
  }
  return p;
}

void fr(E *p) {
  if (p->type == 0) {
    fr(p->l);
    fr(p->r);
  }
  free(p);
}

ll eval(E *p, string s) {
  if (p->type == 0) {
    if (p->op == '+') {
      return eval(p->l, s) | eval(p->r, s);
    } else if (p->op == '*') {
      return eval(p->l, s) & eval(p->r, s);
    } else {
      return eval(p->l, s) ^ eval(p->r, s);
    }
  } else {
    return s[p->index] - '0';
  }
}

string num[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};

int main() {
  while (true) {
    cin >> s;
    ind = 0;
    if (s == ".")
      break;
    string t;
    cin >> t;
    auto f = parse();
    int val = eval(f, t);
    int ans = 0;
    for (int i = 0; i < 10; i++)
      for (int j = 0; j < 10; j++)
        for (int k = 0; k < 10; k++)
          for (int l = 0; l < 10; l++) {
            string ss = num[i] + num[j] + num[k] + num[l];
            if (val == eval(f, ss))
              ans++;
          }
    cout << val << " " << ans << endl;
    fr(f);
  }
  return 0;
}


Measured memory_bytes: 3156
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static bool[,] graph = new bool[8, 8];
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var list = new List<KeyValuePair<long, long>>();
            for(var i=0;i<N;i++)
            {
                var sg = Sarray();
                list.Add(new KeyValuePair<long, long>(sg[0] - sg[1], sg[0] + sg[1]));
            }
            var sl = list.OrderBy(x => x.Value).ToArray();
            var ans = 0;
            var ls = long.MinValue;
            var lg = long.MinValue;
            for (var i=0;i<N;i++)
            {
                if(ls<=sl[i].Key && lg <= sl[i].Key)
                {
                    ans++;
                    ls = sl[i].Key;
                    lg = sl[i].Value;
                }
            }
            WriteLine(ans);
        }
    }
}

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

/*
犬 : 1000000000000001
*/

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

    stack<int> S;
    while(n > 0){
        int x;
        x = n%26;
        if(x == 0){
            x = 26;
        }
        S.push(x);
        n = (n - x)/26;
    }

    while(!S.empty()){
        int x = S.top();
        char c = x  + 'a' - 1;
        if(x == 0){
            cout << "a";
        }
        else{
            //printf("%2d ",x);
            cout << c;
        }
        S.pop();
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3128
#include <cstdio>
#include <algorithm>

int n, d[105], ans;

int main(int argc, const char *argv[])
{
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) scanf("%d", d + i);
  for(int i = 1; i <= n; ++i) for(int j = 1; j < i; ++j) ans = ans + d[i] * d[j];
  return 0 & printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    string s;
    //getline(cin, s);
    int a[26]={0};
    while(cin>>s){
    for(int i=0; i<s.length(); i++){
        if(s[i]>='a' && s[i]<='z')    
            a[s[i]-'a']++;
        else if(s[i]>='A' && s[i]<='Z') a[s[i]-'A']++;
    }
    }
    for(int i=0; i<26; i++){
        cout<<char(i+97)<<" "<<":"<<" "<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3204
#include <cstdio>
#include <algorithm>

const int MAXN = 1e4 + 5;
const int INF = 2147483647;

int h, n;
int cost[MAXN], val[MAXN], dp[MAXN << 1];

int main() {
    scanf("%d%d", &h, &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &val[i], &cost[i]);
    }
    for (int i = 1; i < (MAXN << 1); ++i) {
        dp[i] = INF;
    }
    for (int i = 0; i <= h; ++i) {
        if (dp[i] != INF) {
            for (int j = 1; j <= n; ++j) {
                int nxt = std::min(i + val[j], h);
                dp[nxt] = std::min(dp[nxt], dp[i] + cost[j]);
            }            
        }
    }
    printf("%d", dp[h]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b,c; 
    cin >> a >> b >> c;
    int k;
    cin >> k;
    if(b<c) swap(b,c);
    if(a<b) swap(a,b);
    rp(i,k){
        a*=2;
    }
    print(a+b+c);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
/*
 * @Author: Kaizyn
 * @Date: 2020-05-10 20:33:20
 * @LastEditTime: 2020-05-10 20:47:30
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 2e5+7;

template <int _MOD> struct Mint
{
    int v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int &_v) { return *this = Mint(_v); }
    Mint operator = (const long long &_v) { return *this = Mint(_v); }
    bool operator ! () const { return !this->v; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) const { return Mint(v+b.v); }
    Mint operator - (const Mint &b) const { return Mint(v-b.v); }
    Mint operator * (const Mint &b) const { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) const { return Mint(b.inv()*v); }
    Mint& operator += (const Mint &b) { return *this = *this+b; }
    Mint& operator -= (const Mint &b) { return *this = *this-b; }
    Mint& operator *= (const Mint &b) { return *this = *this*b; }
    Mint& operator /= (const Mint &b) { return *this = *this/b; }
    Mint operator - () const { return Mint(-v); }
    Mint& operator ++ () { return *this += 1; }
    Mint& operator -- () { return *this -= 1; }
    Mint operator ++ (int) { Mint tmp = *this; *this += 1; return tmp; }
    Mint operator -- (int) { Mint tmp = *this; *this -= 1; return tmp; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const { return pow(_MOD-2); }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

int n, m, k;
mint fac[N];

mint C(const int &p, const int &q) {
  return fac[p]/(fac[q]*fac[p-q]);
}

inline void solve() {
  cin >> n >> m >> k;
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = fac[i-1]*i;
  mint res = 0;
  for (int i = 0; i <= k; ++i) { // connec i's
    // res *= C(n-1, i)*m*(m-1)^(n-k)
    res += C(n-1, i)*m*mint(m-1).pow(n-i-1);
  }
  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

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

#define ll long long

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

	int a, p;
	scanf("%d %d", &a, &p);
	int t1, t2, t3;
	ll sum = 0;
	sum += p / 2;
	t1 = p % 2;
	t2 = (a * 3) / 2;
	t3 = (t1 + ((a * 3) % 2)) / 2;
	sum += t2 + t3;
	printf("%lld\n", sum);
	return 0;
}

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

#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int64_t x, y;
    cin >> x >> y;

    int64_t div = y / x;
    int ans = 0;
    bitset<64> bit(div);
    DEBUG_LOG(div << " " << bit);
    for (auto i = 0; i < 64; i++) {
        if(bit.test(i)) ans = i;
    }

    cout << (ans + 1) << endl;
    return 0;
}

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

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("codefi.txt", "r", stdin);
	freopen("codefo.txt", "w", stdout);
#endif


	int n;
	cin >> n;

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

	sort(a, a + n, greater<int>());
	int alice = 0, bob = 0;
	for (int i = 0; i < n; i ++)
	{
		if (i % 2 == 0)
			alice += a[i];
		else
			bob += a[i];
	}
	cout << abs(alice - bob) << endl;
}

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

int main(){

long double a,b,x;
  cin >> a >> b >> x;
  
  x/=a*a;
  double ans;
  
  if(x*2>=b) ans=(180/M_PI)*atan(2*(b-x)/a);
  else{
x=2*a*x/b;
ans=(180/M_PI)*atan(b/x);
  }
  
  cout << fixed << setprecision(9) << ans << endl;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using ll = long long;

int main(void)
{
    int k,sum=0;
    cin >> k;
    rep(p,k)rep(q,k)rep(r,k)
    {
        int gcd;
        int m =min({p,q,r});
        rep(i,m)
        {
            if(p%i==0 &&q%i==0)
            {
                if(r%i==0) gcd=i;
            }
        }
        sum +=gcd;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

seqs [] = []
seqs (x:xs) = seqs' x x xs
  where
    seqs' from prev [] = [(from, prev+1)]
    seqs' from prev ya@(y:ys)
      | y==prev+1 = seqs' from y ys
      | otherwise = (from, prev+1) : seqs ya

f (0:xs) = max (1 + f xs) $ maximum $ 0 : [rr-ll | ((ll, lr), (rl, rr)) <- zip ss (tail ss), lr+1==rl]
  where
    ss = seqs xs

f xs = maximum $ map (\(l,r) -> r - l) $ seqs xs


main = do
    [n, k] <- getInts
    when (n/=0 || k/=0) $ do
        a <- replicateM k getInt
        let sorted = sort a
        print $ f sorted
        main

Measured memory_bytes: 35512
// ABC173A - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	if (N % 1000 == 0) {
		cout << 0 << endl;
	} else {
		cout << 1000 - N % 1000 << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
	
using namespace std;
 
#define int long long
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)
 
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX/2;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int32_t main() {
	FAST_IO;
	
	int l, r, d;
	cin >> l >> r >> d;
	
	if (l%d != 0)
		cout << r/d - l/d << endl;
	else
		cout << r/d - l/d + 1 << endl;
	
	
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 3616
#include <cstdio>

int main() {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
             1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d", &k);
  printf("%d\n", a[k - 1]);
}

Measured memory_bytes: 128
#include <string.h>

#include <algorithm>
#include <cstdlib>  // abs() for integer
#include <iostream>

using namespace std;

int main(void) {

	string S;
	cin >> S;

	int cnt = 0;
	int max = 0;

	for (int i = 0; i <= 2; i++) {
		if (S[i] == 'R') {
			cnt++;
			if (cnt > max) {
				max = cnt;
			}
		}

		else {
			cnt = 0;
		}
	}


	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,y,ykc,hgc,ngc;
  cin >> n >> y;
  ykc = y/10000;
  y %= 10000;
  hgc = y/5000;
  y %= 5000;
  ngc = y/1000;
  int ans = 0;
  bool br = 0;
  int ykca,hgca,ngca;
  while(ykc >= 0){
    if(ykc+hgc+ngc == n){
      ans = 1;
      break;
    }
    ykca = ykc,hgca=hgc,ngca = ngc;
    while(hgca>0){
      hgca--;
      ngca += 5;
      if(ykca+hgca+ngca == n){
        ans = 2;
        br = 1;
        break;
      }
    }
      if(br)
        break;
    ykc--,hgc += 2;
  }
  if(ans == 1){
    cout << ykc << " " << hgc << " " << ngc << endl;
  }
  else if(ans == 2){
    cout << ykca << " " << hgca << " " << ngca << endl;
  }
  else
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long int llint;
#define pub push_back
#define mp make_pair
#define fir first
#define sec second
const llint big=((llint)(1<<30)<<30);
//赤が最大と最小両方持つパターンと
//赤が最小　青が最大で場合分け
int main(void){
	llint ans,rmin=big,rmax=0,bmin=big,bsmin=big,bmax=0,rsa;
	llint i,n,q,w;
	vector<pair<llint,llint>> ball;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld %lld",&q,&w);
		if(q>w){ swap(q,w); }
		ball.pub(mp(q,w));
	}
	sort(ball.begin(),ball.end());
	//赤が最小　青が最大
	for(i=0;i<n;i++){
		rmin=min(rmin,ball[i].fir);
		rmax=max(rmax,ball[i].first);
		bmin=min(bmin,ball[i].sec);
		bmax=max(bmax,ball[i].sec);
	}
	ans=(rmax-rmin)*(bmax-bmin);
	//ここから赤が最大最小両方持つ
	rsa=(bmax-rmin);
	bmin=ball[0].first;
	bmax=ball[n-1].first;
	bsmin=big;
	for(i=0;i<n-1;i++){
		bmin=ball[i+1].first;
		bsmin=min(bsmin,ball[i].sec);
		bmax=max(bmax,ball[i].sec);
		ans=min(ans,rsa*(bmax-min(bmin,bsmin)));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6548
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;
int main() {
    string s;
    cin >> s;
    int a = s[0] - 48, b = s[1] - 48, c = s[2] - 48, d = s[3] - 48;
    if (a + b + c + d == 7)
    {
        cout << a << '+' << b << '+' << c << '+' << d << "=7";
        return 0;
    }
    if (a + b + c - d == 7)
    {
        cout << a << '+' << b << '+' << c << '-' << d << "=7";
        return 0;
    }
    if (a + b - c + d == 7)
    {
        cout << a << '+' << b << '-' << c << '+' << d << "=7";
        return 0;
    }
    if (a + b - c - d == 7)
    {
        cout << a << '+' << b << '-' << c << '-' << d << "=7";
        return 0;
    }
    if (a - b + c + d == 7)
    {
        cout << a << '-' << b << '+' << c << '+' << d << "=7";
        return 0;
    }
    if (a - b + c - d == 7)
    {
        cout << a << '-' << b << '+' << c << '-' << d << "=7";
        return 0;
    }
    if (a - b - c + d == 7)
    {
        cout << a << '-' << b << '-' << c << '+' << d << "=7";
        return 0;
    }
    if (a - b - c - d == 7)
    {
        cout << a << '-' << b << '-' << c << '-' << d << "=7";
        return 0;
    }
}


Measured memory_bytes: 3620
def main():
    w, h = map(int, input().split())
    f = w%2==0
    g = h%2==0
    a = w*h//2
    if w==1 or h==1:
        print(1)
        exit()
    if not f and not g:
        print(a+1)
    else:
        print(a)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef unsigned long long int ulli;

int main(){
	ulli n,a,b;
	cin >> n >> a >> b;
	
	if(a+b == 0){cout << 0;exit(0);}
	
	ulli ans = n/(a+b) * a;
	if(n % (a+b) > a){ans+=a;}
	else if(n % (a+b) < a){ans+= n % (a+b);}
	cout << ans;
	
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;

signed main(){
    int a,b;
    cin >> a >> b;
    if(a>9 || b>9){
        cout << -1 << endl;
        return 0;
    }
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func main() {
	s := readLine()
	l := 0
	maxL := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T' {
			l++
		} else {
			if l > maxL {
				maxL = l
			}
			l = 0
		}
	}
	if l > maxL {
		maxL = l
	}
	fmt.Println(maxL)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding space */
vector<ll> in;
int n,k;
bool check(int center){
  if(center == n) return 1;
  int dp[5001] = {};
  dp[0] = 1;
  rep(i,n){
    if(i == center) continue;
    if(in[i] > k) break;
    else{
      for(int j = 5000; j >= 0; j--){
        if(dp[j]){
          if(j + in[i] <= k-1 && j + in[i] >= k - in[center])
            return 1;
          else if(j + in[i] <= k - 1)
            dp[j + in[i]] = 1;
        }
      }
    }
  }
  for(int j = 5000; j >= 0; j--)
    if(dp[j])
      if(j  >= k - in[center])
        return 1;
  return 0;
}

int main(){
  cin >> n >> k;
  rep(i,n){
    ll a; cin >> a;
    in.pb(a);
  }
  sort(ALL(in));
  //rep(i,n) cerr << i  <<" "<<check(i)<<endl;
  if(check(n-1) == 0){cout << n << endl; return 0;}
  int bottom = 0;
  int top = n;
  int i  = 0;
  while(i < 30){
    i++;
    int center = (bottom + top)/2;
    if(check(center))
      top = center;
    else
      bottom = center;
  }
  cout << top << endl;
  return 0;
}


Measured memory_bytes: 512
x,y=map(int,input().split())
a3=2*x-y
b3=2*y-x
MOD=10**9+7

def cmb(n, r, mod):
  if ( r<0 or r>n ):
    return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % mod

if a3%3!=0 or b3%3!=0:
  print(0)
else:
  a=a3//3
  b=b3//3
  if a>b:
    a,b=b,a
  
  N=a+b

  g1 = [1, 1]
  g2 = [1, 1]
  inverse = [0, 1]

  for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )

  ans = cmb(N,a,MOD)
  print(ans%MOD)

Measured memory_bytes: 82448
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int r, d, x_2000;
    cin >> r >> d >> x_2000;

    for (int i = 0; i < 10; i++) {
        int tmp = r * x_2000 - d;
        cout << tmp << endl;
        x_2000 = tmp;
    }
    

    return 0;
}

Measured memory_bytes: 256
def bellman_ford(s):
    d = [-float("inf")]*n # 各頂点への最小コスト
    d[s] = 0 # 自身への距離は0
    check = [False]*n
    for i in range(n):
        update = False # 更新が行われたか
        for x, y, z in g:
            if d[y] < d[x] + z:
                d[y] = d[x] + z
                update = True
        if not update:
            break
        # 負閉路が存在
        if i == n - 1:
          for x, y, z in g:
            if d[y] < d[x] + z:
                d[y] = d[x] + z
                check[x]=True
                check[y]=True
    if check[n-1]:
      return "inf"
    return d[n-1]

n, w = [int(x) for x in input().split()] # n:頂点数, w:辺の数
g = []
for _ in range(w):
    x, y, z = [int(x) for x in input().split()] # 始点,終点,コスト
    g.append([x-1, y-1, z])
    #g.append([y, x, z]) # 有向グラフでは削除
print(bellman_ford(0))

Measured memory_bytes: 74748
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt();
		List<ArrayList<int[]>> sushi = new ArrayList<ArrayList<int[]>>();
		for(int i=0;i<N;i++)sushi.add(new ArrayList<int[]>());
		for(int i=0;i<N;i++) {
			int t = sc.nextInt() - 1;
			int d[] = {sc.nextInt(), 0};//同要素の中で最大なら1
			sushi.get(t).add(d);
		}
		sc.close();
		
		//to remove an unnecessary factor
		PriorityQueue<int[]> pq = new PriorityQueue<int[]>((p1,p2)->{
			int ret = p1[1]-p2[1];
			if(ret == 0) ret = p1[0]-p2[0];
			return ret;
		});
		
		List<int[]> list = new ArrayList<int[]>();
		
		for(int i=0;i<N;i++) {
			ArrayList<int[]> tmp = sushi.get(i);
			if(tmp.isEmpty())continue;
			tmp.sort((t1,t2)->t2[0]-t1[0]);
			tmp.get(0)[1]=1;//先頭の最大要素にフラグを立てる
			//そしてListにつめる
			for(int t[] :tmp)list.add(t);
		}			

		list.sort((t1,t2)->t2[0]-t1[0]);
		long div = 0;
		long sum = 0;
		for(int i=0;i<K;i++) {
			int tmpMax[] = list.get(i);
			sum += tmpMax[0];
			pq.add(tmpMax);
			if(tmpMax[1]==1)div++;
		}
		for(int i=0;i<K;i++) {
			list.remove(0);			
		}
		
		List<int[]> listMax = new ArrayList<int[]>();
		for(int tmp[]:list) {
			if(tmp[1]==1)listMax.add(tmp);
		}
		
		long ans = sum + div*div;
		for(int i=0;i<listMax.size();i++) {
			int dec[] = pq.poll();
			if(dec[1]==1)break;
			sum -= dec[0];
			int inc[] = listMax.get(i);
			if(inc==null)continue;
			pq.offer(inc);
			sum += inc[0];
			div++;
			ans = Math.max(ans, sum+div*div);
		}
		System.out.println(ans);	
	}
}


Measured memory_bytes: 104104
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;

	h1=h1*60+m1;
	h2=h2*60+m2;
	h1=h2-h1;
	cout<<h1-k<<endl;

	return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
  int n;
  scanf("%d", &n);

  int all_pattern = 1;
  int ng_pattern = 1;
  for (int i=0; i<n; i++) {
    all_pattern *= 3;
    int n;
    scanf("%d", &n);
    if (n%2 == 0) {
      ng_pattern *= 2;
    }
  }

  printf("%d\n", all_pattern - ng_pattern);
  return 0;
}

Measured memory_bytes: 128
#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    n = II()
    s = input()
    a = [[] for i in range(10)]

    for i in range(n):
        a[int(s[i])].append(i)

    ans = 0
    for x in range(10):
        if len(a[x]) == 0:
            continue
        x_index = a[x][0]
        for y in range(10):
            tmp = bisect.bisect(a[y], x_index)
            if tmp == len(a[y]):
                continue
            y_index = a[y][tmp]
            for z in range(10):
                z_index = bisect.bisect(a[z], y_index)
                if z_index != len(a[z]):
                    ans += 1

    print(ans)




if __name__ == '__main__':
    main()


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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void dfs(vector<vector<int>> &tree, vector<int> &cnt, int current, int parent) {

    REP(i, tree[current].size()) {
        int child = tree[current][i];
        if (child == parent) continue;
        cnt [child] += cnt[current];
        dfs(tree, cnt, child, current);
    }
    return;
}

void solve() {
    int N, Q;
    cin >> N >> Q;

    vector<vector<int>> tree(N);
    vector<int> cnt(N);

    REP(i, N-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    REP(i, Q) {
        int p, x;
        cin >> p >> x;
        --p;
        cnt[p] += x;
    }

    dfs(tree, cnt, 0, -1);

    REP(i, N) {
        print(cnt[i]);
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 30464
import sys
input = sys.stdin.readline
from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))
if n == 0:
  if A[0] == 1:
    print(1)
  else:
    print(-1)
  exit()
C = list(accumulate(A[::-1]))[::-1] + [0]
B = [-1]*(n+1)
B[0] = 1 - A[0]
for i in range(1, n+1):
  B[i] = min(C[i+1], 2*B[i-1]-A[i])
  if B[i] < 0 or B[i] < B[i-1] - A[i]:
    print(-1)
    exit()
ans = sum(A) + sum(B)
print(ans)

Measured memory_bytes: 22164
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int num = Math.min(a, b);
        int cnt = 0;
        while (true) {
            if (a % num == 0 && b % num == 0) {
                cnt++;
            }
            if (cnt == k) {
                System.out.println(num);
                return;
            }
            num--;
        }
    }
}


Measured memory_bytes: 23124
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10000000)

def search(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
	search(values,hp-1,vp,item)
	search(values,hp+1,vp,item)
	search(values,hp,vp-1,item)
	search(values,hp,vp+1,item)

def solve(values):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in valid_items:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line,values=input().strip(),list()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		value = list()
		for _ in range(H):
			value.append(list(x for x in input().strip()))
		values.append(value)
		line = input().strip()
	for value in values:
		print(solve(value))

if __name__=='__main__':
	main()

Measured memory_bytes: 15836
def main44():
    data1 = input().split()
    nmc = []
    for i in range(3):
        nmc.append(int(data1[i]))
    data2 = input().split()
    b = []
    for i in range(nmc[1]):
        b.append(int(data2[i]))
    a = []
    for i in range(nmc[0]):
        data3 = input().split()
        kari = []
        for j in range(nmc[1]):
            kari.append(int(data3[j]))
        a.append(kari)
    result = 0
    for i in range(nmc[0]):
        karinum = nmc[2]
        for j in range(nmc[1]):
            karinum = karinum + b[j] * a[i][j]
        if karinum > 0:
            result = result + 1
    print(result)

if __name__ == "__main__":
    main44()

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>

using namespace std;
const int mod=1000000007;

vector<int> st;
vector<long long int> v;





int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long int n,m,k,q,d,x,l,a,b,c;
    cin>>n>>m;
    long long int ans=0;
    if (n>=2) {
        ans+=(n*(n-1))/2;
    }
    if (m>=2) {
        ans+=(m*(m-1))/2;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        t1: i64,
        t2: i64,
        a1: i64,
        a2: i64,
        b1: i64,
        b2: i64
    }
    let d = (b1 - a1) * t1 + (b2 - a2) * t2;
    if d == 0 {
        println!("infinity");
        return;
    }
    if d > 0 && b1 > a1 || d < 0 && b1 < a1 {
        println!("0");
        return;
    }
    let top = (b1 - a1).abs() * t1;
    let d = d.abs();
    if top % d != 0 {
        println!("{}", top / d * 2 + 1);
    } else {
        println!("{}", top / d * 2);
    }
}


Measured memory_bytes: 4352
// Last Change: 05/16/2019 18:32:38.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  ll cntC = 0;
  bool ans = true;
  for (ll i = 0; i < S.size(); ++i) {
    if (i == 0) {
      if (S[0] == 'A') {
        continue;
      } else {
        ans = false;
        break;
      }
    }
    //
    else if (2 <= i and i <= S.size() - 2) {
      if (S[i] == 'C') {
        ++cntC;
      } else {
        if (S[i] >= 'A' and S[i] <= 'Z') {
          ans = false;
          break;
        }
      }
    }
    //
    else {
      if (S[i] >= 'A' and S[i] <= 'Z') {
        ans = false;
        break;
      }
    }
  }

  if (ans and cntC == 1) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
A, B = map(int, input().split())

def hantei(A, B):
    tasu = A + B
    hiku = A - B
    kake = A * B
    if tasu >= hiku:
        if tasu >= kake:
            return(tasu)
        else:
            return(kake)
    else:
        if hiku >= kake:
            return(hiku)
        else:
            return(kake)
print(hantei(A,B))

Measured memory_bytes: 3060
n,k,*x=map(int,open(0).read().split())

if x[0]>=0:
  ans=x[k-1]
elif x[-1]<=0:
  ans=abs(x[~(k-1)])

elif n==k:
  l=abs(x[0])
  r=abs(x[-1])
  ans=min(l+l+r,r+r+l)
else:
  ans=10**10
  for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    if l<=0<=r:
      ll=abs(l)
      rr=abs(r)
      tmp=min(ll+2*rr,2*ll+rr)
      ans=min(ans,tmp)
      
print(ans)
  

Measured memory_bytes: 69672
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if((a+b)%3==0)
    cout<<"Possible"<<endl;
  else if(a%3==0)
    cout<<"Possible"<<endl;
  else if(b%3==0)
    cout<<"Possible"<<endl;
  else
    cout<<"Impossible"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	string s;
	cin >> s;

	int ans = s.size();
	
	for (int i = 0; i < 2; i++) {
		int cnt = 0;
		for (int j = 0; j < s.size(); j++) {
			if (j % 2 == 0 && s[j] != (char)(i + '0'))cnt++;
			if (j % 2 == 1 && s[j] == (char(i + '0')))cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 512
H, N = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

dp = [float('inf')] * (H + 10 ** 4)

dp[0] = 0
for j in range(H + 10 ** 4):
    for i in range(N):
        dp[j] = min(dp[j], dp[max(0, j - A[i])] + B[i])
print(min(dp[H:]))

Measured memory_bytes: 42604
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;
const int INF = 100000000;

int r,res;
vector<bool> used;
vector<int> vis;

void dfs(int cnt,int num,int dist,vector<vector<int> > const & d){
    if(cnt==r){
        if(res>dist)res=dist;
        return;
    }
    for(int i=0;i<r;i++){
        if(!used[i]){
            used[i]=true;
            if(num==-1)dfs(cnt+1,i,0,d);
            else dfs(cnt+1,i,dist+d[vis[num]][vis[i]],d);
            used[i]=false;
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m >> r;
    vector<vector<int> > d(n,vector<int>(n,INF));
    vis.resize(r);
    used.resize(r);
    fill(used.begin(),used.end(),false);
    rep(i,r){
        int a;
        cin >> a,--a;
        vis[i]=a;
    }
    rep(i,n)d[i][i]=0;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        if(d[a][b]>c)d[a][b]=d[b][a]=c;  
    }

    /***warshall_floyd***/
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    res = INF;
    dfs(0,-1,0,d);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
read s;
c=0;
for i in `seq 2 ${#s}`;do
	if echo ${s:$[i-1]:1}|grep -cq "[A-Z]";then
		if [ ${s:$[i-1]:1} = "C" ];then
			c=$[c+1];
		else
			c=$[c+2];
		fi
	fi
done;
if [ $c -ne 1 -o ${s:0:1} != "A" ]||(echo ${s:1:1}|grep -cq "[A-Z]")||(echo ${s:$[${#s}-1]:1}|grep -cq "[A-Z]");then
	echo "WA";
else
	echo "AC";
fi


Measured memory_bytes: 920
N=int(input())
W=[]
for i in range(N):
    a,b=map(int,input().split())
    W.append([b,a])
W.sort()
ans=0
for i in range(N):
    ans+=W[i][1]
    if ans > W[i][0]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 35608
#include <bits/stdc++.h>
#define COUT(str) cout << str << endl
#define REP(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;
int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	bool f = false;
	if (b - a > k) f = true; 
	else if (c - a > k) f = true;
	else if (d - a > k) f = true;
	else if (e - a > k) f = true;
	else if (c - b > k) f = true;
	else if (d - b > k) f = true;
	else if (e - b > k) f = true;
	else if (d - c > k) f = true;
	else if (e - c > k) f = true;
	else if (e - d > k) f = true;
	
	if (f) COUT(":(");
	else COUT("Yay!");

	return 0;
}

Measured memory_bytes: 256