akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
int K,ans;
char s[105];
signed main(){
	scanf("%s",s+1);
	scanf("%lld",&K);
	int k=1,n=strlen(s+1);
	if (s[1]==s[n]){
		while (k<=n&&s[1]==s[k])k++;
		if (k>n){
			printf("%lld\n",n*K/2);
			return 0;
		}
		n--;int p=n+1;
		while (s[n]==s[p])n--;
		ans+=(p-n+k-1)/2*(K-1);
		ans+=(p-n)/2+(k-1)/2;
	}
	for (int i=k,j=1;i<=n;i=j){
		while (s[i]==s[j])j++;
		ans+=(j-i)/2*K;
	}
	printf("%lld\n",ans);
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    if(S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	int ans=min(a+b,min(b+c,c+a));
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   vector<int> x(n);
   rep(i, 0, n) cin >> x[i];
   int ans = INF;
   rep(p, 0, 105) {
      int sum = 0;
      rep(i, 0, n) sum += (p - x[i]) * (p - x[i]);
      chmin(ans, sum);
   }
   cout << ans << endl;
   return 0;
}

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

int main(){
  int AH,AA,BH,BA;
  cin >> AH >> AA >> BH >> BA;
  while(AH > 0 && BH > 0){
    BH = BH - AA;
    if(BH<=0)break;
    
    AH = AH - BA;
  }
  
  if(BH<=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

typedef struct Point{long long x,y;}P;
void readpoint(P*p){scanf("%lld%lld",&p->x,&p->y);}
long long crossproduct(P p,P q,P o){return (p.x-o.x)*(q.y-o.y)-(p.y-o.y)*(q.x-o.x);}
long long area(P*p,int n){
	//凸包の点が順に与えられる（向き不問）
	long long s=0;
	for(int i=2;i<n;i++)s+=crossproduct(p[i-1],p[i],p[0]);
	return llabs(s/2);
}

P p[110];
P x[5];
int main(){
	int n;
	while(scanf("%d",&n),n){
		for(int i=0;i<n;i++)readpoint(p+i);
		for(int i=0;i<4;i++)readpoint(x+i);
		long long l=min(x[0].x,x[2].x);
		long long r=max(x[0].x,x[2].x);
		long long d=min(x[0].y,x[2].y);
		long long u=max(x[0].y,x[2].y);
		long long mado=area(p,n);
		for(int i=0;i<n;i++){
			p[i].x=max(l,min(r,p[i].x));
			p[i].y=max(d,min(u,p[i].y));
		}
		printf("%lld\n",mado-area(p,n));
	}
}


Measured memory_bytes: 2132
from collections import defaultdict
good = defaultdict(int)

N, M = list(map(int, input().split(" ")))
height = list(map(int, input().split(" ")))

for m in range(M):
    a, b = list(map(int, input().split(" ")))
    if height[a-1] < height[b-1]:
        good[a] += 1
    elif height[a-1] > height[b-1]:
        good[b] += 1
    else:
        good[a] += 1
        good[b] += 1

print(N-len(good))

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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    if ((n - 2) * ((n - 2) + 1) / 2 < k) {
        cout << -1 << endl;
    } else {
        vector<int> node1, node2;
        if (k == 0) {
            cout << ((n - 1) * n) / 2 << endl;
            for (int i = 0; i < n; ++i) {
                for (int j = i + 1; j < n; ++j) {
                    cout << i + 1 << " " << j + 1 << endl;
                }
            }
            return 0;
        }

        rep(i, n - 1) {
            node1.push_back(n);
            node2.push_back(i + 1);
        }
        int cur = ((n - 2) * ((n - 2) + 1)) / 2;
        for (int i = 2; i < n; ++i) {
            for (int j = 1; j < i; ++j) {
                if (cur == k) {
                    cout << (int)node1.size() << endl;
                    rep(l, (int)node1.size()) {
                        cout << node1[l] << " " << node2[l] << endl;
                    }
                    return 0;
                }
                node1.push_back(i);
                node2.push_back(j);
                --cur;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		
		long takahashi = Math.max(0, a - k);
		long aoki = Math.max(0, b + Math.min(0, a - k));
		
		System.out.printf("%d %d\n", takahashi, aoki);
		sc.close();
	}
}


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

int main() {
  int A,B;
  cin>>A>>B;
  vector <string>vec(A);
  for(int i=0;i<A;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<A;i++){
    cout<<vec.at(i);
  }
  
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
using namespace::std;
int main()
{
  string s;
  cin >> s;
  if(s == "Sunny")
  {
    cout <<"Cloudy"<<endl;
  }
  else if( s== "Cloudy")
  {
    cout<< "Rainy"<<endl;
  }
  else if(s =="Rainy")
  {
	cout<< "Sunny"<<endl;
  }
  return 0;
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(b<a){a=b;return true;}return false;}

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if(n == 1) cout << "Hello World";
    else cout << a + b;
    
    return 0;
}


Measured memory_bytes: 256
/* h-ex9_1
   Ohshima */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 11

//スタックの定義
typedef struct stack{
  int size;
  int count;
  char data[SIZE];
  char *top;
}stack;

//スタックの初期化
void initialize_stack(stack *stk){
  stk->count = 0;
  stk->size = SIZE;
  stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
  if(stk->count >= stk->size){
    fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
    exit(1);
  }else{
    stk->top--;
    *(stk->top) = elem;
    stk->count++;
  }
}

//データの取り出し
void pop(stack *stk){
  if(stk->count <= 0){
    fprintf(stdout, "Error: stack underflow.\n");
    exit(1);
  }else{
    stk->top++;
    stk->count--;
  }
}

int main(void){
  stack stk;
  char tmp;
  int i;
  //スタックを初期化（ポインタ渡しで関数にわたすこと）
  initialize_stack(&stk);
  //1文字ずつ標準入力から受け取り以下を実行
  while(scanf("%c", &tmp) != EOF){
    //B以外の文字のときスタックにデータを追加
    if(tmp != 'B'){
      push(&stk, tmp);
    }else{
      //Bがきた場合、文字列が空でないならデータを取り出す
      if(stk.count > 0){
        pop(&stk);
      }
    }
  }
  //最後に、スタックに残っている文字を古いものから1文字ずつ出力
  for(i = 0; stk.count-- > 0; i++){
    putchar(stk.data[SIZE - 1 - i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 1572
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    if(k==0){
        print(n*n);
        return;
    }
    repi(i,k+1,n+1){
        ans+=n/i*(i-k);
        ans+=max(0ll,n%i-k+1);
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
G=[]
for i in range(2,n+1):
    G.append((1,i))
s=(n-1)*(n-2)//2
if k > s:
    print(-1); exit()
for i in range(2,n):
    for j in range(i+1,n+1):
        if count < s-k:
            G.append((i,j))
            count += 1

print(len(G))
for gi in G:
    print(*gi)





Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int ans=100000;
    for(int t=1;t<n;t++){
        int gr1=0,gr2=0;
        for(int i=0;i<n;i++){
            if(i+1<=t) gr1+=v[i];
            else gr2+=v[i];
        }
        ans=min(ans,abs(gr1-gr2));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n=5;
  ll a[5];
  rep(i,n) R a[i];
  sort(a,a+n);
  ll ans=MAXL;
  do {
    ll sum=0;
    rep(i,n) {
      double t=ceil((double)sum/10)*10;
      sum=t+a[i];
    }
    ans=min(ans,sum);
  } while(next_permutation(a,a+n));
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

template<typename T>
class Segtree_min{
//min
public:
    int n,sz;
    T monoid=inf;
    vector<T> v;

    Segtree_min():n{0},sz{0}{}
    Segtree_min(int n_in):n{n_in},sz{1}{
        while(sz<n) sz*=2;
        v.assign(2*sz-1,monoid);
    }

    void init_u(){
        for(int i=sz-2;i>=0;i--)
        v[i]=min(v[2*i+1],v[2*i+2]);
    }

    void update(int k,const T& a){
        k+=sz-1;
        v[k]=a;
         while(k>0){
            k=(k-1)/2;
            v[k]=min(v[k*2+1],v[k*2+2]);
        }
    }

    //query(a,b,0,0,s.sz);
    T query(int a,int b,int k,int l,int r) const{
        if(r<=a || b<=l) return monoid;
        if(a<=l && r<=b) return v[k];
        T vl=query(a,b,k*2+1,l,(l+r)/2);
        T vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }

    T operator[](const int& idx) const{
        return v[idx+sz-1];
    }
};

int main(){
    int h,w; cin>>h>>w;
    vector<int> a(h,0),b(h,0);
    rep(i,h){
        cin>>a[i]>>b[i];
        a[i]--; b[i]--;
    }
    Segtree_min<int> s{w};
    rep(i,w) s.v[i+s.sz-1]=0;
    s.init_u();
    set<int> st;
    rep(i,w) st.insert(i);
    st.insert(-1); st.insert(inf);
    rep(i,h){
        int l=*st.lower_bound(a[i]);
        int r=*(--st.upper_bound(b[i]));
        if(l<=r){
            if(b[i]!=w-1){
                if(s.v[b[i]+s.sz]==inf){
                    s.update(b[i]+1,s.v[r+s.sz-1]+b[i]+1-r);
                    st.insert(b[i]+1);
                }
            }
            int cur=l;
            while(cur<=r){
                s.update(cur,inf);
                st.erase(cur);
                cur=*st.upper_bound(cur);
            }
        }
        int ans=s.query(0,s.sz,0,0,s.sz)+i+1;
        if(ans>inf) cout<<-1<<endl;
        else cout<<ans<<endl;
    }
}

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

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

const int INF = 1000000007;
const LL INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 1e3 + 7;
int tab[MAX][MAX], dp[MAX][MAX];

int main() {
    _boost;

    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            char a; cin >> a;
            if(a == '.')
                tab[i][j] = 1;
            else
                tab[i][j] = 0;
        }

    dp[0][1] = 1;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(tab[i][j])
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%INF;

    cout << dp[n][m];
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define rep(i,from,to) for(int i=from; i<to; ++i)
#define REP(i,from,to) for(int i=from; i<=to; ++i)
using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> area;
typedef struct answer answer;
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

const int maxn = 110;
int n;
int a[maxn];
void print(int arr[maxn], int n) {
	for (int i = 0; i < n - 1; ++i) {
		cout << arr[i] << " ";
	}
	cout << arr[n - 1] << endl;
}

void bubbleSort(int arr[maxn], int n) {
	int cnt = 0;
	int flag = 1;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j >= 1; j--) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j], arr[j - 1]);
				flag = 1;
				cnt++;
			}
		}
	}
	print(arr, n);
	cout << cnt << endl;
}

void insertionSort(int arr[maxn], int n) {
	print(arr, n);
	REP(i,1,n-1)
	{
		int v = arr[i];
		int j = i - 1;
		while (j >= 0 && arr[j] > v) {
			arr[j + 1] = arr[j];
			j--;
		}
		arr[j + 1] = v;
		print(arr, n);
	}
}

void solve() {
	cin >> n;
	rep(i,0,n)
	{
		cin >> a[i];
	}
	bubbleSort(a, n);
}

int main() {
	solve();
}

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

using namespace std;

#define INF ((1LL<<31)-1)
#define D 10

struct SegTree {
	int segSize, realSegSize, nodeSize;
	vector<int> seg;

	void init(int n) {
		realSegSize = n;

		nodeSize = 0;
		for (segSize = 1; segSize < n; segSize *= D) nodeSize += segSize;

		seg = vector<int>(nodeSize+n, INF);
	}

	int get(int n) {
		if (n < (int)seg.size()) return seg[n];
		else return INF;
	}
	void set(int n, int v) {
		if (n < (int)seg.size()) seg[n] = v;
	}

	void update(int pos, int val) {
		int n = nodeSize + pos;
		set(n, val);
		while (n) {
			n = (n-1)/D;

			int r = INF;
			for (int i = 0; i < D; ++i) {
				r = min(r, seg[n*D+i+1]);
			}
			set(n, r);
		}
	}
	int get(int n, int l, int r, int L, int R) {
//		cout << n << " " << l << " " << r << endl;
		if (L <= l && r <= R) return get(n);
		else if (R <= l || r <= L) return INF;
		else {
			int ret = INF;
			int prev = l;
			for (int i = 0; i < D; ++i) {
				int next = i == D-1 ? r : prev + (r-l)/D;
				ret = min(ret, get(n*D+i+1, prev, next, L, R));
				prev = next;
			}
			return ret;
		}
	}
	int get(int L, int R) {
		return get(0, 0, segSize, L, R);
	}
};

struct Query {
	int y1, x1, y2, x2;
};

int main() {
	int H, W, Q;
	while ( cin >> H >> W >> Q, H || W || Q ) {
		vector< vector<int> > m(H, vector<int>(W, 0));

		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				cin >> m[y][x];
			}
		}

		bool isSegRow = H < W;
		vector<SegTree> seg;

		if (isSegRow) {
			seg.resize(H);
			for (int y = 0; y < H; ++y) {
				seg[y].init(W);
			}
		}
		else {
			seg.resize(W);
			for (int x = 0; x < W; ++x) {
				seg[x].init(H);
			}
		}

		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				if (isSegRow) seg[y].update(x, m[y][x]);
				else seg[x].update(y, m[y][x]);
			}
		}

		for (int t = 0; t < Q; ++t) {
			int y1, x1, y2, x2; cin >> y1 >> x1 >> y2 >> x2;

			int ans = INF;
			if (isSegRow) {
				for (int y = y1; y <= y2; ++y) {
					ans = min(ans, seg[y].get(x1, x2+1));
				}
			}
			else {
				for (int x = x1; x <= x2; ++x) {
					ans = min(ans, seg[x].get(y1, y2+1));
				}
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 64536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}



ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s, t;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	ll x = 0;
	rep(i, s.size()) {
		t = to_string(i % 2);
		if (t[0] == s[i]) ans++;
		else x++;
	}
	cout << min(x, ans) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int l, r, i, j, min=2020, imod=2020, jmod=2020;
	cin >> l >> r;
	for(i = l; i <= (r-l+1>2019?l+2019:r); i++)
	{
		imod = i % 2019;
		for(j = i+1; j <= (r-l+1>2019?l+2019:r); j++)
		{
			jmod = j % 2019;
			min = ((imod*jmod)%2019>min?min:(imod*jmod)%2019);
		}
	}
	cout << min << endl;
}



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

using namespace std;

#define int long long

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(){
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (LL I = 0; I < (N); ++I)
#define REPP(I, A, B) for (LL I = (A); I < (B); ++I)
#define RI(X) scanf("%lld", &(X))
#define RII(X, Y) scanf("%lld%lld", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define DRI(X) LL (X); scanf("%lld", &X)
#define DRII(X, Y) LL X, Y; scanf("%lld%lld", &X, &Y)
#define DRIII(X, Y, Z) LL X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<LL>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef unsigned long long LL;
using namespace std;
LL A[2]={0},a;
int main(){
  DRII(n,k);
  REP(i,n){
    RI(a);
    ++A[a%2];
  }
  if(k==1 && A[1]==0)return 0*puts("0");
  printf("%lld\n",(1ll<<(n-(A[1]!=0))));
}


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

int main(){
	long long int n,y;
	cin >> n >> y;
	
	int res=n*10000-y;
	if(res<0){
		cout<<"-1 -1 -1"<<endl;
		return 0;
	}
	for(int i=0;i<n+1;i++){
		for(int j=0;j<n-i+1;j++){
			if(res==5000*i+9000*j){
				cout<<n-i-j <<" "<<i<<" "<<j<<endl;
				return 0;
			}	
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

bool judge(int a,int b,int c,int d){
	if(a == 1 && b == 3 && c == 2) return true;
	if(b == 1 && c == 3 && d == 2) return true;
	return false;
}

bool f(int a,int b,int c,int d){
	int x[4] = {a,b,c,d};
	if(judge(a,b,c,d)) return true;
	for(int i = 0;i < 3;i++){
		swap(x[i],x[i + 1]);
		if(judge(x[0],x[1],x[2],x[3])) return true;
		swap(x[i],x[i + 1]);
	}
	return false;
}

signed main(){
	int n,dp[110][5][5][5] = {};
	cin >> n;
	dp[0][0][0][0] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < 5;j++){
			for(int k = 0;k < 5;k++){
				for(int l = 0;l < 5;l++){
					for(int m = 1;m < 5;m++){
						if(!f(j,k,l,m)){
							(dp[i][k][l][m] += dp[i - 1][j][k][l]) %= MOD;
						}
					}
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0;i < 5;i++){
		for(int j = 0;j < 5;j++){
			for(int k = 0;k < 5;k++) ans = (ans + dp[n][i][j][k]) % MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int v[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v,v+n,greater<int>());
    double sum=0;
    for(int i=0;i<n-1;i++){
        sum+= (double)(v[i]/pow(2,i+1));
    }
    sum += (double)(v[n-1]/pow(2,n-1));
    
    cout << sum  << endl;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())
xnum = x2-x1
ynum = y2-y1
x3,y3 = x1-ynum,y1+xnum
x4,y4 = x2-ynum,y2+xnum
print(x4,y4,x3,y3)

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
using namespace std;
struct Node
{
    int value;
    char c;
};
void BubbleSort(Node a[],int n)
{
    for(int i=0;i<n-1;i++)
        for(int j=n-1;j>=i+1;j--)
            if(a[j].value<a[j-1].value)
                swap(a[j],a[j-1]);
}
void SelectionSort(Node a[],int n)
{
    for(int i=0;i<n-1;i++)
    {
        int minj=i;
        for(int j=i+1;j<n;j++)
            if(a[j].value<a[minj].value)
                minj=j;
        swap(a[i],a[minj]);
    }
}
/*
bool func(Node temp[],int n)
{
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            {
                if((temp[i].value==temp[j].value)&&(temp[i].c<temp[j].c))
                    return true;
                //else //if((temp[i].value==temp[j].value)&&(temp[i].c>temp[j].c))
                  //  return false;
            }
    return false;
}
*/

/*
void IsStable(Node a[],Node temp[],int n)
{
    for(int i=0;i<n-1;i++)
    {

        if((a[i].value==a[i+1].value)&&((a[i].c<a[i+1].c)==func(temp,n)))
            cout<<"Stable"<<endl;
        else if((a[i].value==a[i+1].value)&&((a[i].c<a[i+1].c)!=func(temp,n)))
            cout<<"Not stable"<<endl;


        if((a[i].value==a[i+1].value)&&((a[i].c<a[i+1].c)!=func(temp,n)))
        {
            cout<<"Not stable"<<endl;
            return ;
        }

    }
    cout<<"Stable"<<endl;
}
*/
void IsStable(Node a[],Node temp[],int n)
{
	int k=0;
	char str[36];
	for(int i=1;i<=9;i++)
		for(int j=0;j<n;j++)
			if(temp[j].value==i)
				{
					str[k]=temp[j].c;
					k++;
				}
	for(int i=0;i<n;i++)
	{
		if(a[i].c!=str[i])
		{
			cout<<"Not stable"<<endl;
			return ;
		}
	}
	cout<<"Stable"<<endl;
}

int main()
{
    int n;
    //scanf("%d",&n);
    cin>>n;
    Node C[n];
    for(int i=0;i<n;i++)
        cin>>C[i].c>>C[i].value;
    Node temp[n];
    for(int i=0;i<n;i++)
        temp[i].c=C[i].c,temp[i].value=C[i].value;
    Node b[n];
    for(int i=0;i<n;i++)
        b[i].c=C[i].c,b[i].value=C[i].value;
    BubbleSort(C,n);
    for(int i=0;i<n-1;i++)
        cout<<C[i].c<<C[i].value<<' ';
    cout<<C[n-1].c<<C[n-1].value<<endl;
    IsStable(C,temp,n);
    SelectionSort(b,n);
    for(int i=0;i<n-1;i++)
        cout<<b[i].c<<b[i].value<<' ';
    cout<<b[n-1].c<<b[n-1].value<<endl;
    IsStable(b,temp,n);
    return 0;
}

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

int main()
{
	int n;
  	cin >> n;
  	string s[n];
  	for (int i=0; i<n; i++)
      cin >> s[i];
  
  	bool four = false;
  
  	for (int i=0; i<n; i++) {
      if (s[i] == "Y") {
        four = true;
        break;
      }
    }
  
  	if (four) cout << "Four" << endl;
  	else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll digit(int n)
{
    int res=0;
    while(n)
    {
        res++;
        n/=10;
    }
    return res;
}
int main()
{
    ll n,minn = 1e18;
    cin>>n;
    for(ll i = 1; i*i <= n; i++)
    {
        if (n%i != 0)
            continue;
        minn = min(minn, max(digit(i), digit(n/i)));
    }
    cout<<minn<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],ans=1,m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    m=a[0];
    for(int i=1;i<n;i++)
    {
        if(m<=a[i])
        {
            ans++;
            m=a[i];
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;
const int N=2e5+100;
int vis[N];
int a[N];
int main()
{
    ll n,m;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int num=0;
    int k=1;
    vector<int>ve;
    int f=0;
    while(1){
        vis[k]++;
        if(vis[k]==2)  ve.push_back(k);
        if(vis[k]==3) {f=1;break;}
         num++;
        k=a[k];
        if(num==m) break;
    }
//    for(auto x:ve) cout<<x<<" ";
//    cout<<endl;
    if(!f) {printf("%d",k);return 0;}
    int pre=num-2*ve.size();
//    cout<<pre<<endl;
    ll xh=(m+1-pre)%ve.size();

    if(xh==0) printf("%d",ve[ve.size()-1]);
    else printf("%d",ve[xh-1]);
    return 0;
}



Measured memory_bytes: 5416
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

int main(void) {
  ll N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  ll i;
  
  if(s[K-1]=='A') s[K-1]='a';
  if(s[K-1]=='B') s[K-1]='b';
  if(s[K-1]=='C') s[K-1]='c';
  
  pt(s);
  
}











Measured memory_bytes: 256
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<"NO"; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll LL_INF=1e10;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
     string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n;
 cin>>n;
 vector<ll>  v(n);
 forn cin>>v[i];
 sort(all(v));
 reverse(all(v));
 int pos=1;
 ll ans=0;
 ans+=v[0];
 int cnt=0;
 for(int i=1;i<n-1;i++)
 {
           ans+=v[pos];
           cnt++;if(cnt==2) 
           {
                     pos++;
                     cnt=0;
           }
 }
 cout<<ans;
 
 
 
 
 
 
 
 
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 4792
/*
B - Row to Column
http://mujin-pc-2017.contest.atcoder.jp/tasks/mujin_pc_2017_b
*/
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N;
	cin >> N;
	string* field = new string[N];
	int* col_fill = new int[N];
	for (size_t i = 0; i < N; i++)
	{
		cin >> field[i];
		col_fill[i] = 0;
	}

	int* count = new int[N];
	for (int i = 0; i < N; i++)
	{
		count[i] = std::count(field[i].begin(), field[i].end(), '#');
		int pos = 0;
		while ((pos = field[i].find('#', pos)) != string::npos)
		{
			col_fill[pos]++;
			pos++;
		}	
	}

	int best;
	int max = -1;
	int filled = 0;
	for (int i = 0; i < N; i++)
	{
		if (count[i] - (col_fill[i] == 0) > max)
		{
			best == i;
			max = count[i] - (col_fill[i] == 0);
		}
		if (col_fill[i] == N)
			filled++;
	}

	if (max > -1)
	{
		int result = N - max + N - filled;
		cout << result;
	}
	else
		cout << -1;

	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int s = scan.nextInt();
        int w = scan.nextInt();
        if(w >= s){
            System.out.println("unsafe");
        }else{
            System.out.println("safe");
        }
    }
}

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

int main() {
	int x,a,b;
	cin>>x>>a>>b;
	
	int da,db;
	da=x-a;
	db=x-b;
	if(da<0)da*=-1;
	if(db<0)db*=-1;
	
	if(da<db)cout<<"A"<<endl;
	else cout<<"B"<<endl;
	return 0;
}

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


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n;
double ans = 0;
int main() {
	cin >> n;
	REP(i, n) {
		double a; string b;  cin >> a >> b;
		ans += a * (b == "JPY" ? 1 : 380000);
	}
	cout << fixed << ans << endl;
}




Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    s = [I() for _ in range(n)]
    t = [0] * 10001
    t[0] = 1
    for c in s:
        for i in range(10000,c-1,-1):
            t[i] += t[i-c]

    for i in range(10000,c-1,-1):
        if i % 10 == 0:
            continue
        if t[i] > 0:
            return i

    return 0


print(main())


Measured memory_bytes: 7880
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();

        for(int i=M/N; i>=1; i--){
            if(M%i==0){
                System.out.println(i);
                return;
            }
        }
    }
}

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

int main(){
  int N,K,x=1;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    if(x>=K){
      x+=K;
      continue;
    }
    x *= 2;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define pb push_back
const int N=100005;

int n,m,ans;
int to[N],D[N];
vector<int> e[N],q;

int main()
{
	
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		e[x].pb(y);
		to[y]++;
	}
	for(int i=1;i<=n;i++)
		if(!to[i]) q.pb(i);
	
	int cnt=0;
	while(cnt<q.size())
	{
		int x=q[cnt++];
		ans=max(ans,D[x]);
		for(int i=0;i<e[x].size();i++)
		{
			int y=e[x][i];
			to[y]--;
			if(!to[y]) q.pb(y);
			D[y]=max(D[y],D[x]+1);
		} 
	}
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 7164
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>



using namespace std;

int main(void) {

	string str;
	cin >> str;
	if (str[1] == 'B') str[1] = 'R';
	else str[1] = 'B';

	cout << str << endl;

	return 0;
}


Measured memory_bytes: 3584
/**
 *    author        : Saurav Paul 
 *    created       : August 24, 2020 11:32 AM
 *    Problem Name  : C - Step
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc176/tasks/abc176_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

using ll = long long int ;

void solve(){
    ll N ;
    cin >> N ;
    vector<ll> v(N) ;
    for(auto &x : v){
        cin >> x;
    }
    ll answer = 0 ;
    ll mx = 0 ;
    for(int i = 0; i < N ; i++){
        answer += max(0LL,mx-v[i]) ;
        mx = max(mx,v[i]) ;
    }
    cout << answer << endl ;

}

int main(){
    ios_base::sync_with_stdio(false);

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        solve();
    }

    return 0 ;
}


Measured memory_bytes: 4788
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

template<typename T>
using vec2 = vector<vector<T>>;
template<typename T>
using vec3 = vec2<vector<T>>;
template<typename T>
using vec4 = vec3<vector<T>>;
template<typename T>
using vec5 = vec4<vector<T>>;
template<typename T>
using vec6 = vec5<vector<T>>;

void factorize(map<ll,ll>& fac, ll a){
    for(ll i = 2;i < ll(sqrt(a)+1);i++){
        while(a % i == 0){
            a /= i;
            fac[i]++;
        }
    }
    if(a > 1)fac[a]++;
}
bool isp(int n){
    for(int a = 2; a < (int)(sqrt(n) + 1);a++){
        if(n % a == 0 && a < n)return false;
    }
    return true;
}
vector<int> primes(int n){
    vector<int> res;
    for(int i = 2;i <= n;i++){
        if(isp(i))res.push_back(i);
    }
    return res;
    
}
int gcd(int a, int b){
    if(b == 0)return a;
    return gcd(b, a%b);
}
int main(){
    int N;cin>>N;
    vector<ll> A;
    int M = 1000010;
    vector<int> B(M, 0);
    for(int i = 0;i  <N;i++){
        int a;cin>>a;
        A.push_back(a);
        B[a]++;
    }
    sort(A.begin(), A.end());
    bool isPair = true;
    vector<int> p = primes(1000000);
    for(int i = 0;i  < p.size();i++){
        int pr = p[i];
        int num = 0;
        for(int j = 1;j * pr < M;j++){
            num += B[j*pr];
            if(num >= 2){
                // cout<<pr<<endl;
                isPair = false;
                break;
            }
        }
        if(!isPair)break;
    }
    int g = A[0];
    for(int i = 0;i < N;i++){
        g = gcd(g, A[i]);
    }
    bool isSet = g == 1;
    // cout<<isSet<<endl;
    // cout<<isPair<<endl;
    if(isSet && !isPair)cout<<"setwise coprime"<<endl;
    else if(isPair)cout<<"pairwise coprime"<<endl;
    else cout<<"not coprime"<<endl;



}

Measured memory_bytes: 15772
L, R = map(int, input().split())
if R - L + 1 == 2:
    print((R * L) % 2019)
    quit()

if R - L + 1 >= 673:
    print(0)
    quit()

for num in range(L, R + 1):
    if num % 673 == 0:
        print(0)
        quit()


ans = 2018
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        amari = (i*j) % 2019
        if amari < ans:
            ans = amari
print(ans)


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

const ll INF = 1001001001;

int main(){
    string s; cin >> s;
    ll k; cin >> k;
    for(int i = 0; i < min((ll)s.size(), k); i++){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const ll maxn = 1e3 + 5;
ll n,a,b,base;
int main()
{
    char a;
    cin >> a;
    cout << (char) (a + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 3e5 + 6;
const int M = 1e9 + 7;
const int inf = 1e17;


// bool J27 = 1;
#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
 

int A[N];
int n,a,b;
int dp[101][N];

int alpha(int i , int k)
{	
	// if(k < 0)return 0;
	if(i == 0 && k == 0)return 1;
	if(i <= 0)return 0;

	int &abstergo = dp[i][k];
	if(abstergo != -1)return abstergo;
	int ans = 0;
	ans += alpha(i-1,k), ans%=M;
	if(k-1 >= 0)ans += alpha(i,k-1),ans%=M;
	if(k-1 >= A[i])ans -= alpha(i-1,k-1-A[i]);
	if( ans < 0 ) ans += M;

	return abstergo = ans;

}

void solve()
{
	cin >> n >> a;

	loop(i,1,n+1)cin >> A[i];

	mset(dp,-1);

	cout << alpha(n,a);
}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);

 	
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}


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

using std::pair;
typedef pair<int, int> pii;
typedef long long ll;
#define fst first
#define snd second
#define mkp std::make_pair

const int MAXN = 2e5+10;

inline int read() {
	int x = 0;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) ;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x;
}

int n, a[MAXN];
ll ans;
pii p[MAXN];

int main() {

	n = read();
	for(int i = 1; i <= n; i++) {
		a[i] = read();
		if(a[i] < i) p[i] = mkp(i-a[i], i-1);
		else {
			printf("-1\n");
			return 0;
		}
	}
	std::sort(p+1, p+n+1);
	int mr = -1;
	for(int i = 2; i <= n; i++) {
		if(p[i].fst != p[i-1].fst) mr = i-1, ans += p[i-1].snd-p[i-1].fst+1;
		if(~mr && p[i].snd < p[mr].snd) {
			printf("-1\n");
			return 0;
		}
	}
	ans += p[n].snd-p[n].fst+1;
	printf("%lld\n", ans);
	return 0;
}


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

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

  if (std::string::npos != S.find("A") && std::string::npos != S.find("B")) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256