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

#define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++)
#define rrep(i,n,e) for (int i = (ll)n-1; i >= (ll)e; i--)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
// #define M_PI 3.14159265358979323846 // CFでは定義しておく必要あり
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) cout << fixed << setprecision(10) << x << endl; // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

void print() {
  cout << endl;
};

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
};

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
};

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

  int N; cin >> N;
  if (N <= 999) {
    cout << "ABC" << endl;
  } else {
    cout << "ABD" << endl;
  }


  return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  
  vi ord(N);
  rep(i, N) {
    invar(int, A);
    --A;
    ord[A] = i;
  }
  rep(i, N) {
    cout << (ord[i] + 1) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1280
w=str(input())
L=['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']
p=0
for i in range(26):
    num=w.count(L[i])
    if num%2==0:
        p+=1
if p==26:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	int n;
	cin>>n;
	vector<string>s(n);
	rep(i,n)cin>>s[i];
	int a=0,b=0,c=0,d=0;
	rep(i,n){
		if(s[i][0]=='A')++a;
		else if(s[i][0]=='W')++b;
		else if(s[i][0]=='T')++c;
		else ++d;
	}
	cout<<"AC x "<<a<<"\n";
	cout<<"WA x "<<b<<"\n";
	cout<<"TLE x "<<c<<"\n";
	cout<<"RE x "<<d<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 6364
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

int main()
{
    auto h = std::size_t(0);
    auto w = std::size_t(0);

    std::cin >> h >> w;

    auto white = int(0);
    auto s = std::vector<std::vector<char>>(h, std::vector<char>(w, 0));
    auto visited = std::vector<std::vector<bool>>(h, std::vector<bool>(w, false));
    for (std::size_t i = 0; i < h; ++i)
        for (std::size_t j = 0; j < w; ++j)
        {
            std::cin >> s[i][j];
            if (s[i][j] == '.') white++;
        }

    auto comp = [](auto a, auto b) { return std::get<2>(a) > std::get<2>(b); };

    // tuple -> (x,y,round), less round number is priotized in the queue (see the lambda expression above) 
    auto q =
        std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int>>, decltype(comp)>(comp);

    auto sx = int(0);
    auto sy = int(0);
    auto gx = int(w - 1);
    auto gy = int(h - 1);

    auto dx = std::vector<int>({0, 1, 0, -1});
    auto dy = std::vector<int>({1, 0, -1, 0});

    q.emplace(sx, sy, 1);
    visited[static_cast<std::size_t>(sy)][static_cast<std::size_t>(sx)] = true;
    auto steps = std::vector<int>();
    while (!q.empty())
    {
        auto px = std::get<0>(q.top());
        auto py = std::get<1>(q.top());
        auto round = std::get<2>(q.top());

        q.pop();
        auto tx = int(0);
        auto ty = int(0);

        for (std::size_t i = 0; i < 4; ++i)
        {
            tx = px + dx[i];
            ty = py + dy[i];

            if (tx < 0 || static_cast<int>(w) <= tx || ty < 0 || static_cast<int>(h) <= ty) continue;

            if ((!visited[static_cast<std::size_t>(ty)][static_cast<std::size_t>(tx)]) &&
                s[static_cast<std::size_t>(ty)][static_cast<std::size_t>(tx)] == '.')
            {
                if (tx == gx && ty == gy)
                {
                    steps.emplace_back(round + 1);
                    continue;
                }

                visited[static_cast<std::size_t>(ty)][static_cast<std::size_t>(tx)] = true;
                q.emplace(tx, ty, round + 1);
            }
        }
    }

    if (steps.empty())
        std::cout << -1 << std::endl;
    else
        std::cout << white - *std::min_element(steps.begin(), steps.end()) << std::endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
long long fill(long long n,long long *f,long long i,long long *fl){
	if(fl[i]==0){
		f[i]=0;
		for(int j=0;j<16;j++){
			if((1<<j)&(i))
				f[i]+=fill(n-1,f,i^(1<<j),fl);
		}
		f[i]/=(n-2);
		fl[i]=1;
	}
	return f[i];
}
int main(){
	long long n;
	cin >> n;
	long long a[n][n];
	long long N=1<<n;
	long long f[N],fl[N];
	memset(fl,0,sizeof(fl));
	f[0]=0,fl[0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
				cin >> a[i][j];
				if(i>j){
					f[(1<<i)+(1<<j)]=a[i][j];
					fl[(1<<i)+(1<<j)]=1;
				}
				if(i==j){
					f[(1<<i)]=0;
					fl[(1<<i)]=1;
				}
		}
	f[N-1]=fill(n,f,(1<<n)-1,fl);
	for(long long mask = 0; mask < (1<<n); ++mask){
		for(long long i=mask;i;i=(i-1)&mask)
				f[mask] = max(f[mask],f[i]+f[mask-i]);
	}
	cout << f[N-1] << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int n,x,a[200010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d",&x);
		a[x]++;
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 4540
#include<bits/stdc++.h>
#define reg register
using namespace std;
int n[10];
int main()
{
    for(reg int i=1;i<=4;i++)scanf("%1d",&n[i]);
    if((n[1]==n[2]&&n[2]==n[3])||(n[2]==n[3]&&n[3]==n[4]))puts("Yes");
    else puts("No");
    return 0;
}

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

int main(){
	char ch;
	int number[26] = {};
	while(cin >> ch){
		ch = tolower(ch);
		if(isalpha(ch)){
			number[ch-'a']++;
		}
	}
	for(int i = 0; i < 26; i++){
		printf("%c : %d\n", i+'a', number[i]);
	}

	return 0;
}

Measured memory_bytes: 1128
#include <iostream>
#include <algorithm>
#include <vector>

int N, M, temp;
int ans = 0;
std::vector<int> X;
std::vector<int> S;

int main() {
    std::cin >> N >> M;
    for (int i=0; i<M; ++i) {
        std::cin >> temp;
        X.push_back(temp);
    }
    
    std::sort(X.begin(), X.end());
    
    for (int i=0; i<M-1; ++i) {
        S.push_back(X[i+1]-X[i]);
    }
    
    std::sort(S.begin(), S.end(), [](const int x, const int y){return y < x;});
    
    if (N < M) {
        ans = X[M-1] - X[0];
        int num = N-1;
        auto itr = S.begin();
        
        while (num > 0 && itr != S.end()) {
            ans -= *itr;
            num--;
            itr++;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1400
MOD = 1000000007
N, M = map(int, input().split())

def p(n):
    res = 1
    for i in range(1, n+1):
        res *= i
        res %= MOD
    return res

if abs(N-M) == 0:
    tmp = p(N)
    ans = tmp * tmp * 2 % MOD
elif abs(N-M) == 1:
    tmp = p(min(N,M))
    ans = tmp * tmp *max(N,M) % MOD
else:
    ans = 0

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

#define G (9.8)

int main(void)
{
	int ans;
	double y, v, t;
	
	while (scanf("%lf", &v) != EOF){
		t = v / G;
		y = G / 2.0 * t * t;
		
		ans = 0; 
		while (y > 0){
			ans++;
			y -= 5;
		}
		
		printf("%d\n", ans + 1);
	}
		
	return (0);
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
//ofstream fout("output.txt");
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0);
#define pi 4*atan(1)
#define f(n) for(int i=0;i<n;++i)
#define fab(a,b) for(int i=a;i<=b;++i)
#define fba(b,a) for(int i=b;i>=a;--i)
#define reset(a,x) memset(a,x,sizeof(a))
typedef pair<int,int> ipair;
typedef vector<int> vi;
int main(){
    IOS
    cin.tie(0);

    int x,y,z;
    cin>>x>>y>>z;
    int temp=0;
    temp=x;
    x=y;
    y=temp;
    temp =x;
    x=z;
    z=temp;
    cout<<x<<" "<<y<<" "<<z;


    return 0;
}










Measured memory_bytes: 256
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        s: chars,
    }

    let n = s.len();
    let s_rev: Vec<char> = s.iter().cloned().rev().collect();

    let mut s2 = vec![];
    for i in 1..(n - 1) / 2 + 1 {
        s2.push(s[i - 1].clone());
    }
    let s2_rev: Vec<char> = s2.iter().cloned().rev().collect();

    let mut s3 = vec![];
    for i in (n + 3) / 2..n + 1 {
        s3.push(s[i - 1].clone());
    }
    let s3_rev: Vec<char> = s3.iter().cloned().rev().collect();

    if s == s_rev && s2 == s2_rev && s3 == s3_rev {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import Data.Functor
import Data.List

main :: IO ()
main = do
  { [w,h,x,y,r] <- getInts
  ; if x < r then putStrLn "No"
    else if y < r then putStrLn "No"
      else if x + r > w then putStrLn "No"
        else if y + r > h then putStrLn "No"
          else putStrLn "Yes"
}

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts =putStrLn . unwords . map show

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push _back
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;
	string s;
	cin>>s;
	int n;
	cin>>n;
	for(int i=0;i<s.length();i++){
		if(i % n == 0){
			cout<<s[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
s=input()+"v"
n=len(s)
p=0
r=0
c=0
while(1):
    if c>=n:
        break
    if s[0]=="A":
        p+=1
        s=s[1:]
        c+=1
    elif s[:2]=="BC":
        s=s[2:]
        c+=2
        r+=p
    else:
        s=s[1:]
        c+=1
        p=0
print(r)

Measured memory_bytes: 3500
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

ll a[1200];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n;
	ll x;
	cin >> n >> x;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] <= x) {
			x -= a[i];
			++ans;
		}
	}
	if (ans == n && x != 0)
		--ans;
	cout << ans << "\n";
	return 0;
}




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

// auto mod int
// https://github.com/atcoder-live/library/blob/master/mint.cpp
// 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, 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
const int MAX_N = 2005;
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];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} c(MAX_N);

int main() {
    int s;
    cin >> s;
    mint ans = 0;
    for (int i = 1; 3 * i <= s; i++) {
      int n = s - i*3 + i - 1;
      int r = i - 1;
        ans += c(n,r);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), m = sc.nextInt();
        int[] pref = new int[m];
        int[] year = new int[m];
        int[][] a = new int[m][4];

        for (int i = 0; i < m; i++) {
            a[i][0] = i;
            a[i][1] = sc.nextInt(); // city
            a[i][2] = sc.nextInt(); // year
        }

        sortYear(a);
        int currentCity = a[0][1];
        int count = 0;
        for (int i = 0; i < m; i++) {
            if (currentCity == a[i][1]) {
                count++;
                a[i][3] = count;
            } else {
                count = 1;
                currentCity = a[i][1];
                a[i][3] = count;
            }
        }
        sortCity(a);

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < m; i++) {
            sb.append(String.format("%06d", a[i][1])).append(String.format("%06d", a[i][3])).append("\n");
        }
        System.out.print(sb);
    }

    static void sortCity(int[][] array) {
        Arrays.sort(array, Comparator.comparingInt(a -> a[0]));
    }

    static void sortYear(int[][] array) {
        Arrays.sort(array, (a, b) -> {
            if (a[1] > b[1]) {
                return 1;
            }
            if (a[1] == b[1] && a[2] > b[2]) {
                return 1;
            } else {
                return -1;
            }
        });
    }
}

Measured memory_bytes: 170432
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int A[] = new int[N];
    int B[] = new int[N - 1];
    int sumA = 0;

    for (int i = 0; i < N - 1; i++) {
      B[i] = sc.nextInt();
    }

    for (int i = N - 1; i >= 0; i--) {

      if (i == 0) {
        A[i] = B[i];
        continue;
      }

      if (i == N - 1) {
        A[i] = B[i - 1];
        continue;
      }

      if (B[i] >= B[i - 1]) {
        A[i] = B[i - 1];

      } else {
        A[i] = B[i];

      }
    }

    for (int i = 0; i < N; i++) {
      sumA += A[i];
    }

    System.out.println(sumA);
    sc.close();
  }
}


