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

int g[15][15];

int main() {
  int n;
  cin >> n;
  rep(i,n)rep(j,n) g[i][j] = -1;
  rep(i,n) {
    int m;
    cin>>m;
    rep(j,m) {
      int a, x;
      cin >> a >> x;
      a--;
      g[i][a] = x;
    }
  }
  int ans = 0;
  rep(i,1<<n) {
    vector<int> d(n);
    rep(j,n) if (i>>j&1) {
      d[j] = 1;
    }
    bool ok = true;
    rep(j,n) {
      if (d[j]) {
        rep(k,n) {
          if (g[j][k] == -1) continue;
          if (g[j][k] != d[k]) ok = false;
        }
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
  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>;

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  
  int ans = 0;
  
  ans = (N+X-1)/X;
  ans *= T;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
N, M = map(int, input().split())
p = []
for i in range(M):
	p.append(list(map(int, input().split())))

g = [[] for i in range(N + 1)]
for pi in p:
	g[pi[0]].append(pi[1])
	g[pi[1]].append(pi[0])

for i in g[1]:
	if N in g[i]:
		print("POSSIBLE")
		exit()
print("IMPOSSIBLE")


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

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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 << 20);
const int mod = (int)1e9 + 7;

int n, m, k;
vector<int> adj[MAXN];

void read()
{
	cin >> n >> m >> k;
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int disc[MAXN], low[MAXN], dfs_time;
vector<pair<int, int> > st;
vector<vector<pair<int, int> > > bcc;

int pw(int x, int p)
{
	int ret = 1;
	while(p)
	{
		if(p & 1) ret = (ret * 1ll * x) % mod;
		x = (x * 1ll * x) % mod;
		p >>= 1;
	}

	return ret;
}

int fact[MAXN], inv_fact[MAXN], inv_numb[MAXN];
int comb(int n, int k) { if(n < 0 || k < 0 || n < k) return 0; return (((fact[n] * 1ll * inv_fact[n - k]) % mod) * 1ll * inv_fact[k]) % mod; }

void tarjan(int u, int pr)
{
	low[u] = disc[u] = ++dfs_time;

	int children = 0;
	for(int v: adj[u])
		if(!disc[v])
		{
			st.push_back({u, v});
			tarjan(v, u);
			chkmin(low[u], low[v]);

			children++;
			if((children > 1 && pr == -1) || (pr != -1 && low[v] >= disc[u]))
			{
				vector<pair<int, int> > curr;
				while(st.back() != make_pair(u, v))
				{
					curr.push_back(st.back());
					st.pop_back();
				}

				curr.push_back(st.back());
				st.pop_back();	

				bcc.push_back(curr);
			}
		}
		else if(v != pr)
		{
			chkmin(low[u], disc[v]);
			if(disc[v] < disc[u]) 
				st.push_back({u, v});
		}
}

int pwk[MAXN];

void solve()
{
	fact[0] = 1; for(int i = 1; i <= n + m + k; i++) fact[i] = (fact[i - 1] * 1ll * i) % mod;
	inv_fact[n + m + k] = pw(fact[n + m + k], mod - 2); for(int i = n + m + k - 1; i >= 0; i--) inv_fact[i] = (inv_fact[i + 1] * 1ll * (i + 1)) % mod;
	inv_numb[0] = 1; for(int i = 1; i <= n + m + k; i++) inv_numb[i] = (inv_fact[i] * 1ll * fact[i - 1]) % mod; 
	pwk[0] = 1; for(int i = 1; i <= n + m + k; i++) pwk[i] = (pwk[i - 1] * 1ll * k) % mod;

	dfs_time = 0;
	for(int i = 1; i <= n; i++)
		if(!disc[i]) 
		{
			tarjan(i, -1);
			if(!st.empty()) bcc.push_back(st);
			st.clear();
		}

	int answer = 1;
	for(auto it: bcc)
	{
		if(it.size() == 1) answer = (answer * 1ll * k) % mod;       // bridge
		else
		{
			set<int> nodes;
			for(auto e: it)
				nodes.insert(e.first), nodes.insert(e.second);

			if(nodes.size() < it.size()) answer = (answer * 1ll * comb(it.size() + k - 1, it.size())) % mod;       // BCC with more than 1 cycle
			else if(nodes.size() == it.size())      // simple cycle
			{
				int cnt = it.size(), c_ans = 0;
				for(int i = 0; i < cnt; i++)
				{
					int g = (i == 0) ? cnt : __gcd(cnt, i);  
					c_ans = (c_ans + pwk[g]) % mod;
				}

				c_ans = (c_ans * 1ll * inv_numb[cnt]) % mod;
				answer = (answer * 1ll * c_ans) % mod;
			}
		}
	}
	

	cout << answer << endl;
}

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

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



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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int T = sc.nextInt();
    int[][] AB = new int[N][2];
    for (int i = 0; i < N; i++) {
      AB[i][0] = sc.nextInt(); // time
      AB[i][1] = sc.nextInt(); // value
    }
    Arrays.sort(AB, Comparator.comparingInt(a -> a[0]));

    // [i-th-Dish][FinishTImeOf-i-thDish] := max value till i-th-dish
    int[][] dp = new int[N + 1][6001];
    for (int i = 1; i <= N; i++) {
      for (int timeAfterEat = 0; timeAfterEat <= 6000; timeAfterEat++) {
        // No eat
        dp[i][timeAfterEat] = Math.max(dp[i][timeAfterEat], dp[i - 1][timeAfterEat]);
        // Eat
        int time = AB[i - 1][0];
        int value = AB[i - 1][1];
        if (0 <= timeAfterEat - time && timeAfterEat - time < T) {
          dp[i][timeAfterEat] =
              Math.max(dp[i][timeAfterEat], dp[i - 1][timeAfterEat - time] + value);
        }
      }
    }
    System.out.println(Arrays.stream(dp[N]).max().getAsInt());
  }
}


Measured memory_bytes: 124376
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


inline double distance(double x0, double y0, double x1, double y1)
{
  double dx = x1 - x0, dy = y1 - y0;
  
  return sqrt(dx * dx + dy * dy);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(12);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  double x[11], y[11], L = 0.0;

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> x[i] >> y[i];

  std::vector<int> a(N);

  std::iota(ALL(a), 0);

  do {
    double l = 0.0;

    for (int i = 0; i < N - 1; i ++) {
      int m = a[i], n = a[i + 1];
      
      l += distance(x[m], y[m], x[n], y[n]);
    }

    L += l;
  } while (std::next_permutation(ALL(a)));

  for (int i = 1; i <= N; i ++)
    L /= i;

  std::cout << L << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c;	
	int i, FLAG;

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

	for(i=a;i<b+1;i++){
		if(c%i==0){
			FLAG++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 2104
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
map<pii,ll> dp;
int main(){
	int n;
	cin>>n;
	int a;
	cin>>a;
	vi x(n);
	rep(i,n)cin>>x[i],x[i]-=a;
	dp[mp(0,0)]++;
	dp[mp(0,x[0])]++;
	for(int i=1;i<n;i++){
		for(int j=-2500;j<2500;j++){
			dp[mp(i,j)]=dp[mp(i-1,j-x[i])]+dp[mp(i-1,j)];
		}
	}
	cout<<dp[mp(n-1,0)]-1<<endl;	
	
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main()
{
  int x, a;
  cin >> x >> a;
  int ans = 0;
  if (x>=a) ans = 10;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #include<boost/multiprecision/cpp_int.hpp>
// using boost ::multiprecision::cpp_int;
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/

int main()
{
    boost;
    ll n,w;
    cin>>n>>w;
    ll a[n+1],b[n+1];
    b[0]=0;
    for(ll i=1;i<=n;i++)
    cin>>a[i]>>b[i];
    ll total_value = 0 ;
    for(auto &x: b)
    total_value+=x;
    ll dp[n+1][total_value+1]; // mininmum weight we can get when total value is j
    // memset(dp,1000000000,sizeof dp);
    dp[0][0] = 0;
    for(ll i=1;i<=total_value;i++)
    {
        dp[0][i] = 10000000000000;
        // dp[0][i]=0;

    }
    for(ll i=1;i<=n;i++)
    {
        dp[i][0]=0;
    }
    // cout<<dp[0][0]<<"\n";
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=total_value;j++)
        {
            if(b[i] > j )
            {
                dp[i][j] = dp[i-1][j];
            }
            else 
            dp[i][j] = min(dp[i-1][j], a[i] + dp[i-1][j-b[i]]);
            // cout<<dp[i][j]<<" ";
            if(dp[i][j] <= w)
            {
                ans  = max(ans,j);
            }
        }
        // cout<<"\n";.
    }
    
    cout<<ans<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}
/* AnsHuman_7 || Anshuman Gaur */

Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);
		//高橋君の体力
		int A=sc.nextInt();
		//高橋君の攻撃力
		int B=sc.nextInt();
		//青木君の体力
		int C=sc.nextInt();
		//青木くんの攻撃力
		int D=sc.nextInt();
		
		
		while(C>0&&A>0) {
			if(C>0) {
				C=C-B;
			}
				
			if(A>0&&C>0) {
				A=A-D;
			}
		}
		
		
		if(C<A) {
			System.out.println("Yes");
		}else if(A<C) {
			System.out.println("No");
		}
	}
	
}


Measured memory_bytes: 35784
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
         // for declaring
        int n ;
        int [] swim,homework,bugs ;

        public void solve(int testNumber, InputReader in, PrintWriter out) {

                n = in.nextInt();
                swim = new int[n];
                homework = new int[n];
                bugs = new int[n];
                for(int i = 0 ; i < n ; i++ ){
                    swim[i] = in.nextInt();
                    homework[i] = in.nextInt();
                    bugs[i] = in.nextInt();
                }
                int[][] happiness = new int[n+1][3];
                for( int i = 1 ; i <= n ; i++ ){
                    happiness[i][0] = Math.max(happiness[i-1][1],happiness[i-1][2]) + swim[i-1] ;
                    happiness[i][1] = Math.max(happiness[i-1][0],happiness[i-1][2]) + homework[i-1] ;
                    happiness[i][2] = Math.max(happiness[i-1][1],happiness[i-1][0]) + bugs[i-1] ;
                }
                out.println(Math.max(happiness[n][0],Math.max(happiness[n][1],happiness[n][2])));
            }
        }


    }

    class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }




Measured memory_bytes: 48232
N, K = list(map(int, input().split(" ")))
A = sorted(list(map(int, input().split(" "))), reverse=True)

result = 0
S = sum(A)
n = len(A)
s = 0
if S<K:
    result = n
elif S == K:
    result = 0
else:
    for i in range(n):
        if s+A[i] >= K:
            result = n - i - 1
        else:
            s += A[i]

print(result)


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
using ll = long long;
const int mod = 10000007;

ll n,w, cost[100000], weight[100000],memo[100001][101],ans=-1;

ll dp(int weight,int num);
int main() {
	fill(memo[0], memo[100001], -1);
	cin >> n>>w;
	for (int i = 0; i < n; i++) {
		cin >> weight[i] >> cost[i];
	}
	for (int i = 0; i < 101; i++) {
		memo[0][i] = 0;
	}
	for (int i = 0; i < 100001; i++) {
		memo[i][0] = 0;
	}
	for (int i = 0; i <= w; i++) {
		ans = max(ans, dp(i, n));
	}
	cout << ans << endl;
}
ll dp(int w,int num) {
	if (w < 0)return LLONG_MIN;
	if (memo[w][num] == -1) {
		memo[w][num] = max(dp(w,num - 1), dp(w - weight[num - 1],num - 1) + cost[num - 1]);
	}
	return memo[w][num];
}


