akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <complex>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <vector>  
#include <string>
#include <cmath>
#include <ctime>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <ext/pb_ds/assoc_container.hpp>    // PBDS
#include <ext/pb_ds/tree_policy.hpp>      // PBDS

using namespace std;
using namespace __gnu_pbds;                 // PBDS

/* typedef starts */

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> PBDS_INT;               // PBDS for int
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> PBDS_LL;    // PBDS for long long

/* typedef ends */

/* macro starts */

#define PI acos(-1)
#define EPS 1e-9
#define INF (1e9 + 7)
#define fastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define sinD(degree) sin((degree * PI) / 180.0)
#define cosD(degree) cos((degree * PI) / 180.0)
#define tanD(degree) tan((degree * PI) / 180.0)
#define cotD(degree) (1.0 / tanD(degree))
#define secD(degree) (1.0 / cosD(degree))
#define cosecD(degree) (1.0 / sinD(degree))
#define asinD(value) (asin(value) * 180.0) / PI
#define acosD(value) (acos(value) * 180.0) / PI
#define atanD(value) (atan(value) * 180.0) / PI
#define forn(i,n) for(int i=0;i<n;i++)
#define value_at_index(x) find_by_order(x)
#define index_of(x) order_of_key(x)
#define pb push_back
#define setval(add,n) memset(add,n,sizeof(add))
#define max(a,b) a>b ? a : b
#define forr(i,a,b) for(int i=a;i<b;i++)

/* macro ends */

/* function starts */

/// calculates n-th (0-based) Gray Code
template<typename dataType>
dataType nthGrayCode(dataType n)
{
    return (n ^ (n >> 1));
}

/// generates all possible subsets for the given set
//template<typename dataType>
// void generateAllSubset(vector<dataType> &data)
// {
//     int i, j, n;
//     n = data.size();

//     for (i = 0; i < (1 << n); i++) {
//         for (j = 0; j < n; j++) {
//             if (i & (1 << j)) {
//                 cout << data[j] << " ";
//             }
//         }
//         cout << "\n";
//     }
// }


void swap(ll *a, ll *b){
	ll *temp=a;
	*a=*b;
	*b=*temp;
}
int n,k;

void solve(){
  string s;
  cin >> s;
  int n=s.size();
  if(s[n-1]!='s'){
    cout << s << 's' << '\n';
  }
  else{
    cout << s << "es" << '\n';
  }
}





int main()
{
  #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
       freopen("out.txt", "w", stdout);
  #endif
  fastIO;
    int t=1;
    //cin >> t;
    while(t--){
     solve();
     
    }
    return 0;
    }

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

const int INF = 1000000;
char data[22][22]; // x,y
const int dx[4] ={0,1,0,-1};
const int dy[4] ={1,0,-1,0};
int h,w;

int bfs(vector<vector<int> > res,int sx,int sy){
	queue<pair<int,int> >  que;
	
	res[sx][sy] = 0;
	que.push(pair<int,int>(sx,sy));
	//cout << sx << " " << sy <<endl;
	while(!que.empty()){
		pair<int,int> current = que.front(); que.pop();
		int cx = current.first;
		int cy = current.second;
		int cc = res[cx][cy];
		//cout << cx << " " << cy <<endl;
		
		for(int i =0;i<4;++i){
			int nx = cx + dx[i];
			int ny = cy + dy[i];
			//cout << nx << " " << ny << " " << data[nx][ny] << " " << res[nx][ny] <<endl;
			if(data[nx][ny] != '#' && res[nx][ny] == INF){
				res[nx][ny] = cc + 1;
				que.push(pair<int,int>(nx,ny));
			}
		}
	}
	
	int ma = 0;
	for(int i=0;i<22;++i){
		for(int j=0;j<22;++j){
			//cout << res[i][j];
			if(res[i][j] != INF && res[i][j] > ma){
				ma = res[i][j];
			}
		}//cout << endl;
	}
	return ma;
}

int main(){
	cin >> h >> w;
	int sx,sy;
	vector<int> infs(22,INF);
	vector<vector<int> > res_map(22,infs);

	for(int i=0;i<22;++i){
		for(int j=0;j<22;++j){
			data[i][j] = '#';
			res_map[i][j] = INF;
		}
	}

	int ans = 0;
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cin >> data[j][i];
		}
	}
	
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			if(data[j][i] == '.'){
				ans = max(ans,bfs(res_map,j,i));
				//cout << ans << " " << j << " " << i <<endl;
			}
		}
	}

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

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

