akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e7+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

ll n, m = 10e8;
ll p[100100], a[100100], b[100100];

int main(){
	cin >> n;
	REP(i, n){
		cin >> p[i];
		p[i]--;
		a[i] = (m / n)*(i + 1);
		b[i] = (m / n)*(n - i);
	}
	REP(i, n){
		a[p[i]] -= (n - i);
	}
	REP(i, n){
		if (i == 0)cout << a[i];
		else cout << " " << a[i];
	}
	cout << endl;
	REP(i, n){
		if (i == 0)cout << b[i];
		else cout << " " << b[i];
	}
	cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

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

  int n, k;
  cin >> n >> k;
  ld res = 0;
  for(int i = 1; i <= n; i++){
    ld cur = (ld) 1 / n;
    for(int j = i; j < k; j *= 2)
      cur /= 2;
    res += cur;
  }
  cout << fixed << setprecision(10) << res;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int n=s.size();
  int m=s.size()/2;
  int ans=0;
  rep(i,m){
    if(s[i]!=s[n-i-1])ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def main(S):
    d = {x: 0 for x in "NWES"}
    for s in S:
        d[s] += 1
    if d["N"] * d["S"] == 0 and d["N"] + d["S"] != 0:
        return "No"
    if d["E"] * d["W"] == 0 and d["E"] + d["W"] != 0:
        return "No"
    return "Yes"


if __name__ == "__main__":
    S = input()
    ans = main(S)
    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=2e5+5;
int N,a[MN],Xor,Sum;
ll ans;
int main()
{
	N=read();
	reg int i,l,r;
	for(i=1;i<=N;++i) a[i]=read();
	for(l=1,r=1;l<=N;++l)
	{
		while((Xor^a[r])==(Sum+a[r])&&r<=N)
			Xor^=a[r],Sum+=a[r++];
		ans+=r-l;
		Xor^=a[l];Sum-=a[l];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

const ll MAXN = 1000010;
int main()
{
  ll n; cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];
  map<ll, ll> mp;
  rep(i, n) {
    mp[a[i]]++;
  }
  vector<ll> d(MAXN);
  for (auto v:mp) {
    for (int i=1; i*v.first<MAXN; i++) {
      d[i*v.first] += v.second;
    }
  }
  ll ans = 0;
  rep(i, n) {
    if (d[a[i]] < 2) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 25044
#include "bits/stdc++.h"
using namespace std;

struct edge {
	long long from;
	long long to;
	long long cost;
};

int main() {
	long long N, M, P, INF = 1000000000;
	static long long Dist[2500] = {};
	bool visitA[2500] = {}, visitB[2500] = {};
	vector<edge> VE;
	cin >> N >> M >> P;
	visitA[0] = true;
	visitB[N - 1] = true;
	for (int i = 0; i < N; i++) Dist[i] = INF;
	Dist[0] = 0;
	for (int i = 0; i < M; i++) {
		long long A, B, C;
		cin >> A >> B >> C;
		A--, B--;
		edge NE;
		NE.from = A, NE.to = B, NE.cost = P-C;
		VE.push_back(NE);
	}
	for (int i = 0; i < N; i++) {
		for (edge E : VE) {
			if (visitA[E.from]) visitA[E.to] = true;
			if (visitB[E.to]) visitB[E.from] = true;
		}
	}
	for (int i = 0; i < N; i++) {
		for (edge E : VE) {
			if (Dist[E.to] > Dist[E.from] + E.cost) {
				Dist[E.to] = Dist[E.from] + E.cost;
				if (i == N - 1 && visitA[E.from] && visitA[E.to] && visitB[E.from] && visitB[E.to]) {
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}
	cout << max(0LL, -Dist[N - 1]) << endl;
}

Measured memory_bytes: 576
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll X, Y;
ll sum = 0;

int main() {
	scanf("%lld %lld", &X, &Y);
	sum += X + (Y / 2);
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
	ll a,b,c,d,e,f;
    string x,y,z;
    cin>>a>>b;
    
    cout<<a-(b<a)<<endl;
    
    return 0;
}


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

int main() {
  
  vector<char> data(6);
  for (int i = 0; i < 6; i++) {
    cin >> data.at(i);
  }

  
  int answer = 0;

  for (int i = 0; i < 6; i++) {

    if (data.at(i) == '1') {
      answer++;
    }

  }

  cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> T(N), A(N);
  ll accT = 1;
  ll accA = 1;
  for (ll i = 0; i < N; i++) {
    ll t, a; cin >> t >> a;
    ll jt = (accT + (t-1)) / t;
    ll ja = (accA + (a-1)) / a;
    ll jj = max(jt, ja);
    accT = jj * t;
    accA = jj * a;
  }
  cout << accT + accA << endl;

  return 0;
}



Measured memory_bytes: 256
n=int(input())
l=[1]
for i in [6,9]:
    x=i
    while x<=n:
        l.append(x)
        x*=i
dp=[10**9]*(n+1)
dp[0]=0
for x in l:
    for i in range(n):
        if i+x<=n:dp[i+x]=min(dp[i+x],dp[i]+1)
        else:break
print(dp[n])



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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

	int ans = 0;
	int cnt = 0;
	bool in = false;

	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'A' && in == false) {
			cnt = 1;
			in = true;
		}
		else if (s[i] == 'Z' && in == true) {
			ans = max(ans, cnt);
		}

		if (in) {
			cnt++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>
#define N 1000000
 
int A[N];
int c=0;


void Merge(int [],int,int,int);

void Merge_Sort(int [],int,int);


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

    Merge_Sort(A,0,n);

     
   for(i=0;i<n-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[n-1]);
    printf("%d\n",c);
    return 0;
     
}


void Merge(int A[],int left,int mid,int right){
    int n1,n2;
    int i=0,j=0,k;
    int L[N],R[N];
     
    n1=mid-left;
    n2=right-mid;
     
    for(i=0;i<n1;i++){
      L[i]=A[left+i];
    }
    for(j=0;j<n2;j++){
      R[j]=A[mid+j];
    }
    
    i=0;
    j=0;
    
    L[n1] = 2147483647;
    R[n2] = 2147483647;
    for(k=left;k<right;k++){
      if(L[i]<=R[j]){
	A[k]=L[i];
	c++;
	i++;
      }else{
	A[k]=R[j];
	c++;
	j++;
      }
    }
    
}



void Merge_Sort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid = (left + right)/2;
    Merge_Sort(A,left,mid);
    Merge_Sort(A,mid,right);
    Merge(A,left,mid,right);
  }
}

Measured memory_bytes: 8928
#include <stdio.h>
#include <math.h>

int main(void)
{
  int day, i, n;
  double unit, up;
  int debt = 100000;
  double interest = 0.05;

  do{
    scanf("%d", &day);
  }while((0 >= day) && ( 100 <= day));

  for(i = 0; i < day; i++){
    debt += (int)(debt * interest);

  n = 4;
  unit = pow(10, n-1);
  up = (double)debt/unit;
  double a = ceil(up);
  debt = (int)a * (int)unit;
  }
  printf("%d\n", debt);

  return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;

//コピペ用
//		int[] ab = Array.ConvertAll(Console.ReadLine().Split(' '),i=>int.Parse(i));
//      int a = int.Parse(Console.ReadLine());


class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
        int n = int.Parse(Console.ReadLine());
        string s;
      	char[] c;
        var dic = new Dictionary<string,long>();
        long count=0;
        for(int i=0;i<n;i++){
            c = Console.ReadLine().ToCharArray();
          	Array.Sort(c);
          	s = string.Join("",c);
            if(dic.ContainsKey(s)){
                count+=dic[s];
                dic[s]++;
            }else{
                dic.Add(s,1);
            }
        }

		//Console.WriteLine(string.Join("\n",s));
        Console.WriteLine(count);
    }
}

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

#define int int64_t

set < int > st;

int number(string s) {
    int num = 0;
    for(auto x:s) {
        num = num*10 + (x-'0');
    }
    return num;
}

void generate(string s) {
	// cout << s << endl;
    sort(s.begin() , s.end());
    do {
        st.insert(number(s));
    }while(next_permutation(s.begin() , s.end()));
}

void find(string s , int n) {
    if(n <= 0) {
        generate(s);
    }
    else {
        --n;
        s+='3';
        find(s , n);
        s.pop_back();
        s+='5';
        find(s , n);
        s.pop_back();
        s+='7';
        find(s , n);
    }
}

int32_t main() {
	int n , i , j , k , l;
	string q;
	cin >> q;
	n = number(q);
	if(n < 357) {
	    cout << 0;
	    return 0;
	}
	string s = "357";
	for(i=0;i<=q.length()-3;++i) 
		find(s , i);
	int ans = 0;
	for(auto x:st) {
	    if(x <= n) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;

int main()
{
    FASTIO
     /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        int n, k;
        cin >> n >> k;
        int x = ((n - 2) * ( n - 1))/ 2;
        if(x < k)
        {
            cout << "-1\n";
            return 0;
        }
        cout <<  n * ( n - 1 ) / 2 - k << endl;
        for(int i = 1; i < n; i++)
        {
            cout << i << " "<<n << endl;
        }
        x -= k;

        for(int i = 1; i < n && x; i++)
        {
            for(int j = i + 1; j < n && x; j++)
            {
                cout << i << " "<<j << endl;
                x--;
            }
        }
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    ll ans=1;
    for (int i = 1; i < s.length(); ++i)
    {
    	if(s[i]==s[i-1])
    	{
    		if(i+1<s.length())
    		{
    			ans++;
    			i++;
    		}
    		if(i+1<s.length())
    		{
    			ans++;
    			i++;
    		}
    	}
    	else
    	{
    		ans++;
    	}
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    int sum = 0;
    REP(i,2) {
        if(A>=B) {
            sum += A;
            A -= 1;
        }else{
            sum += B;
            B -= 1;
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
int main() {
  fastIO();
  ll n,k,mults=0;
  cin>>n>>k;
  ll t = k;
  if(k%2!=0){
    cout<<(n/k)*(n/k)*(n/k)<<endl;
  }else{
    for(int i=1;i<=n;i++){
      if(i%(k/2)==0&&i%k!=0)mults++;
    }
    cout<<mults*mults*mults+(n/k)*(n/k)*(n/k)<<endl;
  }
}
// - VERIFICAR LONG VS INT -

Measured memory_bytes: 256
f :: Int->Bool
f 0 = True
f n | n < 0 = False
f n | n > 27 = f (n `mod` 28)
f n = f (n - 4) || f (n - 7)
main :: IO ()
main = do
    [a] <- words <$> getLine
    let n = read a :: Int

    putStrLn $ (if f n then "Yes" else "No") where


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

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}


const long long INF = 1LL << 60;
long long dp[100010];

// --------write my fxxkincode!!!!!----------//

int main(){
    int res = 0;
    int N; cin >> N;
    for(int i=0;i<=N;++i){
        res += i;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=2e6+5;
unordered_map<int,int> head[maxn];
struct EDGE{
	int v,nex,c;
}edge[maxn];
int ecnt;
inline void add_edge(int u,int v,int c){
	edge[++ecnt]={v,head[u][c],c};head[u][c]=ecnt;
	edge[++ecnt]={u,head[v][c],c};head[v][c]=ecnt;
}
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n,m;cin>>n>>m;
	bool vvis[maxn];
	map<pii,bool> vis;
	vector<vector<int>> nex(maxn);
	int vcnt=n;
	for(int i=1;i<=m;i++) {
		int u,v,c;cin>>u>>v>>c;
		add_edge(u,v,c);
	}
	std::function<void(int,int)> dfs= [&] (int u,int col) {
		nex[u].push_back(vcnt);nex[vcnt].push_back(u);
		vis[{u,col}]=1;
		for(int i=head[u][col];i;i=edge[i].nex) {
			int v=edge[i].v;if(vis[{v,col}]) continue;
			dfs(v,col);
		}
	};
	for(int i=1;i<=ecnt;i++) {
		if(!vis[{edge[i].v,edge[i].c}]) {
			++vcnt;
			dfs(edge[i].v,edge[i].c);
		}
	}

	vector<int> dis(maxn);queue<int> Q;Q.push(1);dis[1]=1;
	while(!Q.empty()) {
		int u=Q.front();Q.pop();
		for(auto v:nex[u]) {
			if(dis[v]) continue;
			dis[v]=dis[u]+1;
			Q.push(v);
		}
	}
	cout<<(dis[n]?(dis[n]-1)/2:-1)<<endl;
    return 0;
}

Measured memory_bytes: 225032
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());

    if(d[n/2]==d[n/2-1]){
      cout<<0<<endl;
    }
    else{
      cout<<d[n/2]-d[n/2-1]<<endl;
    }
}


Measured memory_bytes: 640
n,m = map(int,input().split())

ac_flag = [False]*n
wa_counts = [0]*n

for i in range(m):
  p,s = map(str,input().split())
  p = int(p)-1
  if s == 'AC':
    ac_flag[p] = True
  else:    
    if ac_flag[p] == False:
      wa_counts[p] += 1

wa_ans = 0
for i in range(n):
  if ac_flag[i]:
    wa_ans += wa_counts[i]
print('{} {}'.format(sum(ac_flag), wa_ans))

Measured memory_bytes: 45656
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if(s==u) a--;
    if(t==u) b--;
    cout << a << " " << b;
}

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

Measured memory_bytes: 256
#include <climits> 
#include <iostream>
#include <vector>

typedef std::vector<int> TList;
int c;
void merge(TList& A, int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  TList L(n1+1);
  for(int i = 0; i < n1; ++i){
    L[i] = A[left + i];
  }
  L[n1] = INT_MAX;

  TList R(n2+1);
  for(int i = 0; i < n2; ++i){
    R[i] = A[mid + i];
  }
  R[n2] = INT_MAX;
  
  int i = 0;
  int j = 0;
  for(int k = left; k < right; ++k){
    ++c;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{ 
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(TList& A, int left, int right)
{
  if(left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> S(n);
  for(int i = 0; i < n; ++i){
    std::cin >> S[i];
  }
  c = 0;
  mergeSort(S, 0, n);
  for(int i = 0; i < n; ++i){
    if(i) std::cout << " ";
    std::cout << S[i];
  }
  std::cout << std::endl;
  std::cout << c << std::endl;
  return 0;
}

Measured memory_bytes: 5060
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll S, W;
  cin >> S >> W;

  if (S <= W) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" <<endl;
  }

  return 0;
}


Measured memory_bytes: 3640
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	string s,t;cin>>s;t=s;reverse(All(t));
	if(s==t) cout<<"Yes"<<endl;else cout<<"No"<<endl;
}


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

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

  vector<int> l(m);
  vector<int> r(m);
  for(int i=0; i<m; i++) std::cin >> l[i] >> r[i];

  sort( l.begin(), l.end() );
  sort( r.begin(), r.end() );
  int ans = r[0] - l[l.size()-1] + 1;
  if( ans < 1 ){
    std::cout << 0 << '\n';
  }else{
    std::cout << ans << '\n';
  }
  return 0;
}


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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    char c;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>c;
    if ('a' <= c && c <='z')
        cout <<'a';
    else
        cout <<'A';



    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A=in(),B=in(),C=in();
	int D[3];
	D[0]=abs(A-B),D[1]=abs(B-C),D[2]=abs(C-A);
	sort(D,D+3);
	
	cout << D[0]+D[1] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        String S = sc.next();

        System.out.println(solve(S) ? YES : NO);
    }

    private static boolean solve(String S) {
        int N = S.length();

        if (!isPalindrome(S)) {
            return false;
        }
        if (!isPalindrome(S.substring(0, (N-1)/2))) {
            return false;
        }
        if (!isPalindrome(S.substring((N+3)/2-1))) {
            return false;
        }

        return true;
    }


    private static boolean isPalindrome(String S) {
        int N = S.length();

        for (int i=0; i<N/2; i++) {
            if (S.charAt(i) != S.charAt(N-i-1)) {
                return false;
            }
        }

        return true;
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a + b;
    int r = c + d;
    if (l > r)
    {
        cout << "Left" << endl;
    }
    else if (l == r)
    {
        cout << "Balanced" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define N 200005
using namespace std;
const int mo=1e9+7,oo=(1<<30); vector<int> G[N];
int n,m,v[N],x[N],tr[N],a[N],w[N],S[N],f[N],L[N],R[N];
void M(int x,int d){ while(x<=n) tr[x]=max(tr[x],d),x+=x&(-x);}
int Q(int x){ int s=0; while(x) s=max(s,tr[x]),x-=x&(-x); return s;}
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d %d",&x[i],&v[i]),w[i]=x[i];
	sort(w+1,w+n+1);
	for(i=1;i<=n;i++) x[i]=lower_bound(w+1,w+n+1,x[i])-w;
	for(i=1;i<=n;i++) w[i]=v[i];
	sort(w+1,w+n+1);
	for(i=1;i<=n;i++) v[i]=lower_bound(w+1,w+n+1,v[i])-w;
	for(i=1;i<=n;i++) a[v[i]]=x[i];
	for(i=1;i<=n;i++) tr[i]=0;
	for(i=1;i<=n;i++){
		L[i]=min(i,n-Q(n-a[i]+1)+1);
		M(n-a[i]+1,n-i+1);
	  }
	for(i=1;i<=n;i++) tr[i]=0;
	for(i=n;i>=1;i--){
		R[i]=max(i,Q(a[i]));
		M(a[i],i);
	  }
	for(i=1;i<=n;i++)
		G[R[i]].push_back(L[i]);
	for(i=1;i<=n;i++)
		sort(G[i].begin(),G[i].end());
	f[0]=S[1]=1;
	for(i=1;i<=n;i++){
		S[i+1]=S[i];
		for(j=0;j<G[i].size();j++){
			f[i]=(1LL*f[i]+S[i+1]-S[G[i][j]-1]+mo)%mo;
			S[i+1]=(2LL*S[i+1]-S[G[i][j]-1]+mo)%mo;
		  }
	  }
	cout<<f[n];
	return 0;
}


Measured memory_bytes: 18176
#include<queue>
#include<cstdio>
#include<cctype>
using i64=long long;
const int N=200007;
int p[N],fa[N],vis[N];
struct node{int a,b,id;}a[N],t;
int operator<(const node&a,const node&b){return 1ll*a.a*b.b<1ll*a.b*b.a;}
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
int find(int x){return x==fa[x]? x:fa[x]=find(fa[x]);}
std::priority_queue<node>q;
int main()
{
    int n=read();i64 ans=0;vis[1]=1;
    for(int i=2;i<=n;++i) p[i]=read();
    for(int i=1,x;i<=n;++i) x=read(),q.push(a[fa[i]=i]={!x,x,i});
    for(int x,y;q.size();)
    if(x=(t=q.top()).id,q.pop(),!vis[x]&&t.a==a[x].a&&t.b==a[x].b)
        vis[x]=1,y=find(p[x]),ans+=1ll*a[y].b*t.a,fa[x]=y,a[y].a+=t.a,a[y].b+=t.b,q.push(a[y]);
    printf("%lld",ans);
}

Measured memory_bytes: 8308
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> b(M, 0);
	for (int i = 0; i < N; ++i) {
		int K;
		cin >> K;
		for (int j = 0; j < K; ++j) {
			int a;
			cin >> a;
			++b[a - 1];
		}
	}

	int ans = 0;
	for (auto v : b) {
		if (v == N) { ++ans; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	lld k;cin>>k;
	int n = ceil(k/10000000000000000.);
	if(n<2) n=2;
	cout<<n<<'\n';
	for(int i=0;i<n-1;i++){
		lld kn = k/n;
		if(i<k%n) kn++;
		cout<<n*kn-(k-kn)+n-2<<' ';
	}
	lld kn = k/n;
	cout<<n*kn-(k-kn)+n-1<<'\n';
	return 0;
}

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

int main () {

  long long int x;

  while (1) {

    cin >> x;

    if (x == 0)
      break;
    /*
    double tmp;

    for (int i = 1; i <= x; i++) {
      tmp = (1 - (2 * i) + sqrt((2 * i - 1) * (2 * i - 1) + 8 * x)) / 2;

      //cout << "i: " << i << " tmp: " << tmp << endl;
      if ((double)(int)tmp == tmp && tmp > 0) {
        cout << i << " " << (int)tmp << endl;
        break;
      }
    }
    */
    long long int tmp = 0;
    long long int max = (-1 + sqrt(1 + 8 * x)) / 2;

    for (int n = max; n > 0; n--) {
      if ((2 * x) % n == 0) {
        tmp = (2 * x) / n - n + 1;
        if (tmp > 0 && tmp % 2 == 0) {
          cout << tmp / 2 << " " << n << endl;
          break;
        }
      }
    }
  }
}



Measured memory_bytes: 3072
//
//  main.swift
//  TestSpace for AtCoder
//
//  Created by Koichi Okai on 2020/06/25.
//  Copyright © 2020 Koichi Okai. All rights reserved.
//

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let N = Int(readLine()!)!
    
    for n in (1...N) {
        var c:Int = 0
        for x in (1...n) {
            let X = x*x
            if(X >= n) { break }
            for y in (1...(n-X)) {
                let Y = y*y
                let xy = x*y
                if(X+Y+xy >= n) { break }
                for z in (1...(n-X-Y-xy)) {
                    let Z = z*z
                    let yz = y*z
                    let zx = z*x
                    if(X+Y+Z+xy+yz+zx > n) { break }
                    else if(X+Y+Z+xy+yz+zx == n) {
                        c += 1
                    }
                }
            }
        }
        print(c)
    }
    
}

main()


Measured memory_bytes: 7716
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for i in range(A)]+[INF]
T = [-INF]+[int(input()) for i in range(B)]+[INF]
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(s-x)+abs(s-t)
            d2 = abs(t-x)+abs(s-t)
            d = min(d,d1,d2)
    print(d)

Measured memory_bytes: 17636
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int i;
	long long n,MIN;
	MIN=1000000000000;
	scanf("%lld",&n);
	for(i=1;i<=1000000;i++){
		if(n%i==0){
			MIN=min(MIN,(i-1)+(n/i-1));
		}
	}
	printf("%lld\n",MIN);
	return 0;
}

Measured memory_bytes: 128
package main

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

type Node struct {
	Key int
	Parent *Node
	Left *Node
	Right *Node
}

const MAX int = 500000
var root *Node
var outBuffer bytes.Buffer

func insert(k int) {
	insertNode := &Node{Key: k}
	var x *Node = root
	var y *Node = nil

	for {
		if x==nil {
			break
		}
		y = x
		if insertNode.Key < x.Key {
			x = x.Left
		} else {
			x = x.Right
		}
	}
	insertNode.Parent = y
	if y==nil {
		root = insertNode
	} else if insertNode.Key < y.Key {
		y.Left = insertNode
	} else {
		y.Right = insertNode
	}
}

func find(start *Node, k int) *Node {
	x := start
	for {
		if x==nil || x.Key==k {
			break
		}
		if k<x.Key {
			x = x.Left
		} else {
			x = x.Right
		}
	}
	return x
}

func inorder(u *Node) {
	if u==nil {
		return
	}
	inorder(u.Left)
	outBuffer.WriteString(fmt.Sprintf(" %d", u.Key))
	inorder(u.Right)
}

func preorder(u *Node) {
	if u==nil {
		return
	}
	outBuffer.WriteString(fmt.Sprintf(" %d", u.Key))
	preorder(u.Left)
	preorder(u.Right)
}

func print() {
	fmt.Printf("%s\n", outBuffer.String())
}

func nextStr(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	N := nextInt(scanner)
	for i:=0; i<N; i++ {
		cmd := nextStr(scanner)
		switch cmd {
		case "insert":
			v := nextInt(scanner)
			insert(v)
		case "print":
			outBuffer.Reset()
			inorder(root)
			print()
			outBuffer.Reset()
			preorder(root)
			print()
		case "find":
			v := nextInt(scanner)
			node := find(root, v)
			if node != nil {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		}
	}
}


Measured memory_bytes: 37980
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(void)
{
    //float f;
    //string s;
    int m,n,o;
    //char a,b,c;
    int i=0,sum=0;
    cin>>m>>n>>o;
    if((o-n-1)%2==0) cout<<"Borys";
    else cout<<"Alice";
    return 0;
}



Measured memory_bytes: 888
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

//解説AC
//https://atcoder.jp/contests/abc044/submissions/4119290

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a;
  cin >> n >> a;
  ll dp[51][2501] = {};
  dp[0][0] = 1;
  REP(i, n){
    int x;
    cin >> x;
    ROF(j, 50, 1) ROF(k, 2500-x, 0) dp[j][k+x] += dp[j-1][k]; //まとめて数え上げる
  }
  ll ans = 0LL;
  FOR(i, 1, n+1) ans += dp[i][i*a]; //a, 2a, 3a, ... / i
  cout << ans << endl;
  return 0;
}

/*
int x[575];
int xx[575];

int main(void){
  int n,a,m=0;
  cin >> n >> a;
  REP(i, n) {
    cin >> x[i];
    xx[x[i]]++;
    m = max(m, x[i]);
  }
  ll ans = 0LL;
  int aa = xx[a];
  ans += pow(2, aa) - 1; //2^a - 1
  int l=a-1, r=a+1;
  while(1 <= l && r <= m){
    int ln = xx[l], lr = xx[r];
    ans += ln*lr*(1<<aa);
    l--;
    r++;
  }
  cout << ans << endl;
  return 0;
}
*/


Measured memory_bytes: 1280
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

// 解答
function main(inputs:Array<String>) : void {

    // 偶数のボールの数
    let num1: number = Number.parseInt(inputs[0].split(' ')[0]);
    // 奇数のボールの数
    let num2: number = Number.parseInt(inputs[0].split(' ')[1]);
    
    let answer1: number = 0;
    let answer2: number = 0;

    if (num1 > 1) {

        answer1 = sum(num1 - 1);
    }

    if (num2 > 1) {

        answer2 = sum(num2 - 1);
    }


    console.log(answer1 + answer2);
}

function sum(num: number) : number {

    if (num <= 1){

        return 1
      }

      return sum(num - 1) + num;
}


Measured memory_bytes: 7500
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }

    var ans = 0
    for (i in 1 until n-1) {
        if (t[i - 1] < t[i] && t[i] < t[i + 1] ||
                t[i - 1] > t[i] && t[i] > t[i + 1]) {
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 31648
n,m,x,y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
x_list.sort()
y_list.sort()
if x_list[-1] < y_list[0]:
  if (y_list[0] > x) and (x_list[-1] < y):
    print("No War")
  else:
    print("War")
else:
  print("War")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
 
using namespace std;
 
using ll = long long;
 
#define all(x) begin(x), end(x)
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); 

map<int, int> yes;
 
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<int> arr(n);
for(int i{}; i<n; i++){
	int x; cin >> x;
	arr[i] = x;
	++yes[x];
}

 ll tp = 0;
    for(auto x : yes){
        if(x.second)
            tp += 1.0*x.second*(x.second-1)/2;
    }


    for(int i{}; i<n; i++){
    	ll p = 1.0*(yes[arr[i]])*(yes[arr[i]]-1)/2;
    	ll nw = 1.0*(yes[arr[i]]-1)*(yes[arr[i]]-2)/2;
    	cout << tp - p + nw << "\n";
    }









 
}

Measured memory_bytes: 10036
const input = require('fs').readFileSync('/dev/stdin', 'utf8').toLowerCase();
const Arr = (input.trim()).split("\n");
const W = Arr[0];
let ctn = 0;
for (i = 1; i < Arr.length; i++) {
    if (Arr[i] == "END_OF_TEXT") {        
        break;
    } else {
        const arr = Arr[i].split(" ");
        arr.forEach(function (v, i) {
            if (v == W) ctn++;
        });
    }
}
console.log(ctn);



Measured memory_bytes: 15384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n, m, i, c = 0;
	cin >> n;
	vector<long> vN(n, 0);
	for(i = 0; i < n; ++i) cin >> vN[i];
	cin >> m;
	vector<long> vM(m, 0);
	for(i = 0; i < m; ++i) cin >> vM[i];
	for(i = 0; i < m; ++i){
		if(std::binary_search(vN.begin(), vN.end(), vM[i]))
			++c;
	}

	cout << c << "\n";

	return 0;
}

Measured memory_bytes: 2324
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, M;
	cin >> N >> M;
	int ans = 0;
	cout << N * (N - 1)/2 + M * (M - 1)/2 << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    int a=in(),b=in(),c=in(),d=in();
    cout<<max(a*b,c*d);
}

Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)

using namespace std;

int main(void) {
	int a, b, c, d, e, k;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);

    if ( e - a <= k) puts("Yay!");
    else puts(":(");

	return 0;
}


