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

int pow_rep(int a,int n){//繰り返し2乗法
  if(!n) return 1;
  
  long long x = pow_rep(a,n/2);
  x = x*x % MOD;
  if(n%2 == 1) x= x*a%MOD;
  //cout<<x<<" "<<n<<endl;
  return x%MOD;
}

long long  ncr(int n,int r){
  long long x=1,y=1;
  for(int i=0;i<r;i++){
    x=x*(n-i)%MOD;
    y=y*(i+1)%MOD;
  }
  int yy = pow_rep(y,MOD-2);
  return x*yy%MOD;
}

 int main () {
   int n,a,b;
   cin >> n >>a >>b;
   int ans = pow_rep(2,n) -1;
   ans -= ncr(n,a);
   if(ans < 0)ans+=MOD;
   ans -= ncr(n,b);
   if(ans < 0)ans+=MOD;
  cout << ans << endl;
   return 0;
 }




Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def print_ans(A, B, C):
    """Test Case
    >>> print_ans(6, 4, 3)
    1
    >>> print_ans(8, 3, 9)
    4
    >>> print_ans(12, 3, 7)
    0
    """
    print(max(0,C - A + B))

if __name__ == '__main__':
    A, B, C = map(int,input().rstrip().split())
    print_ans(A, B, C)


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

int main() {
  int X,ans;
  cin>>X;
  if (X<600) ans = 8;
  else if (X<800) ans = 7;
  else if (X<1000) ans = 6;
  else if (X<1200) ans = 5;
  else if (X<1400) ans = 4;
  else if (X<1600) ans = 3;
  else if (X<1800) ans = 2;
  else ans = 1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll h,w,i;
    cin>>h>>w;
    ll ans=INT_MAX,p;
    for (i=1;i<h;i++)
    {
        vector<ll> s;
        s.pb(i*w);
        p=h-i;
        if (p%2==0)
        {
            if (p/2!=0)
            {
                s.pb(w*(p/2));
                s.pb(w*(p/2));
                ans=min(ans,*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()));
            }
        }
        else
        {
            if (p/2!=0 && p/2+1!=0)
            {
                s.pb(w*(p/2));
                s.pb(w*(p/2+1));
                ans=min(ans,*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()));
            }
        }
        s.clear();
        s.pb(i*w);
        if (w%2==0)
        {
            if (w/2!=0)
            {
                s.pb((w/2)*p);
                s.pb((w/2)*p);
                ans=min(ans,*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()));
            }
        }
        else
        {
            if (w/2!=0 && w/2+1!=0)
            {
                s.pb((w/2)*p);
                s.pb((w/2+1)*p);
                ans=min(ans,*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()));
            }
        }
    }
    for (i=1;i<w;i++)
    {
        vector<ll> s;
        s.pb(i*h);
        p=w-i;
        if (p%2==0)
        {
            if (p/2!=0)
            {
                s.pb(h*(p/2));
                s.pb(h*(p/2));
                ans=min(ans,*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()));
            }
        }
        else
        {
            if (p/2!=0 && p/2+1!=0)
            {
                s.pb(h*(p/2));
                s.pb(h*(p/2+1));
                ans=min(ans,*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()));
            }
        }
        s.clear();
        s.pb(i*h);
        if (h%2==0)
        {
            if (h/2!=0)
            {
                s.pb(h/2*p);
                s.pb(h/2*p);
                ans=min(ans,*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()));
            }
        }
        else
        {
            if (h/2!=0 && h/2+1!=0)
            {
                s.pb((h/2)*p);
                s.pb((h/2+1)*p);
                ans=min(ans,*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()));
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    int N; cin >> N;
    int a[100010];
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    int cnt = 0;
    for (int i = 1; i < N; i++){
        if(a[i-1] == a[i]){
            a[i] = MM;
            cnt++;
        }
    }
    cout << cnt << endl;
}




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

