akhauriyash/Code-Regression huggingface dataset:
/*input
5
0.42 0.01 0.42 0.99 0.42
*/
#include<bits/stdc++.h>
using namespace std;

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define X first
#define Y second
#define pb push_back
#define all(s) s.begin(),s.end()

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

const int MOD = 1e9+7;

int n;
long double prob[3000];
long double dp[3000][3000];




void solve(){
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> prob[i];

    // memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=i;j++){
            // if(i==0 || j==0) {
            //     dp[i][j] = 1;
            //     continue;
            // }
            // cout << i << " " << j << "\n";
            // cout << prob[i] << "\n";
            dp[i+1][j] += dp[i][j]*(1-prob[i]);
            dp[i+1][j+1] += dp[i][j]*prob[i];
            // cout << dp[i][j] << " ";
        }
        // cout << "\n";
    }

    long double ans = 0;
    for(int i=n/2+1;i<=n;i++){
        ans += dp[n][i];
    }
    cout << fixed << setprecision(16);
    cout << ans;

}

int main(){
    FIN;   
    // test
    solve();
}

Measured memory_bytes: 139136
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 2003;

int N,K,c[MAX_N][MAX_N],s[MAX_N][MAX_N];

void prepare(){
  REP(x,1,2*K+2)
    REP(y,1,2*K+2) s[x][y] = c[x][y] + s[x-1][y] + s[x][y-1] - s[x-1][y-1];
  // REP(x,1,2*K+1){
  //   REP(y,1,2*K+1) cout << c[x][y] << " ";
  //   cout << "" << endl;
  // }
}

int query(int x1,int y1,int x2,int y2){
  // return sum(x1<=x<=x2,y1<=y<=y2)
  if(x1>x2||y1>y2) return 0;
  else return s[x2][y2] - s[x1-1][y2] - s[x2][y1-1] + s[x1-1][y1-1];
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  fill(c[0],c[MAX_N-1],0);
  rep(i,N){
    int x,y; char cc;
    cin >> x >> y >> cc;
    if(cc=='B') x += K;
    x %= (2*K); y %= (2*K);
    c[x+1][y+1]++;
  }
  prepare();
  int ans = -INF;
  REP(x,1,K+1) REP(y,1,K+1){
    int temp = query(x,y,x+K-1,y+K-1) + query(x+K,y+K,2*K,2*K) + query(1,1,x-1,y-1)
               + query(x+K,1,2*K,y-1) + query(1,y+K,x-1,2*K);
    ans = max(ans,max(temp,N-temp));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
	ll k, n;
	cin >> k >> n;
	ll a[n], ans = 0, max = 0;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	ll b[n];
	for(int i = 0; i < n; ++i){
	 	if(i == n-1){
	 		b[i] = (k - a[i]) + a[0];
	 	}
	 	else
	 		b[i] = a[i+1] - a[i];
	}
	for(int i = 0; i < n; ++i){
		if(b[i] > max)
			max = b[i];
	}
	for(int i = 0; i < n; ++i){
			ans += b[i];
	}
	cout << ans - max;
	return 0;
}


Measured memory_bytes: 3328
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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)*}
    };
}

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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String,
        k: usize,
    }
    let mut v = vec![];
    for l in 1..(k + 1) {
        for i in 0..(s.len() - l + 1) {
            v.push(&s[i..i + l]);
        }
    }
    v.sort();
    v.dedup();
    println!("{}", v[k - 1]);
}


Measured memory_bytes: 4352
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var M = cin.ReadInt;
            var A = new long[N];
            var B = new long[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = cin.ReadLong;
                B[i] = cin.ReadLong;
            }
            Array.Sort(A, B);
            var ans = 0L;
            var m = 0L;
            for (int i = 0; i < N; i++)
            {
                if (m + B[i] > M)
                {
                    ans += (M - m) * A[i];
                    break;
                }
                else
                {
                    ans += B[i] * A[i];
                    m += B[i];
                }
            }
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 16968
var n,i,j,ans,num,maxi:longint;
var a,b:array[0..100020] of longint;
begin
  read(n);for i:=1 to n do begin read(a[i]);inc(b[a[i]]);inc(b[a[i]+1]);
  inc(b[a[i]-1]);end;ans:=0;
  for i:=0 to 100000 do if b[i]>ans then ans:=b[i];
  writeln(ans);
end.