Measured memory_bytes: 21972
fun main (args: Array<String>){
    val N = readLine()!!.toInt()
    val h = readLine()!!.split(' ').map { it.toInt() }.toMutableList()

    var ans = 0


    for (i in 0 until N){
        while(true) {
            val c = h[i]
            if (c==0)break
            ans++
            (i until N ).takeWhile { h[it] >= c }.forEach{ h[it]--}

        }
    }

    println(ans)


}

Measured memory_bytes: 38452
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    V<string> s(n);
    REP(i, n) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    ll ans = 0;
    unordered_map<string, ll> smap;
    REP(i, n) ans += smap[s[i]]++;
    
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 16036
#include <bits/stdc++.h>
using namespace std;
int n,i,j,a[100010],ok=1;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>a[i-1])
            a[i]--;
        if(a[i]<a[i-1])
            ok=0;
    }
    if(ok==0)
        cout<<"No";
    else cout<<"Yes";
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define N 1010
#define inf 1100000000
using namespace std;
int n,tot,del,ans[N],a[N]; ll sum1,sum2;
int main(){
	scanf("%d",&n); bool flag=0;
	rep (i,1,n){
		scanf("%d",&a[i]);
		if (a[i]>0) flag=1;
		if (i&1){
			if (a[i]>0) sum1+=a[i];
		} else{
			if (a[i]>0) sum2+=a[i];
		}
	}
	if (!flag){
		int mx=-inf,pos;
		rep (i,1,n) if (a[i]>mx) mx=a[i],pos=i;
		rep (i,1,pos-1) ans[++tot]=1;
		per (i,n,pos+1) ans[++tot]=i-pos+1;
		printf("%d\n%d\n",mx,tot);
		rep (i,1,tot) printf("%d\n",ans[i]);
	} else{
		if (sum1>sum2){
			flag=0;
			rep (i,1,n) if (i&1) if (a[i]<0){
				ans[++tot]=i-del;
				if (i==1 || i==n){
					del++; if (i==1) flag=1;
				} else del+=2;
			}
			n-=del;
			if (flag) ans[++tot]=1,n--;
			while (n>1) ans[++tot]=2,n-=2;
		} else{
			rep (i,1,n) if (!(i&1)) if (a[i]<0){
				ans[++tot]=i-del;
				if (i==1 || i==n) del++; else del+=2;
			}
			n-=del;
			ans[++tot]=1,n--;
			while (n>1) ans[++tot]=2,n-=2;
		}
		printf("%lld\n%d\n",max(sum1,sum2),tot);
		rep (i,1,tot) printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 

 string calc(string s, string t){
 	string ret = s;

 	for(int i = 0; i < 4; i++){
 		ret[i] -= t[i] - '0';
 	}

 	for(int i = 3; i > 0; i--){
 		if(ret[i] < '0') {
 			ret[i] += 10;
 			ret[i - 1]--;
 		}
 	}

 	return ret;
 }
 
int main(){
	string s, t;
	while(cin>>s){
		if(s == "0000") break;

		bool f = false;
		for(int i = 0; i < 9; i++){
			if(s == string(4, '1' + i)){
				f = true;
				break;
			}
		}
		if(f){
			cout<<"NA"<<endl;
			continue;
		}

		int n = 0;
		while(1){
			if(s == "6174") break;
			n++;
			t = s;
			sort(all(s));
			sort(all(t));
			reverse(all(t));

			s = calc(t, s);
		}

		cout<<n<<endl;
	}
}

Measured memory_bytes: 1216
h,w = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(h)]
out = []
for i in range(h):
    for j in range(w):
        if A[i][j]&1:
            if j == w-1:
                if i != h-1:
                    A[i+1][j] += 1
                    A[i][j] -= 1
                    out.append((i+1,j+1,i+2,j+1))
            else:
                A[i][j+1] += 1
                A[i][j] -= 1
                out.append((i+1,j+1,i+1,j+2))
print(len(out))
for i,j,k,l in out:
    print(i,j,k,l)

Measured memory_bytes: 30588
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{int a[2],b[2],c,d,i,j,k,y;
 vector<int> arr,a1,a2;
 cin>>a[0]>>a[1]>>b[0]>>b[1];
 for(i=0;i<2;i++)
 {for(j=0;j<2;j++)
 {y=a[i]*b[j];
 arr.push_back(y);
 }
 }
 sort(arr.begin(),arr.end());
 cout<<arr[3];
 return 0;
}

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

int main(){
    int n, k;
    string str;
    
    cin >> n >> k;
    cin >> str;
    
    int max = 0;
    int count = 0;
    int s = 0;
    int g = 0;
    while(s < str.size()){
        for(; g < str.size(); g++){
            if(str[g] == '0' && count == k) break;
            
            if(str[g] == '0' && g+1 < str.size() && str[g+1] == '1') count++;
                
        }
        
        if(max < (g-s)) max = g-s;
        
        for(; s < str.size(); s++){
            if(str[s] == '1') continue;
            if(s+1 < str.size() && str[s+1] == '1'){
                s++;
                count--;
                break;
            }
        }
        
        
    }
    
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 512
@S=map$|++,@p=@i=0..1e5;$\-=<>;sub f{$p[$_]=$_-(local$_=$p[$_])?&f:$_}/ />${*a=-$'}||($S[$p[$v=f$_=$a]=f]+=$S[$v]*($v!=f)),$a=$`for<>;$\+=$S[f$_=${-$_}]for@i;print

Measured memory_bytes: 63344
#include <iostream>
#include <string>
using namespace std;
string str;
int cl=101,fl=0;
int main()
{
	cin>>str;
	for(int i=0; i<(int)str.length(); ++i)
		if(str[i]=='F')
			fl=i;
	for(int i=(int)str.length()-1; i>=0; --i)
		if(str[i]=='C')
			cl=i;
	if(cl<fl)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
<?php
$input=trim(fgets(STDIN));
$array_data=explode(" ", $input);
$a=intval($array_data[0]);
$b=intval($array_data[1]);
if($a<$b){
	print("a < b\n");
}elseif($a>$b){
	print("a > b\n");
}elseif($a==$b){
	print("a == b\n");
}

Measured memory_bytes: 15360
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  string a, b;
  cin >> a >> b;
  int n = b.length();
  char ch = b[n - 1];
  a += ch;
  if (a == b) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n;
	cin >> n;
	cout << (n + 1) / 2;
}


Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int h, w; char s, t; rd(h, w, s, t);
  auto c=new char[][](h, w);
  foreach(i; 0..h) c[i]=readln.chomp.to!(char[]);

  const int n=26;
  auto d=new int[][](n, n);
  foreach(i; 0..n) fill(d[i], 1_000_000);

  auto dir=[[1, 0], [-1, 0], [0, 1], [0, -1]];
  bool A(char ch){return ('A'<=ch && ch<='Z');}
  foreach(int i; 0..h)foreach(int j; 0..w){
    if(A(c[i][j])==false) continue;
    d[c[i][j]-'A'][c[i][j]-'A']=0;
    foreach(dd; dir){
      int ni=i+dd[0]*2, nj=j+dd[1]*2;
      if(ni<0 || ni>=h || nj<0 || nj>=w) continue;
      if(((dd[0]!=0 && c[ni][nj]=='|')||(dd[1]!=0 && c[ni][nj]=='-'))==false) continue;
      while((ni>=0 && ni<h && nj>=0 && nj<w) && A(c[ni][nj])==false){
        ni+=dd[0]; nj+=dd[1];
      }
      if((ni>=0 && ni<h && nj>=0 && nj<w)){
        int x=c[i][j]-'A', y=c[ni][nj]-'A';
        // writeln(c[i][j], " ", c[ni][nj]);
        d[x][y]=d[y][x]=1;
      }
    }
  }

  foreach(_; 0..n)foreach(i; 0..n)foreach(j; 0..n){
    d[i][j]=min(d[i][j], d[i][_]+d[_][j]);
  }

  writeln(d[s-'A'][t-'A']);
}

void rd(Type...)(ref Type x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


Measured memory_bytes: 2476
n,m=map(int,input().split())
lis=[i for i in range(1,n+1)]
for i in range(m):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        if a[j] in lis:
            lis.remove(a[j])
print(len(lis))

Measured memory_bytes: 9212
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

S = input()
stack = []
for c in S:
    stack.append(c)
    while len(stack) >= 2 and stack[-1] != stack[-2]:
        del stack[-2:]
print(len(S) - len(stack))



Measured memory_bytes: 70892
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    double ans = 0;
    for(int i = 0; i < N; i++){
        double a;
        cin >> a;
        ans +=  1 / a;
    }
    printf("%.12f",1/ans);
    return 0;
}


Measured memory_bytes: 3752
#include <cmath>
#include <deque>
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

deque<ll> enumerate_divisors(ll n) {
  deque<ll> ret;
  ll i = floor(sqrt(n));
  if (i*i == n) {
    ret.push_back(i);
    --i;
  }
  while (i) {
    if (n % i == 0) {
      ret.push_front(i);
      ret.push_back(n / i);
    }
    i--;
  }

  return ret;
}

void solve(ll N) {
  auto cnt = enumerate_divisors(N - 1).size() - 1;  // remove 1
  
  auto deq = enumerate_divisors(N);
  
  deq.pop_front();  // remove 1
  for (auto i : deq) {
    auto n = N;
    while (n % i == 0) {
      n /= i;
    }
    if (n % i == 1) {
      ++cnt;
    }
  }
  cout << cnt << endl;
}

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  string answer = "ABC";
  if(s ==  "ABC") answer = "ARC";
  
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

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

    long long min = LLONG_MAX;

    long long diff;

    if (n >= k)
    {
        n %= k;
        diff = abs(n - k);
        if (diff >= n)
            min = n;
        else
            min = diff;
    }
    else
    {
        diff = abs(n - k);
        if (diff >= n)
            min = n;
        else
            min = diff;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

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

int main() {
	int H, W; cin >> H >> W;
	vector<vector<bool>> z(H, vector<bool>(W, 0));
	queue<pair<int, pair<int,int>>> d;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c;cin >> c;
			if (c == '#') { z[i][j] = 1; d.push({ i,{j,0} }); }
		}
	}
	int ans = 0;
	while (d.size()) {
		int x = d.front().first, y = d.front().second.first,c=d.front().second.second;
		d.pop();
		for (int k = 0; k < 4; k++) {
			if (x + dx[k] < H&&x + dx[k] >= 0 && y + dy[k] >= 0 && y + dy[k] < W) {
				if (z[x + dx[k]][y + dy[k]] == 0) {
					z[x + dx[k]][y + dy[k]] = 1;
					d.push({ x + dx[k],{y + dy[k],c + 1} });
					ans = max(ans, c + 1);
				}
			}
		}
	}
	cout << ans << endl;

}





Measured memory_bytes: 12560
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, M; cin >> N >> M;
    map<int, int> MM;
    for (int i = 0; i < N; i++) {
        int A; cin >> A;
        MM[A]++;
    }
    for (int i = 0; i < M; i++) {
        int B, C; cin >> B >> C;
        MM[C] += B;
    }
    Int ans = 0;
    for (auto it = MM.rbegin(); N && it != MM.rend(); ++it) {
        Int n = min(N, it->second);
        ans += it->first * n;
        N -= n;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
typedef long long ll;
using namespace std;

int main() {
    ll x, deposite = 100;
    scanll(x);
    int count = 0;
    while (deposite < x) {
        deposite += deposite / 100;
        count++;
    }
    printInt(count);
    return 0;
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int n;
  cin >> n;
  VI v(n);
  REP(i, n) {
    cin >> v[i];
  }

  int ans = 0;
  int flag = 0;
  REP(i, n) {
    if (v[i] == flag + 1) {
      flag++;
    } else {
      ans++;
    }
  }
  if (ans == n) {
    ANS(-1);
  } else {
    ANS(ans);
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

#define max 100000 + 1

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);

	//素数テーブル作成
	vector< bool > pr;
	vector< int > pl;
	for(int i = 0; i < max; i++)
		pr.push_back( true );
	pr[0] = false;
	pr[1] = false;

	for(int i = 2; i * i < max; i++)
		for(int j = i * 2; j < max; j += i)
			pr[j] = false;

	for(int i = 0; i < pr.size(); i++)
		if( pr[i] ) pl.push_back( i );

	while( 1 ) {
		int a, b, m;
		cin >> m >> a >> b;
		if( a == 0 && b == 0 && m == 0 ) break;

		/*
			p <= q
			aq <= bp を利用する
			pq <= m
		*/
		int Smax = 0;
		int ansp, ansq;
		for(int i = 0; pl[i] * pl[i] <= m; i++) {
			int p = pl[i];
			for(int j = 0; pl[i] * pl[j] <= m; j++) {
				int q = pl[j];
				if( a * q <= b * p && p * q <= m && p * q >= Smax) {
					Smax = p * q;
					ansp = p;
					ansq = q;
				}
			}
		}

		cout << ansp << " " << ansq << endl;

	}
//	while(1){}

    return 0;
}

Measured memory_bytes: 1336
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
a, b = LI()
print((a+b+1)//2)
"""

#B
"""
a = S()
a = a[:-1]
b = S()
b = b[:-1]
a.sort()
b.sort(reverse=True)
if a < b:
    print("Yes")
else:
    print("No")
"""

#C
"""
n = I()
a = LI()
a.sort()
seta = set(a)
ans = 0
for i in seta:
    x = bisect.bisect_right(a,i) - bisect.bisect_left(a,i)
    if x != 0 and x >= i:
        ans += x - i
    else:
        ans += x
print(ans)        
"""

# D
# 解説AC
# X,Y軸に分解して、移動は常に同じ方向に行われる（TFFFTならFは常に同じ方向）
# ためTFFFFFTFFFF→TF5TF4として考えて奇数番目のFがx偶数番目がyに寄与
# あとはDP
s = S()
X, Y = LI()
dx = defaultdict(int)
dy = defaultdict(int)
i = 0
num = 0
lis = []
for i in range(len(s)):
    if s[i] == "T":
        lis.append(num)
        num = 0
    else:
        num += 1
if s[-1] == "F":
    lis.append(num)
dx[lis[0]] = True
dy[0] = True
for i in range(1, len(lis)):
    if not i % 2:
        ndx = defaultdict(int)
        for key, _ in dx.items():
            ndx[key + lis[i]] = True
            ndx[key - lis[i]] = True
        dx = ndx
    else:
        ndy = defaultdict(int)
        for key, _ in dy.items():
            ndy[key + lis[i]] = True
            ndy[key - lis[i]] = True
        dy = ndy
if dx[X] and dy[Y]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 76380
def isOK_under(array, index, key):
    if array[index] >= key:
        return True
    else:
        return False

def isOK_over(array, index, key):
    if array[index] > key:
        return True
    else:
        return False

def binary_serch_under(array, key):
    ng = -1
    ok = len(array)

    while (abs(ok - ng) > 1):
        mid = (ok + ng)//2

        if isOK_under(array, mid, key):
            ok = mid
        else:
            ng = mid
    return ok

def binary_serch_over(array, key):
    ng = -1
    ok = len(array)
    while (abs(ok - ng) > 1):
        mid = (ok + ng)//2
        if isOK_over(array, mid, key):
            ok = mid
        else:
            ng = mid
    return ok

n = int(input())
array1 = list(map(int,input().split()))
array2 = list(map(int,input().split()))
array3 = list(map(int,input().split()))

array1 = sorted(array1)
array2 = sorted(array2)
array3 = sorted(array3)

# a = binary_serch(array2, 5)
count=0
# for array1_index in range(n):
#     start_array2_index = binary_serch(array2, array1[array1_index])
#     # print(array1[array1_index])
#     for cor_array2_index in range(start_array2_index, n):
#         # print(array2[cor_array2_index])
#         start_array3_index = binary_serch(array3, array2[cor_array2_index])
#         # for k in range(start_array3_index,n):
#         #     print(array3)
#         count+=abs(start_array3_index - n)
for index_array2 in range(n):
    a = binary_serch_under(array1, array2[index_array2])
    c = binary_serch_over(array3, array2[index_array2])
    count += a*abs(c-n)
print(count)


Measured memory_bytes: 24052
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>




int main() {
	
	int a, b;

	std::cin >> a >> b;

	if (a > b) {
		printf("a > b");
	}
	else if (a < b) {
		printf("a < b");
	}else {
		printf("a == b");
	}

	printf("\n");

	//system("pause");
	return 0;
}


Measured memory_bytes: 3196
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ab[100010],ac[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;

int main(){
    cin>>a>>b;
    z=b;
    for(int i=0;i<a-1;i++){
        z*=b-1;
    }
    C z E;
}

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

int SA[100009], SB[100009], TA[100009], TB[100009];

int main() {
	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(0);
	string S, T; cin >> S >> T;
	int N = S.size(), M = T.size();
	S = "#" + S; T = "#" + T;
	for(int i=1; i<=N; i++) {
		SA[i] = SA[i-1] + (S[i] == 'A');
		SB[i] = SB[i-1] + (S[i] == 'B');
	}
	for(int i=1; i<=M; i++) {
		TA[i] = TA[i-1] + (T[i] == 'A');
		TB[i] = TB[i-1] + (T[i] == 'B');
	}
	int Q; cin >> Q;
	while(Q--) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		int SM = (SA[b] - SA[a-1]) - (SB[b] - SB[a-1]);
		int TM = (TA[d] - TA[c-1]) - (TB[d] - TB[c-1]);
		SM += 300000;
		TM += 300000;
		if(SM % 3 == TM % 3) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 2540
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100005;
int deg[MAXN], leaves[MAXN];

int n;

vector< set<int> > adj;

queue<PII> q;

int nonleaf(int u) {
    for (auto& v : adj[u]) if (deg[v] > 1) return v;
    return -1;
}

int main() {
    GI(n);

    adj.resize(n+1);

    int a, b;

    memset(deg, 0, sizeof deg);

    FORN(i, n-1) {
        GI(a);
        GI(b);

        adj[a].insert(b);
        adj[b].insert(a);

        deg[a]++;
        deg[b]++;
    }

    memset(leaves, 0, sizeof leaves);

    FOR1(u, n) {
        for (auto& v : adj[u]) {
            if (deg[v] == 1) leaves[u] += 1;
        }

        if (leaves[u] > 1) {
            printf("First\n");
            return 0;
        }

        if (deg[u] == 2 && leaves[u] == 1) {
            q.push(MP(u, nonleaf(u)));
        }
    }

    while (n > 2) {
        auto t = q.front(); q.pop();

//        DEBUG(t.FF);
//        DEBUG(t.SS);

        // cut t.FF - t.SS

        adj[t.SS].erase(t.FF);
        deg[t.SS]--;

        if (deg[t.SS] == 1) {  // t.SS becomes a leaf
            int p = nonleaf(t.SS);
            leaves[p]++;

            if (leaves[p] > 1) {
                printf("First\n");
                return 0;
            }

            if (deg[p] == 2) {
                q.push(MP(p, nonleaf(p)));
            }
        }
        else {
            if (leaves[t.SS] > 1) {
                printf("First\n");
                return 0;
            }

            if (deg[t.SS] == 2 && leaves[t.SS] == 1) {
                q.push(MP(t.SS, nonleaf(t.SS)));
            }
        }

        n -= 2;
    }

    if (n == 2) {
        printf("Second\n");
    }
    else {
        printf("First\n");
    }

    return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>N>>K;
    vector<bool> have(N, false);
    rep(i,K){
        cin>>M;
        rep(j,M){
            cin>>A;
            --A;
            have[A] = true;
        }
    }
    ll ans = 0;
    rep(i,N) ans += !have[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int K,S;
int X,Y,Z,cnt;
int a=0;
int main()
{
	cin>>K>>S;
	for(int i=0;i<=S;i++)
	{
		X=i;
		for(int j=0;j<=S-X;j++)
		{
			Y=j;
			Z=S-X-Y;
			if(X>K||Y>K||Z>K)
			continue;
			else
			{
				cnt++;
				continue;
			}
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256