int main(){
	int n;
	while(cin >> n){
		if(n==0) break;
		int start,prev,page;
		cin >> start; // page1;
		prev = start;
		for(int i=1; i<n; i++){
			cin >> page;
			if(page != prev+1){
				if(start==prev) cout << start << " ";
				else cout << start << "-" << prev << " ";
				start = page;
			}
			prev = page;
		}
		
		if(start == prev) cout << start << endl;
		else cout << start << "-" << prev << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, M;
	cin >> N >> M;

	vector<ll> A(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];

	ll sum = 0;
	for (ll i = 0; i < N; ++i) sum += A[i];
	
	ll cnt = 0;
	for (ll i = 0; i < N; ++i)
	{
		if (A[i] * 4 * M < sum) continue;
		cnt++;
	};

	if (cnt >= M)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0522?year=2008

#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;

    while (cin >> s) {
        int joi = 0, ioi = 0;
        for (int i = 0; i < s.size() - 2; ++i) {
            if (s[i + 1] == 'O' and s[i + 2] == 'I') {
                if (s[i] == 'J') {
                    joi++;
                } else if (s[i] == 'I') {
                    ioi++;
                }
            }
        }

        cout << joi << endl;
        cout << ioi << endl;
    }
}

/*
 * substrでJOI,IOIをそれぞれ探したらTLEだったので
 * OIが共通なことを利用した。
 *
 */


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


int main(){
    int A,B,C,X;
    cin>>A>>B>>C>>X;

    int ans=0;
    for(int a=0;a<A+1;++a){
        for(int b=0;b<B+1;++b){
            for(int c=0;c<C+1;++c){
                int total=500*a+100*b+50*c;
                if(total==X)++ans;
            }
        }
    }


    
    cout<<ans<<endl;

    return 0;
    
}

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

ans=0

n=0
if A[n] > x:
    ans += A[n]-x
    A[n] = x

for n in range(1,N):
    if A[n-1]+A[n] > x:
        ans += A[n]-(x-A[n-1])
        A[n] = x-A[n-1]
        
print(ans)

Measured memory_bytes: 19844
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,k,i,x;
	x=0;
	cin>>n>>k;
	if(n%k>0){
		x=1;
	}
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main(){
	string s; cin >> s;
	int n=s.length();
	ll out = (ll)n*(n - 1) / 2;
	ll cnt[26] = {};
	rep(i, n) {
		cnt[s[i] - 'a']++;
	}
	rep(i, 26) {
		out -= cnt[i] * (cnt[i] - 1) / 2;
	}
	cout << out + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

void _joinmap(int x,int y,int nx,int ny,int** maps)
{
	maps[nx][ny] = 2;
	if(ny % 2)
	{
		if(ny < y-1)
		{
			if(maps[nx][ny+1] == 0)
			{
				_joinmap(x,y,nx,ny+1,maps);
			}
			if(nx < x-1)
			{
				if(maps[nx+1][ny+1] == 0)
				{
					_joinmap(x,y,nx+1,ny+1,maps);
				}
			}
		}
		if(ny > 0)
		{
			if(maps[nx][ny-1] == 0)
			{
				_joinmap(x,y,nx,ny-1,maps);
			}
			if(nx < x-1)
			{
				if(maps[nx+1][ny-1] == 0)
				{
					_joinmap(x,y,nx+1,ny-1,maps);
				}
			}
		}
	}
	else
	{
		if(ny < y-1)
		{
			if(maps[nx][ny+1] == 0)
			{
				_joinmap(x,y,nx,ny+1,maps);
			}
			if(nx > 0)
			{
				if(maps[nx-1][ny+1] == 0)
				{
					_joinmap(x,y,nx-1,ny+1,maps);
				}
			}
		}
		if(ny > 0)
		{
			if(maps[nx][ny-1] == 0)
			{
				_joinmap(x,y,nx,ny-1,maps);
			}
			if(nx > 0)
			{
				if(maps[nx-1][ny-1] == 0)
				{
					_joinmap(x,y,nx-1,ny-1,maps);
				}
			}
		}
	}
	if(nx < x-1)
	{
		if(maps[nx+1][ny] == 0)
		{
			_joinmap(x,y,nx+1,ny,maps);
		}
	}
	if(nx > 0)
	{
		if(maps[nx-1][ny] == 0)
		{
			_joinmap(x,y,nx-1,ny,maps);
		}
	}
}

void joinmap(int x,int y,int** maps)
{
	_joinmap(x,y,0,0,maps);
}

int countlength(int x,int y,int** maps)
{
	int i,j,length = 0;
	for (i = 1; i < y-1; i += 1)
	{
		for (j = 1; j < x-1; j += 1)
		{
			if(maps[j][i] == 1)
			{
				if(i % 2)
				{
					if(maps[j][i+1] == 2)
					{
						length++;
					}
					if(maps[j+1][i+1] == 2)
					{
						length++;
					}
					if(maps[j][i-1] == 2)
					{
						length++;
					}
					if(maps[j+1][i-1] == 2)
					{
						length++;
					}
				}
				else
				{
					if(maps[j][i+1] == 2)
					{
						length++;
					}
					if(maps[j-1][i+1] == 2)
					{
						length++;
					}
					if(maps[j][i-1] == 2)
					{
						length++;
					}
					if(maps[j-1][i-1] == 2)
					{
						length++;
					}
				}
				if(maps[j+1][i] == 2)
				{
					length++;
				}
				if(maps[j-1][i] == 2)
				{
					length++;
				}
			}
		}
	}
	return length;
}

int main()
{
	int x,y,i,j;
	int** maps;
	scanf("%d %d",&x,&y);
	maps = (int**)malloc(sizeof(int*)*(x+2));
	for(i = 0;i < (x+2);i++)
	{
		maps[i] = (int*)malloc(sizeof(int)*(y+2));
		for (j = 0; j < (y+2); j += 1)
		{
			maps[i][j] = 0;
		}
	}
	for (i = 0; i < y; i += 1)
	{
		for (j = 0; j < x; j += 1)
		{
			scanf("%d",&(maps[j+1][i+1]));
		}
	}
	joinmap(x+2,y+2,maps);
	printf("%d\n",countlength(x+2,y+2,maps));
	return 0;
}

Measured memory_bytes: 0
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int k, n;
  string s;
  cin >> k >> s;
  n = s.size();
  combination c(n+k);
  mint ans = 0;
  for (int i = 0; i <= k; ++i) {
    mint now = mint(26).pow(k-i);
    now *= mint(25).pow(i);
    now *= c(i+n-1,n-1);
    ans += now;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35580
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(I, N) for (ll I = 0; I < (N); ++I)
#define repp(I, a, B) for (ll I = (a); I <= (B); ++I)
#define inn ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);srand(time(NULL));cout<<fixed<<setprecision(10);clock_t clk;clk = clock();
#define outt clk=clock()-clk;cerr<<fixed<<setprecision(6)<<"Time: "<<((double)clk)/CLOCKS_PER_SEC<<"\n";return 0;
using namespace std;
#define TRACE
#ifdef TRACE
#define t(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define t(...)
#endif
const int N = 2e5 + 5;
const int MAX = 2e6 + 5;
const int MOD = 1000000007;

//

signed main()
{
    inn;

    int n, m;
    cin >> n >> m;
    if(n >= m) 
    {
        cout << 0;
        return 0;
    }
    int a[m + 1];
    repp(i,1,m) cin >> a[i];
    sort(a + 1, a + m + 1);
    int dif[m + 1];
    repp(i,2,m) dif[i] = a[i] - a[i - 1];
    sort(dif + 2, dif + m + 1);
    int ans = 0;
    int rem = m - n;
    repp(i,2,m)
    {
        if(rem) ans += dif[i]; 
        else break;
        rem--;
    }
    cout << ans;

    outt;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define n_l '\n'
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: "; cerr << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cerr << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cerr << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cerr << endl
#define run(a, b) cerr << fixed << setprecision(6) << (double) (b - a) / (double) (CLOCKS_PER_SEC) << " s" << endl;
#define ll long long
#define ld long double
#define INF (1e18L + 5)
#define MOD (ll)(1e9 + 7)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n; string s;
    cin >> n >> s;
    string ans = "";
    ans += s[0];
    for(int i = 1; i < n; i++) {
        if(ans[ans.size() - 1] != s[i]) {
            ans += s[i];
        }
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 592
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	   long sum = 0;
		Scanner input = new Scanner(System.in);
		long n = input.nextLong();
		
		for(long i=1;i<=n;i++){
		    if(i%3==0 && i%5==0){
		      // System.out.println("FizzBuzz");
		    }else if(i%3==0){
		       //System.out.println("Fizz");
		    }else if(i%5==0){
		        //System.out.println("Buzz");
		    }
		    else{
		        //System.out.println(i);
		        sum+=i;
		    }
		    
		}
		System.out.println(sum);
	}
}


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

long long a, b, c, d, m;

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



Measured memory_bytes: 3644
s = input()
t = input()
if(s == t):
    print("Yes")
    exit()

n = len(s) - 1
for _ in range(n):
    a = s[-1] + s[:-1]
    if(a == t):
        print("Yes")
        exit()
    s = s[-1] + s[:-1]

print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){

    int a = 0 , b = 0 , c = 0 , d = 0 , n = 6 ;
    for(int i = 0 ; i < n ; i ++ ){
        int h ;
        cin >> h ;
        if(h==1){
            a++;
        }
        if(h==2){
            b++;
        }
        if(h==3){
            c++;
        }
        if(h==4){
            d++;
        }
    }
    if(a>2 || b > 2 || c > 2 || d >2 ){
        cout<<"NO"<<endl;
        return 0 ;
    }
    cout<<"YES"<<endl;
    return 0;

}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
  int n, k;
  cin >> n >> k;
  cout << n - k+1 << endl;

  return 0;
}

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

const int maxn = 100 * 1000 + 20; 
int n, a[maxn];

bool solve(bool win) {
    int ha = 0, cnt[2] = {0, 0};
    for (int i = 0; i < n; i++) {
        cnt[a[i] % 2]++;
        if (a[i] == 1)
            ha++;
    }   
    if (cnt[0] % 2)
        return win;
    if (cnt[1] > 1)
        return !win;
    if (ha)
        return !win;
    int g = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2)  
            a[i]--;
        g = __gcd(g, a[i]);
    }   
    for (int i = 0; i < n; i++)
        a[i] /= g;
    return (solve(!win));
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (n == 1)
        return cout << "Second\n", 0;
    cout << (solve(1)? "First\n": "Second\n");
    return 0;
}