Measured memory_bytes: 256
import sys

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

Ant = [a, b, c, d, e]

for i in range(4):
    for j in range(i, 5):
        if abs(Ant[j]-Ant[i]) > k:
            print(":(")
            sys.exit()

print("Yay!")

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

vector<int> primes;

bool isPrime(int p) {
  for (int i = 0; i < primes.size() && primes[i] <= sqrt(p); i++) {
    if (p % primes[i] == 0) {
      return false;
    }
  }
  return true;
}

void makePrimes(int n) {
  primes.pb(2);
  for (int i = 3; i < n; i += 2) {
    if (isPrime(i)) {
      primes.pb(i);
    }
  }
}

int main() {
  makePrimes(300000);
  int n, p;
  while (cin >> n >> p) {
    if (n == -1 && p == -1) break;
    vector<int> sum_list;
    int index;
    for (index = 0; index < primes.size(); index++) {
      if (n < primes[index]) break;
    }
    for (int i = index; i < index+100; i++) {
      for (int j = i; j < index+100; j++) {
        sum_list.pb(primes[i]+primes[j]);
      }
    }
    sort(sum_list.begin(), sum_list.end());
    cout << sum_list[p-1] << el;
  }
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

long long gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

/*  lcm (a, b) : 2整数版
    入力：整数 a, b
    出力：aとbの最小公倍数
*/
long long lcm(long long a, long long b) {
    long long d = gcd(a, b);
    return a / d * b;
}
using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    ll lc = 1;
    for (int i = 0; i < N; i++) {
        lc = lcm(lc, a[i] / 2);
        if (lc > M) {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++) {
        if (lc / (a[i] / 2) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (M - lc) / (lc * 2) + 1 << endl;
}


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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a * b / 2) << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>

int main()
{
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	std::ios::sync_with_stdio(false);

	int nbObj, capacity;
	std::cin >> nbObj >> capacity;

	std::vector<int64_t> weight(nbObj), value(nbObj);

	for (int i=0; i<nbObj; i++)
		std::cin >> weight[i] >> value[i];

	std::vector<int64_t> DP[nbObj+1];

	for (int i=0; i<=nbObj; i++)
		DP[i] = std::vector<int64_t>(capacity+1, 0);

	for (int i=0; i<=nbObj; i++)
		for (int w=0; w<=capacity; w++)
		{
			if (i == 0 || w == 0)
				DP[i][w] = 0;
			else if (weight[i-1] <= w)
				DP[i][w] = std::max(value[i-1] + DP[i-1][w-weight[i-1]], DP[i-1][w]);
			else
				DP[i][w] = DP[i-1][w];
		}

	std::cout << DP[nbObj][capacity] << '\n';
}

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

namespace ABCProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            string u;

            string[] ab;
            int a;
            int b;

            string[] st = Console.ReadLine().Split(' ');

            string s = st[0];
            string t = st[1];

            ab = Console.ReadLine().Split(' ');

            a = int.Parse(ab[0]);
            b = int.Parse(ab[1]);

            u = Console.ReadLine();

            if(s == u)
            {
                a--;
            }

            else if(t == u)
            {
                b--;
            }

            Console.WriteLine(a + " " + b);

        }
    }
}


Measured memory_bytes: 11092
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

import bisect

N= one_int()

import math
def AtkinSieve (limit):
    results = [2,3,5]
    sieve = [False]*(limit+1)
    factor = int(math.sqrt(limit))+1
    for i in range(1,factor):
        for j in range(1, factor):
            n = 4*i**2+j**2
            if (n <= limit) and (n % 12 == 1 or n % 12 == 5):
                sieve[n] = not sieve[n]
            n = 3*i**2+j**2
            if (n <= limit) and (n % 12 == 7):
                sieve[n] = not sieve[n]
            if i>j:
                n = 3*i**2-j**2
                if (n <= limit) and (n % 12 == 11):
                    sieve[n] = not sieve[n]
    for index in range(5,factor):
        if sieve[index]:
            for jndex in range(index**2, limit, index**2):
                sieve[jndex] = False
    for index in range(7,limit):
        if sieve[index]:
            results.append(index)
    return results

temp = AtkinSieve(10**5+4)

index=bisect.bisect_right(temp,N)

if temp[index-1]==N:
    print(N)
else:
    print(temp[index])

Measured memory_bytes: 4712