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

#define int long long
typedef pair<int, int> P;
//#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream & operator>>(istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {

	string S;
	int N;
	cin >> N >> S;

	string T = S.substr(0, N / 2);

	if (S == T + T) Yes;
	else No;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int a, b, k;
    std::cin >> a >> b >> k;
    std::deque<int> q;
    for (int i = 1; i <= std::min(a, b); i++) {
        if (a % i == 0 && b % i == 0) {
            q.push_front(i);
        }
    }
    std::cout << q[k - 1] << std::endl;

    return 0;
}


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

const int maxn = 100010;
int n;
long long a[maxn], b[maxn], mx[maxn];

int main() {
    scanf("%d", &n), n++;
    for (int i = mx[1] = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        if (n == 1) printf("%d\n", a[i] == 1 ? 1 : -1), exit(0);
        if (i == 1 && a[i]) printf("-1\n"), exit(0);
        if (i == 1) continue;
        mx[i] = min(i > 60 ? (long long)2e18 : (1LL << (i - 1)), mx[i - 1] << 1) - a[i];
        if (mx[i] < 0) printf("-1\n"), exit(0);
    }
    long long ans = 0;
    for (int i = n; i; i--) {
        a[i] += min(mx[i], a[i + 1]), ans += a[i];
    }
    printf("%lld\n", ans);
    return 0;
}

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

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

    int n, ans = 0;
    long long h, w;
    cin >> n >> h >> w;
    for(int i = 0; i < n; i++){
        long long a, b;
        cin >> a >> b;
        if((a >= h) && (b >= w)){
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define ff first
#define ss second


int main() {
    int n, w;
    scanf("%d %d", &n, &w);
    vector<pll> a(n);
    for (auto &i: a) scanf("%lld %lld", &i.ff, &i.ss);
    vector<vector<ll>> dp(n+1, vector<ll>(w+5, 0));
    dp[0][0] = 0;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=w; j++) {
            int rem = j-a[i-1].ff;
            dp[i][j] = dp[i-1][j];
            if (rem>=0) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][rem]+a[i-1].ss);
            }
        }
    }

    printf ("%lld\n", dp[n][w]);
}

Measured memory_bytes: 80256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define rr register
#define INF 1e18
#define LINF -1e18

using namespace std;

const int MAXN = 1e5 + 1;

inline int read() {
	int s = 0, m = 0;
	char ch = getchar();
	while (!isdigit(ch)) {m |= ch == '-', ch = getchar();}
	while (isdigit(ch)) {s = s * 10 + (ch ^ 48), ch = getchar();}
	return m ? -s : s;
}

int n, d, sum;
double a[50][50];

signed main(int argc, char const *argv[]) {
	n = read();
	d = read();
	for (rr int i = 1; i <= n; i++)
		for (rr int j = 1; j <= d; j++)
			cin>>a[i][j];
	for (rr int i = 1; i <= n; i++){
		for (rr int k = i+1; k <= n; k++) {
			double ans = 0;
			for (rr int j = 1; j <= d; j++)
				if (i != n)
					ans += (a[i][j] - a[k][j]) * (a[i][j] - a[k][j]);
			if(sqrt(ans) == int(sqrt(ans)))
				sum++;
		}
	}
	cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int N;
std::string s, t;

int main() {
  std::cin >> N >> s >> t;
  for (int i = N; i >= 0; --i)
    if (s.substr(N - i) == t.substr(0, i))
      return std::cout << N + N - i, 0;
}

Measured memory_bytes: 3560
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> S;
  if (S[0] =='A') cout <<"T"<<endl;
  else if (S[0] =='T') cout <<"A"<<endl;
  else if (S[0] =='C') cout <<"G"<<endl;
  else if (S[0] =='G') cout <<"C"<<endl;

  
  
  

  
  //cout << ans << endl;
  

}


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

int main(){

  int x;
  cin>>x;

  //
  //
  int h =x/3600;
  int m =(x/60)%60;
  int s =x%60;
  cout<<h<<":"<<m<<":"<<s<<endl;

  return 0;
}
  