Measured memory_bytes: 80128
#EDP-B
import sys
n, K = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))
dp = [0 for i in range(n)]
#初期条件
for i in range(1, n):
    dp[i] = abs(H[i]-H[i-1]) + dp[i-1]
#print(dp)
for i in range(2, n):
    for k in range(1, K+1):
        if i-k>=0:
            dp[i] = min(dp[i], abs(H[i]-H[i-k])  + dp[i-k])
            #print(dp, i, k)

print(dp[-1])

Measured memory_bytes: 56540
import numpy as np
I=lambda:map(int,input().split())
n,m,q=I()
a=np.zeros((n+2,n+2))
for i in range(m):
  s,e=I()
  a[s,e]+=1
b=np.flipud(a.cumsum(1))
b=np.flipud(b.cumsum(0))
for i in range(q):
  s,e=I()
  print(int(b[s,e]))

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, M; cin >> N >> M;
    priority_queue<ll> pq;
    rep(i, N){
        ll a; cin >> a;
        pq.push(a);
    }

    rep(i, M){
        auto a = pq.top();
        pq.pop();
        a /= 2;
        pq.push(a);
    }
    ll res=0;
    while(!pq.empty()){
        auto a = pq.top();
        res += a;
        pq.pop();
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5496
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(input())
H = list(map(int, input().split()))

if N == 1:
    print (H[0])
    exit()

ans = 00
i = 1
for i in range(N - 1):
    if H[i] < H[i + 1]:
        continue
    else:
        ans += H[i] - H[i + 1]

ans += H[N - 1]
print (ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
  
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi       acos(-1)
#define mp make_pair
#define pb push_back
// #define int long long ////////////
#define MOD 1000000007    ////////
#define POD 998244353 ////////
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define F first
#define S second
#define ppb pop_back
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) (m*n)/GCD(m,n)
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i,a,n)  for(int i=a ; i<n ; i++)
#define repe(i,a,n) for(int i=a;i<=n;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
//define ll long long
#define ld long double 
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef vector<pii > vpii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef map<int,int> mii;
typedef unordered_map<int,int> umii;
typedef map<char,int> mci;
 
