akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m,q = [int(i) for i in readline().split()]
abcd = [[int(i) for i in readline().split()] for _ in range(q)]
for i in range(q):
    abcd[i][0] -= 1
    abcd[i][1] -= 1

from itertools import combinations_with_replacement

ans = 0
L = range(1,m+1)
for v in combinations_with_replacement(L,n):
    res = 0
    for a,b,c,d in abcd:
        if v[b]-v[a] == c: res += d
    ans = max(ans,res)

print(ans)







Measured memory_bytes: 9212
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

const int N = 2011;
ll dp[N][N] = {};
int a[N] = {};
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <pii> b(n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i - 1] = {a[i], i};
    }
    sort(all(b));
    reverse(all(b));
    for (int i = 0; i <= n + 1; i++) {
        for (int j = 0; j <= n + 1; j++) {
            dp[i][j] = -LINF;
        }
    }
    dp[0][n + 1] = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = n + 1; j > i; j--) {
            int num = i + n + 1 - j;
            if (num >= n) continue;
            int val = b[num].x, pos = b[num].y;
            umax(dp[i + 1][j], dp[i][j] + abs(pos - i - 1ll) * 1ll * a[pos]);
            umax(dp[i][j - 1], dp[i][j] + abs(pos - j + 1ll) * 1ll * a[pos]);
        }
    }
    ll ans = -LINF;
    for (int i = 0; i <= n; i++) {
        umax(ans, dp[i][i + 1]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 35120
#include<bits/stdc++.h>
using namespace std;
const int N=16;
int n;
vector<int> t[N][2];
int countbit1(int x) {
    int cnt=0;
    while(x) {
        x&=x-1;
        cnt++;
    }
    return cnt;
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        int Ai;
        cin>>Ai;
        for(int j=1;j<=Ai;j++) {
            int p,v;
            cin>>p>>v;
            t[i][v].push_back(p);
        }
    }
    int ans=0;
    for(int r=0;r<(1<<n);r++) {                         //r是二进制方案
        bool conflict=false;
        for(int i=1;i<=n;i++) {                         //i是每个人
            bool gb=false,bg=false;                     //gb方案中好人被当坏人，bg方案中坏人被当好人
            for(int j=0;j<t[i][0].size();j++) {
                int p=t[i][0][j]-1;
                if((1<<p)&r) gb=true;                   //在方案r中，p是好人，好人被当作坏人
            }  
            for(int j=0;j<t[i][1].size();j++) {
                int p=t[i][1][j]-1;
                if(!((1<<p)&r)) bg=true;                //在方案r中，p是坏人，坏人被当作好人

            }
            if(gb&&(1<<(i-1)&r)) conflict=true;         //i是好人，他将好人作为坏人，出现冲突
            if(bg&&(1<<(i-1)&r)) conflict=true;         //i是好人，他将坏人作为好人，出现冲突
        }
        if(!conflict) ans=max(ans,countbit1(r));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(){
  cin >> a >> b;
  int x = (a*100)/8;
  int y = b*10;
  int xx = ((a+1)*100)/8;
  int yy = (b+1)*10;
  int mi = 1000000;

  for(int i=x ; i<xx ; i++){
    for(int j=y ; j<yy ; j++){
      if(((i*8)/100 == a)&& (j/10 == b)&&i==j){
        mi = min(mi, i);
      }
    }
  }
  if(mi != 1000000){
    cout << mi << endl;
    return 0;
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 256
#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>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(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 };

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

void add(ll& a, ll b) {
	a += b;
	if (a >= mod) a -= mod;
}

ll dp[210000][5];

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

	dp[0][0] = 1;
	rep(i, s.size()) {
		rep(j, 5) {
			if (s[i] != '?') add(dp[i + 1][j], dp[i][j]);
			else add(dp[i + 1][j], dp[i][j] * 3 % mod);
		}
		if (s[i] == 'A' || s[i] == '?') add(dp[i + 1][1], dp[i][0]);
		if (s[i] == 'B' || s[i] == '?') add(dp[i + 1][2], dp[i][1]);
		if (s[i] == 'C' || s[i] == '?') add(dp[i + 1][3], dp[i][2]);
	}
	cout << dp[s.size()][3];
}

Measured memory_bytes: 4608
#include <stdio.h>
int main(){
  
  int A, B, C;
  
  scanf("%d%d%d", &A, &B, &C);
  
  if(A == B && B == C && C == A){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
  
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string n;
	cin>>n;
	bool a=true;
	for(int i=0;i<n.length();i++)
	{
		a=true;
		if(i%2)
		{
			if(n[i]=='L'||n[i]=='U'||n[i]=='D')
			a=false;
		}
		else
		{
			if(n[i]=='R'||n[i]=='U'||n[i]=='D')
			a=false;
		}
		if(a)
		break;
	}
	if(a)
	cout<<"No";
	else
	cout<<"Yes";
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
bool h[2005];
vector<int>edge[2005];
int dist[2005][2005];
int sum[2005][2005];
int cnt[2005][2005];
P dfs(int v,int u,int g,int d){
	dist[g][v] = d;
	if(h[v]){
		sum[g][v] = d;
		cnt[g][v] = 1;
	}
	rep(i,edge[v].size()){
		if(edge[v][i] == u) continue;
		P p = dfs(edge[v][i],v,g,d+1);;
		sum[g][v] += p.fi;
		cnt[g][v] += p.sc;
	}
	return P(sum[g][v],cnt[g][v]);
}
int gen(int v,int u,int g){
	int S = 0, mx = 0;
	rep(i,edge[v].size()){
		if(edge[v][i] == u) continue;
		S += sum[v][edge[v][i]];
		mx = max(mx,sum[v][edge[v][i]]);
	}
	if(mx <= S/2) return cnt[g][v]+S%2;
	else{
		int id;
		rep(i,edge[v].size()){
			if(edge[v][i] == u) continue;
			if(mx == sum[v][edge[v][i]]) id = edge[v][i];
		}
		int reduction = gen(id,v,g);
		if(reduction <= S-mx) return cnt[g][v]+S%2;
		else return (reduction-S+mx)+cnt[g][v];
	}
}
int check(int v,int u,int g){
	int S = 0, mx = 0;
	rep(i,edge[v].size()){
		if(edge[v][i] == u) continue;
		S += sum[g][edge[v][i]];
		mx = max(mx,sum[g][edge[v][i]]);
	}
	if(u == -1){
		if(mx <= S/2) return S;
		int id = -1;
		rep(i,edge[v].size()){
			if(edge[v][i] == u) continue;
			if(sum[g][edge[v][i]] == mx) id = edge[v][i];
		}
		int reduction = gen(id,v,g);
		//cout << id << " " << v << " " << g << " " << reduction << endl;
		if(reduction > S-mx) return INF;
		else return S;
	}
}
int main(){
	cin >> n;
	string s; cin >> s;
	rep(i,n) if(s[i] == '1') h[i+1] = 1;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		edge[a].pb(b);edge[b].pb(a);
	}
	repn(i,n) dfs(i,-1,i,0);
	int ans = INF;
	repn(i,n){
		if(sum[i][i]%2 == 1) continue;
		ans = min(ans,check(i,-1,i));
		assert(ans%2 == 0);
		//cout << i << " " << check(i,-1,i) << endl;
	}
	cout << (ans>INF/2?-1:ans/2) << endl;
}


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

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

  map<string,int> cnt;
  rep(i,n) {
    string s;
    cin >> s;
    cnt[s]++;
  }

  for (string s : {"AC","WA","TLE","RE"}) {
      cout << s << " x " << cnt[s] << endl;
  }
}


Measured memory_bytes: 3636
import java.util.*
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun modpow(n:Long,p:Long = mod-2L):Long = when {
	p==0L->1L
	p%2==1L->n*modpow(n,p-1)%mod
	else-> {
		val d = modpow(n,p/2)
		d*d%mod
	}
}

fun main() {
	abc000X()
}

fun abc000X() {
	val n = int()
	val a = IntArray(n)
	list().forEach {a[it]++}

	val f = if(n%2==1) {
		a.indices.all {i->
			a[i]==when {
				i==0->1
				i%2==0->2
				else->0
			}
		}
	} else {
		a.indices.all {i->
			a[i]==when {
				i%2==1->2
				else->0
			}
		}
	}
	println(if(f) modpow(2,n/2L) else 0)
}


Measured memory_bytes: 52888
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		long ans=0;
		Scanner in = new Scanner(System.in);
		long a=in.nextLong();
		long b=in.nextLong();
		ans=a*b;
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 35568
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  string s;
  cin>>N;
  s = to_string(N);
  int a = s.size();
  if(s[a-1] == '2' || s[a-1] == '4' || s[a-1] == '5' ||
  s[a-1] == '7' || s[a-1] == '9'){
    cout<<"hon"<<'\n';
  }else if(s[a-1] == '0' || s[a-1] == '1' ||
   s[a-1] == '6' || s[a-1] == '8'){
    cout<<"pon"<<'\n';
  }else if(s[a-1] == '3'){
    cout<<"bon"<<'\n';
  }
}

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

const int MAX = 200000;
const int64_t BIG = 20000000000000;
int main() {
	int N;
	int64_t min = BIG, check;
	static int64_t a[MAX];
	cin >> N >> a[0];
	for (int i = 1;i < N;i ++) {
		cin >> a[i];
		a[i] += a[i - 1]; // 累積和
	}
	for (int i = 0;i < N - 1;i ++) {
		check = a[N - 1] - a[i] - a[i];
		if (check < 0) check = -check;
		if (check < min) min = check;
	}
	cout << min;
}

Measured memory_bytes: 1792
import java.util.*;
import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int A[];
        A=new int[N];
        for(int i=0;i<N;i++) A[i]=sc.nextInt();
        boolean dp[][];
        dp=new boolean[N+1][2020];
        dp[0][0]=true;
        for(int i=0;i<N;i++){
            for(int j=0;j<=2000;j++){
                if(dp[i][j]){
                    dp[i+1][j]=true;
                    if(j+A[i]<=2000) dp[i+1][j+A[i]]=true;
                }
            }
        }
        int q=sc.nextInt();
        for(int i=0;i<q;i++){
            int m=sc.nextInt();
            System.out.println(dp[N][m]?"yes":"no");
        }
    }
}


Measured memory_bytes: 26520
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] P = new int[N];
            for (int i = 0; i < N; i++) {
                P[i] = sc.nextInt();
            }

            long max = 0;
            long sum = 0;

            for (int i = 0; i < K; i++) {
                sum += P[i];
            }
            max = sum;

            for (int i = 1; i < N - K + 1; i++) {
                sum = sum + P[K + i - 1] - P[i - 1];
                if (max < sum) {
                    max = sum;
                }
            }

            System.out.println((max + K) / 2.0);
        }
    }

}


