akhauriyash/Code-Regression huggingface dataset:
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef unsigned long ul;
const ul INF = 1LL<<60;
ul ans;
int N,i,a;
map<int,int> cnt;
inline void solve(){
  IN(N);
  REP(i,N){
    IN(a);
    cnt[a]++;
  }
  for(map<int,int>::iterator it=cnt.begin();it!=cnt.end();it++){
    if(it->second>it->first)ans+=(it->second-it->first);
    else if(it->second<it->first)ans+=it->second;
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 4736
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        long[] sum = new long[n+1];
        sum[0]=0;
        for (int i=0;i<n;i++)a[i]=sc.nextInt();
        Arrays.sort(a);
        for (int i=0;i<n;i++)sum[i+1]= sum[i]+a[i];
        int maxF = 0;
        for (int i=0;i<n;i++){
            if(sum[i]*2<a[i]){
                maxF=i;
            }
        }
        System.out.println(n-maxF);
    }
}


Measured memory_bytes: 61252
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,L,R,a[100100],ans1,ans2,cnt1,cnt2;
bool cmp(int a,int b){return a>b;}
int C[55][55];
void init(){
	C[0][0]=1;
	for(int i=1;i<=50;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
		C[i][j]=C[i-1][j]+C[i-1][j-1];
	}
//	for(int i=0;i<=10;i++,puts(""))
//	for(int j=0;j<=i;j++) cout<<C[i][j]<<" ";
}
signed main(){
	init();
	cin>>n>>L>>R;
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=L;i++) ans1+=a[i];
	for(int i=1;i<=n;i++) if(a[i]==a[L]) cnt1++;
	for(int i=1;i<=L;i++) if(a[i]==a[L]) cnt2++;
	if(a[1]==a[L])
		for(int i=L;i<=R;i++) ans2+=C[cnt1][i];
	else ans2=C[cnt1][cnt2];
	printf("%lf\n%lld",(double)ans1/L,ans2);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