Measured memory_bytes: 4032
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def dfs(s, graph, bridge, visit):
    visit[s] = True
    for next in graph[s]:
        if not bridge[s][next]: continue
        if visit[next]: continue
        dfs(next, graph, bridge, visit)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    graph = {n: [] for n in range(N)}

    for _ in range(M):
        a, b = il()
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)

    ret = 0
    bridge = {n: [True] * N for n in range(N)}
    for i in range(N):
        for j in graph[i]:
            visit = [False] * N
            bridge[i][j],bridge[j][i] = False, False
            dfs(0, graph, bridge, visit)
            if not all(visit): ret += 1
            bridge[i][j], bridge[j][i] = True, True
    print(ret//2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll h, n; cin >> h >> n;
    VL a(n); cin >> a;
    each(i, a)h -= i;
    cout << (h <= 0 ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>
using namespace std;

#define int long long


signed main() { 
    string s, t;
    cin >> s >> t;
    
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) ans++;
    }

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

Measured memory_bytes: 3820
import math
n,d = map(int,input().split())
a=[]
for i in range(n):
    arr=list(map(int,input().split()))
    a.append(arr)
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        tmp=0
        for k in range(d):
            tmp+=(a[i][k]-a[j][k])**2
        if math.sqrt(tmp)==int(math.sqrt(tmp)):
            ans+=1
print(ans)

Measured memory_bytes: 3064
N, K = map(int, input().split())

if N <= K:
    while abs(N - K) < N:
        N = abs(N - K)
else:
    N1 = N % K
    N2 = abs(N - int(N // K + 1) * K)
    N = N1 if N1 < N2 else N2

print(N)

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

typedef long long int ll;
typedef pair<ll,ll> P;

int main(){
    int n;
    cin>>n;
    vector<ll>a,b;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a.push_back(x);
        b.push_back(y);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    
    if(!(n%2)){
        cout<<-a[n/2]-a[n/2-1]+b[n/2]+b[n/2-1]+1<<endl;
    }else{
        cout<<-a[(n+1)/2-1]+b[(n+1)/2-1]+1<<endl;
    }
    
    return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  long long res = -1;
  for (int i = 0; i < 10; i++) {
    long long tmp = 10 * b + i;
    if (tmp * 8 / 100 == a) {
      res = tmp;
      break;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
//#include "stdafx.h"
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
//
ll N;
pair<ll, ll> P[500000];
ll A[500000];
ll S[500000];
int main() {
    cin >> N;
    FOR(i, 0, N) {
        cin >> P[i].FI >> P[i].SE;
    }
    sort(P, P + N);
    S[0] = P[0].SE;
    FOR(i, 1, N) {
        S[i] = S[i - 1] + P[i].SE;
    }
    FOR(i, 0, N) {
        A[i] = S[i] - P[i].FI;
    }
    ll ans = P[0].SE;
    ll m = -P[0].FI;
    FOR(i, 1, N) {
        m = min(m, S[i - 1] - P[i].FI);
        ans = max(ans, A[i] - m);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18716
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Measured memory_bytes: 38652
#include <iostream>
bool Check(int length[3]);

int main(void)
{
    int dataCount;
    std::cin >> dataCount;
    while(dataCount--){
        int length[3];
        std::cin >> length[0] >> length[1] >> length[2];
        std::cout << (Check(length) ? "YES" : "NO") << std::endl;
    }
    return 0;
}

bool Check(int length[3])
{
    int z = length[0] > length[1] ? (length[0] > length[2] ? 0 : 2) : (length[1] > length[2] ? 1 : 2);
    int buffer = 0;
    for(int i=0;i < 3;++i){
        if(i != z){
            buffer += length[i] * length[i];
        }
    }
    return buffer == length[z] * length[z];
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


long long func(int A) {
    int res = 0;
    res |= (A + 1) / 2 & 1;

    for(int k = 1; k <= 60; ++k) {
        int s = 1LL << k;
        int t = A / s;

        if (t % 2 == 0) {
            continue;
        }

        res |= (1LL - (A & (s - 1) & 1)) << k;
    }

    return res;
}


void solve(long long A, long long B){
//    fprintf(stderr, "%x %x\n", func(A - 1), func(B));
    cout << (func(A - 1) ^ func(B)) << endl;
}

signed main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int a,b,c;

int main()
{
	cin>>a>>b>>c;
	if(a+b+c>=22) puts("bust");
	else puts("win");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
//#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 200000000
#define N 1000001


int32_t main()
{
    IOS;

    int n,m;
    cin >> n >> m;
    vector<int> g[n];
    vector<int> cost(m);
    vector<int> keys[m];
    for(int i = 0;i < m;i++)
    {
        int sz = 0;
        cin >> cost[i] >> sz;
        for(int j = 0;j < sz;j++)
        {
            int k;
            cin >> k;
            k--;
            g[k].push_back(i);
            keys[i].push_back(k);
        }
    }
    vector<int> dp((1<<n),inf);
    dp[0] = 0;
    for(int i = 0;i < (1<<n);i++)
    {
        for(int j = 0;j < n;j++)
        {
            if(i & (1<<j))
                ;
            else
            {
                for(auto key : g[j])
                {
                    int r = 0;
                    for(auto it : keys[key])
                    {
                        r |= (1 << it);
                    }
                    dp[i | r] = min(dp[i | r],dp[i] + cost[key]);
                }
            }
        }
    }
    if(dp[(1<<n) - 1] == inf)
        cout << -1;
    else
        cout << dp[(1<<n) - 1];
    return 0;
}
 
 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
ll modpow(long long a, long long n, long long mod2) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod2;
        a = a * a % mod2;
        n >>= 1;
    }
    return res;
}

int main() {
    int n;
    ll ans = 0;
    cin >> n;
    map<string,ll> mp;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    for(auto i: mp){
        ans += i.second*(i.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
N,A = map(int,input().split())
X = list(map(int,input().split()))
Y = [x-A for x in X]
dp = {0:1}

for y in Y:
  tmp = list(dp.items())
  for k,v in tmp:
    dp[k+y]=dp.get(k+y,0)+v

print(dp[0]-1)

Measured memory_bytes: 9372
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.Set as S
import Data.Char
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: String -> String
solve s = stage2 "" c0 bs0
  where

  (b0, bs0) = minCoverLS (reverse s)
  c0 = leastNonElem b0

  stage2 acc c []     = reverse (c:acc)
  stage2 acc c (b:bs) = stage2 (c:acc) newC bs
    where newC = leastNonElem (tail (dropWhile (/= c) b))
    
allChars = S.fromDistinctAscList ['a'..'z']

minCoverLS s = sub [] s
  where
    sub acc s = case minCover s of
      (True, t, newS) -> sub (t:acc) newS
      (False, t, _) -> (t, acc)

minCover :: String -> (Bool, String, String)
minCover s = sub "" s allChars
  where
    sub t "" _ = (False, t, "")
    sub t (c:s) cset | S.null newCset = (True, c:t, s)
                     | otherwise      = sub (c:t) s newCset
      where newCset = S.delete c cset

leastNonElem s = S.findMin (foldr S.delete allChars s)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> String
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_str]:remLines1 = remLines0
      str = B.unpack bs_str
  in solve str

outAnswer :: String -> IO ()
outAnswer = putStrLn

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "atcoderregularcontest\n"
inp2 = "abcdefghijklmnopqrstuvwxyz\n"
inp3 = "frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == "b"
test2 = tv2 == "aa"
test3 = tv3 == "aca"
alltest = test1 && test2 && test3



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

using namespace std;

int n;
int main(){
  string a,b,c;
  cin >> n;
  cin >> a >> b >> c;
  int ans=0;
  for(int i=0;i!=n;i++){
    if(a[i]==b[i]){
      if(a[i]==c[i]){

      }
      else{
        ans++;
      }
    }
    else if(a[i]==c[i]){
      ans++;
    }
    else if(b[i]==c[i]){
      ans++;
    }
    else{
      ans=ans+2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define max 10001
#define INFTY (1<<20)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1

struct node{
	struct node *next;
	int v , h;
};

typedef struct node *NodePointer;
NodePointer nil;

NodePointer data[max];
int d[max];
int color[max];
int pi[max];

void create_node(int r , int v , int c)
{
	NodePointer n;
	n = (NodePointer)malloc(sizeof(struct node));
	n->v = v;
	n->h = c;
	n->next = data[r]->next;
	data[r]->next = n;
}

int main(void)
{
	int ex;
	int i , j;
	int n , u, k,v,c,r;
	int uid;
	int mc;
	
	for(i = 0; i < max; i++)
	{
		data[i] = (NodePointer)malloc(sizeof(struct node));
		data[i]->v = INFTY;
		data[i]->h = INFTY;
		data[i]->next = NULL;
	}
	
	scanf("%d",&n);
	
	for(i = 1; i <= n; i++)
	{
		d[i] = INFTY;
		color[i] = WHITE;
		pi[i] = NIL;
		
		scanf("%d%d",&uid,&k);
		r = uid;
		for(j = 0; j < k; j++)
		{
			scanf("%d%d",&v,&c);
			create_node(r,v,c);
		}
	}
	d[0] = 0;
	for(ex = 0; ;ex++)
	{
		mc = INFTY;
		for(j = 0; j < n; j++)
		{
			if(color[j] != BLACK && d[j] < mc)
			{
				mc = d[j];
				u = j;
			}
		}
		if(mc == INFTY)
		{
			break;
		}
		
		color[u] = BLACK;
		
		nil = data[u]->next;
		while(nil != NULL)
		{
			if(color[nil->v] != BLACK && d[u]+nil->h<d[nil->v])
			{
				pi[nil->v] = u;
				d[nil->v] = nil->h+d[u];
			}
			nil = nil->next;
		}
	}
	for(i = 0; i < n; i++)
	{
		printf("%d %d\n",i,d[i]);
	}
	return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

ll gcd(ll n, ll m) {
    // nとmの最大公約数を返す関数
    if(m > n) {
        ll c = n;
        n = m; 
        m = c;
    }
    if(n%m == 0) return m;
    else return gcd(m, n%m);
}

vector< pair<ll, ll> > prime_factorize(ll n) {
    // 素因数分解アルゴリズム
    vector< pair<ll, ll> > res;
    for(ll a = 2; a*a <= n; ++a) {
        if(n % a != 0) continue;
        ll ex = 0;
        while(n % a == 0) {
            ++ex;
            n /= a;
        }
        res.push_back({a, ex});
    }
    if(n != 1) res.push_back({n, 1});
    return res;
}

int main(){
    ll n, m;
    scanf("%lld%lld", &n, &m);
    ll g = gcd(n, m);
    vector< pair<ll, ll> > prime = prime_factorize(g);
    printf("%d\n", int(prime.size()) + 1);
    return 0;
    
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    int x=0;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3132
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
n = int(input())

cnt = 0

def check(d):
    tmp = n
    while tmp % d == 0:tmp //= d
    tmp %= d
    return tmp == 1

d = 1
while d * d <= n:
    if n % d != 0:
        d+=1
        continue
    if d != 1:
        cnt += check(d)
    if n // d > d:
        cnt += check(n // d)
    d += 1

n -= 1
d = 1
while d * d <= n:
    if n % d != 0:
        d+=1
        continue
    if d != 1:
        cnt += 1
    if n // d > d:
        cnt += 1
    d += 1

print(cnt)


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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int ans;
    if(a+b+1>=c){
        ans=b+c;
    }
    else{
        ans=a+b+1+b;
    }
    cout<<ans;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
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; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    ll n, k; cin >> n >> k;
    vector<int> a(n); inv(n, a);
    vector<int> v;
    ll in_a = 0, in_a_a = 0;
    rep(i, a.size()){
        ll bf = 0, af = 0;
        rep(j, a.size()){
            if(i==j) continue;
            if(i > j){ //前を見ている
                if(a[i] > a[j]) bf++;
            }else{
                if(a[i] > a[j]) af++;
            }
        }
        in_a += af;
        in_a_a += (af+bf);
    }
    ll ans = 0;
    ll mul1 = k % MOD;
    ll mul2 = (k * (k-1) / 2) % MOD;
    ans = (in_a * mul1 % MOD + in_a_a * mul2 % MOD);
    cout << ans % MOD << endl;
    return 0;   
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long S = sc.nextLong();
		long x1, x2, y1, y2;
		x1 = (int)Math.ceil(Math.sqrt(S));
		y2 = x1;
		x2 = x1*y2 - S;
		y1 = 1;
		System.out.println(x1 + " " + y1 + " " + x2 + " " + y2 + " " + 0 + " " + 0);

	}

}

Measured memory_bytes: 23892
A, B, C, D = map(int, input().split())
Tcount = 0
Acount = 0
while C > 0:
  C = C -B
  Acount = Acount + 1
while A > 0:
  A = A - D
  Tcount = Tcount + 1
print("Yes" if Tcount >= Acount else "No")

Measured memory_bytes: 9184
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S, T):
    sc = Counter(S)
    tc = Counter(T)

    for i in range(len(S)):
        if sc[S[i]] != tc[T[i]]:
            return 'No'

    return 'Yes'


def main():
    S = read_str()
    T = read_str()
    print(slv(S, T))


if __name__ == '__main__':
    main()


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

int dp[51][5001];
//i枚目までのカードで合計がkになる組み合わせ

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

  int n,a; cin >> n >> a;
  vector<int> x(n);
  for(int i = 0; i < n; i++){
    cin >> x[i];
    x[i] -= a;
  }
  //平均がa <==> x[i]-aの合計が0

  int base = n*a/2;
  dp[0][base] = 1;
  for(int i = 0; i < n; i++){
    for(int k = 0; k <= 2*n*a; k++){
      if(0 <= k+x[i] && k+x[i] <= 5000){
        dp[i+1][k+x[i]] += dp[i][k];
      }
      dp[i+1][k] += dp[i][k];
    }
  }
  cout << dp[n][base] - 1 << endl;

  return 0;
}


Measured memory_bytes: 2176
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  n PIC 9(08).
       01  m PIC 9(08).
       PROCEDURE DIVISION.
        ACCEPT n
        ACCEPT m

         IF n = 1 THEN
           IF m = 2 THEN
                  DISPLAY "3"
           END-IF
           IF m = 3 THEN
                  DISPLAY "2"
           END-IF
         END-IF

         IF n = 2 THEN
           IF m = 1 THEN
                  DISPLAY "3"
           END-IF
           IF m = 3 THEN
                  DISPLAY "1"
           END-IF
         END-IF

         IF n = 3 THEN
           IF m = 2 THEN
                  DISPLAY "1"
           END-IF
           IF m = 1 THEN
                  DISPLAY "2"
           END-IF
         END-IF


       STOP RUN.


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define pf push_front
#define Mid ((l+r)/2)
#define pi pair<int,int>
#define pii pair<int,pi>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    go;
    int k;
    string s;
    cin>>k;
    cin>>s;
    int n=s.size();
    if(n<=k)
        cout<<s;
    else
    {
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"...";
    }
    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
int x[105],y[105],h[105];
int main(){
	int n,i,j,k,t,p=0;
	bool ok;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&x[i],&y[i],&h[i]);
		if(!p&&h[i])p=i;
	}
	for(i=0;i<=100;i++)
		for(j=0;j<=100;j++){
			ok=1;
			t=h[p]+abs(i-x[p])+abs(j-y[p]);
			for(k=0;k<n;k++)if(max(t-abs(i-x[k])-abs(j-y[k]),0)!=h[k])ok=0;
			if(ok){
				printf("%d %d %d\n",i,j,t);
				return 0;
			}
		}
}

Measured memory_bytes: 128
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


def matrix_cal(A, B, mod):
    a = len(A)
    b = len(A[0])
    c = len(B)
    d = len(B[0])

    assert(b == c)
    ans = [[0] * d for _ in range(a)]
    for aa in range(a):
        for dd in range(d):
            v = 0
            for bb in range(b):
                v = (v + A[aa][bb] * B[bb][dd]) % mod
            ans[aa][dd] = v
    return ans


def matrix_pow(A, n, mod=0):
    if n == 1:
        return A
    a = matrix_pow(A, n//2, mod)
    ans = matrix_cal(a, a, mod)
    if n % 2 == 1:
        ans = matrix_cal(ans, A, mod)
    return ans


N, K = na()
A = naa(N)
mod = 10 ** 9 + 7

B = matrix_pow(A, K, mod)

ans = 0
for i in range(N):
    for j in range(N):
        ans = (ans + B[i][j]) % mod


print(ans)


Measured memory_bytes: 74788
def actual(n, P):
    # 正しくない配置にある数字が2つ以下なら、1回以下のSwapで照準になる
    n_unmatched = [i == p for i, p in enumerate(P, start=1)].count(False)

    if n_unmatched <= 2:
        return 'YES'

    return 'NO'


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

print(actual(n, P))

Measured memory_bytes: 3060
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  
  
  if (s < t)
    cout << "Yes\n";
  else
    cout << "No\n";
  
  
}

Measured memory_bytes: 256
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
if m1 != 12:
  if m2 == m1+1:
    print(1)
  else:
    print(0)
else:
  if m2 == 1:
    print(1)
  else:
    print(0)

Measured memory_bytes: 2940