Measured memory_bytes: 85580
n = int(input())
s = input()
l = 0
r = s.count('.')
# if s[0] == '#':
#     l += 1
# else:
#     r -= 1
ans = float('inf')
for i in range(n-1):
    if s[i] == '#':
        l += 1
    else:
        r -= 1
    ans = min(ans, l+r)
    # print(ans, l, r)
ans = min(ans, s.count('.'))
ans = min(ans, s.count('#'))
print(ans)


Measured memory_bytes: 9492
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, B = map(int, readline().split())

    print(min(A * N, B))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          firstn
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define fr(i,l,u) 	for(i=l;i<=u;i++)
#define bk(i,l,u)	for(i=l;i>=u;i--)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll posx[]={1,-1,0,0};
ll posy[]={0,0,1,-1};

void solve()
{
    ll n,i,j,w;
    cin>>n>>w;
    ll wt[n+1],val[n+1];
    for(i=1;i<=n;i++)
    cin>>wt[i]>>val[i];
    ll dp[w+1];
    mset(dp,0);
    for(i=1;i<=n;i++)
    {
        for(j=w;j>=wt[i];j--)
            dp[j]=max(dp[j],val[i]+dp[j-wt[i]]);
    }
    cout<<dp[w];
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

using namespace std;

int n, m, d;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> d;
    cout << fixed << setprecision(10) << (1LL * (m - 1) * (n - d) * (d == 0 ? 1 : 2) ) / (1.0L * n * n);

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAX 200005
#define int long long int

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
void solve()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    map<int,int> factors;
    bool found  = true;
    for(int i = 0 ; i < n ; i++)
    {
        int ele = a[i];
        for(int j = 1 ; j*j <= ele ; j++)
        {
            if(ele%j == 0)
            {
                if(ele/j == j)
                {
                    if(factors[j] > 0 and j!=1)
                    {
                        found = false;
                        break;
                    }
                    factors[j]++;
                }
                else
                {
                    if(factors[j] > 0 and j!=1)
                    {
                        found = false;
                        break;
                    }
                    if(factors[ele/j]>0 and ele/j != 1)
                    {
                        found = false;
                        break;
                    }
                    factors[ele/j]++;
                    factors[j]++;
                }
            }
        }
        if(!found)
            break;
    }

    if(found)
    {
        cout << "pairwise coprime";
        return;
    }
    
    
    int GCD = a[0];
    for(int i = 1 ; i < n ; i++)
        GCD = gcd(GCD,a[i]);
    if(GCD == 1)
        cout << "setwise coprime";
    else cout << "not coprime";
    
    
    
    return;
}