#define itv for(auto it= v.begin(); it != v.end(); ++it )
 
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(ALL(container),element) != container.end())
//#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
//#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);commands}
//#define trav(a, x) for(auto& a : x)
//#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
 
 
#define bs binary_search
#define  lb(v,val)  lower_bound(ALL(v), val); 
#define  ub(v,val)  upper_bound(ALL(v), val); 
 /*
#define dbg1(a) cout<<" *"<<a<<" ";
#define dbg2(a,b) cout<<" *"<<a<<" **"<<b<<" "     /////
#define dbg cout<<"move"
*/
#define dbg cerr <<"At line "<<__LINE__<<" move "<<nl
#define dbg1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define dbg2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define dbg3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
 
#define nl "\n"
#define sz(s)         (int)((s).size())
#define coutsp(k)   cout<<setprecision(k)  //set precision (total length k icluding decimal and non decimal)
#define coutfsp(k)   cout<<fixed<<setprecision(k)  //fixed set precision(after decimal fixing)
#define  INF   (int)1e18 
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define vin(v,n);   vi v(n); rep(i,0,n)  cin>>v[i];
#define prv(v);     rep(i,0,sz(v))  cerr<<v[i]<<" ";

#define isvowel(a) (a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
//#define siz  (int)1e8
#define N 20000

void solve()
{ 

string s;   cin>>s;

if(s=="BBB" || s=="AAA")
cout<<"No";
else
cout<<"Yes";
 
}
 
signed main()
{
 
 
 
   FAST

   
   int t; 
      t=1;              
   // cin>>t;
    while(t--)
    {
    
      solve();
      cout<<nl;
          
}
 
 
 
 
 
 
   return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val Array(n, k) = readLine.split(" ").map(_.toLong)
  if (k % 2 == 0) {
    val i = n / k
    val j = (n + k / 2) / k
    println((i * i * i) + (j * j * j))
  } else {
    val i = n / k
    println(i * i * i)
  }
}


Measured memory_bytes: 25416
# フーリエ変換は、多項式の積動詞の積において指数の和が一定となるようなものをまとめる感じ
# Ci=Aj*Bk となるときはi=j+kのものをまとめている
# 今回はmod=200003でi+jが一致するものを集めたいので
# 係数→log→フーリエ変換→指数で戻す、という流れ？
import numpy as np
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

mod = 200003
n = int(readline())
A = list(map(int, input().split()))
F = np.zeros(mod, dtype=int)
prime = 2
now = 1
pow2 = [0] * (mod)
log2 = [-1] * (mod)
# 累乗の関数と逆関数を求めておく。
for i in range(mod):
    pow2[i] = now
    log2[pow2[i]] = i
    now *= prime
    now %= mod

# x**(log(Ai)) * x**(log(Aj)) とすれば
# convoluteすればx**(log(Ai)+log(Aj))となり、
# x**log(log(Ai * Aj))となってくれる
for i in range(n):
    if A[i]:
        # なのでlog(A[i])のところに1を立てる
        pos = log2[A[i]]
        F[pos] += 1


# maspyさんのyukicoder解答から
def fft_convolve(f, g):
    """
    数列 (多項式) f, g の畳み込みの計算．上下 15 bitずつ分けて計算することで，
    30 bit以下の整数，長さ 250000 程度の数列での計算が正確に行える．
    """
    fft = np.fft.rfft
    ifft = np.fft.irfft
    Lf = len(f)
    Lg = len(g)
    L = Lf + Lg - 1
    fft_len = 1 << L.bit_length()
    fl = f & (1 << 15) - 1
    fh = f >> 15
    gl = g & (1 << 15) - 1
    gh = g >> 15
    conv = lambda f, g: ifft(fft(f, fft_len) * fft(g, fft_len))[:L]
    x = conv(fl, gl)
    y = conv(fl + fh, gl + gh)
    z = conv(fh, gh)
    a, b, c = map(lambda x: (x + 0.5).astype(np.int64), [x, y, z])
    return a + ((b - a - c) << 15) + (c << 30)