int main(){
    int a[3];
    int b[3];
    for(int i = 0;i < 3;i++){
        std::cin >> a[i];
    }
    b[0] = std::max(a[0],std::max(a[1],a[2]));
    b[2] = std::min(a[0],std::min(a[1],a[2]));
    b[1] = a[0]+a[1]+a[2] - b[0] - b[2];
    if(b[0] == (b[1]+b[2])){
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    

}

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (a == 0 && b == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll s = n / (a + b);
    cout << a * s + min(a, n % (a + b)) << endl;
}


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

std::string S;

bool parse(size_t i) {
    if (i == S.size()) {
        return true;
    }

    if ((i + 4) >= S.size()) {
        return false;
    }

    const std::string five = S.substr(i, 5);
    if (five == "dream") {
        if ((i+6) < S.size() && S[i+5] == 'e' && S[i+6] == 'r') {
            if (parse(i + 7) == true) {
                return true;
            } else {
                return parse(i + 5);
            }
        } else {
            return parse(i + 5);
        }
    } else if (five == "erase") {
        if ((i+5) < S.size() && S[i+5] == 'r') {
            return parse(i + 6);
        } else {
            return parse(i + 5);
        }
    } else {
        return false;
    }
}

int main() {
    std::cin >> S;

    if (parse(0)) {
        std::cout << "YES\n";
    } else {
        std::cout << "NO\n";
    }

    return 0;
}


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

int n,m;
double P[16][16];
double dp[1<<16][17];

int main(){
    cin >> m >> n;
    rep(i,m)rep(j,n) cin >> P[i][j];
    rep(S,1<<m)rep(i,n+1) dp[S][n] = (S > 0 && i == n) ? 1 : 0;
 
    for(int u = n-1; u >= 0; --u){
        rep(S,1<<m){
            rep(i,m){
                if(S>>i&1){
                    double p = 1, q = 0;
                    for(int v = u; v < n; ++v){
                        q += dp[S^(1<<i)][v] * p * (1-P[i][v]);
                        p *= P[i][v];
                    }
                    q += dp[S][n] * p;
                    dp[S][u] = max(dp[S][u], q);
                }
            }
        }
    }
    double ans = dp[(1<<m)-1][0];
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 11988
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

int main() {
    std::string s;
    std::vector<char> v;

    std::cin >> s;

    for(int i=0;i<s.size();i++){
        if(s[i] == 'B'){
            if(v.size()) v.pop_back();
        } else {
            v.push_back(s[i]);
        }
    }

    for(int i=0;i<v.size();i++){
         std::cout << v[i];
    }

    std::cout << std::endl;
}

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

using namespace std;

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

    int r = 0;

    char last = 0;
    for(int i = 0; i < S.size(); i++ ) {
        if(S[i] == last) {
            i++;
            r++;
            last = 0;
            continue;
        }

        if(i == S.size() - 2 && S[i] == S[i+1]) {
            r++;
            break;
        }


        r++;
        last = S[i];
    }

    cout << r << endl;
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> X(N);
  
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    X.at(a-1) = i+1;
  }

  for (int i = 0; i < N-1; i++) {
    cout << X.at(i) << " " ;
  }
 cout << X.at(N-1) << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> cnt(n, 0);


    FOR(i,1,n){
        cin >> a[i];
        a[i]--;
        cnt[a[i]]++;
    }

    REP(i,n){
        cout << cnt[i] << endl;
    }

    return 0;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<int>> edges(10010);
vector<int> c,ans;
int j = 0;

void dfs(int i,int p = -1) {
    for (int& k : edges[i]) if (k != p) dfs(k,i);
    ans[i] = c[j];
    j++;
}

int main() {
    int n;
    cin >> n;
    c.resize(n);
    ans.resize(n);
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    for (int i = 0;i < n;++i) cin >> c[i];
    sort(c.begin(),c.end());
    int sum = 0;
    for (int i = 0;i < n-1;++i) sum += c[i];
    dfs(0);
    cout << sum << endl;
    for (int i = 0;i < n;++i) cout << ans[i] << " \n"[i == n-1];
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
using namespace std;
#define MAX 100005
#define ALPHA 26
vector<int> Graph[MAX];
int parent[MAX];
void bfs(int root,int n)
{
    int i,j,node;
    for(i=1;i<=n;i++)
    {
        parent[i]=-1;
    }
    queue<int> Nodes;
    parent[root]=0;
    Nodes.push(root);
    while(!Nodes.empty())
    {
        node=Nodes.front();
        Nodes.pop();
        for(i=0;i<Graph[node].size();i++)
        {
            if(parent[Graph[node][i]]!=-1) continue;
            parent[Graph[node][i]]=node;
            Nodes.push(Graph[node][i]);
        }
    }
}
int main()
{
    int N,M,i,j,u,v;
    scanf("%d %d",&N,&M);
    for(i=0;i<M;i++)
    {
        scanf("%d %d",&u,&v);
        Graph[u].push_back(v);
        Graph[v].push_back(u);
    }
    bfs(1,N);
    for(i=2;i<=N;i++)
    {
        if(parent[i]==-1)
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    for(i=2;i<=N;i++)
    {
        printf("\n%d",parent[i]);
    }
    return 0;
}


Measured memory_bytes: 10552
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
#include<set>
#include<queue>
#include<list>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	list<int> s;
	list<int>::iterator it, endit;
	int n; cin >> n;
	pair<string, int> p;
	string str;
	for (int i = 0; i < n; i++) {
		cin >> str;
		if (str != "deleteFirst"&&str!="deleteLast") {
			cin >> p.second; p.first = str;
			if (p.first == "insert")s.push_front(p.second);
			else if (p.first == "delete") {
				it = s.begin(), endit = s.end();
				for (; it != endit; ++it) {
					if (*it == p.second) {
						s.erase(it);
						break;
					}
				}

			}
		}
		else if (str == "deleteFirst") {
			s.pop_front();
		}else s.pop_back();			
	}
	cout << s.front(); s.pop_front();
	for (; !s.empty();) {
		cout << " " << s.front();
		s.pop_front();
	}
	cout << endl;
}

Measured memory_bytes: 32484
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    auto T = sread();
    auto f = new char[](100);
    auto g = new char[](100);
    foreach (i; 0 .. S.length)
    {
        if (f[S[i] - 'a'] == char.init && g[T[i] - 'a'] == char.init)
        {
            f[S[i] - 'a'] = T[i];
            g[T[i] - 'a'] = S[i];
            continue;
        }
        if (f[S[i] - 'a'] != T[i] || g[T[i] - 'a'] != S[i])
        {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}


Measured memory_bytes: 2744
D = int(input())
C = list(map(int,input().split())) #C[i]AiCを実施しないと下がる満足度
S = [] #S[i][j] i日目にAjcというコンテストを実施した場合に上がる満足度
for i in range(D): #コンテストは0index
    temp = list(map(int,input().split()))
    S.append(temp)
T = []
for i in range(D):
    temp = int(input())
    T.append(temp)
since = [0 for _ in range(26)] #最後に開催されてから何日経ったか。
manzoku = 0
for i in range(26):
    since[i] += C[i]
for i in range(D):
    contest = T[i]-1 #0index
    manzoku += S[i][contest]
    for j in range(26):
        if j != contest:
            manzoku -= since[j]
    print(manzoku)
    for j in range(26):
        if j != contest:
            since[j] += C[j]
        else:
            since[j] = C[j]    

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

long long int MOD=1000000007;

long long int gamma[100001];

long long int inv(long long int t){//逆元
	long long int t2[36];
	t2[0]=1;t2[1]=t;
	for(int i=2;i<36;i++){
		t2[i]=(t2[i-1]*t2[i-1])%MOD;
	}
	long long int ans=1;
	long long int s=MOD-2;
	int i=1;
	while(s>0){
		if(s%2==1){ans=(ans*t2[i])%MOD;}
		s=s/2;i++;
	}
  return ans;
}

long long int C(long long int a,long long int b){//combination
  if(a==b or b==0){return 1;}
	long long int ans=gamma[a];
	ans=(ans*inv(gamma[b]))%MOD;
	ans=(ans*inv(gamma[a-b]))%MOD;
	return ans;
}

long long int gcd(long long int a,long long int b){
	while(a!=b){
		if(b>a){swap(a,b);}
		a=a-b;
	}
	return a;
}

int main(){
	int n;cin>>n;
	int a[300000];
	int count=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==count+1){count++;}
	}
	if(count!=0){cout<<n-count;}
	else{cout<<-1;}
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 1<<20+1
bool HA[L];
char T[256];

int main() {
    U n, s, t;
    char c;
    T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    for ( register U i = 0; i++ < n; ) {
        s = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            s += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[s] = true;
        } else {
            puts( HA[s] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 2096
#include <vector>
#include <cstdio>
#include <algorithm>

namespace
{
	std::vector<unsigned int> altitude(10);
}

int main()
{
	for (unsigned int i = 0; i < 10; i++)
	{
		std::scanf("%u", &altitude[i]);
	}
	std::sort(altitude.begin(), altitude.end(), std::greater<unsigned int>());
	for (unsigned int i = 0; i < 3; i++)
	{
		std::printf("%u\n", altitude[i]);
	}
	return 0;
}


Measured memory_bytes: 2760
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

class Edge
{
public:
	int src,dst,cst;
	Edge(int src, int dst, int cst)
	:src(src),dst(dst),cst(cst)
	{}
};

class State
{
public:
	int p,c,d;
	State(int p, int c, int d)
	:p(p),c(c),d(d)
	{}
	
	bool operator<(const State& s) const {
		if(c != s.c) return c > s.c;

		return d > s.d;
	}
};

typedef vector<vector<Edge> > Graph;

int N,M,C,S,G;
int COST[10001][20];
int P[20], Q[20][51], R[20][51];
int ct[100][100][20];

int dijkstra(int Start, int Goal, int com, Graph& graph)
{
	priority_queue<State> q;
	q.push(State(Start, 0, 0));

	bool vis[100] = {0};
	while(!q.empty()) {
		State s=q.top(); q.pop();
		if(vis[s.p]) continue;
		vis[s.p] = 1;

		if(s.p == Goal) return s.c;

		for(int i=0; i<graph[s.p].size(); i++) {
			Edge& e = graph[s.p][i];

			int td = s.d + e.cst;
			int nc = 0;
			if(td > Q[com][P[com] - 1]) {
				nc = COST[Q[com][P[com] - 1]][com] + abs(td - Q[com][P[com]-1]) * R[com][P[com]-1];
			}
			else nc = COST[td][com];

			if(vis[e.dst]) continue;
			q.push(State(e.dst, nc, td));
		} 
	}

	return -1;
}

int solve(int Start, int Goal, Graph& graph)
{
	priority_queue<State> q;
	q.push(State(Start, 0, 0));

	bool vis[100] = {0};
	while(!q.empty()) {
		State s=q.top(); q.pop();
		if(vis[s.p]) continue;
		vis[s.p] = 1;

		if(s.p == Goal) return s.c;

		for(int i=0; i<graph[s.p].size(); i++) {
			Edge& e = graph[s.p][i];

			if(vis[e.dst]) continue;
			q.push(State(e.dst, s.c + e.cst, 0));
		}
	}

	return -1;
}

int main()
{
	while(cin >> N >> M >> C >> S >> G, (N||M||C||S||G)) {
		S--; G--;

		vector<Graph> graph(C);
		for(int i=0; i<C; i++)
			graph[i].resize(N);

		for(int i=0; i<M; i++) {
			int a,b,c,d;
			cin >> a >> b >> d >> c;
			a--; b--; c--;

			graph[c][a].push_back(Edge(a,b,d));
			graph[c][b].push_back(Edge(b,a,d));
		}

		for(int i=0; i<C; i++)
			cin >> P[i];

		for(int i=0; i<C; i++) {
			Q[i][0] = 0;

			for(int j=1; j<P[i]; j++)
				cin >> Q[i][j];
			
			for(int j=0; j<P[i]; j++)
				cin >> R[i][j];
		}

		for(int i=0; i<C; i++)
			COST[0][i] = 0;

		for(int i=0; i<C; i++)
		for(int j=1; j<P[i]; j++)
		for(int k=Q[i][j-1]+1; k<=Q[i][j]; k++) 
			COST[k][i] = COST[k-1][i] + R[i][j - 1];

		for(int k=0; k<C; k++)
		for(int i=0; i<N; i++)
		for(int j=i+1; j<N; j++) {
			ct[i][j][k] = ct[j][i][k] = dijkstra(i, j, k, graph[k]);
		}


		Graph final(N);
		for(int i=0; i<N; i++)
		for(int j=i+1; j<N; j++) {
			int mmm = (1<<28);
			for(int k=0; k<C; k++) {
				if(ct[i][j][k] == -1) continue;
				mmm = min(mmm, ct[i][j][k]);
			}

			if(mmm == (1<<28)) continue;
			final[i].push_back(Edge(i,j,mmm));
			final[j].push_back(Edge(j,i,mmm));
		}

		cout <<  solve(S, G, final) << endl;
	}
	
}

Measured memory_bytes: 2888
num_digit, num_cond = map(int, input().split())
d = {}
for _ in range(num_cond):
    digit, val = map(int, input().split())
    if (digit in d and d[digit] != val) or (num_digit != 1 and digit == 1 and val == 0):
        print(-1)
        exit()
    d[digit] = val
if num_digit == 1:
    print(d.get(1, 0))
if num_digit == 2:
    print(str((d.get(1, 1))) + str(d.get(2, 0)))
if num_digit == 3:
    print(str((d.get(1, 1))) + str(d.get(2, 0)) + str(d.get(3, 0)))

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

int main()
{
    string s, t; cin>>s>>t;
    int n=s.size();
    array<int, 128> a={}, b={};
    bool ok=true;
    for(int i=0; i<n; ++i) {
        int c=s[i], d=t[i];
        if (!a[c]) {
            a[c]=d;
        }
        else if (a[c]!=d) {
            ok=false;
        }
        if (!b[d]) {
            b[d]=c;
        }
        else if (b[d]!=c) {
            ok=false;
        }
    }
    cout<<(ok ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 776
// -*- coding:utf-8-unix -*-

use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
use std::convert::TryInto;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//abc128-C

#[fastout]
fn main() {
    // input!
    //     input! {
    //         n: u8,
    //         m: u8,
    //         sk: [[u8]; n],
    //         ps: [u8; m]
    //     }

    //     println!(
    //         r#"
    // n: {},
    // m: {},
    // sk: {:?},
    // ps: {:?}
    //         "#,
    //         n, m, sk, ps
    //     );

    // read
    // let n: usize = read();
    // let m: usize = read();
    // let mut s: Vec<Vec<usize>> = vec![vec![]; m];
    // let mut p: Vec<usize> = vec![];

    // for i in 0..m {
    //     let k = read();
    //     for _ in 0..k {
    //         s[i].push(read());
    //     }
    // }

    // for _ in 0..m {
    //     p.push(read());
    // }
    // let mut ans = 0;

    input![s: String,];

    let mut ans = vec![0; s.len()];

    //rlを探す
    let mut rl_idx = Vec::new();
    let mut previous_s = 'A';
    for (idx, s) in s.chars().enumerate() {
        if previous_s == 'R' && s == 'L' {
            rl_idx.push(idx - 1);
        }

        previous_s = s;
    }

    eprintln!("{:?}", rl_idx);

    //rlまでの距離をはかって、どちらかに足す
    for (idx, r_or_l) in s.chars().enumerate() {
        if idx == 0 {
            if &s[0..2] == "RL" {
                ans[0] += 1;
            } else {
                //Rまでの距離を図る
                let r_idx = rl_idx[rl_idx.upper_bound(&(idx))];
                eprintln!("R:{}, {}", idx, r_idx);
                let len = r_idx - idx;

                if len % 2 == 0 {
                    ans[r_idx] += 1;
                } else {
                    ans[r_idx + 1] += 1;
                }
            }
            continue;
        }
        if r_or_l == 'R' {
            //Rまでの距離を図る
            let r_idx = rl_idx[rl_idx.upper_bound(&(idx - 1))];
            eprintln!("R:{}, {}", idx, r_idx);
            let len = r_idx - idx;

            if len % 2 == 0 {
                ans[r_idx] += 1;
            } else {
                ans[r_idx + 1] += 1;
            }
        } else {
            //Lまでの距離を図る
            let l_idx = rl_idx[rl_idx.lower_bound(&idx) - 1];
            eprintln!("L:{}, {}", idx, l_idx);
            let len = (idx + 1) - l_idx;

            if len % 2 == 0 {
                ans[l_idx + 1] += 1;
            } else {
                ans[l_idx] += 1;
            }
        }
    }

    print!("{} ", ans[0]);

    for ans in &ans[1..] {
        print!("{} ", ans);
    }
}


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

// ワーシャル・フロイド法
// 負の辺があっても動作する。

//#define UNDIRECTED // 無向グラフ

constexpr int MAX_V = 100;
constexpr int MAX_D = 2e7;
constexpr int INF = MAX_D * MAX_V + 7; // D * V より大きい値

int V;
int dp[MAX_V][MAX_V];

void initialize() {
  fill_n(&dp[0][0], MAX_V * MAX_V, INF);
  for (int i{}; i < MAX_V; ++i) dp[i][i] = 0;
}

bool warshall_floyd() {
  for (int k{}; k < V; ++k) {
    for (int i{}; i < V; ++i) {
      for (int j{}; j < V; ++j) {
        if (dp[i][k] != INF && dp[k][j] != INF) {
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
        }
      }
      if (dp[i][i] < 0) {
        return false;
      }
    }
  }

  return true;
}

int main() {
  initialize();

  int E;
  cin >> V >> E;
  for (int i{}; i < E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    dp[s][t] = d;
#ifdef UNDIRECTED
    dp[t][s] = d;
#endif
  }

  if (!warshall_floyd()) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }

  for (int i{}; i < V; ++i) {
    for (int j{}; j < V; ++j) {
      cout << (j > 0 ? " " : "") << (dp[i][j] < INF ? to_string(dp[i][j]) : "INF");
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3320
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int gcd(int p,int q){for(int t;q;)t=p%q,p=q,q=t;return p;}

int a[1010];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int d=gcd(n,k);
	int ans=0;
	for(int l=0;l<n;l+=d){
		int m=1e3,M=0;
		for(int i=0;i<k;i++){
			m=min(m,a[(l+i)%n]);
			M=max(M,a[(l+i)%n]);
		}
		ans+=M-m;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2144
# -*- coding:utf-8 -*-
import sys
input = sys.stdin.readline
n, d = map(int, input().split())
count = 0
for i in range(n):
  x, y = map(int, input().split())
  if (x**2+y**2)**0.5 <= d:
    count += 1
  else:
    continue
print(count)

Measured memory_bytes: 9632
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 gcd(a,b):
    while b>0:
        a,b = b,a
        b %= a
    return a

def main():
    n,m = LI()
    a = [LI() for _ in range(n)]
    ai = [0] * n
    d = collections.defaultdict(int)
    for i in range(n):
        d[a[i][0]] += 1
    dr = r = max(d.values())
    s = set(list(range(1,m+1)))
    while s:
        for k,v in d.items():
            if v == dr:
                s.remove(k)
        if not s:
            break
        d = collections.defaultdict(int)
        for i in range(n):
            while a[i][ai[i]] not in s:
                ai[i] += 1
        for i in range(n):
            d[a[i][ai[i]]] += 1
        dr = max(d.values())
        if r > dr:
            r = dr
    return r


print(main())





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

int main() {
  int N, X, donuts[100], sum = 0, min_donut = 1000;
  cin >> N >> X;

  for (int i = 0; i < N; i++) {
    cin >> donuts[i];
    sum += donuts[i];
    if (donuts[i] < min_donut) min_donut = donuts[i];
  }

  cout << (N + (X - sum) / min_donut) << endl;
}

Measured memory_bytes: 3584
import itertools
"""
n = 1
while n**5 < 10**9:
  n += 1
print(n)
# 64
"""
X = int(input())

for a in range(128):
    for b in range(-128,128):
        if a ** 5 - b ** 5 == X:
            print(a, b)
            exit()

Measured memory_bytes: 9188
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer, Set<Element>> map = new HashMap<>(); // map: 県 -> Set of 市
        Map<Integer, Element> answerMap = new HashMap<>(); // 回答出力用のMap
        for (int i = 0; i < m; i++) {
            int p = sc.nextInt();
            int y = sc.nextInt();
            Element element = new Element(p, y, i);
            if (!map.keySet().contains(p)) {
                map.put(p, new TreeSet<>());
            }
            map.get(p).add(element);
            answerMap.put(i, element);
        }
        sc.close();

        // 県ごとのカウンターをインクリメントしながら、認識番号を割り振り
        for (Integer p : map.keySet()) {
            int counter = 1;
            for (Element e : map.get(p)) {
                e.id = String.format("%06d%06d", e.p, counter);
                counter++;
            }
        }

        // 識別番号を出力
        for (int i = 0; i < m; i++) {
            System.out.println(answerMap.get(i).id);
        }
    }

    static class Element implements Comparable<Element> {
        int p;
        int y;
        int no;
        String id;

        Element(int p, int y, int no) {
            this.p = p;
            this.y = y;
            this.no = no;
        }

        @Override
        public String toString() {
            return "(p=" + p + ", y=" + y + ", no=" + no + ", id=" + id + ")";
        }

        @Override
        public int compareTo(Element o) {
            return y - o.y;
        }
    }

}


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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> dp(n,vector<int>(3));
  for(int i=0;i<3;i++) cin >> dp[0][i];
  
  for(int i=1;i<n;i++){
    int a,b,c;
    cin >> a >> b >> c;
    dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b+max(dp[i-1][2],dp[i-1][0]);
    dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
  }
  
  cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
  
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
static const int INF = 1000010000;
//static const int NIL = -1;
//static const int MOD = 1000000007;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
//#define int ll

signed main(){
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<3;i++){
        if(s[i]=='1') ans ++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 768
N=int(input())
tlist=list(map(int,input().split()))
vlist=list(map(int,input().split()))

def const(l,r,v,t):
  if t<l:
    return v+(l-t)
  elif r<t:
    return v+(t-r)
  else:
    return v
  
const_list=[(0,0,0)]
tsum=0
for i in range(N):
  l=tsum
  r=tsum+tlist[i]
  v=vlist[i]
  const_list.append((l,r,v))
  tsum+=tlist[i]
const_list.append((tsum,tsum,0))
#print(const_list)

answer=0
t=0
while(t<tsum):
  s1=s2=10**9
  for con in const_list:
    l,r,v=con
    s1=min(s1,const(l,r,v,t))
    s2=min(s2,const(l,r,v,t+0.5))
  #print(s1,s2)
    
  answer+=(s1+s2)*0.5/2
  t+=0.5
  
print(answer)

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

int main() {
    string o, g, pass;
    cin >> o >> g;
    for(int i = 0; i < o.size(); i++) {
        pass += o[i];
        if(i != g.size()) pass += g[i];
    }
    cout << pass << endl;
    return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int,input().split())

#まず間の角度を求める
x = h*30+m/2
y = m*6
kakudo = max(x,y)-min(x,y)
kakudo = min(kakudo,360-kakudo)

ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo)))**0.5

print(ans)

Measured memory_bytes: 9508
def partition(arr, p, r)
  x = arr[r]
  i = p-1
  p.upto(r-1) { |j|
    if arr[j] <= x
      i += 1
      exchange(arr, i, j)
    end
  }
  exchange(arr, i+1, r)
  return i+1
end

def exchange(arr, i, j)
  buf = arr[i]
  arr[i] = arr[j]
  arr[j] = buf
end

n = gets.to_i
arr = gets.chomp.split.map(&:to_i)
idx = partition(arr, 0, arr.size-1)

puts arr.map.with_index { |x, i| (i == idx) ? "[#{x}]" : x }.join(' ')

Measured memory_bytes: 18376
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int W = scanner.nextInt();
        String[] a = new String[H];
        for (int i = 0; i < H; i++) {
            a[i] = scanner.next();
        }
        for (int h = 0; h < H + 2; h++) {
            if (h == 0 || h == H + 1) {
                for (int w = 0; w < W + 2; w++) {
                    System.out.print("#");
                }
                System.out.print("\n");
                continue;
            }
            System.out.print("#");
            System.out.print(a[h - 1]);
            System.out.print("#\n");
        }
    }
}


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

using namespace std;
int n,m,k,i,j,x,y,a[200005],st=1,dr,mij,sol;
bool verif(int x)
{
    int nr=0;
    for(i=1;i<=n;i++)
        if(a[i]>x)
            nr+=((a[i]-1)/x);
    return nr<=k;

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            dr=max(dr,a[i]);
        }
    while(st<=dr)
    {
        mij=(st+dr)>>1;
        if(verif(mij)){
            sol=mij;
            dr=mij-1;
        }
        else st=mij+1;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
typedef long long lint;

int main() {
    int N;
    cin >> N;
    vector<int> A(3*N);
    for (int i = 0; i < 3*N; i++) {
        cin >> A[i];
    }
    vector<lint> former(3*N), latter(3*N);
    // former
    {
        priority_queue<int, vector<int>, greater<int> > que;
        lint sum = 0;
        for (int i = 0; i < N; i++) {
            sum += A[i];
            que.push(A[i]);
        }
        for (int i = N; i <= 2*N; i++) {
            former[i-1] = sum;
            int top = que.top();
            if (top < A[i]) {
                que.pop();
                que.push(A[i]);
                sum += A[i] - top;
            }
        }
    }
    // latter
    {
        priority_queue<int> que;
        lint sum = 0;
        for (int i = 3*N-1; i >= 2*N; i--) {
            sum += A[i];
            que.push(A[i]);
        }
        for (int i = 2*N-1; i >= N-1; i--) {
            latter[i+1] = sum;
            int top = que.top();
            if (top > A[i]) {
                que.pop();
                que.push(A[i]);
                sum += A[i] - top;
            }
        }
    }
    lint ans = -1e18;
    for (int i = N-1; i < 2*N; i++) {
        ans = max(ans, former[i] - latter[i+1]);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char s[1001];
  scanf("%s",s);
  int w;
  scanf("%d",&w);
  int len=0;
  while(s[len]!='\0') len++;
  int i;
  for(i=0;i<len;i+=w) printf("%c",s[i]);
  printf("\n");
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
import numpy as np

N = int(input())
T,A = np.array(list(map(int,input().split())))
H = np.array(list(map(int,input().split())))

ave = T-H*0.006
dif = abs(ave - A)

print(np.where(min(dif) == dif)[0][0]+1)


Measured memory_bytes: 12508
#include <cstdio>
#include <cstring>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
const int p=998244353;
int n,m,cnt,f[10010][10010],fac[10010],inv[10010],ans;
char a[10100],b[10100];

int c(int n,int m)
{
    return LL(fac[n])*inv[m]%p*inv[n-m]%p;
}

int main()
{
    scanf("%s%s",a+1,b+1),n=strlen(a+1);
    repu(i,1,n)
        if (a[i]=='1')
            cnt+=b[i]=='0',++m;
    fac[0]=fac[1]=inv[0]=inv[1]=1;
    repu(i,2,m)
        inv[i]=LL(p-p/i)*inv[p%i]%p;
    repu(i,2,m)
        fac[i]=LL(fac[i-1])*i%p,inv[i]=LL(inv[i-1])*inv[i]%p;
    f[0][cnt]=1;
    repu(i,0,m)
    {
        repu(j,1,m-i)
            if (f[i][j])
            {
                f[i+1][j]=(f[i+1][j]+LL(m-i-j)*j*f[i][j])%p;
                f[i+1][j-1]=(f[i+1][j-1]+LL(j)*j*f[i][j])%p;
            }
        ans=(ans+LL(f[i][0])*c(m,i)%p*fac[m-i]%p*fac[m-i])%p;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 389632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int h,w;
  cin>>h>>w;
  char s[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cin>>s[i][j];
  }
    
  int dp[h][w]={0};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
          if(j==0&&i==0) dp[0][0]=1;
          else if(j==0){
            if(s[i-1][j]=='.') dp[i][j]=dp[i-1][j]+1;
            else dp[i][j]=dp[i-1][j];
          }
          else if(i==0){
            if(s[i][j-1]=='.') dp[i][j]=dp[i][j-1]+1;
            else dp[i][j]=dp[i][j-1];
          }
          else{
            if(s[i-1][j]=='.'&&s[i][j-1]=='.') dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1);
            else if(s[i-1][j]=='.'&&s[i][j-1]!='.') dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]);
            else if(s[i-1][j]!='.'&&s[i][j-1]=='.') dp[i][j]=min(dp[i-1][j],dp[i][j-1]+1);
            else dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
          }
        }
      else{
          if(j==0&&i==0) dp[0][0]=0;
          else if(j==0){
            if(s[i-1][j]=='#') dp[i][j]=dp[i-1][j]+1;
            else dp[i][j]=dp[i-1][j];
          }
          else if(i==0){
           if(s[i][j-1]=='#') dp[i][j]=dp[i][j-1]+1;
           else dp[i][j]=dp[i][j-1];
          }
          else{
           if(s[i-1][j]=='#'&&s[i][j-1]=='#') dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1);
           else if(s[i-1][j]=='#'&&s[i][j-1]!='#') dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]);
           else if(s[i-1][j]!='#'&&s[i][j-1]=='#') dp[i][j]=min(dp[i-1][j],dp[i][j-1]+1);
           else dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
          }
        }
    }
  }
  
    cout<<(dp[h-1][w-1]+1)/2<<endl;
    
  }

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > vc(N-1, 0LL);
  std::vector< ll > vs(N-1, 0LL);
  std::vector< ll > vf(N-1, 0LL);
  for (ll i = 0; i < N-1; i++) {
    std::cin >> vc[i] >> vs[i] >> vf[i];
  }

  for (ll q = 0; q <= N-1; q++) {
    ll time = 0;
    for (ll i = q; i < N-1; i++) {
      ll ride_time = std::max(time, vs[i]);
      if (time > vs[i]) {
	ride_time = ((time - vs[i] + vf[i] - 1) / vf[i]) * vf[i] + vs[i];
      }
      time = ride_time + vc[i];
    }
    print(time);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int32 = int_fast32_t;
using int64 = int_fast64_t;

#define INF (int32)1e9
#define INF_LL (int64)1e18
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define RANGE(i, a, b) for(int64 i = a; i < b; i++)

int main() {
  int32 n, m, k;
  cin >> n >> m >> k;
  int64 a[n+1], b[m+1];
  a[0] = 0;
  b[0] = 0;
  REP(i, n) cin >> a[i+1];
  REP(i, m) cin >> b[i+1];
  REP(i, n) a[i+1] += a[i];
  REP(i, m) b[i+1] += b[i];
  int32 ia = 0, ib = m;
  int32 book = 0;
  while (ia <= n) {
    while (ib > 0 && a[ia] + b[ib] > k) {
      ib--;
    }
    if (a[ia] + b[ib] <= k) {
      book = max(book, ia + ib);
    }
    ia++;
  }
  cout << book << endl;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

vector<ll> findDivisor(ll n) {
	vector<ll> divisor;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			divisor.push_back(i);
			if (i * i != n) divisor.push_back(n / i);
		}
	}
	return divisor;
}