int main(void)
{
	int num1, num2, ans;
	char op;

	cin >> num1 >> op >> num2;

	if (op == '+') {
		cout << num1 + num2 << endl;
	}
	else {
		cout << num1 - num2 << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=9e18;
const double PI=3.14159265359;

int main() {
    int N, K;
    cin>>N>>K;
    ll x[N], y[N];
    map<ll, int> xmap;
    map<ll, int> ymap;
    vector<ll> xarr, yarr;
    for(int i=0;i<N;++i){
        cin>>x[i]>>y[i];
        if(xmap[x[i]]==0) xarr.push_back(x[i]);
        if(ymap[y[i]]==0) yarr.push_back(y[i]);
        xmap[x[i]]++;
        ymap[y[i]]++;
    }
    sort(xarr.begin(), xarr.end());
    sort(yarr.begin(), yarr.end());
    ll ans = big;
    int tmp;
    ll x1, y1, x2, y2;
    for(int i=0;i<xarr.size();++i){
        for(int j=i+1;j<xarr.size();++j){
            for(int k=0;k<yarr.size();++k){
                for(int l=k+1;l<yarr.size();++l){
                    x1 = xarr[i];
                    x2 = xarr[j];
                    y1 = yarr[k];
                    y2 = yarr[l];
                    tmp = 0;
                    for(int m=0;m<N;++m){
                        if((x1<=x[m]) & (x[m]<=x2) & (y1<=y[m]) & (y[m]<=y2)) tmp++;
                    }
                    if((tmp>=K) & (ans>(x2-x1)*(y2-y1))){
                        ans = (x2-x1)*(y2-y1);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split(' ')))

min_sum = sum(w)
for i in range(1, n):
    tmp1 = sum(w[:i])
    tmp2 = sum(w[i:])
    min_sum = min(abs(tmp1 - tmp2), min_sum)
print(min_sum)


Measured memory_bytes: 3060
#include <stdio.h>


int main()
{
    unsigned long int a, b, x, ans;
    
    scanf("%lu %lu %lu", &a, &b, &x);

    if ((a % x) == 0)
    {
	ans = (b / x) - (a / x) + 1;
    }
    else
    {
	ans = (b / x) - (a / x);
    }
    
    printf("%lu\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> H(N);
    for (int n = 0; n < N; ++n) cin >> H[n];
    
    bool b = true;
    for (int n = N-2; n >= 0; --n) {
        if (H[n] > H[n+1]+1) {
            b = false;
            break;
        } else if (H[n] == H[n+1]+1) {
            --H[n];
        }
    }
    if (b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;



 
int main() {
int H, W, h, w;
  cin >> H >> W >> h >> w;
  
  cout << (H-h) * (W-w) << endl;
}

 

Measured memory_bytes: 256
N = int(input()) + 1
A = list(map(int, input().split()))

B = [0] * N
for i in reversed(range(N)):
    if i == N - 1:
        B[i] = A[i]
    else:
        B[i] = B[i + 1] + A[i]

if A[0] >= 2:
    print(-1)
    exit(0)

if A[0] == 1:
    if N == 1:
        print(1)
    else:
        print(-1)
    exit(0)

m = 1 
ans = 1
for i in range(1, N):
    m = min((m - A[i - 1]) * 2, B[i])
    if m < A[i]:
        print(-1)
        exit(0)
    ans += m
print(ans)

    
    
    

Measured memory_bytes: 83416
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)
		cin >> A[i];

	int ans = 0;
	REP(i, N) {
		if (A[i] == i + 1) {
			if(A[i]+1==A[i+1] && i+1!=N)
				swap(A[i], A[i + 1]);
			else if (i != 0 && A[i - 1] != i + 1)
				swap(A[i - 1], A[i]);
			else
				swap(A[i], A[i + 1]);

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



Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it,o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;
bool solve(string s){
    if(s.find('N') == string::npos || s.find('S') == string::npos){
        if(s.find('N') == string::npos && s.find('S') == string::npos){
        }else{
            return false;
        }
    }
    if(s.find('W') == string::npos || s.find('E') == string::npos){
        if(s.find('W') == string::npos && s.find('E') == string::npos){
        }else{
            return false;
        }
    }
    return true;
}

int main(){
    string s;
    cin >> s;
    if(solve(s)){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <vector>

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

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

	std::sort(a.begin(), a.end());

	long long answer = -1;
	// XXX: すべての理解を失った
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 2; j++) {
			auto b = a;
			const int cIndex = (N - j) / 2;
			const int center = b.at(cIndex);
			b.erase(b.begin() + cIndex);

			std::deque<int> queue(b.begin(), b.end());

			if(i == 0) {
				std::reverse(queue.begin(), queue.end());
			}

			int left = 0;
			int right = center;
			long long ans = 0;
			while(!queue.empty()) {
				left = right;
				right = queue.back();
				queue.pop_back();
				ans += std::abs(left - right);
				if(queue.empty()) {
					break;
				}
				left = right;
				right = queue.front();
				queue.pop_front();
				ans += std::abs(left - right);
				if(queue.empty()) {
					break;
				}
			}
			if(ans > answer) {
				answer = ans;
			}
		}
	}

	std::cout << answer << std::endl;

	return 0;
}

Measured memory_bytes: 1564
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		int n = 700;
		for(int i = 0 ; i < 3 ; i++) if(s.charAt(i) == 'o') n += 100;
		ou.println(n);
		ou.flush();
	}
}

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



int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	ll n,i,p,k,ans=0;
  	cin>>n;
  	ll a[n][3]={{0}},x[n][3]={{0}};
  	for(i=0;i<n;i++){
  		for(p=0;p<3;p++){
  			cin>>a[i][p];
		  }
	  }for(i=0;i<3;i++){
	  	x[0][i]=a[0][i];
	  }for(i=1;i<n;i++){
	  	for(p=0;p<3;p++){
	  		for(k=0;k<3;k++){
	  			if(p!=k){
	  				x[i][p]=max(x[i][p],x[i-1][k]+a[i][p]);
				  }
			  }
		  }
	  }for(i=0;i<3;i++){
	  	ans=max(x[n-1][i],ans);
	  }cout<<ans;
	  
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int w[105];
int val[105];
ll dp[101][100001];
int main() {
    int n, W;
    cin>>n>>W;
    for(int i=0;i<n;i++) {
        cin>>w[i]>>val[i];
    }

    for(int i=1;i<=100000;i++) {
        dp[0][i] = INT_MAX;
    }
    dp[0][0] = 0;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=100000;j++) {
            dp[i][j] = dp[i-1][j];
            if(j>=val[i-1]) {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-val[i-1]] + w[i-1]);
            }
        }
    }
    //cout<<dp[n][100000]<<endl;
    for(int i=100000;i>=0;i--) {
        if(dp[n][i] <= W) {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 79104
#include <stdio.h>

int main(void)
{
	int a, b, c, d=0;

	scanf("%d %d %d", &a, &b, &c);

	while (a<=b)
	{
		if (c%a == 0)
		{
			d++;
		}

		a++;
	}

	printf("%d\n", d);

	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
string s,t;
int dp[3005][3005];
int si[3005][3005][2];
int ls,lt;

void dfs(int x,int y){
	if(x==0||y==0) return;
	dfs(si[x][y][0],si[x][y][1]);
	if(dp[si[x][y][0]][si[x][y][1]]+1==dp[x][y]) cout<<s[x-1];
}

int main(){
	cin>>s>>t;
	ls=s.size();
	lt=t.size();
	for(int i=1;i<=ls;i++){
		for(int j=1;j<=lt;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
				si[i][j][0]=i-1;
				si[i][j][1]=j-1;
			}
			else{
				if(dp[i-1][j]>=dp[i][j-1]){
					dp[i][j]=dp[i-1][j];
					si[i][j][0]=i-1;
					si[i][j][1]=j;
				}
				else{
					dp[i][j]=dp[i][j-1];
					si[i][j][0]=i;
					si[i][j][1]=j-1;
				}
			}
		}
	}
	dfs(ls,lt);
	
	return 0;
}

Measured memory_bytes: 106240
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n-1);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		ans += b[i];
	}
	for (int i = 0; i < n-1; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n - 1; i++) {
		if (a[i + 1] - a[i] == 1) ans += c[a[i]-1];
	}
	cout << ans << endl;
	return 0;
}

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

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

x.sort()

d = [x[i] - x[i-1] for i in range(1,m)]

d.sort()

if n >= m:
    print(0)
else:
    ans = sum(d[:m-n])
    print(ans)


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

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

int main()
{
  int dp[128][128][2][2];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0][1] = 1;
  dp[0][0][1][0] = 1;
  for (int y = 0; y <= 100; y++){
    for (int x = 0; x <= 100; x++){
      (dp[y + 1][x][1][0] += dp[y][x][0][0]) %= Mod;
      (dp[y + 1][x][1][1] += dp[y][x][1][0] + dp[y][x][1][1]) %= Mod;
      (dp[y][x + 1][0][0] += dp[y][x][0][1] + dp[y][x][0][0]) %= Mod;
      (dp[y][x + 1][0][1] += dp[y][x][1][1]) %= Mod;
    }
  }
  int w, h;
  while (cin >> w >> h, w){
    w--;
    h--;
    if (!w && !h){
      puts("1");
      continue;
    }
    int tot = 0;
    for (int i = 0; i < 2; i++){
      for (int j = 0; j < 2; j++){
        (tot += dp[h][w][i][j]) %= Mod;
      }
    }
    cout << tot << endl;
  }

  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

Measured memory_bytes: 1420
import math

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]


def ok(n):
    d = n * B
    t = 0
    for h in H:
        if h <= d:
            continue
        t += math.ceil((h - d) / (A - B))
        # t += (h - d) // (A - B)
    return t <= n


lo, hi = 0, 10 ** 9

while lo < hi:
    mi = (lo + hi) // 2
    if ok(mi):
        hi = mi
    else:
        lo = mi + 1

print(hi)


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


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair 
using namespace std;
int a[100001]={-1};
int n;
vector<int> v[100001];
map<pair<int,int>,int> mp2;
queue<int> q;
bool visit[100001];
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y,w;
		cin>>x>>y>>w;
		v[x].push_back(y);
		v[y].push_back(x);
		mp2[mp(x,y)]=w;
		mp2[mp(y,x)]=w;
	}
	q.push(1);
	a[1]=0;
	while(!q.empty())
	{
		int b=q.front();
		q.pop();
		for(int i=0;i<v[b].size();i++)
		{
			if(!visit[v[b][i]])
			{
				q.push(v[b][i]);
				a[v[b][i]]=a[b]+mp2[mp(v[b][i],b)];
				visit[v[b][i]]=true;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2)
		{
			cout<<1<<endl;
		}
		else
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 18944
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll _pow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; b >> i; i++) {
		if ((b >> i) & 1) ans *= a;
		a *= a;
	}
	return ans;
}
char inp[60];
int main(void) {
	int n, idx; scanf("%d %d", &n, &idx);
	scanf("%s", inp);
	inp[idx-1] -= 'A' - 'a';
	printf("%s\n", inp);
	return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
ns = list(map(int, input().split()))

for i in range(1, len(ns)+1):
    ns[i-1] -= i

ns.sort()

if len(ns) % 2 != 0:
    ind  = math.ceil(len(ns)/2)
    m = ns[ind-1]
    m1 = 0
else:
    ind = int(len(ns)/2)
    m = math.floor((ns[ind-1]+ns[ind])/2)
    m1 = m + 1


ls = 0
hs = 0

for na in ns:
    ls += abs(na-m)
    hs += abs(na-m)


print(min(ls, hs))


Measured memory_bytes: 26608
for v in range(5):
    n, k = map(int, input().split())
    if n == 0 and k == 0:
        break
    a = [int(input()) for i in range(n)]
    sum = []
    s = [0] * (n+1)

    for i in range(n):
        s[i+1] = s[i] + a[i]
    
    for i in range(n-k):
        sum.append(s[i+k] - s[i])

    print(max(sum))
    


Measured memory_bytes: 15356
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    if (n / 10) % 111 == 0 || (n - (n / 1000 * 1000)) % 111 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
int a;
int main(){
	for(;;){
		a=0;
		int n,x;
		cin>>n>>x;
		if(n==0&&x==0)break;
		for(int i=1;i<=n;i++){
			for(int j=1;j<i&&j<=x-i;j++){
				for(int k=1;k<j&&k<=x-i-j;k++){
					if(i+j+k==x){
						a++;
					}
				}
			}
		}
		cout<<a<<endl;
	}
}




Measured memory_bytes: 3108
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;
using System.Threading;

static class MainClass
{
    public static void Main(string[] args)
    {

        Console.WriteLine("ABC"+Console.ReadLine());
    }


    #region ライブラリ

    #region 文字列処理
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion


    #endregion
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std; //
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<" "<<a+a+b+b<<endl;
	return 0;
}

Measured memory_bytes: 1164
s=input()

res=False
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        res=(i,i+1)
        break

for i in range(len(s)-2):
    if s[i] == s[i+2]:
        res = (i,i+2)
        break


if res:
    res=list(map(lambda x:x+1,res))
    print(res[0],res[1])
else:
    print("-1 -1")


Measured memory_bytes: 3188
from collections import deque

n = int(input())

g = [[] for _ in range(n)]
# 0indexに直している
for i in range(n - 1):
    u, v, w = map(int, input().split())
    g[u - 1].append((v - 1, w))
    g[v - 1].append((u - 1, w))

"""
ex.
3
1 2 2
2 3 1
の場合、g = [[(1, 2)], [(0, 2), (2, 1)], [(1, 1)]]
"""

#print(g)

"""
根から各頂点への距離をd_iとする
u,vという2頂点について、その最小共通祖先をwとすると
uとvの距離=d_u+d_v-2d_w
第3項は常に偶数
d_uとd_vの偶奇が等しければ全体は偶数、偶奇が異なれば全体は奇数
例えば、d_iが偶数なら白に、奇数なら黒に塗るとすれば条件を満たす
"""

dq = deque([0])
#  各頂点について、根からの距離
# 頂点0を根とする（別にどれを選んでも良い）
ds = [-1] * n
ds[0] = 0

# BFS(幅優先探索)
while dq:
    t = dq.popleft()
    # tと繋がっている各頂点について
    for i in g[t]:
        # まだ調べていない場合
        if ds[i[0]] == -1:
            # 根からtまでの距離+tから次への距離
            ds[i[0]] = ds[t] + i[1]
            # 今調べた頂点をdequeに追加
            dq.append((i[0]))

# 偶数なら白、奇数なら黒とした。逆でも良い。
for i in ds:
    if i % 2 == 0:
        print(0)
    else:
        print(1)


Measured memory_bytes: 47704
#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 rv(s) reverse(s.begin(),s.end());
 
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 vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
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, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  ll n;
  cin>>n;
  vll v(5);
  rep(i,5)cin>>v[i];
  
  vsort(v);
  ll min=v[0];
  ll ans=4+(n+min-1)/min;
  cout(ans);
}

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

using namespace std;

char c[8005];
int x,y;
int nx,ny;
int sx=10000,sy=10000;
int F[8005];
int dpx[8005][20005],dpy[8005][20005];
vector<int> X,Y;

int check_x(int x){

  if(nx==0){
    if(sx==x) return 1;
    else return 0;
  }

  if(c[0]=='T') dpx[0][sx-X[0]]=1;
  dpx[0][sx+X[0]]=1;

  for(int j=1; j<nx; j++){

    for(int i=0; i<=20000; i++){
      if(i+X[j]>20000){
        dpx[j][i]=dpx[j-1][i-X[j]];
      }
      else if(i-X[j]<0){
        dpx[j][i]=dpx[j-1][i+X[j]];
      }
      else{
        dpx[j][i]=dpx[j-1][i-X[j]]+dpx[j-1][i+X[j]];
      }
    }

  }

  return dpx[nx-1][x];

}

int check_y(int y){

  if(ny==0){
    if(sy==y) return 1;
    else return 0;
  }

  dpy[0][sy-Y[0]]=1;
  dpy[0][sy+Y[0]]=1;

  for(int j=1; j<ny; j++){

    for(int i=0; i<=20000; i++){
      if(i+Y[j]>20000){
        dpy[j][i]=dpy[j-1][i-Y[j]];
      }else if(i-Y[j]<0){
        dpy[j][i]=dpy[j-1][i+Y[j]];
      }
      else{
        dpy[j][i]=dpy[j-1][i-Y[j]]+dpy[j-1][i+Y[j]];
      }
    }
  }

  return dpy[ny-1][y];

}

int main() {

cin.tie(0);
ios::sync_with_stdio(false);

cin>>c>>x>>y;

string s=c; int n=s.size();

int j=0; 

for(int i=0; i<n; i++){
  if(c[i]=='T'){
    j++;
  }
  if(c[i]=='F'){
    F[j]++;
  }
}

for(int i=0; i<=j; i++){
  if(i%2==0){
    if(F[i]){
      X.push_back(F[i]);
    }
  }else{
    if(F[i]){
      Y.push_back(F[i]);
    }
  }
}

x=x+sx; y=y+sy;

nx=X.size(); ny=Y.size(); 

if(check_x(x)&&check_y(y)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;

//cout<<X[0]<<" "<<X[1]<<" "<<X[2]<<endl;
//cout<<dpx[2][10000]<<endl;

}


Measured memory_bytes: 315648
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[p[0]]
for i in range(1,n):
    s.append(s[-1]+p[i])
ans=0
c=0
for i in range(n-k):
    if c<=s[i+k]-s[i]:
        c=s[i+k]-s[i]
#print(s)
if n!=k:
    print((c+k)/2)
else:
    print((s[-1])/2+0.5*k)

Measured memory_bytes: 76040
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

bool check(string& s){
    if(s[0]!='A') return false;
    if(count(s.begin()+2,s.end()-1,'C')!=1) return false;
    REP(i,s.size())
        if(s[i]!='A' and s[i]!='C' and isupper(s[i])) return false;
    return true;
}

signed main()
{
    string s; cin>>s;
    cout<<(check(s)? "AC":"WA")<<endl;
}


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

int main() {
	int n,m;cin>>n>>m;
	int a[m],b[m];
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
	}
	int ans=0;
	for(int i=0;i<m;i++){
		int d[n][n];
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				d[j][k]=50;
			}
		}
		for(int j=0;j<m;j++){
			d[a[j]][b[j]]=1;
			d[b[j]][a[j]]=1;
		}
		d[a[i]][b[i]]=50;
		d[b[i]][a[i]]=50;
//		for(int j=0;j<n;j++){
//			for(int k=0;k<n;k++){
//				cout<<' ';
//				cout<<d[j][k];
//			}
//			cout<<endl;
//		}
		for(int k=0;k<n;k++){
			for(int i2=0;i2<n;i2++){
				for(int j2=0;j2<n;j2++){
					if(d[i2][j2]>d[i2][k]+d[k][j2]){
						d[i2][j2]=d[i2][k]+d[k][j2];
					}
				}
			}
		}
//		for(int j=0;j<n;j++){
//			for(int k=0;k<n;k++){
//				cout<<' ';
//				cout<<d[j][k];
//			}
//			cout<<endl;
//		}
		int flag=0;
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(d[j][k]==50){
					if(j!=k)flag=1;
				}
			}
		}
		if(flag)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int n;