Measured memory_bytes: 3120
#include<stdio.h>
int partition(int A[],int p,int r)
{
	int x = A[r];
	int i = p-1;

	for (int j = p; j < r; j++)
	{
		if (A[j] <= x)
		{
			i++;
			int tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	int tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;

	return i + 1;
}
void B()
{
	int A[100000];
	int n = 0;

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

	int q = partition(A,0,n-1);
	for (int i = 0; i < n; i++)
	{
		if (i != 0)printf(" ");
		if (i == q)
		{
			printf("[%d]", A[i]);
		}
		else
		{
			printf("%d", A[i]);
		}
	}

	printf("\n");
}
int main()
{
	B();
	return 0;
}

Measured memory_bytes: 1424
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int base=1000000000+7;
const int maxn=100000+10;

string s;
int n;
long long f[maxn][13]={0};

int main(){
  cin>>s;n=s.length();s="0"+s;
  f[0][0]=1;
  for(int i=0;i<=n-1;i++)
    for(int j=0;j<13;j++){
      if (s[i+1]!='?'){
        int t=(s[i+1]-'0');
        f[i+1][(j*10+t)%13]=(f[i+1][(j*10+t)%13]+f[i][j])%base;
      }
      else{
        for(int t=0;t<=9;t++)
          f[i+1][(j*10+t)%13]=(f[i+1][(j*10+t)%13]+f[i][j])%base;
      }
    }
  long long kq=f[n][5];
  cout<<kq;
}


Measured memory_bytes: 10620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int ans = 0;
    rep(i,N){
        ans += vec[i];
    }
    sort(all(vec));
    if (ans % 10 != 0){
        cout << ans << endl;
    }
    else{
        bool possible = false;
        rep(i,N){
            if (vec[i] % 10 != 0){
                possible = true;
                cout << ans - vec[i] << endl;
                break;
            }
        }
        if (!possible){
            cout << 0 << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
typedef long long int ll;
using namespace std;

int main(){
	int n;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	ll dp[n];
	dp[0] = arr[0];
	ll ans = 0;
	for(int i=1;i<n;i++){
	    if(arr[i]<dp[i-1]){
	        ans+=(dp[i-1]-arr[i]);
	        dp[i] = dp[i-1];
	    }
	    else{
	        dp[i] = arr[i];
	    }
	}
	cout<<ans;
}

Measured memory_bytes: 6744
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
typedef long long ll;
const int INF=1e+09;
ll N,A,B;


int main(){    
    //入力
    cin >> N >> A >> B;
    cout <<(ll)(N/(A+B))*A+min((N-(ll)(N/(A+B))*(A+B)),A) <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (int i = 1; i < N; i++) {
    if (H[i - 1] > H[i]) {
      cout << "No\n";
      return 0;
    } else {
      if (H[i] != H[i - 1]) {
        H[i] = H[i] - 1;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}

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

signed main(){
  int N,H,W;
  cin>>N>>H>>W;
  int ans=0;
  int h,w;
  for(int i=0;i<N;i++){
    cin>>h>>w;
    if(h>=H&&w>=W)ans++;
  }
  cout<<ans<<endl;
}


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

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  vector<long long> eff(2 * m, 0), num(2 * m, 0);
  for(int i = 1; i < n; i++){
    ++num[a[i - 1]];
    --num[a[i] + (a[i] >= a[i - 1] ? 0 : m)];
    
    --eff[a[i - 1]];
    eff[a[i] + (a[i] >= a[i - 1] ? 0 : m)] -= (m + a[i] - a[i - 1] - 1) % m;
  }
  
  for(int i = 1; i < 2 * m; i++) num[i] += num[i - 1];
  
  for(int i = 1; i < 2 * m; i++) eff[i] += eff[i - 1] + num[i];
  
  long long m_eff = 0;
  for(int i = 0; i < m; i++) m_eff = max(eff[i] + eff[i + m], m_eff);
  
  m_eff = -m_eff;
  
  for(int i = 1; i < n; i++){
    m_eff += (m + a[i] - a[i - 1]) % m;
  }
  
  cout << m_eff << endl;
  
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;
  if(a < b) swap(a, b);
  int c = a - b;
  if(c % 2 == 0) cout << (c / 2) + b << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  string s;
  cin >> s;
  ll ans = MOD;
  rep(i, sz(s) - 2){
    string t = s.substr(i, 3);
    ll x = stoi(t);
    ll y = abs(x - 753);
    chmin(ans, y);
  }
  print(ans);
}

Measured memory_bytes: 256
def countng_sort(a):
  MAX = 10000
  n = len(a)
  b = [None] * n
  c = [0] * MAX
  
  for i in range(n):
      c[a[i]] += 1
  
  for i in range(1, MAX):
      c[i] += c[i - 1]
  
  for i in reversed(range(0, n)):
      b[c[a[i]] - 1] = a[i]
      c[a[i]] -= 1

  return b

n = int(input())
a = [int(i) for i in input().split()]
print(*countng_sort(a))


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

const int N = 200010;

std::vector <int> vec[N];
int fa1[N], fa2[N], n, k, l, cnt[N], ans[N];

int find(int fa[], int u){
	return fa[u] == u ? u : fa[u] = find(fa, fa[u]);
}

int unite(int fa[], int u, int v){
	int _u = find(fa, u), _v = find(fa, v);
	fa[_u] = _v;
}

int main(){
	scanf("%d%d%d", &n, &k, &l);
	for (int i = 1; i <= n; ++ i){
		fa1[i] = i;
		fa2[i] = i;
	}
	for (int i = 0, u, v; i < k; ++ i){
		scanf("%d%d", &u, &v);
		if (find(fa1, u) == find(fa1, v)){
			continue;
		}
		unite(fa1, u, v);
	}
	for (int i = 0, u, v; i < l; ++ i){
		scanf("%d%d", &u, &v);
		if (find(fa2, u) == find(fa2, v)){
			continue;
		}
		unite(fa2, u, v);
	}
	for (int i = 1; i <= n; ++ i){
		find(fa1, i);
		find(fa2, i);
	}
	for (int i = 1; i <= n; ++ i){
		vec[fa1[i]].push_back(i);
	}
	for (int i = 0; i <= n; ++ i){
		for (int j = 0; j < vec[i].size(); ++ j){
			++ cnt[fa2[vec[i][j]]];
		}
		for (int j = 0; j < vec[i].size(); ++ j){
			ans[vec[i][j]] = cnt[fa2[vec[i][j]]];
		}
		for (int j = 0; j < vec[i].size(); ++ j){
			cnt[fa2[vec[i][j]]] = 0;
		}
	}
	for (int i = 1; i <= n; ++ i){
		printf("%d ", ans[i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 14080
i = 1
rs = []
n = int(input())

while i <= n:
    x = i
    if x % 3 == 0:
        rs.append(i)
    else:
        while x:
            if x % 10 == 3:
                rs.append(i)
                break
            x //= 10

    i += 1

print(' ' + ' '.join(map(str, rs)))


Measured memory_bytes: 5980
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 100500;
const int mod = (int) 1e9 + 7;

int subMod(int a, int b) {
  int res = a - b;
  return res < 0 ? res + mod : res;
}

int n, k;
int a[MAXN];
int dp[105][MAXN];

int main() { 

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

  for (int i = 0; i <= a[0]; i++) {
    dp[0][i] = 1;
  }

  for (int i = 1; i < n; i++) {
    int sum = 0;
    for (int j = 0; j <= k; j++) {
      sum = (sum + dp[i - 1][j]) % mod;
      if (j - a[i] - 1 >= 0) {
        sum = subMod(sum, dp[i - 1][j - a[i] - 1]);
      }
      dp[i][j] = sum;
    }
  }

  cout << dp[n - 1][k] << endl;

  return 0;
}


Measured memory_bytes: 41216
# include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
int cal(int a, int b)
{
    int c = a/2;
    if((LL)a+c > (LL)b*c)
         return (int)((LL)a+c-(LL)b*c);
    int x = (int)ceil(b*c*1.0/(a+c));
    return max((a+c)*x-b*c, (b-x)*(a-2*c));
}
int cal2(int a, int b)
{
    int c = (int)ceil(a/2.0);
    if(a+c > (LL)b*c) return 1e9;
    int x = (LL)b*c/(c+a);
    return max((int)((LL)b*c-(LL)x*(a+c)), (int)((LL)(b-x)*(2*c-a)));
}
int cal3(int a, int b)
{
    double x = floor(b/3.0);
    double y = ceil(b/3.0);
    return (int)(y*a-x*a);
}
int main()
{
    int a, b;
    scanf("%d%d",&a,&b);
    int ans = min(cal(a, b), min(cal(b, a), min(cal2(a, b), min(cal2(b, a), min(cal3(a, b), cal3(b, a))))));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
S=[]
T=[]

n=int(input())
S=list(map(int,input().split()))
q=int(input())
#T=input().split()
T=list(map(int,input().split()))

def B(S,n,t):
    low=0
    high=n-1

    while low <= high:

        mid =(low + high)//2
        guess = S[mid]

        if guess == t:
           return 1;

        if guess > t:
            high = mid-1
        else:
            low = mid + 1
    return 0

c=0

for i in range(q):
    if(B(S,n,T[i])):
        c=c+1
print(c)



Measured memory_bytes: 16708
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0){
    	cout<<abs(a-b)/2<<endl;
    }
    else{
    	cout<<1+min(a-1,n-b)+(b-a-1)/2<<endl;
    }
    return 0;   
}


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

int main(){
  int N;
  cin >> N;
  int a;
  for(int i=0;i<N;i++){
    cin >> a;
    if(a%2!=0){
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		bool flag=false;
		for(int i=1;i<3;i++){
			if(s[i]!=s[0]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

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



signed main(){
   int n,ans=1;cin>>n;string s;cin>>s;
   rep(i,1,n){
      if(s[i-1]!=s[i])ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define M 100005
char s[M],t[M];
int abcde[30][M],pre[30];
int main(){
	cin>>s+1>>t+1;
	int l1=strlen(s+1),l2=strlen(t+1);
	for(int i=l1*2;i>l1;--i)pre[s[i-l1]-'a']=i-l1;
	for(int i=l1;i>=0;--i){
		for(int j=0;j<26;++j)abcde[j][i]=pre[j];
		if(i)pre[s[i]-'a']=i;
	}
	int id=1,p=0;
	long long ans=0;
	while(id<=l2){
		int q=abcde[t[id]-'a'][p];
		if(!q){
			puts("-1");
			return 0;
		}
		if(p>=q){
			ans+=q+l1-p;
			p=q;
			++id;
		}else {
			ans+=q-p;
			p=q;
			++id;
		}
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  string s, t;
  cin >> s >> t;

  vector<char> sc(s.length()), tc(t.length());
  rep(i, s.length()) sc.pb(s[i]);
  rep(i, t.length()) tc.pb(t[i]);
  sort(all(s));
  sort(all(t), greater<char>());

  string sn = "", tn = "";
  rep(i, s.length()) sn += s[i];
  rep(i, t.length()) tn += t[i];

  if(sn < tn) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int N, M, X;
int nums[15][15];
int ans = 0x3f3f3f3f;
vector<int> vec;

bool check(vector<int>& vec) {
    vector<int> summ(M, 0);
    for (int i = 0; i < vec.size(); ++i) {
        int j = vec[i];
        for (int k = 1; k <= M; ++k) {
            summ[k - 1] += nums[j][k];
        }
    }
    for (int i = 0; i < M; ++i) {
        if (summ[i] < X) return false;
    }
    return true;
}

void dfs(int pos) {
    if (pos == N + 1) {
        if (check(vec)) {
            int summ = 0;
            for (int i = 0; i < vec.size(); ++i) {
                summ += nums[vec[i]][0];
            }
            ans = min(ans, summ);
        }
        return ;
    }
    vec.push_back(pos);
    dfs(pos + 1);
    vec.pop_back();
    dfs(pos + 1);
}
int main() {
    cin >> N >> M >> X;
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= M; ++j) {
            cin >> nums[i][j];
        }
    }
    dfs(1);
    if (ans == 0x3f3f3f3f) cout << "-1\n";
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long
#define MOD 1000000007
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{ 
    ll H,W,i,j;
    cin >> H >> W;
    char grid[H][W];
    ll now[H][W];
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++) cin >> grid[i][j];
    }
    now[0][0]=1;
    for(i=1;i<W;i++)
    {
        if(grid[0][i]!='#') now[0][i]=now[0][i-1];
        else now[0][i]=0;
    }
    for(i=1;i<H;i++)
    {
        if(grid[i][0]!='#') now[i][0]=now[i-1][0];
        else now[i][0]=0;
    }
    for(i=1;i<H;i++)
    {
        for(j=1;j<W;j++) 
        {
            if(grid[i][j]!='#') now[i][j]=(now[i-1][j]+now[i][j-1])%MOD;
            else now[i][j]=0;
        }
    }
    /*for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++) cout << now[i][j] << ' ';
        cout << "\n";
    }*/
    cout << now[H-1][W-1] << "\n";
}

 
int main()
{
    opt;
    solve();
    return 0;
}       

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
        if(b&1)res = res * x % MOD;
        x = x * x % MOD;
        b>>=1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
}
void outendl(){
    was_output = false;
    cout << endl;
}
ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
}

int main(){
    string str;
    cin >> str;
    if(str.size()&1){
        cout << "No" << endl;
        return 0;
    }
    bool flag = true;
    for(int i=0;i<str.size();i+=2){
        if(str.substr(i,2)!="hi"){
            flag = false;
            break;
        }
    }

    cout << (flag?"Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
	long long a, b, c;
	cin >> a >> b >> c;
	long long x, y, z;
	if(c%2==1)
		x = a * b;
	else
		x = 0;
	if(b%2==1)
		y = a * c;
	else
		x = 0;
	if(a%2==1)
		z = c * b;
	else
		z = 0;
	cout << min(min(x, y), z) << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    const string s = "CODEFESTIVAL2016";
	string str;

	cin >> str;

	int ans = 0;

	int i, len = str.size();

	rep(i, len) if (s[i] != str[i]) ans++;

	Out(ans);
	
	return 0;
}


Measured memory_bytes: 256
s = raw_input()

ans = 0
c = 0
i = 0
while i<len(s)-1:
  if s[i]=="A":
    c += 1
    i += 1
  elif s[i:i+2]=="BC":
    ans += c
    i += 2
  else:
    c = 0
    i += 1
print ans


Measured memory_bytes: 2948
fun main(args: Array<String>) {
    val N = readInt()
    val p = readLine()!!.replace(" ", "").toInt()
    val q = readLine()!!.replace(" ", "").toInt()

    var pPos = 0
    var qPos = 0

    val a = IntArray(N)
    var cnt = 0
    fun create(n: Int, ary: List<Int>) {
        ary.forEach {
            a[n] = it
            if (n + 1 == N) {
                val i = a.joinToString("").toInt()
                cnt++
                if (i == p) pPos = cnt
                if (i == q) qPos = cnt
            } else {
                create(n + 1, ary.minus(it))
            }
        }
    }

    val all = mutableListOf<Int>()
    repeat(N) {
        all.add(it + 1)
    }
    create(0, all)

    println(Math.abs(pPos - qPos))
}


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

Measured memory_bytes: 43608
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;

int main()
{
    int N, M, L, Q;
    cin >> N >> M >> L;

    vector<vector<ll>> d(N, vector<ll>(N, INF)), f(N, vector<ll>(N, INF));

    rep(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        d[A - 1][B - 1] = C;
        d[B - 1][A - 1] = C;
    }

    rep(i, N) d[i][i] = 0;
    rep(i, N) f[i][i] = 0;

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    rep(i, N) {
        rep(j, N) {
            if (d[i][j] <= L) f[i][j] = 1;
        }
    }

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
            }
        }
    }

    cin >> Q;
    rep(i, Q) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        ll ans = (f[s][t] != INF) ? f[s][t] - 1 : -1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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 T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	if (x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.numeric;
import std.math;

void main() {
  auto N = readln.chomp.to!int;
  auto Ln = readln.split.to!(int[]).sort;

  int total = 0;
  foreach(i; 0..N-2) {
    auto a = Ln[i];
    for(int j=i+1; j<N-1; j++) {
      auto b = Ln[j];
      for(int k=j+1; k<N; k++) {
        if (a + b <= Ln[k]) break;
        total++;
      }
    }
  }

  writeln(total);
}


Measured memory_bytes: 2428
#include<iostream>
#include<cmath>

using namespace std;

int f(long long a)
{
	int ans=0;
	while(true)
	{
		ans++;
		a/=10;
		if(a==0)break;
	}
	return ans;
}

int main()
{
	long long n;
	cin >> n;
	int mini=1000000;
	int lim=sqrt(n)/1+10;
	for(int i=1;i<=lim;i++)
	{
		if(n%i==0)
		{
//			cout << i << " : " << n/i << endl;
			mini=min(mini,max(f(i),f(n/i)));
		}
	}

	cout << mini << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 0; i < n; i++) 
        cin >> a[i + 1];
    ll ans = 0;
    ll s[n + 1];
    ll mod = pow(10,9)+7;
    s[n] = a[n];
    for(int i = n - 1; i > 0; i--){
        s[i] = s[i + 1] + a[i];
        s[i] %= mod;
    }
    for(int i = 1; i < n; i++){
        ans += a[i] * s[i + 1];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<vector<int>> graph(n + 1);
	vector<int> numf(n + 1);
	vector<int> numb(n + 1);
	FOR(i, 1, m) {
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		numf[a]++;
		numf[b]++;
	}
	
	vector<int> par(n + 1);
	queue<int> que;
	map<int, int>numch;
	FOR(i, 1, n) {
		if (par[i] != 0)continue;
		que.push(i);
		par[i] = i;
		numch[i]++;
		while (!que.empty()) {
			int node = que.front();
			que.pop();
			for (int dest : graph[node]) {
				if (par[dest])continue;
				par[dest] = i;
				numch[i]++;
				que.push(dest);
			}
		}
	}
	FOR(i, 1, k) {
		int c, d;
		cin >> c >> d;
		if (par[c] == par[d]) {
			numb[c]++;
			numb[d]++;
		}
	}
	FOR(i, 1, n) {
		int candi = numch[par[i]] - 1 - numf[i] - numb[i];
		cout << candi;
		if (i == n)cout << endl;
		else cout << " ";
	}
}

Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };

    // 約数一覧を返します
vector<ll> devisors(ll a){
    vector<ll> ret;
    for(ll i=1; i*i<=a; i++){
        if(a%i!=0) continue;
        ret.push_back(i);
        ll another = a/i;
        if(i!=another) ret.push_back(another);
    }
    sort(ALL(ret), greater<ll>());//大きい順にソート
    return ret;
}

void solve() {
    ll n,m; cin >> n >> m;
    vll d = devisors(m);
    ll t = m/n;
    rep(i,d.size()){
        if(d[i]<=t) {
            print(d[i]);
            return;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

signed main() {
    int n, p[20], ans;

    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> p[i];
    }
    
    ans = 0;
    for ( int i = 1; i < n-1; i++ ) {
        if ( (p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1]) ) {
            ans ++;
        }
    }
    
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
from bisect import bisect_left as bl
class segtree:
    def __init__(self, nn):
        self.NN = nn
        self.XX = [0] * (2**(nn+1)-1)
    def getmax(self, i):
        j = 2**self.NN + i - 1
        ma = -1
        while j >= 0:
            ma = max(ma, self.XX[j])
            j = (j-1) // 2
        return -1 if ma <= 0 else INF - ma
    def updaterange(self, a, b, x):
        l = a + (1<<self.NN)
        r = b + (1<<self.NN)
        s = 0
        while l < r:
            if l%2:
                self.XX[l-1] = max(self.XX[l-1], x)
                l += 1
            if r%2:
                r -= 1
                self.XX[r-1] = max(self.XX[r-1], x)
            l >>= 1
            r >>= 1

N, Q = map(int, input().split())
st = segtree(18)
INF = 1<<50
X = []
D = []
for _ in range(N):
    s, t, x = map(int, input().split())
    X.append((s, t, x))
for _ in range(Q):
    D.append(int(input()))

for s, t, x in X:
    st.updaterange(bl(D, s-x), bl(D, t-x), INF-x)
for i in range(Q):
    print(st.getmax(i))


Measured memory_bytes: 116604
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int Y = X-A;

	System.out.println(Y%B);
      }
}



Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll ans=0;
    rep(1,i,n+1){
        if(i%5!=0 && i%3!=0)ans+=i;
    }
    cout<<ans;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  ll i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    ll n;
    cin >> n;
    ll a = 1, b = n;
    for(i = 2;i * i <= n;++i){
      if(n % i == 0){
        a = i;
        b = n / i;
      }
    }
    //pri2(a, b);

    int res = 0;
    for(;;){
      if(b == 0)break;
      b /= 10;
      ++res;
    }

    pri(res);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	char a[500][10];
	int i = 0, count = 0, stack[1000], num;
	while (scanf("%s", &a[i]) != EOF) {
		num = atoi(a[i]);
		if (0 < num && num < 1000000) {
			stack[count] = num;
			count++;
		} else if (*a[i] == '+') {
			stack[count - 2] = stack[count - 2] + stack[count - 1];
			count--;
		}else if (*a[i] == '-') {
			stack[count - 2] = stack[count - 2] - stack[count - 1];
			count--;
		}else if (*a[i] == '*') {
			stack[count - 2] = stack[count - 2] * stack[count - 1];
			count--;
		}
		i++;
	}
	printf("%d\n", stack[0]);
	return 0;
}

Measured memory_bytes: 556
import itertools

n = int(input())
num = ['3','5','7']
elements = []
for i in range(1,len(str(n))+1):
    options = itertools.product(num, repeat=i)
    for s in options:
        num1 = ''.join(s)
        elements.append(num1)

cnt = 0

for i in range(len(elements)):
    if int(elements[i]) <= n:
        if '3' in elements[i] and '5' in elements[i] and '7' in elements[i]:
            cnt += 1
    else:
        break

print(cnt)

Measured memory_bytes: 5236
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
int main(int argc, char const *argv[]) {
    int a,b;
    cin >> a >> b;
    if(a+b==15){
        cout << '+' << endl;
    }else if(a*b == 15){
        cout << '*' << endl;
    }else{
        cout << 'x' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long inv[1005],dp[1005];
long long pw(long long x,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1)res=res*x%md;
		x=x*x%md;
		b>>=1;
	}
	return res;
}
int main()
{
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	dp[n]=1;
	for(int i=1;i<=n;i++)dp[n]=dp[n]*i%md;
	inv[n]=pw(dp[n],md-2);
	for(int i=n;i>0;i--)inv[i-1]=inv[i]*i%md;
	for(int i=a;i<=b;i++)for(int j=0;j<=n;j++)for(int k=c;k<=d;k++)if(j+i*k<=n)dp[j]=(dp[j]+dp[j+i*k]*pw(inv[i],k)%md*inv[k]%md)%md;
	cout<<dp[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
typedef long long int ll;

// ll dp[1000000002];

// void solve() {
// 	for(ll i = 0; i < n - 1; i++)
// 	{
// 		for(ll k = 0; k < n; k++)
// 		{
			
// 		}
// 	}
// }

int main(int argc, char const *argv[])
{
	string n;
	cin >> n;

	ll cnt = 0;

	for (ll i = 0; i < n.size(); i++)
	{
		if(n[i] == 'o')
			cnt++;
	}

	if (n.size() - cnt < 8)
	{
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define eps 1.0e-14;

ll combination(ll n,ll r){
	ll a = 1,b = 1;
	for (int i = n; i > n - r; i--){
		a *= i;
	}
	for (int i = r; i > 0; i--){
		b *= i;
	}
	return (a / b);
}

ll nc2(ll x){
	return (((x) * (x - 1)) / 2);
}

int main(){
	int a,b; cin >> a >> b;
	int ans = 0;
	if (a - (b * 2) < 0) ans = 0;
	else ans = a - (b * 2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256