int32_t main()
{
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
        solve();
    
    return 0;
}
/*
 AtCoder after Google Online Challenge Fail:(
 */


Measured memory_bytes: 11380
n=gets.to_i
h=gets.chomp.split(" ").map(&:to_i)
dp=Array.new(n)
dp[0]=0
dp[1]=(h[0]-h[1]).abs
for i in 2..n-1
	way1=dp[i-1]+(h[i]-h[i-1]).abs
	way2=dp[i-2]+(h[i]-h[i-2]).abs
	if(way1>way2)
		dp[i]=way2
	else
		dp[i]=way1
	end
end
p dp[n-1]

Measured memory_bytes: 9220
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)

    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]


N, M = map(int, input().split())
A, B = [0] * M, [0] * M  # 入力時に 0-index に合わせる

direct =[[] for _ in range(N)]  # 同じ集合の友達もしくはブロック関係の人
uf = UnionFind(N)  # 友達関係をまとめた UnionFind 木

for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
    direct[A[i]].append(B[i])
    direct[B[i]].append(A[i])
    uf.unite(A[i], B[i])

ans = 0
for i in range(N):
    ans= max(ans, uf.group_size(i))
print(ans)

Measured memory_bytes: 50748
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   int A,H;
   cin>>H>>A;
  if(H%A==0){
    cout<<H/A<<endl;
  }
  else{
    cout<<H/A+1<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  int cnt=0;
  for(;A>=B;B*=2)cnt++;
  for(;B>=C;C*=2)cnt++;
  if(cnt<=K)puts("Yes");
  else puts("No");
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main()
{
	int p[100010];
	int acc[100010];
	int Q;
	int r, l;
	fill(begin(p), end(p), 1);
	p[0] = p[1] = 0;
	for (int i = 2; i*i <= 100010; i++)
	{
		if (p[i] == 1)
		{
			for (int j = 2; i*j <= 100000; j++)
			{
				p[i*j] = 0;
			}
		}
	}
	for (int i = 1; i < 100010; i++)
	{
		acc[i] = acc[i - 1];
		if (i % 2 == 1 && p[i] == 1 && p[(i + 1) / 2] == 1)
		{
			acc[i]++;
		}
	}
	cin >> Q;
	for (int i = 0; i < Q; i++)
	{
		cin >> l >> r;
		cout << acc[r] - acc[l - 1] << endl;
	}

	return 0;
}

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

void lcs(string a,string b)
{
	int n=a.size();
	int m=b.size();
	int l[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0 || j==0)
			{
				l[i][j]=0;
			}
			else if(a[i-1]==b[j-1])
			{
				l[i][j]=l[i-1][j-1]+1;
			}
			else
			{
				l[i][j]=max(l[i-1][j],l[i][j-1]);	

			}
		}
	}
	
	//return l[n][m];
	int mx=l[n][m];
	string s="";
	int i=n;
	int j=m;
	while(i>0 && j>0)
	{
		
		if(mx!=l[i-1][j] && mx!=l[i][j-1])
		{
			s=s+a[i-1];
			mx=l[i-1][j-1];
			
			i=i-1;
			j=j-1;
			
		}
		else if(mx==l[i-1][j])
		{
			//s=s+b[i];
			mx=l[i-1][j];
			
			i=i-1;
			//mx=a[i-1][j];
		}
		else
		{
			//s=s+b[j];
			mx=l[i][j-1];
			j=j-1;
			
		}
	}
	reverse(s.begin(),s.end());
	cout<<s;
	
}