x = fft_convolve(F, F)
ans1 = 0
L = len(x)
for i in range(L):
    ans1 += pow2[i % (mod - 1)] * x[i]  # why mod-1????????
for i in range(n):
    ans1 -= A[i] * A[i] % mod
print(ans1 // 2)

# ans2 = 0
# for i in range(n):
#     for j in range(i + 1, n):
#         ans2 += A[i] * A[j] % mod
#         print((i, j), A[i] * A[j] % mod)
#         print(log2[A[i] * A[j] % mod])
# print(ans2)


Measured memory_bytes: 92988
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <complex>
#include <cstdio>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i]--;
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] == i) {
			if (i + 1 < N)
				swap(p[i], p[i + 1]);
			else
				swap(p[i], p[i - 1]);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    int rx = root(x);         // xの根をrx
    int ry = root(y);         // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind tree(n);
  vector<int> fri(n);
  vector<int> bro(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    fri[a]++;
    fri[b]++;
    tree.unite(a, b);
  }
  rep(i, k) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    if (tree.root(c) == tree.root(d)) {
      bro[c]++;
      bro[d]++;
    }
  }
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    // cout << tree.root(i) << endl;
    t[tree.root(i)]++;
  }
  rep(i, n) { cout << t[tree.root(i)] - fri[i] - bro[i] - 1 << " "; }
  cout << endl;
}

Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    ll right = 0,left = 0;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
        right += a[i];
    }

    ll answer = INT64_MAX;
    
    REP(i,n){
        left+=a[i];
        right-=a[i];
        answer = min(answer,llabs(left-right));
    }
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 1792
package main

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

var N, M, cnt int

func main() {
	fmt.Scan(&N, &M)
	result, tree, ptr := make([]int, M+1), make([]int, N), make([]int, N)
	ab := make([][]int, M)

	result[M] = (N * (N - 1)) / 2

	ptr, tree = init_ptr(ptr, tree)

	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)

	for i := 0; i < M; i++ {
		ab[i] = make([]int, 2)

		reader.Scan()
		ab[i][0], _ = strconv.Atoi(reader.Text())
		reader.Scan()
		ab[i][1], _ = strconv.Atoi(reader.Text())

		ab[i][0] = ab[i][0] - 1
		ab[i][1] = ab[i][1] - 1
	}

	for i := M - 1; 0 <= i; i-- {
		a, b := ab[i][0], ab[i][1]

		if !same(a, b, ptr) {
			ra, _ := root(a, ptr)
			rb, _ := root(b, ptr)
			x := tree[ra] * tree[rb]
			result[i] = result[i+1] - x

			ptr, tree = unit(a, b, ptr, tree)
		} else {
			result[i] = result[i+1]
		}

	}
	for i := 1; i <= M; i++ {
		fmt.Println(result[i])
	}
}

func init_ptr(ptr []int, tree []int) ([]int, []int) {
	for i := 0; i < N; i++ {
		ptr[i], tree[i] = i, 1
	}
	return ptr, tree
}

func root(x int, ptr []int) (int, []int) {
	if ptr[x] == x {
		return x, ptr
	} else {
		ptr[x], ptr = root(ptr[x], ptr)
		return ptr[x], ptr
	}
}

func unit(x int, y int, ptr []int, tree []int) ([]int, []int) {
	m, _ := root(x, ptr)
	n, _ := root(y, ptr)
	if m != n {
		tree[n] += tree[m]
		tree[m] = 0
		ptr[m] = n
	}
	return ptr, tree
}

func same(x int, y int, ptr []int) bool {
	m, _ := root(x, ptr)
	n, _ := root(y, ptr)
	if m == n {
		return true
	} else {
		return false
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy [][]int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i][0] < a[j][0] }


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define MX 309
#define inf 1e15+5
long long n;
long long g[MX][MX];
long long d[MX][MX];
bool v[MX][MX];
void fw(int n)
{

    for(int k=0; k<n; k++)
    {
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                d[i][j]=min(d[i][k]+d[k][j],d[i][j]);
            }
    }

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

        for(int j=0;j<n;j++){

            if(d[i][j]!=g[i][j]){

                cout<<-1<<endl;
                return;

            }
        }

    }

    for(int k=0; k<n; k++)
    {
        for(int i=0; i<n; i++)

            for(int j=0; j<n; j++)
            {
                long long x=g[i][j];
                long long y=g[i][k]+g[k][j];
                if(i!=k && j!=k && x==y) v[i][j]=v[j][i]=true;

            }
    }

    long long ans=0;
    for(int i=0;i<n;i++){

        for(int j=0;j<n;j++){
            if(v[i][j]!=true)
            {
                ans+=g[i][j];
            }
        }

    }

    cout<< ans/2 <<endl;
