akhauriyash/Code-Regression huggingface dataset:
import sys
from bisect import bisect_right

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())

if N == 1:
    print(0)
    sys.exit()

L = factorization(N)
A = [i for i in range(1,101)]
for i in range(99):
    A[i+1] += A[i]

ans = 0
for _, l in L:
    ans += bisect_right(A,l)
print(ans)

Measured memory_bytes: 9508
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<pair<int, int> > a(n);
  REP(i, n) {
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(ALL(a));
  REP(i, n) cout << a[i].second << (i + 1 == n ? '\n' : ' ');
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	
	long long a=0, b=0, c=0;
	long long max;

	cin >> a >> b >> c;

	max = a * c;

	if (max > b) {
		max = b / a;
	}
	else {
		max = c;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
a = n.times.map{[]}

q.times do
  com = gets.split.map(&:to_i)
  case com[0]
  when 0
    if idx = a[com[1]].bsearch_index{|n| n > com[2]}
      a[com[1]].insert(idx, com[2])
    else
      a[com[1]]<<com[2]
    end
  when 1
    puts a[com[1]][-1] if a[com[1]][0]
  else
    a[com[1]].pop if a[com[1]][0]
  end
end


Measured memory_bytes: 8516
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

/*
puts("aa");
//*/


int main(void) {
	int A, B, C, X;
	scanf("%d%d%d%d", &A, &B, &C, &X);

	int count = 0;
	double x;
	for (int i = 0; 500 * i <= X; i++) {
		
		for (int j = 0; 500 * i + 100 * j <= X; j++) {
			
			
			
			x = ((double)X - (500 * i + 100 * j))/50;
			if (i<=A&&j<=B&&x<=C) {
				//printf("%d %d %f\n", i, j,x);
				count++;
			}
		}
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int count(ll x){
	int cnt = 0;
	while(x != 0){
		cnt++;
		x /= 10;
	}
	return cnt;
}
int cnt[1000000];
int main()
{
	int a , b;
	cin >> a >> b;
	if(a == 1)a = 14;
	if(b == 1)b = 14;
	if(a > b )
		cout << "Alice" << endl;
	else if(b > a)
		cout << "Bob" << endl;
	else
		cout << "Draw" <<endl;
	return 0;
} 



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define R(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
const int maxn=1e5+5;
int n,m;
struct Union_Set {
	int p[maxn],v[maxn];
	Union_Set() {
		R(i,1,maxn-1) p[i]=i;
	}
	void fp(int x) {
		if(x==p[x]) return;
		fp(p[x]);
		v[x]+=v[p[x]];
		p[x]=p[p[x]];
	}
	bool merge(int x,int y,int val) {
		fp(x); fp(y);
		int X=p[x],Y=p[y];
		if(X==Y) {
			int v1=-v[x],v2=-v[y];
			if(v1+val==v2) return true;
			return false;
		}
		val=val+v[y]-v[x];
		p[X]=Y;
		v[X]=val;
		return true;
	}
}us;
int main() {
#ifdef LOCAL
	//freopen("line.in","r",stdin);
#endif
	cin>>n>>m;
	R(i,1,m) {
		int Li,Ri,Di;
		cin>>Li>>Ri>>Di;
		if(!us.merge(Li,Ri,Di)) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

//コピペ用
//		int[] ab = Array.ConvertAll(Console.ReadLine().Split(' '),i=>int.Parse(i));
//      int a = int.Parse(Console.ReadLine());


class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
        int n = int.Parse(Console.ReadLine());
        string[] s = new string[n];
      	char[] c;
        var dic = new Dictionary<string,long>();
        long count=0;
        for(int i=0;i<n;i++){
            c = Console.ReadLine().ToCharArray();
          	Array.Sort(c);
          	s[i] = string.Join("",c);
            if(dic.ContainsKey(s[i])){
                count+=dic[s[i]];
                dic[s[i]]++;
            }else{
                dic.Add(s[i],1);
            }
        }

		//Console.WriteLine(string.Join("\n",s));
        Console.WriteLine(count);
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
 
  deque<long double> v(N);
  rep(i, N) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());

  rep(i, N - 1) {
    long double x = (v.at(0) + v.at(1)) / 2;
    v.pop_front();
    v.pop_front();
    v.push_front(x);
    sort(v.begin(), v.end());
  }

  cout << fixed << setprecision(10);
  cout << v.at(0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n,k; cin>>n>>k;
    vector<ll> h(n);
    rep(i,0,n) cin>>h[i];
    sort(all(h));
    ll ans=LLINF;
    for(int i=0; i+k<=n; i++){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout<<ans<<endl;
}

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

long long solve(string S) {
	long long cnt = 0, ret = 0;
	for (int i = 0; i < S.size(); i++) {
		cnt++;
		if (i == (int)S.size() - 1 || S[i] != S[i + 1]) {
			ret += cnt / 2;
			cnt = 0;
		}
	}
	return ret;
}

int main() {
	string T; cin >> T;
	long long K; cin >> K;

	bool flag = true;
	for (int i = 0; i < (int)T.size() - 1; i++) {
		if (T[i] != T[i + 1]) flag = false;
	}

	if (flag == true) {
		long long len = 1LL * (long long)(T.size()) * K;
		cout << len / 2LL << endl;
	}
	else {
		string V1 = T;
		string V2 = T + T;
		long long R1 = solve(V1);
		long long R2 = solve(V2);
		cout << R1 + (R2 - R1) * (K - 1LL) << endl;
	}
	return 0;
}

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

int main() {
  string a,b;
  cin>>a>>b;
  int c,d;
  c=a.size();d=b.size();
  string ans="EQUAL";
  if(c<d){
    ans="LESS";
  }else if(d<c){
    ans="GREATER";
  }else{
      rep(i,c){
          if(a[i]<b[i]){
            ans="LESS";
            break;
          }else if(b[i]<a[i]){
            ans="GREATER";
            break;
          }
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <cstdio>
typedef long long ll;
inline int rd(){
    int x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
const int N=1000002;
int n,m,k;
char s[N];
int a[N];
int sum=0,p=0;
int main(){
	n=rd(),m=rd();
	for(int i=1;i<=m;i++){
		int x=rd();
		scanf("%s",s);
		if(s[0]=='W'){
			if(a[x]==1)continue;
			else a[x]--;
		}
		if(s[0]=='A'){
			if(a[x]==1)continue;
			else{
				sum++,p-=a[x],a[x]=1;
			}
		}
	}
	printf("%d %d\n",sum,p);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,r;
	cin >> n >> r;
	if(n >= 10){
		cout << r << '\n';
	}
	else{
		cout << r + 100 * (10 - n) << '\n';
	}
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  val X = new Array[Int](N)
  val Y = new Array[Int](N)
  for (i <- 0 until N)
    X(i) = sc.nextInt
  for (i <- 0 until N)
    Y(i) = sc.nextInt
  println((0 until N).map(i => X(i) - Y(i)).filter(_ > 0).sum)
}

Measured memory_bytes: 27340
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int M=1000000;
int a[M]={0},b[M]={0};
int ans[M]={0},len;
void show(int xa,int x[]){for(int i=0;i<fabs(xa);i++) printf("%d",x[i]);printf("\n");}
void add(int ma,int mb){
	int len;
	for(int i=0;i<ma/2;i++) swap(a[i],a[ma-1-i]);
	for(int i=0;i<mb/2;i++) swap(b[i],b[mb-1-i]);
	for(len=0;len<ma||len<mb;len++){
		if(a[len]+b[len]+ans[len]>9) ans[len+1]++;
		ans[len]=(a[len]+b[len]+ans[len])%10;
	}
	if(ans[len]!=0) len++;
	for(int i=0;i<len/2;i++) swap(ans[i],ans[len-1-i]);
	show(len,ans);
} 
int sub(int ma,int mb){
	int len,f=1;
	if(ma<mb) f=-1;
	else if(ma==mb) for(int i=0;i<ma;i++) if(a[i]<b[i]) {f=-1;break;}
	if(f==-1){swap(a,b);swap(ma,mb);}
	for(int i=0;i<ma/2;i++) swap(a[i],a[ma-1-i]);
	for(int i=0;i<mb/2;i++) swap(b[i],b[mb-1-i]);
	for(len=0;len<ma;len++){
		ans[len]=(ans[len]+a[len]-b[len]+10)%10;
		if(a[len]-b[len]<0) a[len+1]--;
	}
	if(len>1&&ans[len-1]==0) len--;
	for(int i=0;i<len/2;i++) swap(ans[i],ans[len-1-i]);
	if(f==-1) printf("-");	
	show(len,ans);
	return f*len;
}
inline int read(int x[]){
	int f=1,cnt=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x[cnt++]=ch-'0';ch=getchar();}
	return cnt*f;
} 
int main(){
	int ma=read(a);
	int mb=read(b);
	if (ma*mb>=0){ 
		if(ma<0||mb<0) printf("-"); 
		add(fabs(ma),fabs(mb));
	}
	else{
		if(ma<0){swap(a,b);swap(ma,mb);}
		sub(fabs(ma),fabs(mb));
	}
	return 0;
}
//17 18



Measured memory_bytes: 11396
#include<bits/stdc++.h>
#define BASE 1000000
#define veto vector<long long>
using namespace std;
veto a,b,c;
void fix(veto &a)
    {
        a.push_back(0);
        for (int i=0; i < a.size()-1; i++)
            {
                a[i+1]+=a[i]/BASE;
                a[i]%=BASE;
                if (a[i] < 0)
                    a[i]+=BASE, a[i+1]--;
            }
        while ((a.size() >= 2)&&(a.back() == 0))
               a.pop_back();
    }
istream& operator >> (istream& cin, veto &a)
    {
        string st;
        cin>>st;
        a.clear();
        a.resize(st.length()/6+1);
        for (int i=0; i < st.length(); i++)
            {
                int x=(st.length()-i-1)/6;
                a[x]=a[x]*10 + st[i]-'0';
            }
        fix(a);
        return cin;
    }
ostream& operator << (ostream& cout, const veto &a)
    {
        printf("%d",a.back());
        for (int i=a.size()-2; i >= 0; i--)
            printf("%06d",a[i]);
        return cout;
    }
bool operator < (const veto &a, const veto &b)
    {
        if (a.size() != b.size())
            return a.size() < b.size();
        for (int i=a.size()-1; i >= 0; i--)
            if (a[i] != b[i])
                return a[i] < b[i];
        return 0;
    }
bool operator == (const veto &a, const veto &b)
    {
        if (a.size() != b.size())
            return 0;
        for (int i=0; i < a.size(); i++)
            if (a[i] != b[i])
                return 0;
        return 1;
    }
veto operator * (veto a, veto b)
    {
        veto c(a.size()+b.size());
        for (int i=0; i < a.size(); i++)
            for (int j=0; j < b.size(); j++)
                c[i+j]+=a[i]*b[j];
        return fix(c), c;
    }
veto operator + (veto a, veto b)
    {
        a.resize(max(a.size(),b.size()));
        for (int i=0; i < b.size(); i++)
            a[i]+=b[i];
        return fix(a), a;
    }
veto operator - (veto a, veto b)
    {
        for (int i=0; i < b.size(); i++)
            a[i]-=b[i];
        return fix(a), a;
    }
main()
{
    //ios::sync_with_stdio(0);
    veto four; four.clear();
    four.push_back(4); fix(four);
    veto zero; zero.clear();
    four.push_back(0); fix(zero);

    cin>>a>>b>>c;
    c=c-a;
    c=c-b;
    if (c <= zero){
        cout<<"No";
        return 0;
    }
    c=c*c;

    a=a*b;
    a=a*four;

    if (a < c){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

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

int ctoi(char c){
  return (int)c-'0';
}

int main(){
  int H,W;
  cin>>H>>W;
  char dt[H][W];
  int dist[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>dt[i][j];
    }
  }
  dist[0][0]=ctoi(dt[0][0]);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i!=0 && j!=0 ){
	dist[i][j]=min(dist[i-1][j]+ctoi(dt[i][j]),dist[i][j-1]+ctoi(dt[i][j]));
      }else if(i==0 && j!=0){
	dist[i][j]=dist[i][j-1]+ctoi(dt[i][j]);
      }else if(j==0 && i!=0){
	dist[i][j]=dist[i-1][j]+ctoi(dt[i][j]);
      }
    }
  }
  cout<<dist[H-1][W-1]<<endl;
  return 0;
}

Measured memory_bytes: 1172
import java.util.*;

public class Main {

	static Map<Long, Integer> map = new TreeMap<Long, Integer>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			if (!map.containsKey(a)) {
				map.put(a, 1);
			} else {
				map.put(a, map.get(a) + 1);
			}
			sum += a; // 初期の合計を計算
		}
		int Q = sc.nextInt();
		for (int i = 0; i < Q; i++) {
			long b = sc.nextLong();
			long c = sc.nextLong();
			// Biが含まれない場合はスキップ
			if (!map.containsKey(b)) {
				System.out.println(sum);
				continue;
			}
			// BiをCiに置き換える
			int cnt = map.get(b);
			// sumの更新
			sum += (c - b) * (long) cnt;
			// Map操作
			map.remove(b);
			if (!map.containsKey(c)) {
				map.put(c, cnt);
			} else {
				map.put(c, map.get(c) + cnt);
			}
			System.out.println(sum);
		}
		sc.close();
	}
}


Measured memory_bytes: 64412
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        mut n: usize,
        a: usize,
        b: usize,
    }

    let mut ans = 0;

    let c = a + b;

    ans += n / c * a;

    ans += std::cmp::min(a, n % c);

    println!("{}", ans);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);++i)

int main(){
	int n;
	cin>>n;
	reep(i,0,n){
		int a,b;
		cin>>a>>b;
		a%=b;
		if(a==0){
			cout<<b<<endl;
		}
		else{
			cout<<a<<endl;
		}
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <cmath>
#include <queue>
#include <unordered_map>

using namespace std;

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

  unordered_map<int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (m.find(a) == m.end()) { m.emplace(a, 0); }
    m[a]++;
  }

  priority_queue<int> q;
  for (const auto& e : m) {
    q.push(e.second);
  }

  int count = n;
  for (int k = 1; k <= n; k++) {
    int max_pairs = count / k;
    int t;

    while (!q.empty() && (t = q.top()) > max_pairs) {
      // 可能な最大回数(max_pairs)を超える数値についてはカード枚数を減らす。
      // (すべての数値のカード枚数がmax_pairs以下の場合は、max_pairs回操作可能)
      q.pop();
      int diff = t - max_pairs;

      q.push(max_pairs);
      count -= diff;
      max_pairs = count / k;
    }

    cout << max_pairs << endl;
  }
}


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

int main(){
    using namespace std;
    unsigned long Q;
    cin >> Q;
    constexpr unsigned long M{205891132094649UL};
    vector<unsigned long> p3{1};
    for(unsigned long i{0}; i < 30; ++i)p3.push_back(p3.back() * 3);
    const auto& calc = [&p3](unsigned long a, unsigned long b, unsigned long c, unsigned long d) -> unsigned long {
        vector<unsigned long> i;
        for(const auto& p : p3)if(a / p % 3 == 1 || a / p * p + p * (1 + (a / p % 3 == 2)) <= c)i.push_back(p);
        auto ub{b}, lb{b};
        for(const auto& p : i){
            if(ub / p % 3 == 1)ub = ub / (3 * p) * 3 * p + 2 * p;
            if(lb / p % 3 == 1)lb = lb / (3 * p) * 3 * p + p - 1;
        }
        return c - a + min(ub - b + max(ub, d) - min(ub, d), b + d - 2 * lb);
    };
    for(unsigned long _{0}, a, b, c, d; _ < Q; ++_){
        cin >> a >> b >> c >> d;
        if(--a > --c){
            swap(a, c);
            swap(b, d);
        }
        if(--b > --d){
            b = M - b - 1;
            d = M - d - 1;
        }
        cout << max(calc(a, b, c, d), calc(b, a, d, c)) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
program main
  implicit none
  integer(16) i, N, ans, p
  read(*, *) N
  ans = 0
  do i = 1,N
    p = N/i
    ans = ans + i * p * (p + 1)
  end do
  ans = ans/2
  !read(*, *) (L(i), i = 1,N)

  write(*, *) ans
end program main


Measured memory_bytes: 2728
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	auto N = IN();
	auto A = IN();
	print(N*N-A);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX = 11;
int N, M;

int K[MAX];
int S[MAX][MAX];
int P[MAX];

bool used[MAX];
int ans = 0;

void dfs(int pos)
{
  if(pos == N) {
    REP(m,M) {
      int tmp = 0;
      REP(k,K[m]) {
        tmp += used[S[m][k]];
      }
      if(tmp%2 != P[m]) {
        return;
      }
    }
    ans++;
  } else {
    dfs(pos+1);
    used[pos] = true;
    dfs(pos+1);
    used[pos] = false;
  }
}

signed main()
{
  cin >> N >> M;
  REP(m,M) {
    cin >> K[m];
    REP(k,K[m]) {
      cin >> S[m][k];
      S[m][k]--;
    }
  }

  REP(m,M) {
    cin >> P[m];
  }

  dfs(0);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (long long i = 0; i < (n); i++)
using namespace std;


void solve(long long N, long long K, std::vector<long long> l){
    sort(l.begin(), l.end(), greater<long long>());

    long long ans = 0;
    REP(i, K) {
        ans += l[i];
    }

    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> l(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&l[i]);
    }
    solve(N, K, std::move(l));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    s = s.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "");
    if (s.equals("")) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 28364
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<unordered_map>

using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define INF 0x3f3f3f3f
#define ll long long
#define mod  998244353
const  int N = 1e6+5;
int main(){
    int a,b;
    cin>>a>>b;
    int c;
    cin>>c;
    a = max(a,b);
    cout<<(c + a-1) / a;
}

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

using namespace std;

using ll = long long;

int main() {
   ios_base::sync_with_stdio(false);
   int N, K, MOD;
   cin >> N >> K >> MOD;
   vector<vector<int>> C(N + 2, vector<int>(N + 2));
   for (int i = 0; i <= N + 1; ++i) {
      C[i][0] = 1;
      for (int j = 1; j <= i; ++j) {
         C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
         if (C[i][j] >= MOD) C[i][j] -= MOD;
      }
   }
   vector<vector<int>> dp(N + 2, vector<int>(K + 1));
   vector<vector<int>> suff(N + 2, vector<int>(K + 2));
   for (int i = K; i >= 0; --i) {
      dp[1][i] = 1;
      suff[1][i] = suff[1][i + 1] + dp[1][i];
      if (suff[1][i] >= MOD) suff[1][i] -= MOD;
   }
   for (int i = 2; i <= N + 1; ++i) {
      for (int j = K; j >= 0; --j) {
         for (int k = 1; k < i; ++k) {
            dp[i][j] += ll(dp[k][j]) * suff[i - k][j + 1] % MOD * C[i - 2][k - 1] % MOD;
            if (dp[i][j] >= MOD) dp[i][j] -= MOD;
         }
         suff[i][j] = suff[i][j + 1] + dp[i][j];
         if (suff[i][j] >= MOD) suff[i][j] -= MOD;
      }
   }
   cout << dp[N + 1][0] << "\n";
   return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 1000000000;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int L;
  cin >> L;
  vector<int> A(L);
  REP(i, L) cin >> A[i];
  vector<vector<int>> dp(L+1, vector<int>(5, INF));
  dp[0][0] = 0;
  REP(i, L) {
    REP(j, 5) {
      int num;
      if(j == 0 || j == 4) {
        num = A[i];
      } else if(j == 1 || j == 3) {
        if(A[i] == 0) {
          num = 2;
        } else {
          num = A[i] % 2;
        }
      } else {
        num = (A[i] + 1) % 2;
      }
      REP(k, j+1) {
        dp[i+1][j] = min(dp[i+1][j], dp[i][k] + num);
      }
    }
  }
  int ans = INF;
  REP(i, 5) if(dp[L][i] < ans) ans = dp[L][i];
  cout << ans << endl;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][now[i]];
        last[now[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);

    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);
    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);now.resize(d);
    rep(i,d){now[i] = i%26;t[i] = now[i];}
    best = score();
    rep(_,1000){
        // cout << best << endl;
        // rep(i,d)now[i] = rnd1(mt);
        int choice = rnd2(mt);
        rep(i,26){
            now[choice] = i;
            ll now_s = score();
            if(best < now_s){
                best = now_s;
                rep(j,d)t[j] = now[j];
            }
        }
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

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

int main() {
    int a,b,ans=1,count=0;
    cin>>a>>b;
    while(true){
        if(b<=ans){
            break;
        }
        ans--;
        ans+=a;
        count++;
    }
    cout<<count<<'\n';
	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))

sum=0
for a in A:
    sum+=a
judge=sum/(4*M)
count=0
#print(judge)
for a in A:
    if a>=judge:
        count+=1

if count>=M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]
ans = float('inf')
for i in range(2**N):
    da = [True]*N
    for j in range(N):
        if (i>>j) & 1:
            da[j] = False
    a = []
    lb = []
    for j in range(N):
        if da[j] == True:
            a.append(l[j])
        else:
            lb.append(l[j])
    #print(a,lb)
    if len(lb) >= 2:
        for j in range(2**len(lb)):
            db = [True] * len(lb)
            for k in range(len(lb)):
                if (j>>k) & 1:
                    db[k] = False
            b = []
            lc = []
            for k in range(len(lb)):
                if db[k] == True:
                    b.append(lb[k])
                else:
                    lc.append(lb[k])
            #print(db)
            if len(lc) >= 1:
                for k in range(2**len(lc)):
                    dc = [True] * len(lc)
                    for m in range(len(lc)):
                        if (k>>m) & 1:
                            dc[m] = False
                    c = []
                    for m in range(len(lc)):
                        if dc[m] == True:
                            c.append(lc[m])
                    if len(a) > 0 and len(b) > 0 and len(c) > 0:
                        #print(a,b,c)
                        ans = min(ans, 10*(len(a)-1)+abs(A-sum(a)) + 10*(len(b)-1)+abs(B-sum(b)) + 10*(len(c)-1)+abs(C-sum(c))          )
print(ans)


    


Measured memory_bytes: 76012
N = int(input())
m = int((N**0.5 )//1  + 1)
#print(m)

res = 1000000000000
for i in range(1, m):
    if N%i == 0:
        o =  int(N/i)
        if res > o + i:
            res = o + i
print(res-2)

Measured memory_bytes: 2940
from functools import reduce
S = input()

def dfs(res, depth, path, S):
    if len(''.join(path)) == len(S):
        res.append(path)
    for i in range(depth + 1, len(S) + 1):
        dfs(res, i, path + [S[depth:i]], S)

res = []

dfs(res, 0, [], S)

print(sum(int(num) for nums in res for num in nums))


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=998244353;
const ll INF=1000000000;
int dx[8]={0,0,1,1,1,-1,-1,-1};
int dy[8]={1,-1,1,-1,0,1,-1,0};
int main(){
    int a=0;
    string s;cin>>s;
    for(int i=0;i<4;i++){
        if(s[i]=='+'){
            a++;
        }else{
            a--;
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
t,a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
min = 10 ** 9
ans = nil
h.each_with_index do |x,i|
  if min > ( t - x*0.006 - a).abs
    min = ( t - x*0.006 - a).abs
    ans = i+1
  end
end
p ans

Measured memory_bytes: 1788
N,M = map(int,input().split())
c = list(map(int,input().split()))
dp = list(range(N+1))
for i in range(N+1):
    for ci in c:
        if i + ci <= N:
            dp[i+ci] = min(dp[i+ci],dp[i] + 1)
print(dp[N])
#print(dp)


Measured memory_bytes: 7512
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(A);CIN(B);CIN(C);CIN(D);CIN(E);
    LL ans = 1000000000000;

    for(LL a = 0;a < max(D,E)*5;a++){
        LL ins = a * C;
        LL X = D;
        LL Y = E;
        LL w = (a%2==0?a/2:a/2-1);
        X -= w;
        Y -= w;
        ins += A*max(X,0LL);
        ins += B*max(Y,0LL);
        ans = min(ans,ins);
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input! {
        _n:i32,
        a:i32,
        b:i32,
    };

    let d = b-a;
    if d%2 == 0 {
        println!("Alice");
    } else {
        println!("Borys");
    }


}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using PP = pair<long, long>;
const int INF = 1e9;
template <class T> T Next() { T buf; cin >> buf; return buf; }

long input() {
  long ret = 0;
  char c;
  while (c = getchar(), isdigit(c)) {
    ret *= 10;
    ret += c - '0';
  }
  return ret;
}

const long INFLL = 1e18;
int main() {
  int a = input();
  int b = input();
  int c = input();
  int z = input();
  
  vector<long> s, t, u;
  s.reserve(a + 1);
  t.reserve(b + 1);
  u.reserve(c + 1);
  for (int i = 0; i < a; ++i) s.push_back(input());
  for (int i = 0; i < b; ++i) t.push_back(input());
  for (int i = 0; i < c; ++i) u.push_back(input());
  
  sort(s.rbegin(), s.rend());
  sort(t.rbegin(), t.rend());
  sort(u.rbegin(), u.rend());
  s.push_back(-INFLL);
  t.push_back(-INFLL);
  u.push_back(-INFLL);
  
  using Pair = pair<long, int>;
  
  unordered_set<int> st;
  vector<Pair> mem;
  mem.reserve(2 * z + 1);
  priority_queue<Pair> Q(std::less<Pair>(), move(mem));
  Q.push(make_pair(s[0] + t[0] + u[0], 0));
  
  int cnt = 0;
  while (cnt < z) {
    auto q = Q.top(); Q.pop();
    long sc = q.first;
    int pos = q.second;
    if (st.count(pos)) continue;
    st.insert(pos);
    
    int i =  pos        & 0x3ff;
    int j = (pos >> 10) & 0x3ff;
    int k = (pos >> 20) & 0x3ff;
    
    cout << sc << endl;
    Q.push(make_pair(s[i + 1] + t[j] + u[k], pos +  1       ));
    Q.push(make_pair(s[i] + t[j + 1] + u[k], pos + (1 << 10)));
    Q.push(make_pair(s[i] + t[j] + u[k + 1], pos + (1 << 20)));
    ++cnt;
  }
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef pair<int, int> P;
#define INF (1 << 30)
int dist[1080];
int n, m, a, b;
vector<P> edge[1080];
int main(){
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> a >> b;
		b++;
		edge[a].push_back(P(b, 1));
	}	
	for(int i = 1;i <= n;i++){
		edge[i+1].push_back(P(i, 0));
	}
	priority_queue<P, vector<P>, greater<P> > pq;
	fill(dist, dist + 108, INF);
	dist[1] = 0;
	pq.push(P(0, 1));
	while(!pq.empty()){
		P tmp = pq.top();pq.pop();
		int from = tmp.second, d = tmp.first;
		if(dist[from] < d)continue;
		for(int i = 0;i < edge[from].size();i++){
			int to =edge[from][i].first, c = edge[from][i].second;
			if(dist[from] + c < dist[to]){
				dist[to] = dist[from] + c;
				pq.push(P(dist[to], to));
			}
		}
	}

	if(dist[n+1] == INF)cout << "Impossible" << endl;
	else cout << dist[n+1] << endl;
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    int n;
    int ans=0;
    int l,r;
    cin >> n;
    rep(i,n){
        cin >> l >> r;
        ans += (r-l)+1;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A  = new int[N];
        int[] numCount = new int[200001];
        long totalComb = 0;


        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
            numCount[A[i]]++;
            totalComb += numCount[A[i]]-1;
        }


        for(int i=0;i<N;i++){
            System.out.println(totalComb-(numCount[A[i]]-1));
        }


    }

}









Measured memory_bytes: 92400
while True:
    n=int(input())
    if n==0:exit()
    l0=list(map(str,input().split()))
    ans=0
    l=0
    r=0
    k=1
    for x in l0:
        if x=="lu":
            l=1
        elif x=="ld":
            l=0
        elif x=="ru":
            r=1
        else:
            r=0
        if k+l+r==3:
            ans+=1
            k-=1
        elif k+l+r==0:
            ans+=1
            k+=1
    print(ans)




Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


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

    vector<string> S(N);
    int i;
    for(i = 0; i < N; i++)
        cin >> S.at(i);

    sort(S.begin(), S.end());

    for(i = 0; i < N; i++)
        cout << S.at(i);

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, M = map(int, input().split())

i = 1

divs = []
while i ** 2 <= M:
    if M % i != 0:
        i += 1
        continue
    divs.append(i)
    divs.append(M // i)
    i += 1
divs = sorted(divs)
ans = 1
for d in divs:
    if N <= M // d:
        ans = max(d, ans)
print(ans)


Measured memory_bytes: 9504
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<31;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0}; 
ll mpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%MOD;
        }
        n>>=1;
        x=x*x%MOD;
    }
    return res;
}
vector<ll> f,fi;
void comb(){
    f.resize(1010);
    fi.resize(1010);
    f[0]=1;
    for(ll i=1;i<=1000;i++){
        f[i]=f[i-1]*i;
        f[i]%=MOD;
    }
    fi[1000]=mpow(f[1000],MOD-2);
    for(ll i=999;i>=0;i--){
        fi[i]=fi[i+1]*(i+1LL);
        fi[i]%=MOD;
    }
}
ll ncr(ll n,ll r){
    return f[n]*fi[r]%MOD*fi[n-r]%MOD;
}
int main(){
    comb();
    ll n,k;cin>>n>>k;
    if(n<k){
        cout<<0<<endl;
        return 0;
    }
    ll ans=mpow(k,n);
    for(ll i=1;i<=k;i++){
        if(i%2){
            ans+=MOD;
            ans-=ncr(k,i)*mpow(k-i,n)%MOD;
            ans%=MOD;
        }else{
            ans+=ncr(k,i)*mpow(k-i,n)%MOD;
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3128
import sys
from collections import defaultdict as dd
from itertools import combinations as combi
input = sys.stdin.readline
N = int(input())
el = []
e = dd(list)
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
  if u > v: u, v = v, u
  el.append((u, v))

vis = []
def dfs(s, t):
  global vis
  vis.append(s)
  if s == t:
    res = list(vis)
    vis.remove(s)
    return res
  res = []
  for x in e[s]:
    if x in vis: continue
    tt = dfs(x, t)
    if len(tt):
      res = tt
      break
  vis.remove(s)
  return res


M = int(input())
table = [[0] * (N - 1) for _ in range(M)]
for i in range(M):
  u, v = map(int, input().split())
  p = dfs(u, v)
  #print(p, i, vis)
  for j in range(len(p) - 1):
    for k in range(N - 1):
      x = p[j]
      y = p[j + 1]
      if x > y: x, y = y, x
      #print(el[k], x, y, i)
      if el[k] == (x, y):
        table[i][k] = 1
        break
revtable = [0] * (N - 1)
for i in range(N - 1):
  for j in range(M):
    if table[j][i]: revtable[i] += pow(2, j)

dp = [0] * pow(2, M)
dp[0] = 1
#print(revtable)
#print(table)
for i in range(N - 1):
  for j in range(pow(2, M) - 1, -1, -1):
    dp[revtable[i] | j] += dp[j]
print(dp[-1])

Measured memory_bytes: 50652
#include <iostream>
using namespace std;
void trace(int A[], int N)
{
	for (int i = 0; i < N; i++){
	    if (i > 0)
	        cout << " ";
		cout << A[i];
	}
	cout << "\n";
}

void Insertion_sort(int A[], int N)
{
	int v, j;
	for (int i = 1; i < N; i++)
	{
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A, N);
	}
}
int main()
{
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++)
		cin >> A[i];

	trace(A,N);
	Insertion_sort(A,N);
}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

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

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int n;
  cin >> n;
  lvec a(n);
  ll sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  ll count = 0;
  ll minDiff = INF;
  ll diff = INF;
  REP(i, n - 1) {
    count += a[i];
    diff = abs(count - (sum - count));
    minDiff = min(minDiff, diff);
  }
  cout << minDiff << endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = n; i--> 0;) {
		cin >> a[i];
	}
	
	for (int i = 0; i < n; i++) {
		cout << a[i] << " \n"[i + 1 == n];
	}
	
	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(char *s)
{
    int i;

    for(i = 0; i < strlen(s); i++)
        printf("x");
    printf("\n");
}

int
main(int argc, char *argv[])
{
    char S[101];
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    scanf("%s", S);
    solver(S);
    return 0;
}

Measured memory_bytes: 128
#!/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,m=map(int,input().split())
G=[[] for i in range(n)]
for i in range(m):
    u,v=map(int,input().split())
    u-=1; v-=1
    G[u].append(v)
s,t=map(int,input().split())
s-=1; t-=1

# dp=[[inf]*3 for i in range(n)]
# dp[s][0] = 0

def disktra(g,s):
    n=len(g)
    dist = [[inf]*3 for i in range(n)]
    dist[s][0] = 0
    hq=collections.deque(); hq.appendleft((0,s))
    while hq:
        cost,u =hq.pop()
        if dist[u][cost%3] < cost:
            continue
        for v in g[u]:
            if dist[v][(dist[u][cost%3]+1)%3] <= dist[u][cost%3] + 1:
                continue
            dist[v][(dist[u][cost%3]+1)%3] = dist[u][cost%3] + 1
            hq.appendleft((dist[v][(dist[u][cost%3]+1)%3],v))
    return dist

dp=disktra(G,s)
print(-1 if dp[t][0]==inf else dp[t][0]//3)
# print(*dp,sep="\n")

Measured memory_bytes: 77104
s=' '+input()
t=' '+input()
dp=[[0]*len(t)for _ in range(len(s))]
for i in range(1,len(s)):
    for j in range(1,len(t)):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=[]
i,j=len(s)-1,len(t)-1
while dp[i][j]:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans.append(s[i])
        i-=1
        j-=1
print(''.join(ans[::-1]))

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

int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  bool flg=true;
  
  for(int i=0;i<(int)s.size();i++){
    if(i==a)continue;
    if(s[i]<'0' || '9'<s[i])flg=false;
  }
  
  if(s[a]=='-'&&flg){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,n;
        n=scan.nextInt();
        double x[]=new double[n],y[]=new double[n],p1=0,p2=0,p3=0,p=0;
        for(i=0;i<n;i++) {
        	x[i]=scan.nextDouble();
        }
        for(i=0;i<n;i++) {
        	y[i]=scan.nextDouble();
        }
        for(i=0;i<n;i++) {
        	p1+=Math.abs(x[i]-y[i]);
        	p2+=Math.pow(Math.abs(x[i]-y[i]),2);
        	p3+=Math.pow(Math.abs(x[i]-y[i]),3);
        	if(i==0) {
        		p=Math.abs(x[i]-y[i]);
        	}
        	else if(p<Math.abs(x[i]-y[i])) {
        		p=Math.abs(x[i]-y[i]);
        	}
        }
        System.out.println(p1);
        System.out.println(Math.sqrt(p2));
        System.out.println(Math.cbrt(p3));
        System.out.println(p);
    }
}


Measured memory_bytes: 29112