akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 100000000000000000

int main() {
    int N;
    cin >> N;
    ll ans = 1;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    sort(all(A));
    rep(i, N) {
        if (A[i] != 0 && ans > LLONG_MAX / A[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }

    if (ans > 1000000000000000000)
        cout << -1 << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 4056
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
int DX[4] = {-1, 0, 1, 0};
int DY[4] = {0, -1, 0, 1};

int H, W;
char S[50][50];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W;
  rep(y, H) rep(x, W) cin >> S[x][y];
  rep(y, H) rep(x, W) if (S[x][y]=='#') {
    bool ok = false;
    rep(k, 4) {
      int nx = x+DX[k], ny = y+DY[k];
      if (nx<0||ny<0||nx>=W||ny>=H) continue;
      if (S[nx][ny] == '#') ok =true;
    }
    if (!ok) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
string S[27]={"","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
long long int N;
  string name="";
  cin>>N;
  int amari;
 if(N<26){
 cout<<S[N];
 }else{ 
   int k=0;
   for(int i=0;N>0;i++){
   amari=N%26;
    if(amari==0){amari=26;}
     N-=amari;
     name=S[amari]+name;
     N/=26;
   }  
  cout<<name;
 }
}

Measured memory_bytes: 3128
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll H,W,h,w;
	cin >>H>>W>>h>>w;
	
	// 解法
	ll ans = (H-h)*(W-w);
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>
using namespace std;

int main(void){
    // Your code here!
    int a, b, c;
    
    cin >> a >> b >> c;
    if(a <= c && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
        
    return 0;
        
}

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

using namespace std;
using namespace atcoder;

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

typedef long long ll;
typedef unsigned long long ull;

string solve(int k) {
    string ret = "";
    for (int i = 0; i < k; i++) {
        ret += "ACL";
    }
    return ret;
}


int main() {
    int k;
    cin >> k;
    cout << solve(k) << endl;
    return 0;
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    string s[15];
    for(int i = 0; i < h; i++) cin >> s[i];
    int c = 1;
    int l = w - 1;
    while(l > 0){
        c *= l;
        l -= 2;
    }
    for(int p = 0; p < w; p++){
        for(int q = 0; q < c; q++){
            string t[15];
            for(int i = 0; i < h; i++) t[i] = s[i];
            for(int i = 0; i < h; i++) swap(t[i][p], t[i][w / 2]);
            int m = q;
            for(int j = w - 1; j > 0; j -= 2){
                int n = m % j;
                for(int i = 0; i < h; i++) swap(t[i][(w + j - 1) / 2], t[i][(w - j + 1) / 2 + n]);
                m /= j;
            }
            bool b[15]{0};
            int d = 0;
            bool f = true;
            for(int i = 0; i < h; i++){
                if(b[i]) continue;
                reverse(t[i].begin(), t[i].end());
                bool g = false;
                for(int j = i + 1; j < h; j++){
                    if(b[j]) continue;
                    if(t[i] == t[j]){
                        g = true;
                        b[j] = true;
                        break;
                    }
                }
                if(!g){
                    if(d){
                        f = false;
                        break;
                    }
                    string u = t[i];
                    reverse(u.begin(), u.end());
                    if(u == t[i]) d++;
                    else{
                        f = false;
                        break;
                    }
                }
            }
            if(f){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    if(s == "SUN"){
        ans = 7;
    }
    else if(s == "MON"){
        ans = 6;
    }
    else if(s == "TUE"){
        ans = 5;
    }
    else if(s == "WED"){
        ans = 4;
    }
    else if(s == "THU"){
        ans = 3;
    }
    else if(s == "FRI"){
        ans = 2;
    }
    else if(s == "SAT"){
        ans = 1;
    }
    cout << ans << endl;
}


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

int main(){
 
  long long N,X,T,res;
  cin >> N >> X >> T;

  res = N / X ;
  if (N % X != 0)
    res++;
  res *= T;
  
  cout << res << "\n";

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll n;

struct Camel {
  ll l, r, k;
};
Camel arr[N];

bool comp(Camel &a, Camel &b) { return a.k < b.k; }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t;
  cin >> t;
  while (t--) {
    cin >> n;

    vector<Camel> pos;
    vector<Camel> neg;
    vector<Camel> zero;

    ll res = 0;
    for (ll i = 1; i <= n; i++) {
      cin >> arr[i].k >> arr[i].l >> arr[i].r;

      res += min(arr[i].l, arr[i].r);
      if ((arr[i].r - arr[i].l) < 0)
        neg.push_back(arr[i]);
      else if ((arr[i].r - arr[i].l) > 0)
        pos.push_back(arr[i]);
      else
        zero.push_back(arr[i]);
    }

    sort(neg.begin(), neg.end(), comp);

    multiset<ll> par;

    for (Camel &a : neg) {
      ll k = a.k;

      if (par.size() >= k) {
        ll val = *par.begin();
        if (val >= (a.l - a.r))
          continue;
        par.erase(par.begin());
        res -= val;
      }
      par.insert(a.l - a.r);
      res += a.l - a.r;
    }

    sort(pos.begin(), pos.end(), comp);
    reverse(pos.begin(), pos.end());

    par.clear();
    for (Camel &a : pos) {
      ll k = n - a.k;

      if(k==0)
      continue;

      if (par.size() >= k) {
        ll val = *par.begin();
        if (val >= (a.r - a.l))
          continue;
        par.erase(par.begin());
        res -= val;
      }
      par.insert(a.r - a.l);
      res += a.r - a.l;
    }


    cout << res << en;
  }

  return 0;
}


Measured memory_bytes: 17356
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N;
  cin >> N;
  int dp[N+1];
  rep(i, N+1){
    dp[i] = inf;
  }
  dp[0] = 0;
  rep(i, N+1){
    int tmp=1;
    while(i>=tmp){
      dp[i] = min(dp[i], dp[i-tmp]+1);
      tmp *= 6;
    }
    tmp=9;
    while(i>=tmp){
      dp[i] = min(dp[i], dp[i-tmp]+1);
      tmp *= 9;
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n,ans=0;
    int R=0,W=0;
    string s,c;
    cin >> n >> s;
    rep(i,n){
        if(s[i] == 'W') W++;
        else R++;
    }
    rep(i,R) c.push_back('R');
    rep(i,W) c.push_back('W');
    rep(i,n){
        if(s[i] != c[i]) ans++;
    }
    cout << ans/2 << endl;
    
}

Measured memory_bytes: 3920
#include<cstdio>
int arr[110];
int main()
{
    int N;
    scanf("%d",&N);
    long long sum=0;
    for(int i=0;i<N;i++)
    {
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    int M;
    scanf("%d",&M);
    int p,x;
    long long temp;
    for(int i=0;i<M;i++)
    {
        scanf("%d%d",&p,&x);
        temp=sum;
        printf("%lld\n",temp-arr[p-1]+x);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 11);
const int MAXK = (int)1e4 + 17;

int n, k;
string s[MAXN];

void read()
{
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> s[i];
}

bitset<MAXK> dp[MAXN];
bitset<MAXK * 100> bs[26], curr, temp, pref_bs[26];
int last[MAXN];
vector<char> cli;

bool check(char let, int c_l)
{
	temp = (curr << 1) & pref_bs[let - 'a'];

	bool ok = 0;
	for(int i = 0; i < n; i++)
	{
		if(curr[last[i]]) ok = 1;
		if(ok && cli[last[i] + 1] <= let)
		{
			temp[last[i] + 1] = 0;
			if(c_l + (int)s[i].size() <= k && dp[i + 1][k - c_l - (int)s[i].size()]) 
				temp[last[i] + 1] = 1;
		}
	}

	return !temp.none();
}

void solve()
{
	dp[n][0] = 1;
	for(int i = n - 1; i >= 0; i--)
		dp[i] = dp[i + 1] | (dp[i + 1] << s[i].size());

	cli.push_back(0);
	for(int i = 0; i < n; i++)
	{
		for(char c: s[i])
			cli.push_back(c);

		last[i + 1] = cli.size() - 1;
	}

	for(int i = 1; i < (int)cli.size(); i++)
		bs[cli[i] - 'a'][i] = 1;

	for(int i = 0; i < 26; i++)
		pref_bs[i] = (i == 0) ? (bs[0]) : (pref_bs[i - 1] | bs[i]);

	string answer = "";
	curr[0] = 1;
	for(int c_l = 0; c_l < k; c_l++)
	{
		char let, low = 'a', high = 'z', mid;
		while(low <= high)
		{
			mid = (low + high) >> 1;

			if(check(mid, c_l))
				let = mid, high = mid - 1;
			else 
				low = mid + 1;
		}

		temp = (curr << 1) & bs[let - 'a'];

		bool ok = 0;
		for(int i = 0; i < n; i++)
		{
			if(curr[last[i]]) ok = 1;
			if(ok && cli[last[i] + 1] == let)
			{
				temp[last[i] + 1] = 0;
				if(c_l + (int)s[i].size() <= k && dp[i + 1][k - c_l - (int)s[i].size()]) 
					temp[last[i] + 1] = 1;
			}
		}

		answer += let;
		curr = temp;
	}

	cout << answer << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 12280
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI()
	order = [0]*N
	for i,a in enumerate(A):
		order[a-1] = i+1
	order = list(map(str,order))
	print(" ".join(order))

main()

Measured memory_bytes: 61200
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize,
      p: [i64; n]
    };

    let mut ans = 0;
    let mut min = p[0];

    for &v in &p {
        if v <= min {
            ans += 1;
            min = v;
        }
    }

    println!("{}", ans);
}


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

namespace ConsoleApp1
{
    static class AOddsofOddness
    {
        static void Main(string[] args)
        {
            var n = double.Parse(Console.ReadLine());
            double oddCount = 0;

            for (int i = 1; i <= n; i++)
            {
                if (i == 1 || i % 2 != 0)
                {
                    oddCount++;
                }
            }

            Console.WriteLine(oddCount / n);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
n,m = map(int,input().split())
C = list(map(int,input().split()))
INF = 50010
dp = [[INF]*(n+1) for _ in range(m+1)]


for i in range(m):
    dp[i+1][0] = 0
    for j in range(1,n+1):
        if j-C[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j-C[i]]+1,dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[m][n])




Measured memory_bytes: 43736
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vi a(n), b(n);
  vi c(n-1);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n-1) cin>>c[i];

  int ans=0;
  rep(i,n){
    ans += b[i];
  }
  dump(ans);
  rep(i,1,n){
    if (a[i]==a[i-1]+1){
      dump(i, c[a[i-1]-1]);
      ans += c[a[i-1]-1];
    }
  }
  cout << ans << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N;
    cin >> N;

    map <ll , ll> m;
    for(int i = 0; i < N; i++){
        ll num ;
        cin >> num;
        m[num] ++;        
    }

    ll single_num = 0;
    ll double_num = 0;
    for(auto i = m.begin(); i != m.end(); i++){
        if( i-> second == 1){
            single_num += i->second;
        }
        else{
            if(i->second % 2 == 0) double_num += 1;
            else single_num ++;
        }
    }

    if(double_num % 2 == 0){
        cout << m.size()  << endl;
    }
    else{
        cout << m.size() - 1 << endl;
    }



}

Measured memory_bytes: 6528
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

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

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく


//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

bool E[2005][2005];
vector<bool> seen;
typedef pair<int, int> P;
int D[2005];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;
vector<int> ans(2005, 0);

int main() {
    int N; cin >> N;
    int X, Y; cin >> X >> Y;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (i >= j)continue;
            int dist = min({ j - i,abs(X - i) + abs(Y - j) + 1 });
            ans.at(dist)++;
        }
    }

    for (int i = 1; i <= N - 1; i++) {
        cout << ans.at(i) << endl;
    }
}


Measured memory_bytes: 256
while(True):
    n,x = [ int(s) for s in input().split() ]
    if n == 0 and x == 0:
        break

    cnt = 0
    for i in range(1,n):
        for j in range(i+1, min(n,x-i+1)):
            if x - i - j >= j + 1 and x - i - j <= n:
                cnt += 1
    print(cnt)


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

using namespace std;

struct UnionFindTree{
  vector<int> parent;
  
  UnionFindTree(int n) : parent(n){
    for(int i = 0; i < n; i++) parent[i] = i;
  }
  
  int root(int x){
    if(parent[x] == x) return x;
    else return parent[x] = root(parent[x]);
  }
  
  bool same(int x, int y){
    return root(x) == root(y);
  }
  
  void unite(int x, int y){
    int root_x = root(x);
    int root_y = root(y);
    if(root_x != root_y) parent[root_x] = root_y;
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  
  UnionFindTree permutable(n);
  
  vector<int> permutation(n);
  for(int i = 0; i < n; i++){
    int p;
    cin >> p;
    permutation[i] = p - 1; // 0 ~ n-1
  }
  
  for(int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    permutable.unite(x - 1, y - 1);
  }
  
  int count = 0;
  for(int i = 0; i < n; i++) if(permutable.same(i, permutation[i])) count++;
  
  cout << count << endl;
  
  return 0;
}

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

int main(){

	string s,t;
	int len_s,len_t;

	cin>>s;len_s = s.size();
	cin>>t;len_t = t.size();

	int ans = 919919;
	int cnt = 0;
	for(int i=0;i<len_s-len_t+1;i++){
		cnt = 0;
		for(int j=0;j<len_t;j++){
			if(s[i+j]!=t[j])cnt++;
		}
		ans = min(cnt,ans);
	}

	cout<<ans<<endl;

	return(0);
}

Measured memory_bytes: 3624
//テンプレ
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string S,T;
  cin >> S >> T;
  int a = 1;
  rep(i,S.size()){
    if(S.at(i)!=T.at(i)){
      a = 0;
      break;
    }
  }
  if(a==1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, d0=0, d1=0, d2=0;

	cin>>n;

	vi a(n), d(n);

	rep(i, n){
		cin>>a[i];
		d[i]=a[i]%4;
		if(d[i]==0){
			d0++;
		}else if(d[i]==1||d[i]==3){
			d1++;
		}else{
			d2++;
		}
	}
	if(d0+1<d1){
		cout<<"No"<<endl;
	}else if(d0+1==d1){
		if(d2==0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 1024
import math
data = input().split(' ')
h = int(data[0])
w = int(data[1])
if h == 1 or w == 1:
    print(1)
else:
    ans = math.ceil(h/2) * math.ceil(w/2) + math.floor(h/2) * math.floor(w/2)
    print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {

	
	public static void main(String[] args) {
		FastScanner scanner=new FastScanner();
		int n=scanner.nextInt();
		int a[]=scanner.readArray(n);
		
		long dp[][]=new long[n][n];
		for(int i=n-1;i>=0;i--) {
			for(int j=i;j<n;j++) {
				if(i==j) dp[i][j]=a[i];
				else dp[i][j]=Math.max(a[i]-dp[i+1][j], a[j]-dp[i][j-1]);
			}
		}
		System.out.println(dp[0][n-1]);

	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}

}


Measured memory_bytes: 104364
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun mapa-b (fn a b &optional (step 1))
  (do ((i a (+ i step))
       (result nil))
      ((> i b) (nreverse result))
    (push (funcall fn i) result)))

(defun map0-n (fn n)
  (mapa-b fn 0 n))

(defun map1-n (fn n)
  (mapa-b fn 1 n))

(defun read-string (&optional (stream *standard-input*))
  (labels ((is-empty (x)
             (or (char= x #\space) (char= x #\newline))))
    (loop for char = (read-char stream)
          with result
          when (is-empty char)
            do (return (concatenate 'string (nreverse result)))
          do (push char result))))

(defun main (str k)
  (if (every (lambda (x) (char= x #\1)) (subseq str 0 (min (length str) k)))
      #\1
      (loop for i across str
            when (null (char= i #\1))
              do (return i))))

(princ (main (read-string) (read)))


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

vector<unsigned long> ans;

void dfs(unsigned long now, unsigned long prev, unsigned long col, const vector<vector<pair<unsigned long, unsigned long>>>& edge){
    ans[now] = col;
    for(const auto& i : edge[now]){
        if(i.first != prev){
            dfs(i.first, now, col ^ i.second, edge);
        }
    }
}

int main() {
    unsigned long N;
    cin >> N;
    ans = vector<unsigned long>(N);
    vector<vector<pair<unsigned long, unsigned long>>> edge(N);
    for(unsigned long i = 1, a, b, c; i < N; ++i){
        cin >> a >> b >> c;
        edge[--a].emplace_back(--b, c &= 1);
        edge[b].emplace_back(a, c);
    }
    dfs(0, 0, 0, edge);
    for(const auto i : ans)cout << i << endl;
    return 0;
}

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

#define clean(x,y) memset(x,y,sizeof(x));
#define pb push_back
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define ALL(v) v.begin(),v.end()
#define PI acos(-1.0)
#define EPS 1e-9
#define INF (1 << 30)
#define MOD 1000000007
#define MAX 100005
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define dbg(x) cout<<(#x)<<"="<<(x)<<":\n"
#define CS(i) cout<<"Case "<<i<<": "
#define tin ll T; cin>>T; while(T--)

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


int main()
{
    FAST

    ll n,m,ans;
    cin>>n>>m;
    ans=((n)*(n-1))/2;
    ans+=(m*(m-1))/2;
    cout<<ans<<endl;



    return 0;
}




Measured memory_bytes: 256
N = int(input())

p = list(map(int,input().split()))

sa =  [0 if p[i]-i-1==0 else 1  for i in range(N) ]

cnt = 0
flag = 0
for i in sa:
    if i == 0:
        if flag == 0:            
            cnt+=1
            flag = 1
        else:
            flag= 0
    else:
        flag = 0

print(cnt)

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

int main(){
  int n;
  cin >> n;
  vi l(n);
  rep(i,n) cin >> l[i];
  int ans = 0;
  for(int a=0; a<n; a++){
    for(int b=a+1; b<n; b++){
      for(int c=b+1; c<n; c++){
        if(l[a]+l[b]>l[c] && l[a]+l[c]>l[b] && l[b]+l[c]>l[a]) {
          if(l[a] == l[b] || l[b] == l[c]|| l[c]==l[a]) continue;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i = 2; i < N; ++i) {
        if(S[i-2] == 'A' && S[i-1] == 'B' && S[i] == 'C') ++ans;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(void){
    string a,b,c;
    cin >> a >> b >> c;
    string str  = a+b+c;
    string ans = "NO";
    if(str=="557"||str=="575"||str=="755"){
        ans = "YES";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    string s;
    cin >> n >> s;
    int all = count(s.begin(), s.end(), '#');
    vector<int> a(n+1, 0);
    for(int i = n-1; i >= 0 ; i--) {
        a[i] = a[i+1] + (s[i] == '#');
    }
    int ans = INF;
    for(int i = 0; i <= n; i++) {
        int now = (n-i-a[i])+(all-a[i]);
        chmin(ans, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N, K;
    cin >> N >> K;
    
    ll ans = K;
    for(int i=2;i<=N;i++){
        ans = ans*(K-1);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def input_1line_number():
    return map(int, input().split())

def sum_of_equal_number_sequence(first_term, difference, number_of_terms):
    return (2*first_term + (number_of_terms-1)*difference) * number_of_terms // 2

def mod_number():
    return 10**9+7

def main():
    n, k = input_1line_number()

    answer = 0

    for i in range(k, n+2):
        number_of_fractions = sum_of_equal_number_sequence(n-i+1, 1, i) - sum_of_equal_number_sequence(0, 1, i) + 1
        answer += number_of_fractions

    answer %= mod_number()

    print(answer)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9164
N, L = map(int, input().split())
apples = [i + L - 1 for i in list(range(1, N+1))]
abs_apples = list(map(abs, apples))
min_index = abs_apples.index(min(abs_apples))
print(sum(apples[0:min_index]) + sum(apples[min_index+1:]))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e3+100;
int dp[maxn][maxn];
string str;
int main()
{
    int N;
    cin>>N;
    cin>>str;
    for(int j=1;j<N;++j)
        dp[0][j]=(str[j]==str[0]);
    for(int i=1;i<N;++i)
    {
        for(int j=i+1;j<N;++j)
        {
            dp[i][j]=min(min(j-i,i+1),(str[j]==str[i])*(dp[i-1][j-1]+1));
        }
    }
    int ans=0;
    for(int i=0;i<N;++i)
        for(int j=i+1;j<N;++j)
            ans=max(ans,dp[i][j]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 100736
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N; cin >> N;
    vector<uint> vecA(3*N);
    for(uint i=0; i<vecA.size(); ++i){ cin >> vecA[i]; }
    
    // head
    int64 sumH=0ull;
    priority_queue<int64,vector<int64>,greater<int64>> queH;
    for(uint i=0; i<N; ++i){ queH.push(vecA[i]); sumH+=vecA[i]; }
    
    vector<int64> vecH(N+1); vecH.resize(0);
    vecH.push_back( sumH );
    for(uint i=N; i<2*N; ++i){
        queH.push(vecA[i]);
        sumH += vecA[i];
        sumH -= queH.top(); queH.pop();
        vecH.push_back( sumH );
    }
    
    // tail
    int64 sumT=0ull;
    priority_queue<int64> queT;
    for(uint i=2*N; i<3*N; ++i){ queT.push(vecA[i]); sumT+=vecA[i]; }
    
    vector<int64> vecT(N+1); vecT.resize(0);
    vecT.push_back( sumT );
    for(uint i=2*N-1; i>=N; --i){
        queT.push(vecA[i]);
        sumT += vecA[i];
        sumT -= queT.top(); queT.pop();
        vecT.push_back( sumT );
    }
    
    // solve
    int64 max=INT64_MIN;
    for(uint i=0; i<N+1; ++i){
        int64 buf = vecH[i] - vecT[N-i];
        if(buf>max){ max=buf; }
    }
    
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 4724
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream& operator>>(istream& is, vector<T>& v);
template<class T> ostream& operator<<(ostream& os, vector<T> const& v);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream&, const tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream& os, const tuple<T...>& t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream& operator<<(ostream& os, const tuple<T...>& t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream&, tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream& is, tuple<T...>& t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream& operator>>(istream& is, tuple<T...>& t){ _it<0>(is, t); return is; }
template<class T> istream& operator>>(istream& is, vector<T>& v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
        src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int const inf = 1<<29;

Weight visit(Graph const & g, int S, int v, Weight dp[1<<16][16]){
    Weight & res = dp[S][v];
    if(res != -1) return res;
    if (S == (1 << g.size()) - 1 && v == 0) {
        res = 0;
    } else {
        res = inf;
        for(Edge const & e : g[v]){
            int dst = e.dst;
            if(S >> e.dst & 1) continue;
            res = min(res, visit(g,S|1<<dst,dst,dp)+e.weight);
        }
    }
    return res;
}
Weight TravelingSalesmanProblem(Graph const & g){
    static Weight dp[1<<16][16];
    memset(dp,-1,sizeof(dp));
    return visit(g,0,0,dp);
}

int main(){
    int n,m;
    cin >> n >> m;
    Graph g(n);
    rep(i,m){
        int s,t,d; cin >> s >> t >> d;
        g[s].eb(s,t,d);
    }
    Weight res = TravelingSalesmanProblem(g);
    if(res >= inf) res = -1;
    cout << res << endl;
}

Measured memory_bytes: 5308
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 10;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int x,y;
ll fac[maxn];
void init(){
	fac[0] = 1;
	for(int i = 1;i < maxn;i++) fac[i] = (fac[i-1] * i) % mod;
}
ll C(int n,int m){
	if(n < m) return 0;
	if(m == 0 || m == n) return 1;
	ll ans = (fac[n] * poww(fac[m],mod-2,mod))% mod * poww(fac[n-m],mod-2,mod) % mod;
	return ans;
}
void solve(){
	if((x + y) % 3 != 0){
		cout << 0 << endl;
		return;
	}
	int a = 2 * (x + y) / 3 - x; 
	int b = x - (x + y) / 3; 
	if(a < 0 || b < 0) cout << 0 << endl;
	else cout << C(a+b,a) << endl;
	return;
}
int main(){

	init();
	cin >> x >> y;
	solve();	
	return 0; 
}



Measured memory_bytes: 8192
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    b = sorted(a.copy())
    m1 = b[-1]
    m2 = b[-2]
    if m1 == m2:
        res = [m1] * n
    else:
        res = [None] * n
        for i in range(n):
            if a[i] < m1:
                res[i] = m1
            else:
                res[i] = m2
    return res
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 25156
#include <iostream>

int main(){
    int n;
    std::cin >> n;
    int mochis[n];
    int answer = 0;
    int count = 0;
    for(int i = 0; i < n; i++){
        int x;
        std::cin >> x;
        count = answer;
        if(i == 0){
            mochis[count] = x;
            answer++;
        }
        else{
            for(int ii = 0; ii < count; ii++){
                if(x == mochis[ii]){
                    break;
                }
                else if(ii == count - 1){
                    mochis[count] = x;
                    answer++;
                    break;
                }
            }
        }
    }
    std::cout << answer;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=0,b=0;
	for(int i=0;i<(int)s.size();i++){
		if(s[i]=='0')a++;
		else b++;
	}
	cout<<min(a,b)*2<<endl;
	return 0;
}

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

int main() {
    
    int N;
    cin >> N;
    
    ll sum = 1;
    
    std::vector<ll> A(N, 0);
    
    rep(i, N){
        cin >> A[i];
    }
    
    for(ll item : A){
        if(item == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    
    rep(i, N){
        if(i == 0){
          if(A[i] > LLONG_MAX || A[i] < -LLONG_MAX){
            cout << -1 << endl;
          }
            sum = A[i];
        }else{
            
            if(!(sum < LLONG_MAX/A[i])){
                cout << -1 << endl;
                return 0;
            }
            
            sum = sum * A[i];
        }
    }
    
   if(sum > 1000000000000000000 || sum < -1000000000000000000){
      cout << -1 << endl;
   }else{
    cout << sum << endl;
   }
    
    return 0;
}

Measured memory_bytes: 4052
package main

import (
	"fmt"
	"sort"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	sort.Ints(A)
	var flag int = 0
	for i := 0; i < N-1; i++ {
		if A[i] == A[i+1] {
			flag = 1
		}
	}

	if flag == 1 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

ll dp[51][2501];
int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n,a;
    cin >> n >> a;
    vi x(n);
    rep(i, n) cin >> x[i];

    dp[0][0] = 1;
    rep(i, n) for (int j = 50; j >= 0; j--) rep(k, 2501) {
        if (dp[j][k] > 0 and k + x[i] <= 2500) dp[j + 1][k + x[i]] += dp[j][k];
    }

    ll ans = 0;
    rep(i, n) {
        ll aa = (i + 1) * a;
        ans += dp[i + 1][aa];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath> 
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const unsigned long long BIGEST=1000000000000000+1000000000000000;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
const long long MOD=19260817;
int mx=0,mn=0;
int s1=0,s2=0;
int a[400005];
vector<int>vt1;
vector<int>vt2;
queue<pair<int,int> >q;
int main()
{
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>a[mx])mx=i;
		if(a[i]<a[mn])mn=i;
		if(a[i]>0)s1+=a[i];
		if(a[i]<0)s2-=a[i];
		if(a[i]>0)vt1.push_back(i);
		if(a[i]<=0)vt2.push_back(i);
	}
	if(s1==0)
	{
		cout<<n-1<<endl;
		for(int i=n;i>1;i--)
		{
			cout<<i<<" "<<i-1<<endl;
		}
		return 0;
	}
	if(s2==0)
	{
		cout<<n-1<<endl;
		for(int i=1;i<n;i++)
		{
			cout<<i<<" "<<i+1<<endl;
		}
		return 0;
	}
	if(s1>=s2)
	{
		cout<<2*n-2<<endl;
		for(int i=0;i<vt1.size()-1;i++)cout<<vt1[i]<<" "<<vt1[i+1]<<endl;
		for(int i=0;i<vt2.size();i++)cout<<vt1[vt1.size()-1]<<" "<<vt2[i]<<endl;
		for(int i=1;i<n;i++)
		{
			cout<<i<<" "<<i+1<<endl;
		}
		return 0;
	}
	else
	{
		cout<<2*n-2<<endl;
		for(int i=vt2.size()-2;i>=0;i--)cout<<vt2[i+1]<<" "<<vt2[i]<<endl;
		for(int i=0;i<vt1.size();i++)cout<<vt2[0]<<" "<<vt1[i]<<endl;
		for(int i=n;i>1;i--)
		{
			cout<<i<<" "<<i-1<<endl;
		}
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
var n : int64;
s : string;
i : longint;
begin
        readln(n);
        readln(s);
        if (n mod 2 = 1) then begin write('No'); halt; end; 
        for i := 1 to n div 2 do
                if (s[i]<>s[i+n div 2]) then begin write('No'); halt; end;
        write('Yes');
end.


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)

//変数
int N;
vector<ll> x, y, h;
//解法
void solve() {

	bool flag;
	rep(X, 101) rep(Y, 101) {

		flag = true;
		ll H;
		rep(k, N) {
			if (h[k] != 0) {
				H = h[k] + abs(X - x[k]) + abs(Y - y[k]);
				break;
			}
		}

		rep(k, N) {

			ll hh = h[k] + abs(X - x[k]) + abs(Y - y[k]);

			if (h[k]!=0 && H != hh) {
				flag = false;
				break;
			}
			if (h[k] == 0 && H > hh) {
				flag = false;
				break;
			}
		}

		if (flag) {
			cout << X << " " << Y << " " << H;
			break;
		}
	}

	return;
}

int main() {
	//入力
	cin >> N;
	x.resize(N);
	y.resize(N);
	h.resize(N);
	rep(i, N) cin >> x[i] >> y[i] >> h[i];
	solve();
	cout << endl;
	return 0;
}


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

int main() {
  int a,b;
  char opt;
  cin>>a>>opt>>b;
  if (opt=='+') cout<<a+b<<endl;
  else cout<<a-b<<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() {
  ll n,m;
  cin >> n >> m;
  if (n%2 == 1){
    rep(i,m){
      cout << i+1 << " " << n-i-1 << endl;
    }
  } else {
    rep(i,(m+1)/2){
      cout << i+1 << " " << (m+1)/2*2-i << endl;
    }
    rep(i,m/2){
      cout << n-m/2*2+i << " " << n-i << endl;
    }

  }
  return 0;
}


Measured memory_bytes: 3624