Measured memory_bytes: 896
num = int(input())
bill =[ [ [ 0 for i in range(10) ] for n in range(3) ] for j in range(4) ]
for i in range(num):
    lines = input().split()
    b, f, r, v = int(lines[0]), int(lines[1]), int(lines[2]), int(lines[3])
    bill[b - 1][f - 1][r - 1] += v

for number,i in enumerate(bill):
    for n in i:
        for j in n:
            print(" " + str(j),end="")
        print()
    if number != 3: 
        print("#"*20)
    else:
        break


Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define int long long
using namespace std;
pair<int,int>a[114514];
signed main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        cin>>a[i].second;
    }
    sort(a,a+n);
    for(int j=0;j<n;j++){
        k=k-a[j].second;
        if(k<1){
            cout<<a[j].first<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
/**
 *    author:   K.R.Surrya  
 *    created:  03/05/2020 18:25:10
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}
bool check(float x) { 
    if(x-floor(x)==0) return true;
    return false;
}
void solve() { 
    // cerr << setprecision(20) << fixed << pow(33.00,0.2);
    int X;
    cin >> X;
    int a=0;
    int sign=1;
    while(true) { 
        float one=pow(a,5);
        float two=one-X;
        if(two!=0)
         sign=two/abs(two);
        float b=pow(abs(two),0.2);
        // error(a,b,one,two);
        if(check(b)) {
            b=sign*b;
            cout << a << ' ' << b << '\n';
            return;
        }
        ++a;
    }
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   //  freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

     auto start = chrono::high_resolution_clock::now();
     solve();
     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


Measured memory_bytes: 4284
#include <bits/stdc++.h>
const int maxn=1e5+10,mod=1e9+7;
typedef long long ll;
using namespace std;
int n,m,k,t;
int main()
{
    int i,j;
    //freopen("in.txt","r",stdin);
    char a;
    scanf("%c",&a);
    printf("%c\n",(a-'a'+1)%26+'a');
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

int parent(int);
int left(int);
int right(int);

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=1;i<=H; i++) scanf("%d",&A[i]);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}

int parent(int x){
  return x/2;
}

int left(int x){
  return 2*x;
}

int right(int x){
  return 2*x+1;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int main()
{
	char s;

	cin >>s;
	
	int a=0;
	char ans[4]={'T','G','C','A'};
	switch(s){
		case 'A':
		a=0;
		break;
				case 'C':
		a=1;
		break;

				case 'G':
		a=2;
		break;
				case 'T':
		a=3;
		break;

	}
	cout <<ans[a]<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
const int N = 1e6 + 10;
int32_t main()
{
   int d,t,s; cin >> d >> t >> s;
   if(t * s >= d) cout << "Yes\n";
   else cout << "No\n";



}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

int f ( string s )
{
    string t = s ;
    reverse ( all ( t ) ) ;

    if ( t == s )
        return 1 ;

    return 0 ;
}

void solve ( int test_case )
{
    string s ;
    cin >> s ;

    int n = s.size() ;
    n >>= 1 ;

    string s1 = s.substr ( 0 , n ) ;
    string s2 = s.substr ( n + 1 , n ) ;

    if ( f ( s ) + f ( s1 ) + f ( s2 ) == 3 )
        cout << "Yes" ;

    else
        cout << "No" ;

    line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;
long long int a[100001];

int main(void) {
	bool flag = true;
	long long int k;
	long long int n;
	long long int mi = 2;
	long long int ma = 3;
	
	cin >> k;
	FOR(i, 1, k) {
		cin >> a[i];
	}

	if (a[k] != 2) {
		flag = false;
	}
	else {
		RFOR(i, k-1, 1) {
			if (ma < mi) {
				flag = false;
				break;
			}
			if (a[i] >= mi) {
				mi = a[i];
			}
			else {
				if (mi%a[i] == 0) {
					mi = (mi / a[i])*a[i];
				}
				else {
					mi = ((mi / a[i]) + 1)*a[i];
				}
			}
			if (a[i] > ma) {
				flag = false;
				break;
			}
			else {
				if (ma%a[i] == 0) {
					ma = ((ma / a[i]) + 1)*a[i] - 1;
				}
				else {
					ma = ((ma / a[i]) + 1)*a[i] - 1;
				}
			}
			if (ma < mi) {
				flag = false;
				break;
			}
		}

	}

	if (flag == false) {
		cout << -1 << endl;
	}
	else {
		cout << mi << " " << ma << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 500000
 
int tmp[N], count;
 
void MergeSort(int data[], int l, int r){
  int mid, i, j, k;

  if(l >= r) return;
  mid = (l + r) / 2;

  MergeSort(data, l, mid);
  MergeSort(data, mid+1, r);

  for(i=l;i<=mid;i++){
 tmp[i] = data[i];
}
  for(i=mid+1,j=r;i<=r;i++,j--){
 tmp[i] = data[j];
}

  i = l;
  j = r;

  for(k=l;k<=r;k++,count++){
    if(tmp[i] <= tmp[j]) data[k] = tmp[i++];
    else data[k] = tmp[j--];
  }
}
 
main(){
  int n, data[N], i;

  scanf("%d", &n);
  for(i=0;i<n;i++){
 scanf("%d", &data[i]);
}
  MergeSort(data, 0, n-1);

  for(i=0;i<n-1;i++){
 printf("%d ", data[i]);
}
  printf("%d\n%d\n", data[n-1], count);
  return 0;
}

Measured memory_bytes: 4504
//fifer a tak luboin
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define mp make_pair
#define pb push_back
#define s second
#define f first
#define endl "\n"

// using namespace __gnu_pbds;
using namespace std;
// template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

const double eps = 1e-10;                                     
const double pi = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    // freopen("input.in.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());
    int sum = 0;
    for (int i = 0; i < k; i++) sum += a[i];
    cout << sum << endl;
    return 0;  
}


Measured memory_bytes: 3676
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define itn int
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int prevv[100010];
struct edge{int to,cost;};

vector<ll> dijkstra(int n,vector<vector<edge> > G,int s){
  fill(prevv,prevv+n,-1);
  priority_queue<pii,vector<pii>,greater<pii> > que;
  vector<ll> dist(n,inf);
  dist[s]=0;
  que.push(pii(0,s));
  while(!que.empty()){
    int c,v;
    tie(c,v)=que.top();
    que.pop();
    if(dist[v]<c) continue;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      int nc=e.cost;
      int nv=e.to;
      if(dist[nv]>dist[v]+nc){
        dist[nv]=dist[v]+nc;
        prevv[nv]=v;
        que.push(pii(dist[nv],nv));
      }
    }
  }
  return dist;
}

//頂点への最短路
vector<int> get_path(int t){
  vector<int> path(0);
  for(;t!=-1;t=prevv[t]) path.push_back(t);
  reverse(path.begin(),path.end());
  return path;
}

struct unionfind{
  vector<int> par;
  unionfind(int n):par(n,-1){}
  void init(int n){par.assign(n,-1);}
  int root(int x){
    if(par[x]<0) return x;
    else return par[x]=root(par[x]);
  }
  bool issame(int x,int y){
    return root(x)==root(y);
  }
  bool merge(int x,int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(par[x]>par[y]) swap(x,y);
    par[x]+=par[y];
    par[y]=x;
    return true;
  }
  int size(int x){
    return -par[root(x)];
  }
};

int main(){
  itn n; cin >> n;
  vector<vector<edge> > g(n,vector<edge>(0));
  vector<vector<int> > g2(n,vector<int>(0));
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back({b,1});
    g[b].push_back({a,1});
    g2[a].push_back(b);
    g2[b].push_back(a);
  }
  vector<ll> dist=dijkstra(n,g,0);
  //cout << dist[n-1] << endl;
  vector<int> path=get_path(n-1);
  itn cutv1=path[(path.size()-1)/2];
  itn cutv2=path[(path.size()+1)/2];
  unionfind uf(n);
  rep(i,n){
    for(auto j:g2[i]){
      if((i==cutv1&&j==cutv2)||i==cutv2&&j==cutv1) continue;
      uf.merge(i,j);
    }
  }
  if(uf.size(0)>uf.size(n-1)) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}

Measured memory_bytes: 21560
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#include <numeric>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET{IOSET(){cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    double left = 0, right = 10000000000;
    rep(i, 200) {
        double mid = (right + left) / 2, cnt = 0;
        rep(i, n) {
            cnt += ceil(a[i] / mid) - 1;
        }
        if (cnt > k) left = mid;
        else right = mid;
    }
    
    ll ans = ceil(right);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3988
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  case class Restaurant(num: Int, city: String, score: Int)

  def solve(sc: Scanner): String = {
    val n = sc.nextInt()
    val evaluations = Vector.fill(n)((sc.next(), sc.nextInt())) // (市名, 評価点)
    val restaurants = evaluations.zipWithIndex.map { case ((city, score), i) => Restaurant(i + 1, city, score) }
    debug(n, evaluations)

    val cities = evaluations.map(_._1).sorted.distinct // Vector(kazan, khabarovsk, moscow)

    val restaurantNumBuf = ArrayBuffer.empty[Int]

    cities.foreach { city =>
      restaurants.filter(_.city == city).sortBy(_.score).reverse.foreach { restaurant =>
        restaurantNumBuf += restaurant.num
      }
    }
    debug(restaurantNumBuf)

    restaurantNumBuf.mkString("\n")
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 27352
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
  ll a, b, c, d, e, f;
  cin>>a>>b>>c>>d>>e>>f;
  a *= 100;
  b *= 100;
  ll anssug = 0;
  ll anstotal = a;
  repn(aa, 0, 100)
    repn(bb, 0, 100)
      repn(cc, 0, 100)
        repn(dd, 0, 100)
        {
          ll tw = a * aa + b * bb;
          ll ts = cc * c + dd * d;
          if((tw+ts) <= f)
          {
            if(ts*100 <= tw*e)
            {
              if((anssug*(tw + ts)) < (ts*anstotal))
              {
                anssug = ts;
                anstotal = tw + ts;
              }
            }
          }
        }
  cout<<anstotal<<" "<<anssug<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define Max 1 << 19
using namespace std;
int n,e,s[Max];
int r[Max][2];
bool cmp(int a,int b){
	return s[a] < s[b];
}
int main(){
	scanf("%d",&n);
	e = 1 << n;///总数个数
	for (int i = 0;i < e;i ++)
		scanf("%d",&s[i]);
	s[e] = -1;
	r[0][0] = 0;
	r[0][1] = e;
	for (int i = 1;i < e;i ++){
		r[i][0] = i;
		r[i][1] = e;
		int x[4];
		for (int j = 0;j < n;j ++)
			if (i & (1 << j)){///此位为1
				int d = i ^ (1 << j);///把这位变成0
				x[0] = r[i][0];
				x[1] = r[i][1];
				x[2] = r[d][0];
				x[3] = r[d][1];
				sort(x,x + 4,cmp);
				r[i][0] = x[3];
				r[i][1] = x[2] == x[3] ? x[1] : x[2];
			}
	}
	int mx = 0;
	for (int i = 1;i < e;i ++){
		mx = max(mx,s[r[i][0]] + s[r[i][1]]);
		printf("%d\n",mx);
	}
	return 0;
}


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

using F = double;

struct Robot {
  string nickname;
  vector<F> t, x, y, vx, vy;
};

int N, T, R;
vector<Robot> robot;

const F EPS = 1e-6;

vector<F> solve(F a, F b, F c) {
  if(a == 0) {
    if(b == 0) return {};
    else       return {-c / b};
  }
  F D = b * b - 4 * a * c;
  if(D < 0) return {};
  else      return {(-b - sqrt(D)) / (2 * a), (-b + sqrt(D)) / (2 * a)};
}

set<F> schedule() {
  set<F> res;

  for(auto r: robot) for(auto t: r.t) res.emplace(t);

  for(auto i = 0; i < N; ++i) for(auto j = 0; j < i; ++j) {
    auto& lhs = robot[i];
    auto& rhs = robot[j];

    for(auto a = 0; a + 1 < lhs.t.size(); ++a) for(auto b = 0; b + 1 < rhs.t.size(); ++b) {
      auto lx = lhs.x[a] - lhs.t[a] * lhs.vx[a];
      auto rx = rhs.x[b] - rhs.t[b] * rhs.vx[b];
      auto dx = lx - rx;

      auto ly = lhs.y[a] - lhs.t[a] * lhs.vy[a];
      auto ry = rhs.y[b] - rhs.t[b] * rhs.vy[b];
      auto dy = ly - ry;

      auto dvx = lhs.vx[a] - rhs.vx[b];
      auto dvy = lhs.vy[a] - rhs.vy[b];

      auto A = dvx * dvx + dvy * dvy;
      auto B = 2 * dx * dvx + 2 * dy * dvy;
      auto C = dx * dx + dy * dy - R * R;

      auto low  = max(lhs.t[a], rhs.t[b]);
      auto high = min(lhs.t[a + 1], rhs.t[b + 1]);

      for(auto t: solve(A, B, C)) if(low <= t + EPS && t <= high + EPS) res.emplace(t);
    }
  }

  return res;
}

multiset<string> solve() {
  vector<bool> ok(N);
  ok[0] = true;
  for(auto t: schedule()) {
    for(auto i = 0; i < N; ++i) for(auto j = 0; j < i; ++j) {
      if(!ok[i] && !ok[j]) continue;

      auto& lhs = robot[i];
      auto& rhs = robot[j];

      auto a = 0, b = 0;
      for(a = 0; a + 1 < lhs.t.size(); ++a) if(lhs.t[a] <= t + EPS && t <= lhs.t[a + 1] + EPS) break;
      for(b = 0; b + 1 < rhs.t.size(); ++b) if(rhs.t[b] <= t + EPS && t <= rhs.t[b + 1] + EPS) break;

      auto lx = lhs.x[a] + (t - lhs.t[a]) * lhs.vx[a];
      auto rx = rhs.x[b] + (t - rhs.t[b]) * rhs.vx[b];
      auto dx = lx - rx;

      auto ly = lhs.y[a] + (t - lhs.t[a]) * lhs.vy[a];
      auto ry = rhs.y[b] + (t - rhs.t[b]) * rhs.vy[b];
      auto dy = ly - ry;

      if(dx * dx + dy * dy <= R * R + EPS) ok[i] = ok[j] = true;
    }
  }

  multiset<string> res;
  for(auto i = 0; i < N; ++i) if(ok[i]) res.emplace(robot[i].nickname);
  return res;
}

int main() {
  while(cin >> N >> T >> R, N | T | R) {
    robot = vector<Robot>(N);

    for(auto& r: robot) {
      cin >> r.nickname;

      while(true) {
        int t, vx, vy;
        cin >> t >> vx >> vy;
        if(r.t.empty()) {
          r.x.emplace_back(vx);
          r.y.emplace_back(vy);
        } else {
          r.vx.emplace_back(vx);
          r.vy.emplace_back(vy);
          auto d = t - r.t.back();
          r.x.emplace_back(r.x.back() + d * vx);
          r.y.emplace_back(r.y.back() + d * vy);
        }
        r.t.emplace_back(t);
        if(t == T) break;
      }
    }

    for(auto s: solve()) cout << s << endl;
  }
}

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

int main()
{
    int N,K;
    string S;
    cin >> N >> K >> S;
    char tmp = S[K-1];
    tmp -= 'A';
    tmp += 'a';

    S[K-1] = tmp;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
A = []
V = []
B = []
for i in range(n):
    A.append(list(map(int, input().split())))
for j in range(m):
    V.append([int(input())])
for i in range(n):
    B.append([0])
    for j in range(m):
            B[i][0] += A[i][j] * V[j][0]
for i in range(n):
    print(B[i][0])

Measured memory_bytes: 8116
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=a; i<b; i++)
typedef long long ll;
#define MP make_pair

#define N 112345
pair<pair<int, int>, int> d[N];
int e[30], f[30];

int main(){
  int n, cs; scanf("%d%d", &n, &cs);
  REP(i, n){
    int s, t, c;
    scanf("%d%d%d", &s, &t, &c);
    d[i]=MP(MP(s*2,t*2),c-1);
  }
  sort(d, d+n);
  fill(e, e+30, 0);
  int ans=0;
  REP(i, n){
    int s=d[i].first.first, t=d[i].first.second, c=d[i].second;
    REP(j, 30){
      if(e[j]<=s-1 || (e[j]<=s && f[j]==c)){
        e[j]=t;
        f[j]=c;
        ans=max(ans, j+1);
        break;
      }
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1536
from collections import defaultdict
import heapq

a_dict = defaultdict(lambda: [])
n, m = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a_dict[a].append(-b)
ans = 0
heap_list = []
for i in range(1, m + 1):
    for aa in a_dict[i]:
        heapq.heappush(heap_list, aa)
    if len(heap_list) > 0:
        ans -= heapq.heappop(heap_list)
print(ans)

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

class UnionFind {
public:
vector<int> Parent;

UnionFind(int N) {
  Parent = vector<int>(N, -1);
}

int root(int A) {
  if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }

int size(int A) {
  return -Parent[root(A)];
}

bool connect(int A, int B) {
  A = root(A);
  B = root(B);
  if (A == B) {
    return false;
  }
  if (size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
};

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

  vector<int> p(n+1);
  for (int i = 1; i <= n; i++)
  {
    cin >> p[i];
  }

  UnionFind uni(n+1);
  for (int i = 0; i < m; i++)
  {
    int x,y;
    cin >> x >> y;
    uni.connect(x,y);
  }

  int ans=0;
  for (int i = 1; i <= n; i++)
  {
    if(uni.root(i)==uni.root(p[i])) ans++;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	char s[100001];
	scanf("%s", s);
	int n, count = 0;
	for (n = 0; s[n] != 0; n++) if (s[n] == 'p') count++;
	printf("%d\n", n / 2 - count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, m;
    cin>>n>>m;
    cout<<(((n*(n-1))/2) + ((m*(m-1))/2));
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;
#define _ << " " <<

int main() {
    ll n, q;
    string s;
    cin >> n >> s >> q;

    for (int i = 0; i < q; i++) {
        ll k;
        cin >> k;

        ll ans = 0, dp[3] = {0, 0, 0};
        ll sm[3] = {0, 0, 0};
        for (int j = 0; j < k; j++) {
            if (char(s[j]) == 'D') {
                dp[0]++;  sm[0]++;
            }
            if (char(s[j]) == 'M') {
                dp[1] += dp[0];  sm[1]++;
            }
            if (char(s[j]) == 'C') {
                dp[2] += dp[1];  sm[2]++;
            }
        }
        ans += dp[2];
        //cerr << sm[0] _ sm[1] _ sm[2] _ dp[0] _ dp[1] _ dp[2] _ ans << endl;

        for (int j = k; j < n; j++) {
            dp[2] = 0;
            if (char(s[j - k]) == 'D') {
                dp[0]--;  dp[1] -= sm[1];  sm[0]--;
            }
            if (char(s[j - k]) == 'M') {
                sm[1]--;
            }
            if (char(s[j - k]) == 'C') {
                sm[2]--;
            }

            if (char(s[j]) == 'D') {
                dp[0]++;  sm[0]++;
            }
            if (char(s[j]) == 'M') {
                dp[1] += dp[0];  sm[1]++;
            }
            if (char(s[j]) == 'C') {
                dp[2] = dp[1];  sm[2]++;
            }
            ans += dp[2];
            //cerr << sm[0] _ sm[1] _ sm[2] _ dp[0] _ dp[1] _ dp[2] _ ans << endl;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 1412
def ume(n):
  st = str(n)
  le = len(st)
  re = ["0"]*le
  for i in range(le):
    if st[i]=="0":
      re[i]=str(m)
    else:
      re[i]=st[i]
  return int("".join(re))


n, k = map(int, input().split())
d = list(map(int, input().split()))
num = []

#使える文字をリスト化
for i in range(10):
  if not i in d:
    num.append(i)

ds = str(n)#nを文字列にしたもの
l = len(ds)#nの桁数
m = min(num)#numのうち最小の数

if l == 1:
  for i in num:
    if i>=n:
      print(i)
      quit()

dp1=[0]*(l+1)

for i in num:
  if i != 0:
    ans = ume(i*(10**(l)))
    break

for i in num:
  flg = True
  if i == int(ds[0]):
    dp1[1]=i*(10**(l-1))
    flg = False
  if i > int(ds[0]):
    ans = ume(i*(10**(l-1)))
    break
    
if flg:
  print(ans)
  quit()

for i in range(1, l):
  flg = True
  flg2 = True
  for j in num:
    if j == int(ds[i]):
      dp1[i+1]=dp1[i]+j*(10**(l-1-i))
      flg = False
      flg2 = False
      break
    if j > int(ds[i]):
      flg2 = False
      ans = ume(dp1[i]+j*(10**(l-1-i)))
      if flg:
        print(ans)
        quit()
      break
  if flg2:
    print(ans)
    quit()
  #print(dp1[i+1])
print(dp1[l])

Measured memory_bytes: 9128
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().ToCharArray().Select(c => int.Parse(c.ToString()));
            var ans = 0;

            foreach (var i in input)
            {
                ans = (ans + i) % 9;
            }

            Console.WriteLine(ans == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 33436
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

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

long euclid(long c, long d){ // 最大公約数を求めるプログラム
    long mx = max(c,d);
    long mi = min(c,d);
    long tmp=0;
    while(mi > 0){
        tmp = mx % mi;
        if(tmp==0){
            return mi;
        } else{
            mx = mi;
            mi = tmp;
        }
    }
    return 1;
} 

int main() {
  int N;
  cin >> N;
  vector<long> a(N);
  
  rep(i, N){
    cin >> a[i];
  }

  long min_num = euclid(a[N-1], a[0]);
  long tmp, index = 0;
  for(int i = 1; i < N; i++){
    tmp = euclid(a[i-1], a[i]);
    if(tmp <= min_num){
      index = i;
      min_num = tmp;
    }
  }


  vector<long> b;
  vector<long> c;
  // index番目
  rep(i, N) {
    if (i == index) continue;
    else {
      b.push_back(a[i]);
    }
  }

  // indexの前後
  if (index == 0) { // この場合はN-1番目がいらない
    for(int i = 0; i < N-1; i++){
      c.push_back(a[i]);
    }
  } else {
    for(int i = 0; i < N; i++){
      if (i == index-1) continue;
      else {
        c.push_back(a[i]);
      }
    }
  }

  int count = 0;
  for(int i = 1; i < N; i++){ // min_num自身が最小の場合
    tmp = euclid(a[i], min_num);
    if(tmp != min_num){
      count++;
    }
  }


  long b_ans, c_ans;
  // 最初の一つ目
  b_ans = euclid(b[N-2], b[0]);
  c_ans = euclid(c[N-2], c[0]);
  for(int i = 0; i < N-2; i++){
    b_ans = euclid(b_ans, b[i]);
    c_ans = euclid(c_ans, c[i]);
  }

  if (count == 1){
    b_ans = max(min_num, b_ans);
  }
  
  cout << max(b_ans, c_ans) << endl;

}


Measured memory_bytes: 3316
#include <stdio.h>
#define FOUND 1
#define NOT_FOUND 0
#define MAX 100000
#define max 50000

int n;
int binarySearch(int *,int);

int main(){

    int S[MAX],T[max],q,count,i;

    scanf("%d",&n);
    for( i = 0; i < n; i++) scanf("%d",&S[i]);
    scanf("%d",&q);
    for( i = 0; i < q; i++){
        scanf("%d",&T[i]);
        if(binarySearch(S,T[i]) == FOUND) count++;
    }

        printf("%d\n",count);
        return 0;
}

int binarySearch(int *A,int key){

    int Left = 0,Right = n,mid;

    while( Left < Right ){
        mid = ( Left + Right ) / 2;
        if(A[mid] == key) return FOUND;
        else if(key < A[mid]) Right = mid;
        else Left = mid + 1;
    }

    return NOT_FOUND;
}

Measured memory_bytes: 1184
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#define N 200010
#define ll long long
using namespace std;

ll T[N * 8], tag[N * 8];
#define ls id<<1
#define rs id<<1|1
void add(int id, ll x) {tag[id] += x, T[id] += x;}
void pushdown(int id) {
	if (tag[id] == 0)return;
	add(ls, tag[id]), add(rs, tag[id]);
	tag[id] = 0;
}
void upd(int l, int r, int id, int L, int R, ll x) {
	if (L <= l && r <= R) {add(id, x); return;}
	pushdown(id);
	int m = (l + r) >> 1;
	if (L <= m)upd(l, m, ls, L, R, x);
	if (R > m)upd(m + 1, r, rs, L, R, x);
	T[id] = max(T[ls], T[rs]);
}

ll Q(int l, int r, int id, int L, int R) {
	if (L <= l && r <= R)return T[id];
	pushdown(id);
	int m = (l + r) >> 1; ll res = 0;
	if (L <= m)res = max(res, Q(l, m, ls, L, R));
	if (R > m)res = max(res, Q(m + 1, r, rs, L, R));
	return res;
}

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
struct info {int l, x;};
vector<info> A[N];
int main() {
	int n = read();
	for (int o = read(); o--;) {
		int l = read(), r = read(), x = read();
		A[r].push_back((info) {l, x});
	}
	for (int i = 1; i <= n; ++i) {
		upd(1, n, 1, i, i, Q(1, n, 1, 1, i));
		for (info t : A[i])upd(1, n, 1, t.l, i, t.x);
	}
	printf("%lld\n", max(T[1], 0ll));
	return 0;
}


Measured memory_bytes: 22912
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-10-6 21:19:14
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int ans = 1;

int main()
{
  cin >> N >> M;

  for (auto i = 1; i < 100010; i++)
  {
    if (M % i == 0)
    {
      int x[2] = {i, M / i};
      for (auto k = 0; k < 2; k++)
      {
        int g = x[k];
        int n = M / g;
        if (n >= N)
        {
          ans = max(ans, g);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int X,N,p,v;
	int min=10000,id=0;
	bool a[301]={0};
	cin>>X>>N;
	for(int i=0;i<N;i++){
		cin>>p;
		a[p]=true;
	}
	for(int i=-300;i<=300;i++){
		if(i>=0 && a[i])continue;
		v = X-i;
		if(v<0)v*=-1;
		if(v<min){
			min=v;
			id = i;
		}
	}
	cout<<id;
	return 0;
}

Measured memory_bytes: 3612
#ifdef local_mode
    #include <cstdio>
    #include <cassert>
#endif
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
#ifdef local_mode
    ios_base::sync_with_stdio(0), cin.tie(0);
    assert(freopen("in", "r", stdin));
    assert(freopen("out", "w", stdout));
#endif
    
    int n;
    cin >> n;
    char a[n][n];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    int ans = 0;
    for (int d = 0; d < n; d++) {
        bool good = true;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (a[(i + d) % n][j] != a[(j + d) % n][i])
                    good = false;
        if (good) ans += n;
    }
    cout << ans;
    
    return 0;
}







































Measured memory_bytes: 384
n = int(input())
H = list(map(int,input().split()))
inf = float('INF')
dp = [inf]*n
dp[0] = 0
for i in range(1,n):
    if i != 1:dp[i]=min(dp[i],dp[i-2]+abs(H[i]-H[i-2]))

    dp[i]=min(dp[i],dp[i-1]+abs(H[i]-H[i-1]))

print(dp[-1])

Measured memory_bytes: 13928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_034
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nabcd = ReadInts();
            int n = nabcd[0];
            int a = nabcd[1]-1;
            int b = nabcd[2]-1;
            int c = nabcd[3]-1;
            int d = nabcd[4]-1;
            string s = Read();

            int notSeqCnt = 0;
            int nowNotCnt = 0;
            for(int i = a; i <= Max(c,d); i++)
            {
                if (s[i] == '.')
                {
                    nowNotCnt = 0;
                }
                else
                {
                    nowNotCnt++;
                    notSeqCnt = Max(notSeqCnt, nowNotCnt);
                }
            }

            if (notSeqCnt > 1)
            {
                WriteLine("No");
                return;
            }

            if (c < d)
            {
                WriteLine("Yes");
                return;
            }

            int canSeqCnt = 0;
            int nowCanCnt = 0;
            for (int i = b - 1; i <= d + 1; i++)
            {
                if (s[i] == '.')
                {
                    nowCanCnt++;
                    canSeqCnt = Max(canSeqCnt, nowCanCnt);
                }
                else
                {
                    nowCanCnt = 0;
                }
            }
            if (canSeqCnt >= 3)
            {
                WriteLine("Yes");
            }
            else WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main(void){
    int x;
    int max = 1;
    cin >> x;
    for(int i = 2;i*i <= x;i++){
        int j = 1;
        for(j = 1;j*i <= x;){
            j *=i;
        }
        if(max < j)max = j;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
int x=0,y=0,z=0;
std::cin >> x;
std::vector<int> v(9,0);
rep(i,x){
  std::cin >> y;
  if(y<400)v[0]++;
  else if(y<800)v[1]++;
  else if(y<1200)v[2]++;
  else if(y<1600)v[3]++;
  else if(y<2000)v[4]++;
  else if(y<2400)v[5]++;
  else if(y<2800)v[6]++;
  else if(y<3200)v[7]++;
  else v[8]++;
}
rep(i,8){
  if(v[i]>0)z++;
}
if(z==0)  std::cout << 1<<" "<<v[8]<< '\n';
else  std::cout << z<<" "<<z+v[8]<< '\n';
}


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

typedef long long ll;
using namespace std;

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

    int n = 2;
    while (true) {
        bool ok = true;
        for (int i = 2; i < n; ++i) {
            if (n % i == 0) {
                ok = false;
                break;
            }
        }
        if (ok && x <= n) {
            cout << n;
            return 0;
        }
        n++;
    }
}


Measured memory_bytes: 256
n = int(input())
t = list(map(int,input().split()))
a = list(map(int,input().split()))
MOD = 10**9 + 7

m_left =[[1,t[0]]]
for i in range(1,n):
    if t[i] > t[i-1]:
        m_left.append([1,t[i]])
    else:
        m_left.append([0,t[i]])

m_right = [[1,a[n-1]]]
for i in range(n-2,-1,-1):
    if a[i] > a[i+1]:
        m_right.append([1,a[i]])
    else:
        m_right.append([0,a[i]])
m_right = m_right[::-1]
#print(m_left)
#print(m_right)

ans = 1
for i in range(n):
    if m_right[i][0] == 1 and m_left[i][0] == 1:
        if m_right[i][1] != m_left[i][1]:
            ans = 0
    elif m_right[i][0] == 1:
        if m_right[i][1] > m_left[i][1]:
            ans = 0
    elif m_left[i][0] == 1:
        if m_left[i][1] > m_right[i][1]:
            ans = 0
    else:
        ans *= min(m_right[i][1], m_left[i][1])
        ans %= MOD

print(ans)


Measured memory_bytes: 105444