return;
}

int main()
{


        cin>>n;
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                {
                cin>>g[i][j];
                d[i][j]=g[i][j];
                }
        fw(n);
        return 0;

}


Measured memory_bytes: 1792
// # Problem A - Frog 2 - Algoritmos e Grafos - MATA52
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;

int frog2(int stones[], int n, int h[], int k_max){
    stones[0] = 0;
    stones[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++){
        for(int j = 1; j <= min(i, k_max); j++){
            int w1 = stones[i];
            int w2 = abs(h[i - j] - h[i]);
            stones[i] = min(w1, stones[i - j] + w2);
        }
    }
    return stones[n - 1];
}

int main() {
    int n, k_max;
    scanf("%d %d", &n, &k_max);
    int stones[n], h[n];
    for(int i = 0; i < n; stones[i] = INT_MAX, scanf("%d", &h[i]), i++);
    printf("%d", frog2(stones, n, h, k_max));
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  
  cin >> N;
  
  if((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
s = input()
result = "Yes"

for i in range(len(s)):
  if(s[i] in ["U", "D"] or (i % 2 == 0 and s[i] == "R") or (i % 2 == 1 and s[i] == "L")):
    continue
  else:
    result = "No"
    break
    
print(result)

Measured memory_bytes: 3060
#!/usr/bin/env python3
#ABC123 A

LI = [int(input()) for _ in range(6)]
K = LI[-1]

for i in range(1,5):
    for j in range(i):
        if LI[i] - LI[j] > K:
            print(':(')
            exit()
print('Yay!')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define mci       	  map<char,int>  	
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define pii           pair<int ,int >
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN   		  1000000
#define f(n) for(int i=0;i<n;i++)
using namespace std;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n,a,b=0,c;
    cin>>n;
  	rep(i,1,7)
    {
    	c=pow(10,i);
      if(n/c==0)
      {
        a=i-1;
        break;
      }
    }

    if(a%2==0 )
  	b+=n-pow(10,a)+1;

  	for(int i=0;i<a;i=i+2)
      b+=(9*pow(10,i));
    cout<<b;
	return 0;
}


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

using namespace std;

typedef long long I64;

const double EPS = 1e-6;
const double PI  = acos(-1);
const int NMAX = 303;

int d[NMAX+2][NMAX+2][NMAX+2];

int max(int a, int b, int c)
{
    return max(max(a,b), c);
}

int max2(int a, int b, int c)
{
    return max(max(a,b), c);
}

int main()
{
    int N, K;
    string str;
    cin >> str;
    N = str.size();
    if( N == 1 ) {
        cout << "1\n";
        return 0;
    }
    str = "#" + str + "*";
    cin >> K;
    int Ans = 1;
    for( int i = 1;  i <= N;  ++i ) {
        for( int j = N;  i < j;  --j ) {
            d[i][j][0] = max2( d[i - 1][j][0], d[i][j + 1][0], d[i - 1][j + 1][0] + (str[i] == str[j]) );
            Ans = max( Ans, d[i][j][0] * 2 + (i + 2 == j) );
            Ans = max( Ans, d[i][i + 1][0] * 2 );
            for( int k = 1;  k <= K;  ++k ) {
                if( str[i] == str[j] )
                    d[i][j][k] = max2( d[i - 1][j][k], d[i][j + 1][k], d[i - 1][j + 1][k] + 1 );
                else
                    d[i][j][k] = max2( d[i - 1][j][k],
                                      d[i][j + 1][k],
                                      d[i - 1][j + 1][k - 1] + 1 );
                Ans = max(Ans, d[i][j][k] * 2 + (i + 2 == j));
            }
        }
    }
    cout << Ans << '\n';
    return 0;
}


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

using namespace std;
const int nmax = 1e6;
typedef long long ll;
ll mod = 22333333333;
ll p = 67;
vector<ll> value;
char str[100];
void getHash() {
    int len = strlen(str);
    sort(str, str + len);
    ll val = 0;
    for(int i = 0; i < len; ++i) {
        val = val * p + (str[i] - 'a' + 1);
    }
    // cout << "debug " << val << endl; 
    value.push_back(val);
}
int main() {
    int n;
    cin >> n;
    for(int i = 1 ; i <= n; ++i) {
        cin >> str;
        getHash();
    }
    sort(value.begin(), value.end());
    int lastpos = 0, lastval = value[0];
    ll cnt = 1;
    ll ans = 0;
    for(int i = 1; i < value.size(); ++i) {
        if(value[lastpos] == value[i]) {
            cnt ++;
        } else {
            // cout << lastpos << " " << cnt << " " << i << endl;
            lastpos = i;
            ans += (cnt * (cnt - 1)) / 2;
            cnt = 1ll;
        }
    }
    ans += (cnt * (cnt - 1)) / 2;
    cnt = 0;   
    cout << ans << endl;
}

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

int main() {
  int K, X;
  cin >> K >> X;
  if(K*500>=X) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main () {
    
    int c[26] = {0};
    
    char ch;
    
    while (cin >> ch) {
        
        
        
        if (isalpha(ch)) {
            
            if (isupper(ch)) {
                
                char ch1 = tolower(ch);
                
                int num = ch1 - 'a';
                
                c[num] += 1;
                
            } else {
                
                int num = ch - 'a';
            
                c[num] += 1;
                
            }
            
        }
        
    }
    
    for (int i = 0; i < 26; i ++) {
        
        char alpha = i + 'a';
        
        cout << alpha << ' ' << ':' << ' ' <<  c[i] << endl;
        
    }
    
    return 0;
    
}



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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n, m; cin >> n >> m;
    ll u, v;
    vvll G(1<<17, vll(0));
    vll p(1<<17, 0);
    rep(i, m){
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    } 

    queue<ll> q;
    q.push(1);

    p[1] = 1;
    while(!q.empty()){
        u = q.front(); q.pop();
        for(auto e:G[u]){
            if(!p[e]){
                q.push(e);
                p[e] = u;
            }
        }
    }

    cout << "Yes" << endl;
    rep(i, n-1) cout << p[i+2] << endl;

    return 0;
}

Measured memory_bytes: 13808
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

class Combination {
private:
    int64_t mod; // 元, 素数でないとNG
    int64_t max_size; // 最大値, 10^7まで
    int64_t* factorial;
    int64_t* inverse;
    int64_t* inverse_factorial;
    // vector<int64_t> factorial; // 階乗
    // vector<int64_t> inverse; // 逆元
    // vector<int64_t> inverse_factorial; // 逆元の階乗

    void init() {
        // 値は1で初期化する
//        factorial.assign(max_size, 1);
//        inverse.assign(max_size, 1);
//        inverse_factorial.assign(max_size, 1);
        factorial = new int64_t[max_size];
        inverse = new int64_t[max_size];
        inverse_factorial = new int64_t[max_size];
        factorial[0] = factorial[1] = 1;
        inverse[1] = 1;
        inverse_factorial[0] = inverse_factorial[1] = 1;
        for (auto i = 2; i < max_size; i++) {
            factorial[i] = factorial[i - 1] * i % mod;
            inverse[i] = mod - inverse[mod % i] * (mod / i) % mod; // 拡張Euclidの互除法の変形版
            // inverse[i] = modinv(i); // Fermatの小定理
            inverse_factorial[i] = inverse_factorial[i - 1] * inverse[i] % mod;
            // cout << i << " " << factorial[i] << " " << inverse[i] << " " << inverse_factorial[i] << endl;
        }
    };
public:;
    Combination(int64_t mod, int64_t max_size) {
        this->mod = mod;
        assert(max_size < 1e7);
        this->max_size = max_size + 1;
        // テーブル生成
        init();
    };
    virtual ~Combination(){
//        delete factorial;
//        delete inverse;
//        delete inverse_factorial;
    };

    int64_t modpow(int64_t a, int64_t n) {
        int64_t ret = 1;
        while(n > 0) {
            if(n & 1) ret = ret * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return ret;
    };
    int64_t modinv(int64_t a) { return modpow(a, mod - 2); };
    int64_t combination(int64_t n, int64_t k) {
        if (n < k) return 0;
        if (n < 0 or k < 0) return 0;
        // cout << factorial[n] << " " << inverse_factorial[k] << " " << inverse_factorial[n - k] << endl;
        return factorial[n] * (inverse_factorial[k] * inverse_factorial[n - k] % mod) % mod;
    };
};

int main(){
    int x, y;
    cin >> x >> y;

    int a = x / 2, b = (x - a * 2);
    while(y != a + b * 2) {
        a--; b+=2;
        // cout << a << " " << b << " " << a * 2 + b << " " << a + b * 2 << endl;
        if(a < 0 or b > y / 2) {
            cout << 0 << endl;
            return 0;
        }
    }

    int64_t mod = 1e9+7, n = a + b;
    Combination c(mod, n);

    cout << c.combination(n, a) % mod << endl;
    return 0;
}

Measured memory_bytes: 19228
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u)
{
    int v;
    color[u] = GRAY;
    d[u] = ++tt;
    for (v = 0; v < n; v++)
    {
        if (M[u][v] == 0)
            continue;
        if (color[v] == WHITE)
        {
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}

void dfs()
{
    int u;
    for (u = 0; u < n; u++)
        color[u] = WHITE;
    tt = 0;

    for (u = 0; u < n; u++)
    {
        if (color[u] == WHITE)
            dfs_visit(u);
    }
    for (u = 0; u < n; u++)
    {
        printf("%d %d %d\n", u + 1, d[u], f[u]);
    }
}

int main()
{
    int u, v, k, i, j;

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

    for (i = 0; i < n; i++)
    {
        scanf("%d %d", &u, &k);
        u--;
        for (j = 0; j < k; j++)
        {
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }
    dfs();
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  Rep(i,j,n) for(li i=(j);i<(n);i++)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;


int main(int argc,char* argv[])
{
    int N,T;
    cin>>N>>T;
    vi A(N);
    rep(i,N)cin>>A[i];
    int bot=A[0],ans=1,dif=0,dif_max=0;
    Rep(i,1,N){
        if(A[i]>A[i-1]){
            dif=A[i]-bot;
            if (dif_max <dif){
                dif_max=dif;
                ans=1;
            }
            else if(dif_max==dif) {
                if(A[i+1]<A[i]) ans++;
            }
        }
        else if(A[i]<bot) bot=A[i],dif=0;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
n,y=map(int,input().split())
for i in range(0,n+1):
    for j in range(0,n+1-i):
        money=10000*i+5000*j
        x=y-money
        if x >=0 and x//1000 + i + j ==n:
            print(i,j,x//1000)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}

void dfs(vector<int>adj[],int u,int visited[]) {
       visited[u] = 1;
       for (int i = 0; i < adj[u].size(); i++) {
       int v = adj[u][i];
       if (visited[v]) {
       continue;
       }
      dfs(adj,v,visited);
      }
      }
void bfs(vector<int>adj[],int u,int visited[],int layer[]){
    queue<int> q;
    layer[u]=0;
    visited[u]=1;
    q.push(u);
    while(!q.empty()){
         u = q.front();
         q.pop();
        for(int i=0;i<adj[u].size();i++){
            int v = adj[u][i];
            if(!visited[v]){
                q.push(v);
                layer[v]=layer[u]+1;
                visited[v]=1;
            }
        }
    }
}    
void bfs01(vector<pair<int,int> >adj[],int start,int d[]){
    deque<int> q;
    q.pf(start);
    d[start]=0;
    while(!q.empty()){
         int u = q.front();
         q.pop_front();
        for(int i=0;i<adj[u].size();i++){
           if(d[adj[u][i].first]>d[u]+adj[u][i].second){
               d[adj[u][i].first] = d[u]+adj[u][i].second;
               if(adj[u][i].second==0)
               q.pf(adj[u][i].first);
               else 
               q.pb(adj[u][i].first);
               
           } 
          
        }
    }
   
}
void addedge(vector<int>adj[],int a,int b){
    adj[a].pb(b);
    adj[b].pb(a);
}

int main(){
    ll n,d;
    cin>>n>>d;
    ll a[n][2];
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1];
    int count =0;
    for(int i=0;i<n;i++){
        if(a[i][0]*a[i][0]+a[i][1]*a[i][1]<=d*d)count++;
    }
    cout<<count;
    return 0;
}



Measured memory_bytes: 6724
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, k = map(int, input().split())

data = []
input_data = input().split()
data = [int(n) for n in input_data]

data_exp = [0]
for i in range(n):
    data_exp.append(data_exp[i] + 1 + (data[i]-1)/2)

ans = 0
for i in range(n-k+1):
    tmp_ans = data_exp[i+k] - data_exp[i]
    ans = max(ans, tmp_ans)

print(ans)




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

ll factorize(long long n) 
{ 
    ll count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  ll m=0;
    // if 2 divides it 
    if (count) 
        m++; 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            m++;
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        m++;
    return m;
}
int main()
{
	// ios_base::sync_with_stdio(false);
 //    cin.tie(NULL);
 //    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll c=__gcd(a,b);
    ll p=factorize(c);
    cout<<p+1<<"\n";
    return 0;
}

Measured memory_bytes: 256