int main()
{
	string a,b;
	cin>>a;
	cin>>b;
	lcs(a,b);
	//cout<<lcs(a,b);
	cout<<"\n";
}

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

int main() {

int N,M;
 cin >> N >>M;

 int sama=0, samb=0;
 if(M==0){
   cout<<sama<<endl;
   cout<<samb<<endl;}

 else{ 
 int pi[M];
 string si[M];
 int k[N],l[N];
 for(int i=0;i<M;i++){
  cin >>pi[i]>>si[i];

  }
  for(int i=0;i<N;i++){
 
  k[i]=0;
  l[i]=0;
  }
  int i=1;
  for(int j=0;j<M;j++){
  if(k[pi[j]-1]==0){
  if(si[j]=="AC"){
  sama++;
  k[pi[j]-1]++;
  samb+=l[pi[j]-1];}
  else l[pi[j]-1]++;}}
 

  cout<<sama<<endl;
   cout<<samb<<endl;}

   }

Measured memory_bytes: 6912
import math

X = int(input())

n = int(math.sqrt(X))
max_numbers = [1]
for i in range(1, n):
    index = 0
    for j in range(X):
        if pow((i+1), j) > X:
            break
        index = j
    # index = int(math.log(X, i+1))
    max_numbers.append(pow((i+1), index))
    # print(pow((i+1), index))