int a[10],b[10];
int f[10];
int x,y;
void check(int t)
{
	for(int i=1;i<=n;i++)
	if(a[i]!=f[i]) goto ending;
	x=t;
	ending:
	for(int i=1;i<=n;i++)
	if(b[i]!=f[i]) return;
	y=t;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<=n;i++) f[i]=i;
	int cnt=1;
	do{
		check(cnt++);
	}while(next_permutation(f+1,f+n+1));
	cout<<abs(x-y)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){

    string str;
    long long sum = 0;
    cin >> str;
    
    // 各計算の式のプラスが入る場所を作る
    for(int tmp = 0; tmp < (1 << (str.size()-1)); tmp++){
        bitset<10> s(tmp);
        string now_Str;
        
        // 各計算の式を作る場所、bitset<>でプラスがある場所を設定
        for(int i = 0; i < (str.size()); i++){
            now_Str += str[i];
            if(s.test(i)) now_Str += "+";
                //now_Str += str[i+1];
        }
    
        int begin = 0;
        for(int j = 0; j < now_Str.size(); j++){
            if(now_Str[j] == '+'){
                sum += stoll(now_Str.substr(begin, j - begin));
                //cout << stoll(str_Now.substr(begin, j - begin)) << endl;
                begin = j+1;
            }
            
            if(j == now_Str.size()-1){
                sum += stoll(now_Str.substr(begin, now_Str.size() - begin));
                //cout << stoll(str_Now.substr(begin, str_Now.size() - begin)) << endl;
            }
        }
        
    }
    
    cout << sum << endl;
    
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    int state = 0, count = 0;
    rep(i,n-1) {
        if (a.at(i) < a.at(i+1)) {
            if (state == -1) {
                count++;
                state = 0;
            }
            else state = 1;
        }
        if (a.at(i) > a.at(i+1)) {
            if (state == 1) {
                count++;
                state = 0;
            }
            else state = -1;
        }
    }
    cout << count + 1 << endl;
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define f(i,a,b) for(i=a;i<=b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define scan1(x) scanf("%lld",&x)
#define scan2(x,y) scanf("%lld %lld",&x,&y)
#define scan3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define print(x) printf("%lld\n",x)
#define ff first
#define ss second
using namespace std;
vector<ll> adj[100001];
vector<bool> visited(100001);
vector<ll> dp(100001);
ll n,m,i,j,u,v;

void dfs(ll src){
    visited[src]=true;
    for(auto x:adj[src]){
    if(!visited[x])
    dfs(x);
    dp[src]=max(dp[src],dp[x]+1);
    }
    
}


int main(){
    
    scan2(n,m);
    
    f(i,1,m){
        scan2(u,v);
        adj[v].pb(u);
    }
    
    f(i,1,n)
    if(!visited[i])
    dfs(i);
    
    
    ll ans=INT_MIN;
    f(i,1,n)
    ans=max(dp[i],ans);
    
    cout<<ans<<"\n";
    
}

Measured memory_bytes: 11008
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort(reverse=True)
f.sort()
mx=10**12
mn=-1
def test(buf):
    count=0
    for i in range(n):
        count+=max(0,a[i]-buf//f[i])
        if count>k:
            return False
    return True

while mx-mn>1:
    buf=(mx+mn)//2
    if test(buf):
        mx=buf
    else:
        mn=buf
print(mx)

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

int main()
{
	std::vector<char> v(100000);
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
    	cin >> v[i];
    }

    for(int i=0;i<n-1 ;i++){
    	if(v[i] == 'F' && v[i+1] == 'F') v[i+1] = 'T';
    }

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

}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (int i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef long double lldb;
typedef pair<ll, ll>  ii;
typedef pair<lldb, lldb>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const lldb PI = acos(-1);
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 2020000
#define offset 200
#define ptr nodo*
const ll MOD=1e9+7;
#define lazy first
#define sum second

int main()
{
	int n,m;
	cin>>n>>m;
	set<ii> s;
	int iz,der;
	forr(i,0,m)
	{
		cin>>iz>>der;
		s.insert({iz,der});
		s.insert({der,iz});
	}	

	forr(i,2,n)
	{
		if (s.find({1,i})!=s.end() && s.find({i,n})!=s.end())
		{
			cout<<"POSSIBLE\n";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE\n";
}

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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int K;
  cin >> s >> K;
  int N = s.size();
  
  vector<vector<int> > a(26);
  
  rep(i,N){
    a[s[i]-'a'].PB(i);
  }
  
  vector<string> S,ans;
  
  
  rep(i,26){
    if(!a[i].empty()){
      rep(j,a[i].size()){
        REP(k,K){
          if(a[i][j] + k - 1 < N){
            S.PB(s.substr(a[i][j],k));
            //cout << s.substr(a[i][j],k) << endl;
          }
        }
      }   
    }
  }
  
  sort(ALL(S));
  
  bool flag;
  
  rep(i,S.size()){
    flag = true;
    rep(j,ans.size()){
      if(ans[j] == S[i]){
        flag = false;
      }
    }
    if(flag) ans.PB(S[i]);
  }
  
  
  cout << ans[K-1] << endl;
  

}

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}






void test_case() {

  int n, m;
  cin>>n>>m;


  int ans = max(0, (n * (n-1))/2 );

  ans+= max(0, (m*(m-1))/2);
  cout<<ans<<endl;
  

    


}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define PI 3.141592653589793238
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in2.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		char c; cin >> c;
		if(isupper(c)) cout << 'A';
		else cout << 'a';
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define P (1'000'000'007)

using vi = vector<int>;

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;}

signed main() {
    int n, k;
    cin >> n >> k;

    vector<double> va;
    double max = 0.0;
    rep(i, n) {
        capi(a);
        va.push_back(a);
        chmax(max, (double)(a));
    }

    double d = max / 4.;
    double x = max / 2.;
    for (; d > 1E-9; d /= 2.) {
        int res = 0;
        rep(i, n) {
            res += ceil(va[i] / x) - 1.0;
        }
        if (res > k) {
            x += d;
        } else {
            x -= d;
        }
    }

    cout << (int)(ceil(x));

    return 0;
}

Measured memory_bytes: 4848
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 100005
#define ll long long
ll a[N],b[N],A,B;int n;
int check(ll x)
{
	for(int i=1;i<=n;i++)b[i]=a[i]-x*B;
	for(int i=1;i<=n;i++)if(b[i]>0)x-=(ll)(ceil((1.0*b[i])/(1.0*A-B)));
	return x>=0;
}
int main()
{
	// freopen("Study.in","r",stdin);freopen("Study.out","w",stdout);
	scanf("%d%lld%lld",&n,&A,&B);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	ll l=1,r=1ll<<31;
	while(l<r)
	{
		ll m=(l+r)>>1;
		if(check(m))r=m;
		else l=m+1;
	}printf("%lld\n",l);return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int M;
    cin >> M;
    cout << 48-M;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
const int MAX=1000001;

int main(){
    int n,m;cin>>n;
    string s[100],t[100];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>t[i];
    }
    
    int M=0;
    for(int i=0;i<n;i++){
        int cb=0,cr=0;
        for(int j=0;j<n;j++)if(s[i]==s[j]) cb++;
        for(int j=0;j<m;j++)if(s[i]==t[j]) cr++;
        M=max(M,cb-cr);
    }

    cout<<M<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int a[100005];

int abs(int u){ return u>0?u:-u; }

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    std::sort(a+1,a+1+n);
    int diff = -1, find = -1;
    for(int i = 1; i <= n-1; i++){
        int curDiff = abs(a[n]-a[i]-a[i]);
        if(diff==-1 || curDiff<diff){ 
            find = a[i];
            diff = curDiff;
        }
    }
    printf("%d %d\n",a[n],find);
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k, x;
	cin >> k >> x;
	for (int i = max(-1000000ll, x - k + 1); i <= min(1000000ll, x + k - 1); i++)
		cout << i << ' ';
	cout << '\n';
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, x, t) = readIntList()
    val ans = ((n + x - 1) / x) * t
    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 36392
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from bisect import bisect_right

N,K = LI()
A = LI()

P = []
Z = []
M = []
for a in A:
    if a < 0:
        M.append(a)
    elif a == 0:
        Z.append(a)
    else:
        P.append(a)

P.sort()
M.sort()

lm,lz,lp = len(M),len(Z),len(P)

nm = lm*lp
nz = lz*(lz-1)//2 + lz*(lm+lp)

if K <= nm:
    ok = 0
    ng = -10**18-1
    while abs(ok-ng) > 1:
        now = (ok+ng)//2
        num = 0
        p = -1
        for i in range(lp):
            tmp = p
            for j in range(p+1,lm):
                if P[i]*M[j] <= now:
                    tmp = j
                else:
                    break
            p = tmp
            num += p+1
        if num >= K:
            ok = now
        else:
            ng = now
    print(ok)
elif K <= nm+nz:
    print(0)
else:
    # 負数のリストを正数のリストと同様に扱えるようにする
    M = [-m for m in M]
    M.sort()
    ok = 10**18+1
    ng = 0
    while abs(ok-ng) > 1:
        now = (ok+ng)//2
        num = 0
        p = -1
        for i in range(lp)[::-1]:
            tmp = p
            for j in range(p+1,i):
                if P[i]*P[j] <= now:
                    tmp = j
                else:
                    break
            p = tmp
            num += min(p+1,i)
        p = -1
        for i in range(lm)[::-1]:
            tmp = p
            for j in range(p+1,i):
                if M[i]*M[j] <= now:
                    tmp = j
                else:
                    break
            p = tmp
            num += min(p+1,i)
        if num >= K-nm-nz:
            ok = now
        else:
            ng = now
    print(ok)

Measured memory_bytes: 90596