int main() {
	
	int N, M;
	cin >> N >> M;
	vector<ll> div = findDivisor(M);
	
	int ans = 1;
	REP(i, div.size()) if (M / div[i] >= N) chmax(ans, div[i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ary = Array.new()
ans = Array.new()
while n > 0  do
    tmp = n % 26
    if tmp > 0
        ary <<  tmp
        n /= 26
    else
        ary << 26
        n = n / 26 - 1
    end
end

ary = ary.reverse

ary.each do |x|
    ans << (x + 96).chr
end

puts ans.join()

Measured memory_bytes: 14336
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    if n%2==1:
        print(0)
    else:
        m=n//2
        ans=0
        for i in range(1,30):
            ans+=m//(5**i)
        print(ans)

 
if __name__=='__main__':
    main()

Measured memory_bytes: 9120
# -*- coding: utf-8 -*-

import sys
from math import hypot, sin, atan2, degrees, radians

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def add(a, b):
    x1, y1 = a
    x2, y2 = b
    return (x1+x2, y1+y2)

def sub(a, b):
    x1, y1 = a
    x2, y2 = b
    return (x1-x2, y1-y2)

def mul(a, b):
    x1, y1 = a
    if isinstance(b, tuple):
        x2, y2 = b
    else:
        x2, y2 = b, b
    return (x1*x2, y1*y2)

def div(a, b):
    x1, y1 = a
    if isinstance(b, tuple):
        x2, y2 = b
    else:
        x2, y2 = b, b
    return (x1/x2, y1/y2)

def get_dig(a, b, c):
    # aから見たb,cへ向かうベクトル
    v1 = sub(b, a)
    x1, y1 = v1
    v2 = sub(c, a)
    x2, y2 = v2
    # atan2がx=0から見た角度を返すので、差分を取る
    res = degrees(atan2(y2, x2) - atan2(y1, x1))
    # 今回は向き関係なく小さい方の角度が欲しい
    res = abs(res)
    if res >= 180:
        res = 360 - res 
    return res

def get_dist(a, b):
    x1, y1 = a
    x2, y2 = b
    return hypot(x1-x2, y1-y2)

# 3点から外接円の中心(外心)を求める
def calc(a, b, c):
    dig1 = get_dig(a, b, c)
    dig2 = get_dig(b, c, a)
    dig3 = get_dig(c, a, b)
    try:
        xy = div(add(add(mul(a, sin(radians(dig1)*2)), mul(b, sin(radians(dig2)*2))), mul(c, sin(radians(dig3)*2))),
            sin(radians(dig1)*2) + sin(radians(dig2)*2) + sin(radians(dig3)*2))
        return xy
    except:
        # 3点が三角形を作らないなら、2点間距離で考慮できてるはずなので無視
        return ()

N = INT()
XY = []
for i in range(N):
    x, y = MAP()
    XY.append((x, y))

centers = []
for i in range(N):
    for j in range(i+1, N):
        # 2点間
        xy = div(add(XY[i], XY[j]), 2)
        centers.append(xy)

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            # 3点間
            xy = calc(XY[i], XY[j], XY[k])
            if xy:
                centers.append(xy)

ans = INF
for center in centers:
    mx = 0
    for xy in XY:
        mx = max(mx, get_dist(center, xy))
    ans = min(ans, mx)
print(ans)


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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool compareHeight(const pair<lli,lli> &a,const pair<lli,lli> &b){
	return a.first > b.first;
}

signed main(){

	lli h,w;
	cin>>h>>w;

	char c;
	vector<lli> data(26,0);
	REP(i,0,h*w){
		cin>>c;
		data[c-'a']++;
	}

	sort(data.begin(),data.end(),greater<lli>());

/*
	if(h==1 && w==1){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(h==1 || w==1){
		lli cnt = max(h,w)%2;
		for(lli i=0;i<26;i++){
			if(data[i]%2){
				cnt--;
			}
			if(cnt<0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes"<<endl;
		return 0;
	}
	*/

	/*意外と全探索でいける?*/
	vector<lli> d;
	lli mp[100][100];
	for(lli i=0;i<(h+1)/2;i++){
		for(lli j=0;j<(w+1)/2;j++){
			mp[i][j]=4;
			if(i==(h+1)/2-1 && h%2==1)mp[i][j]/=2;
			if(j==(w+1)/2-1 && w%2==1)mp[i][j]/=2;
			if(DEBUG)cout<<mp[i][j]<<" ";
			d.push_back(mp[i][j]);
		}
		if(DEBUG)cout<<endl;
	}
	sort(d.begin(),d.end(),greater<lli>());

	REP(i,0,26){
		if(DEBUG)cout<< data[i]<<" ";
	}
	if(DEBUG)cout<<endl;

	for(lli i=0;i<d.size();i++){
		if(d.at(i)>data[0]){
			cout<<"No"<<endl;
			return 0;
		}
		data[0]-=d.at(i);
		sort(data.begin(),data.end(),greater<lli>());
	}
	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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


  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin>>v[i];
  }

  int a=INF;
  rrep(i,n-1){
    if(a<v[i]){
      v[i]--;
    }
    a=v[i];
  }


  rep(i,n-1){
    if(v[i]>v[i+1]){
      cout<<"No"<<endl;
      return 0;
    }
  }

  cout<<"Yes"<<endl;


}


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

using namespace std;

int main(){
    int a,b;

    cin >> a >> b;

    for(int i = a*100.0/8.0;i<(b+1)*10;i++){
        if(int(i*0.08)==a && int(i*0.10)==b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

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

#define int long long

vector<int> sieve_of_eratosthenes(int n)
{
    vector<int> primes(n);
    for (int i=2; i<n; ++i)
        primes[i] = i;
    for (int i=2; i*i<n; ++i)
        if (primes[i])
            for (int j=i*i; j<n; j+=i)
                primes[j] = 0;

    primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}

signed main()
{
    vector<int> primes = sieve_of_eratosthenes(123456*3);
    int n;
    while(cin>>n, n) {
        auto iter = upper_bound(primes.begin(), primes.end(), n);
        int ans = 0;

        for(;*iter<=2*n; ++iter) {
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5508
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
U_MAP mp;
ll dat[ohara];
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>k;
    rep(i,n)cin>>a[i],mp[a[i]]++;
    rep(i,n){
        if(mp[a[i]]==0)continue;
        dat[cnt]=mp[a[i]];
        cnt++;
        mp[a[i]]=0;
    }
    sort(dat,dat+cnt);
    rep(i,cnt-k){
        ans+=dat[i];
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 14152
#include<bits/stdc++.h>
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]<<'\n';
}

Measured memory_bytes: 256