print(int(max(max_numbers)))

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

int main()
{
    int n, count=0, comp=0;
    cin >> n;
    vector<char> s(n);
    for (int i = 0; i < n;i++){
        cin >> s.at(i);
        if(s.at(i)=='D'){
            count--;
        }
        else{
            count++;
        }

        if(comp<count){
            comp = count;
        }
    }
    cout << comp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 1e6+5;
 
const int mod = 1e9+7;
 
int main(){
    int x;
    cin >> x;
    map < int , int > cnt;
    for(int i = 1; i <= x; i++){
        //I
        int cur_num = i;
        for(int j = 2; j*j <= cur_num; j++){
            while(cur_num % j == 0){
                cur_num /= j;
                cnt[j] ++;
            }
        }
        if(cur_num != 1){
            cnt[cur_num]++;
        }
    }
    ll ans = 1;
    map < int , int > :: iterator it = cnt.begin();
    for(; it != cnt.end(); it++){
        ans = (ans * ((it)->second + 1)) % mod;
        ans %= mod;
 
    }
    cout << ans << "\n";
}
 

Measured memory_bytes: 3588
D,G=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(D)]
ans=G // 100

for i in range(2**D):
    score=0
    b=0
    cnt=0
    for j in range(D):
        if ((i>>j)&1):
            score+=100*(j+1)*pc[j][0]+pc[j][1]
            cnt+=pc[j][0]
        else:
            b=j
    for k in range(pc[b][0]):
        if score>=G and cnt<ans:
            ans=cnt
        score+=(b+1)*100
        cnt+=1
print(ans)

Measured memory_bytes: 71484
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const int maxn = 1e5+7;
int main(){
	fast_io;
	ll a,b;
	cin>>a>>b;
	if(a<b){
		cout<<min(a,(b-a));
	}
	else{
		ll d = a%b; 
		cout<<min(d,(b-d));
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
double to_rad(int deg){
    return deg * M_PI / 180.0;
}
  
int main(void){
    int a,b,d;
    cin >> a >> b >> d;

    double S = (a * b * sin(to_rad(d)) / 2);
    double c = sqrt(pow(a,2) - 2*a*b*cos(to_rad(d)) + pow(b,2));
    double L = a + b + c;
    double h = 2 * S / a;
    cout << fixed << S << endl;
    cout << fixed << L << endl;
    cout << fixed << h << endl;
}

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

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

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   ll a[5], k;
   rep (i, 3) cin >> a[i];
   cin >> k;
   sort(a,a+3,greater<ll>());
   ll ans = a[1] + a[2];
   while (k--) {
      a[0] *= 2;
   }
   cout << ans + a[0] << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace  std;
bool check(string &st,int i,int j)
{
  while(i<=j)
  {
    if(st[i]!=st[j])
    return false ;
    else
    {
      i++;j--;
    }
  }
  return true;
}
int main()
{
  string st;
  cin>>st;
  bool flag=true;
  int n=st.size();
  flag=flag&check(st,0,n-1);
  flag=flag&check(st,0,(n-1)/2-1);
  flag=flag&check(st,(n+3)/2-1,n-1);
  if(flag==true)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int ret;
    if (A > B) {
        ret = A--;
    } else {
        ret = B--;
    }
    if (A > B) ret += A;
    else ret += B;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int road[100][100];
int mem[100][100];
int a,b;
int n;
int solve(int x,int y);
int main(){
  int x,y;
  while(cin>> a>> b){
    if(a==0 && b==0){
      break;
    }
    road[a-1][b-1]=2;
    cin>> n;
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	road[i][j]=0;
	mem[i][j]=0;
      }
    }
    
    for(int i=0;i<n;i++){
      cin>> x>> y;
      road[x-1][y-1]=1;
    }
    
    int ans;
    ans=solve(0,0);
    
    cout<< ans<< endl;
  }
  return 0;
}

int solve(int x,int y){
  if(road[x][y]==1) return 0;
  if(x>=a || y>=b) return 0;
  if(mem[x][y]>0) return mem[x][y];
  if(x==a-1 && y==b-1) return 1;
  return mem[x][y]=solve(x+1,y) + solve(x,y+1);
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine( Console.ReadLine().Split(' ').Select(item => double.Parse(item)).OrderByDescending(item => item).Select((val,idx)=> val / Math.Pow(2, idx==N-1?idx:idx+1)).Sum());

            
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    if(a<=0 && b>=0) cout<<"Zero"<<endl;
    else if(a>0 && b>0) cout<<"Positive"<<endl;
    else{
      if((b-a+1)%2==0) cout<<"Positive"<<endl;
      else cout<<"Negative"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	vector<pair<int, int>> v(N);
	for (int i = 0; i < N; ++i) scanf("%d%d", &v[i].first, &v[i].second);
	vector<int> a(N);
	iota(a.begin(), a.end(), 0);
	long double r = 0;
	long double F = 1;
	for (int i = 2; i <= N; ++i) F *= i;
	do {
		long double c = 0;
		for (int i = 0; i < N - 1; ++i) {
			long double A = v[a[i]].first - v[a[i + 1]].first;
			long double B = v[a[i]].second - v[a[i + 1]].second;
			c += sqrt(A * A + B * B);
		}
		r += c / F;
	} while (next_permutation(a.begin(), a.end()));
	printf("%.20lf\n", (double) r);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

int f(string x) {
  int h = stoi(x.substr(0, 2));
  int m = stoi(x.substr(3, 2));
  int s = stoi(x.substr(6, 2));
  return h*3600+m*60+s;
}

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int n;
  while (cin >> n) {
    if (!n) { break; }
    int cnt[90005] = {0};
    rep(i, n) {
      string a, b;
      cin >> a >> b;
      int head = f(a);
      int tail = f(b);
      cnt[head]++;
      cnt[tail]--;
    }
    rep(i, 90000) {
      if (i == 0) { continue; }
      cnt[i] += cnt[i-1];
    }
    int ans = 0;
    rep(i, 90000) {
      ans = max(ans, cnt[i]);
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3448
#include<stdio.h>
#define N 2000
int num1,math[N+1];
int main(){
    int a,num2,ans,sum=0,math[N+1];
    int i,j;

    math[0]=1;
    
    scanf("%d",&num1);
    for(i=0;i<num1;i++){
	    scanf("%d",&a);
	    sum+=a;
	    for(j=sum-a;j>=0;j--){
	       if(math[j]==1) math[j+a]=1;
    	}
    	
    }

    scanf("%d",&num2);
    for(i=0;i<num2;i++){
	    scanf("%d",&ans);
	    math[ans]==1 ? printf("yes\n") :printf("no\n");
    }

    return 0;
}



Measured memory_bytes: 2108
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 998244353;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

ll modpow(ll a, ll p){
	ll ret = 1;
	while(p){
		if(p&1) ret = ret * a % MOD;
		a = a * a % MOD;
		p >>= 1;
	}
	return ret;
}

struct Combination{
        std::vector<ll> fac, finv, inv;
        Combination(int max=6e5): fac(max+1), finv(max+1), inv(max+1) {
                fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
                for(int i=2; i<=max; i++){
                        fac[i] = fac[i-1] * i % MOD;
                        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
                        finv[i] = finv[i-1] * inv[i] % MOD;
                }
        }
        ll C(int n, int r) const {
                if(n<0 or n<r) return 0;
                return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
        }
};

int main(){
	ll n, m, k, ans = 0;
	scanf("%ld %ld %ld", &n, &m, &k);
	Combination comb;
	REP(i, 0, k+1){
		ans += m * modpow(m-1, n-i-1) % MOD * comb.C(n-1, i);
		ans %= MOD;
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long x,t;
   while(cin>>x>>t)
   {
       if(t>=x)
       {
           cout<<"0"<<endl;
       }
       else
       {
           cout<<x-t<<endl;
       }
   }


   return 0;
}


Measured memory_bytes: 256
import heapq
 
N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
 
hpq = list(map(lambda x: -1 * x, A))
heapq.heapify(hpq)
for i in range(M):
    x = heapq.heappop(hpq)
    heapq.heappush(hpq, x / 2)

print(sum(map(lambda x: int(-1 * x), hpq)))

Measured memory_bytes: 14224
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    M, *DC = map(int, read().split())
    D = DC[::2]
    C = DC[1::2]

    total = sum(d * c for d, c in zip(D, C))
    ans = sum(C) - 1 + (total - 1) // 9
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 112172
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
/*int c[105][105];
int main(){
    int h,w;
    int n;
    cin >> h >> w;
    int H=h;
    int W=w;
    cin >> n;
    vector<int>a(n+1);
    rep(i,n){
        cin >>a[i+1];
    }
    int now = 1;
    int kai = 0;
    while(1){
        rep(j,w-kai*2){
            c[0+kai][j+kai] = now;
            a[now]--;
            if(a[now]==0)now++;
        }
        
        if(now==n+1)break;
        rep(i,h-1-kai*2){
            c[i+1+kai][w-1-kai] = now;
            a[now]--;
            if(a[now]==0){
                now++;
            }
        }
        
        if(now==n+1)break;
        rep(j,w-1-kai*2){
            c[h-1-kai][w-j-2-kai] = now;
            a[now]--;
            if(a[now]==0){
                now++;
            }
        }
        
        if(now==n+1)break;
        rep(i,h-2-kai*2){
            c[h-i-2-kai][0+kai] = now;
            a[now]--;
            if(a[now]==0){
                now++;
            }
        }
        //h-=2;
        //w-=2;
        kai++;
        if(now==n+1)break;
    }
    rep(i,H){
        rep(j,W-1){
            cout << c[i][j] << " ";
        }
        cout << c[i][W-1] << endl;
    }
    return 0;
}*/
void yes(){
    puts("Yes");
}
void no(){
    puts("No");
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    int b = 0,c = 0,d=0;
    rep(i,n){
        cin >> a[i];
        if(a[i]%4==0)b++;
        else if(a[i]%2==0)c++;
        else d++;
    }
    if(d>b+1){
        no();
        return 0;
    }
    if(d<=b){
        yes();
        return 0;
    }
    if(d==b+1 && c>0){
        no();
    }else yes();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	bool hantei=false;
	while(n>=1){
		if(fmod(n,10)==7)	hantei=true;
		n /= 10;
	}
	if(hantei==true) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
vector<bool> visited(1e5 + 5);
vl graph[100005];
vl parent(1e5 + 5);
void bfs(ll root) {
    queue<ll> que;
    que.push(1ll);
    parent[1] = -1;
    while(!que.empty()) {
        ll frnt = que.front();
        que.pop();
        for(auto num: graph[frnt]) {
            if(!visited[num]) {
                visited[num] = true;
                parent[num] = frnt;
                que.push(num);
            }
        }
    }
}
int main() {
    fast_io;
    ll n, m, from, to;
        cin >> n >> m;
        for(int i = 1; i <= m; ++i) {
            cin >> from >> to;
            graph[from].pb(to);
            graph[to].pb(from);
        }
        visited[1] = true;
        bfs(1ll);
        bool ans = true;
        for(int i = 1; i <= n; ++i) {
            if(!visited[i]) {
                ans = false;
                break;
            }
        }
        if(ans) {
            cout << "Yes" << "\n";
            for(int i = 2; i <= n; ++i) {
                cout << parent[i] << "\n";
            }
        }
        else {
            cout << "No" << "\n";
        }
}


Measured memory_bytes: 12920
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(int argc, char const *argv[]) {
  double n,k;
  cin>>n>>k;
  double ans=0.0;
  for(double i=0;i<n;i++){
    if(i>=k){
      ans+=1/n;
      // cout<<"i>=k;"<<ans<<endl;
    }else{
      double a=ceil(log2(k/(i+1)));

      // cout<<"a="<<a<<endl;
      // cout<<"1/n="<<1/n<<endl;
      // cout<<"pow="<<pow(0.5,a);

      ans+=(1/n)*pow(0.5,a);
      // cout<<"i<=k;"<<ans<<endl;
    }
  }
  cout<<fixed<<setprecision(14)<<ans<<endl;
  return 0;
}


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

vector<long long> divs(long long n){
  vector<long long> ret;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(n/i);
      if(i != n/i)ret.push_back(i);
    }
  }
  sort(ret.begin(),ret.end());
  return ret;
}

void solve(long long N, long long M) {
  auto vs = divs(M);
  long long ans = 1;
  for( auto v : vs ){
      if( v >= N ){
        ans = max(M / v, ans);
      }
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int n,a[100001];
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	bool b[100001];
	int k=1,s=0;
	bool h=false;
	while(1){
		if(b[k]){
			h=true;
			break;
		}
		b[k]=true;
		if(k==2)break;
		k=a[k];
		++s;
	}
	if(h)cout<<-1<<endl;
	else cout<<s<<endl;;
	return 0;
}


Measured memory_bytes: 768
import Control.Applicative
import Control.Monad
import Data.Set

suitToNum (x:_:xs) =
    suit * 13 + read xs - 1
    where suit = case x of
                'S' -> 0
                'H' -> 1
                'C' -> 2
                'D' -> 3

numToSuit x =
    suit ++ show (num)
    where num = x `mod` 13 + 1
          suit = "SHCD"!!(x `div` 13) : " "
             

main = do
    n <- readLn
    ss <- replicateM n ( suitToNum <$> getLine )
    let lostcards = (fromAscList [0..51]) `difference` (fromList ss)
    putStr $ concat[numToSuit x ++"\n" | x <- toAscList lostcards]

Measured memory_bytes: 3972
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 10**20
for i in range(1<<n):
    use = [i>>j&1 for j in range(n)]
    if sum(use) < k:continue
    res=0
    now=a[0]
    for i in range(1,n):
        if now < a[i]:
            now = a[i]
        else:
            if use[i]:
                res += now+1-a[i]
                now += 1

    ans = min(ans,res)

print(ans)


Measured memory_bytes: 42972
#include <stdio.h>

int main(){
  int n;

  scanf("%d", &n);
  
  int a[n];
  int b[n];
  int c[n-1];
  
  for(int i = 0; i < n; i++)
    scanf("%d", &a[i]);

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

  for(int i = 0; i < n-1; i++)
    scanf("%d", &c[i]);
    
  int sum = 0;
  for(int i = 0; i < n; i++){
  	sum += b[a[i]-1];
    if(i > 0 && a[i-1] == a[i]-1){
    	sum += c[a[i-1]-1];
    }
  }
  printf("%d", sum);
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

map<char, char> m;
map<char, char> m2;
string S, T;

int main(void) {

    cin >> S >> T;

    bool flag = true;
    rep(i, T.size()) {
        auto tItr = m.find(T[i]);
        if (tItr != m.end()) {
            if (tItr->second != S[i]) {
                flag = false;
                break;
            }
        }

        auto tItr2 = m2.find(S[i]);
        if (tItr2 != m2.end()) {
            if(tItr2->second != T[i]) {
                flag = false;
                break;
            }
        }
        else
        {
            m[T[i]] = S[i];
            m2[S[i]] = T[i];
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a > b)
    {
        for (int i = 0; i < a; i++)
        {
            cout << b << "";
        }
        cout << endl;
    }
    else if (a < b)
    {
        for (int i = 0; i < b; i++)
        {
            cout << a << "";
        }
        cout << endl;
    }
    else
    {
        for (int i = 0; i < a; i++)
        {
            cout << b << "";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;


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

        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int sum = 0;
        for(int i = 0;i < N;i++){
          int A = sc.nextInt();
          sum += A;
        }
        if(sum >= H){
        	System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define int long long

using namespace std;


signed main(){
  string S;
  cin>>S;
  int count=0;
  int index=0;
  char first='D';
  char second='D';
  char third='D';
  int A_count = 0;
  while(true){
    if(S[index]=='A'){
      A_count++;
    }else if(S[index]=='B' && S[index+1]=='C'){
      count+=A_count;
      index++;
    }else{
      A_count = 0;
    }

    index++; 
    if(S.length()<=index) break;
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);
    int count = 1;
    while (A > 0 && C > 0)
    {
        if (count % 2 == 1)
            C -= B;
        else
            A -= D;
        count++;
    }
    if (A <= 0)
        printf("No\n");
    else
        printf("Yes\n");
}

Measured memory_bytes: 3764
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskB {    
    int n, x;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      n = in.nextInt();
      x = in.nextInt();
      if (x == 1 || x == 2 * n - 1) {
        out.println("No");
        return;
      }
      out.println("Yes");
      for (int i = 0; i < 2 * n - 1; ++i)
        out.println((i + x - n + (2 * n - 1)) % (2 * n - 1) + 1);
    }
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      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 String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

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

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 22404
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

int main() {
	int n;
	cin >> n;
	VS a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	bool flag=true;
	for (int i = 1; i < n; i++) {
		int size = a[i-1].size();
		if (a[i - 1][size-1] != a[i][0]) {
			flag = false;
		}
	}
	
	sort(a.begin(), a.end());
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			flag = false;
		}
	}

	if (flag)cout << "Yes" << endl;
	else if (flag == false) cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256