akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

void solve() {
    int t;
    cin >> t;
    while (t--) {
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n, m, a, b) << "\n";
    }
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3644
#include<iostream>
#define INF 10000000;
using namespace std;

int main() {
	int towns[10][10]; 
	int n;
	while (1) {
		cin >> n;
		if (!n)break;

		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				towns[i][j] = INF;
			}
		}
		for (int i = 0; i < 10; i++) {
			towns[i][i] = 0;
		}
		int biggest_town = 0;
		int a, b, c;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			if (biggest_town < a)biggest_town = a;
			if (biggest_town < b)biggest_town = b;
			towns[a][b] = c;
			towns[b][a] = c;
		}

		for (int k = 0; k < 10; k++) {
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					if (towns[i][j] > towns[i][k] + towns[k][j]) {
						towns[i][j] = towns[i][k] + towns[k][j];
					}
				}
			}
		}
		int start, total_time = 100000;
		for (int i = 0; i <= biggest_town; i++) {
			int tmp = 0;
			for (int j = 0; j <= biggest_town; j++) {
				if (towns[i][j] != 10000000)tmp += towns[i][j];
			}
			if (total_time > tmp) {
				total_time = tmp;
				start = i;
			}
		}
		cout << start << ' ' << total_time << endl;
	}
}


Measured memory_bytes: 3100
package main

import (
	"fmt"
	//"sort"
	"strconv"
	//"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	a, _ := strconv.Atoi(s)
	l := a/100
	r := a%100
	if 1 <= l && l <= 12{
		if 1 <= r && r <= 12{
			fmt.Print("AMBIGUOUS")
		}else{
			fmt.Print("MMYY")
		}
	} else {
		if 1 <= r && r <= 12{
			fmt.Print("YYMM")
		}else {
			fmt.Print("NA")
		}
	}
}

Measured memory_bytes: 512
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make2(string,s,t);
    ll n=s.length(); ll m=t.length(); bool flag=0;
    fr(i,n){
        fr(j,m){
            if(s[i]<t[j]) flag=1;
        }
    }
    unordered_map <ll,ll> um1,um2;
    fr(i,n) um1[s[i]]=1;
    fr(j,m) um2[t[j]]=1;
    ll f=0;
    for(auto x : um1) f++;
    if(flag || (um1==um2 && f==1 && n<m)) cout<<"Yes \n";
    else cout<<"No \n";

    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
// ------------------------
void solve() {
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;

    if(S == U) --A;
    if(T == U) --B;

    cout << A << " " << B << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
n,a=map(int,input().split())
x=list(map(int,input().split()))

for i in range(n):
    x[i]=x[i]-a
    
nx=n*n
dp=[[0]*(2*nx+1) for i in range(n+1)]

#print(dp)

dp[0][nx]=1

for j in range(1,n+1):
    jj=j-1
    for t in range(2*nx+1):
        if t-x[jj]<0 or 2*nx<t-x[jj]:
            dp[j][t]=dp[j-1][t]
        elif 0<t-x[jj] and  t-x[jj]<2*nx:
            dp[j][t]=dp[j-1][t]+dp[j-1][t-x[jj]]
        else:
            dp[j][t]=0

print(dp[n][nx]-1)
        


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int look_site(int i, int j, int H, int W){
    
    if (i < 0) return 0;
    if (j <0) return 0;
    if (i>=H)return 0;
    if (j >= W) return 0;
    
    return 1;
    
}


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

    
    
    
    int K = in();

    
    vector<string> inp;
    
    set<string,greater<string> > st;
    
    string largest;
    
    string temp;
    
    for(auto i = 0; i < s.size(); i++){   /// si.... sj
        
        for(auto j = i+1; j<= s.size();j++){
            temp = s.substr(i,(j-i));
            
            if (st.size() == K && temp > *st.begin()) break;
            
            st.insert(temp);
            
            while(st.size()>K){
                st.erase(st.begin());
            }
        }
    }
    
    
    cout << *st.begin() << endl;
    
    return 0;
}









Measured memory_bytes: 256
from collections import deque

A = deque([])

for i in range(int(input())):
    a = [int(j) for j in input().split()]
    if a[0] == 0:
        if a[1] == 0:
            A.insert(0,a[2])
        elif a[1] == 1:
            A.append(a[2])
    elif a[0] == 1:
        print(A[a[1]])
    elif a[0] == 2:
        if a[1] == 0:
            A.popleft()
        else:
            A.pop()
            



Measured memory_bytes: 21860
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int a[111111];

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  for (int i = 0; i < q; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    a[tmp]++;
  }
  for (int i = 0; i < n; i++) {
    if (k - (q - a[i]) > 0)
      cout << "Yes" << endl;
    else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
	int number;
	double weight,height,bmi;
	
	while(scanf("%d,%lf,%lf",&number,&weight,&height)!=EOF){
		bmi=weight/height/height;
		if(bmi>=25.0){
			printf("%d\n",number);
		}
	}
	
	return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
using namespace std;


int partition(int *A, int p, int r){
	int x = A[r];
	int i = p-1;
	for(int j = p; j <= r-1; j++){
		if(A[j] <= x){
			swap(A[j], A[++i]);
		}
	}
	swap(A[r], A[++i]);
	return i;
}

int main() {
	int n;
	scanf("%d", &n);
	
	int d[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &d[i]);
	}
	
	int kijun = partition(d, 0, n-1);
	for(int i = 0; i < n; i++){
		printf(i==kijun ? "[%d]%c" : "%d%c", d[i], i+1==n ? '\n' : ' ');
	}
	
    return 0;
}

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

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  if(A>B){
    cout<<"0"<<endl;
    return 0;
  }
  if(N==1&&(B-A)!=0){
    cout<<"0"<<endl;
    return 0;
  }
  cout<<(B-A)*(N-2)+1<<endl;
  return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

def mi():
    return map(int, input().split())

def main():
    N = int(input())
    dic = {}
    ans = 1
    for i in range(1, N+1):
        for v in prime_decomposition(i):
            if not v in dic:
                dic[v] = 0
            dic[v] += 1

    for v in dic.values():
        ans *= (v+1)
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 41436
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmin(T &a, T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	vector<int> A(M);
	vector<int> C(M);
	for (int i = 0; i < M; i++) {
		int b;
		cin >> A[i] >> b;
		for (int j = 0; j < b; j++) {
			int c;
			cin >> c;
			C[i] += (1 << (c - 1));
		}
	}
	DMP(A, C);

	auto dp = make_vec(M + 1, (1 << N), INF);
	dp[0][0] = 0;
	for (int i = 0; i < M; i++) {
		for (int bit = 0; bit < (1 << N); bit++) {
			chmin(dp[i + 1][bit], dp[i][bit]);
			chmin(dp[i + 1][bit | C[i]], dp[i][bit] + A[i]);
		}
	}

	if (dp[M][(1 << N) - 1] == INF) cout << -1 << "\n";
	else cout << dp[M][(1 << N) - 1] << "\n";

	return 0;
}

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

int main(){
	int n;
  cin>>n;
  vector<vector<int> > cards(4, vector<int>(13));
  char mark;
  int num;
  rep(i,n){
    cin >> mark >> num;
    if (mark == 'S') cards.at(0).at(num-1) = 1;
    if (mark == 'H') cards.at(1).at(num-1) = 1;
    if (mark == 'C') cards.at(2).at(num-1) = 1;
    if (mark == 'D') cards.at(3).at(num-1) = 1;
  }
  rep(i,4){
    rep(j,13){
      if (cards.at(i).at(j) == 0){
        if (i==0) printf("S %d\n", j+1);
        if (i==1) printf("H %d\n", j+1);
        if (i==2) printf("C %d\n", j+1);
        if (i==3) printf("D %d\n", j+1);
      }
    }
  }
  
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
//#ifndef OJ
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	int n;
	cin >> n;
	ll a;
	ll b;
	cin >> a >> b;
	ll ans = __gcd(a, b);
	n -= 2;
	while (n--)
	{
		cin >> a;
		ans = __gcd(ans, a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

ll dp[85];

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    dp[0] = 1000;
    REP(i,n+1) {
        chmax(dp[i],dp[i-1]);
        for (int j = 1; j < i; j++) {
            ll n_stock = dp[j]/a[j-1];
            chmax(dp[i],n_stock*a[i-1]+dp[j]-n_stock*a[j-1]);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std; 
const int N = 1e5 + 5, M = (1 << 15);
int val[N], cnt[N], sum[M], f[M];
int main() {
	int n; scanf("%d", &n); 
    for (int i = 1; i < n; ++i) {
        int x, y, z; scanf("%d%d%d", &x, &y, &z); 
        val[++x] ^= z, val[++y] ^= z; 
    }
    for (int i = 1; i <= n; ++i) cnt[val[i]]++; 
    int ans = n - cnt[0], mask = 0;
    for (int i = 1; i <= 15; ++i) {
        ans -= cnt[i] / 2 ; 
        mask |= (cnt[i] & 1) << (i - 1); 
    }
    for (int i = 0; i < (1 << 15); ++i) 
        for (int j = 1; j <= 15; ++j) 
            if (i & (1 << (j - 1))) sum[i] ^= j; 
    for (int i = 1; i < (1 << 15); ++i) 
        for (int j = i; j; j = (j - 1) & i) 
            if (!sum[i]) f[i] = max(f[i], f[i ^ j] + 1); 
    printf("%d\n", ans - f[mask]); 
    return 0; 
}


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClarss
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] io = Input();
		int[] p = new int[n];
		int[] p2 = new int[n];
		for(int i = 0; i < n; i++)
		{
			p[i] = int.Parse(io[i]);
			p2[i]=p[i];
		}
		
		Array.Sort(p);
		
		int r=0;
		for(int i = 0; i < n;i++)
		{
			if(p2[i]!=p[i])
				r++;
		}
		if(r<=2)
		{
			Console.WriteLine("YES");
		}
		else
			Console.WriteLine("NO");
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 11092
from itertools import product


def solve(string):
    n, a, b, c, *l = map(int, string.split())
    ans = 3000
    for p in product(range(4), repeat=n):
        if not ({0, 1, 2} <= set(p)):
            continue
        sums = [0, 0, 0, 0]
        for _p, _l in zip(p, l):
            sums[_p] += _l
        mp12 = sum(abs(_s - _abc) for _s, _abc in zip(sums[:3], [a, b, c]))
        mp3 = sum(1 for _p in p if _p < 3) - 3
        ans = min(ans, mp12 + mp3 * 10)
    return str(ans)


if __name__ == '__main__':
    n, a, b, c = map(int, input().split())
    print(solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([input() for _ in range(n)])))


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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int b[NN];
int n, m, k;
string s;


integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    map<string, int> M;
    for (int i = 0; i < n; i++){
        cin >> s;
        M[s]++;
    }
    cout << "AC x " << M["AC"] << endl;
    cout << "WA x " << M["WA"] << endl;
    cout << "TLE x " << M["TLE"] << endl;
    cout << "RE x " << M["RE"] << endl;


}

//2 9 1 1 2 4 4 2 9

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int sum = 0;
	int ans = INF;
	vector<int> A;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		sum += A[i];
	}
	
	int sum2 = 0;
	for(int i = 0; i < N-1; i++){
		int con2 = N - i - 1;
		sum2 += A[i];
		
		ans = min((int)abs(sum - sum2 - sum2), ans);
		
	}
	
	
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]

T.sort()
i = 0
ans = 0
time =0
p = 0

for i in range(N):
 
    if  p==0 or p ==C:
        ans = ans+1
        p =1
        time =T[i]+K
    elif p<C :
        if T[i]<=time:
            p +=1
        elif T[i]>time:
            ans =ans+1
            time=T[i]+K
            p =1

print(ans)
        

Measured memory_bytes: 7388
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import           Text.Printf

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

--

newtype VDouble =
    VDouble Double
    deriving (Show, Read, Num, Floating, Fractional)

instance Eq VDouble where
    VDouble a == VDouble b = abs (a - b) < 1e-10

instance Ord VDouble where
    VDouble a `compare` VDouble b
        | VDouble a == VDouble b = EQ
        | a <  b                 = LT
        | otherwise              = GT

--

newtype V2 =
    V2 (VDouble, VDouble)
    deriving (Show)

(|+|) :: V2 -> V2 -> V2
V2 (a, b) |+| V2 (c, d) = V2 (a + c, b + d)

(|-|) :: V2 -> V2 -> V2
V2 (a, b) |-| V2 (c, d) = V2 (a - c, b - d)

(*|) :: VDouble -> V2 -> V2
k *| V2 (c, d) = V2 (k * c, k * d)

norm :: V2 -> VDouble
norm (V2 (a, b)) = a * a + b * b

abs' :: V2 -> VDouble
abs' = sqrt . norm

dot :: V2 -> V2 -> VDouble
V2 (a, b) `dot` V2 (c, d) = a * c + b * d

cross :: V2 -> V2 -> VDouble
V2 (a, b) `cross` V2 (c, d) = a * d - b * c

--

data Wise
    = COUNTER_CLOCKWISE
    | CLOCKWISE
    | ONLINE_BACK
    | ONLINE_FRONT
    | ON_SEGMENT
    deriving (Show)

w2i :: Wise -> Int
w2i COUNTER_CLOCKWISE = 1
w2i CLOCKWISE         = -1
w2i ONLINE_BACK       = 2
w2i ONLINE_FRONT      = -2
w2i ON_SEGMENT        = 0

ccw :: V2 -> V2 -> V2 -> Wise
ccw p0 p1 p2
    | cross a b > 0   = COUNTER_CLOCKWISE
    | cross a b < 0   = CLOCKWISE
    | dot a b < 0     = ONLINE_BACK
    | norm a < norm b = ONLINE_FRONT
    | otherwise       = ON_SEGMENT
  where
    a = p1 |-| p0
    b = p2 |-| p0

intersect :: V2 -> V2 -> V2 -> V2 -> Bool
intersect p0 p1 p2 p3 = b1 && b2
  where
    b1 = w2i (ccw p0 p1 p2) * w2i (ccw p0 p1 p3) <= 0
    b2 = w2i (ccw p2 p3 p0) * w2i (ccw p2 p3 p1) <= 0

main :: IO ()
main = do
    q <- readLn
    replicateM_ q $ do
        [a, b, c, d, e, f, g, h] <-
            fmap (fromIntegral . readi) . B.words <$> B.getLine
        let p0 = V2 (a, b)
        let p1 = V2 (c, d)
        let p2 = V2 (e, f)
        let p3 = V2 (g, h)
        if intersect p0 p1 p2 p3
            then putStrLn "1"
            else putStrLn "0"



Measured memory_bytes: 4284
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>

int main(){
  std::string S;
  std::cin >> S;
  
  if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]){
    std::cout << "Yes" << std::endl;
  }
  else if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1]){
    std::cout << "Yes" << std::endl;
  }
  else if(S[0] == S[3] && S[1] == S[2] && S[0] != S[2]){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int h, w, k, a[505][505];
int b[250005], c[250005], d[250005],e[250005];
int main() {
	int i, j;
	scanf("%d%d", &h, &w);
	for(i=1; i<=h; i++) for(j=1; j<=w; j++) scanf("%d", &a[i][j]);
	for(i=1; i<=h; i++) for(j=1; j<w; j++) if(a[i][j]%2) {
		a[i][j+1]++, b[k]=i, c[k]=j, d[k]=i, e[k]=j+1, k++;
	}
	for(i=1; i<h; i++) if(a[i][w]%2) {
		a[i+1][j]++, b[k]=i, c[k]=j, d[k]=i+1, e[k]=j, k++;
	}
	printf("%d\n", k);
	for(i=0; i<k; i++) printf("%d %d %d %d\n", b[i], c[i], d[i], e[i]);
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
	string s, t;
	cin  >> s >> t;
	vector<vector<ll>> dp(s.size(), vector<ll>(26, INF));
	for(ll i = s.size() - 1 ; i > 0; i--)  {
		REP(j, 26) {
			dp[i-1][j] = dp[i][j];
		}
		ll a = s[i] - 'a';
		dp[i-1][a] = i;
	}

	REP(i, 26) {
		dp[s.size()-1][i] = dp[0][i];
	}
	dp[s.size() - 1][s[0] - 'a'] = 0;

	ll cur = s.size()-1;
	ll cnt = 0;
	REP(i, t.size()) {
		if (cur == s.size() -1 && dp[cur][t[i]-'a'] == INF) {
			PRINT(-1);
			return 0;
		}
		if (dp[cur][t[i]-'a'] != INF) {
			if (cur == s.size() - 1) {
				cnt += dp[cur][t[i]-'a']+1;
			} else {
				cnt += dp[cur][t[i]-'a'] - cur;
			}
			cur = dp[cur][t[i]-'a'];
		} else {
			cnt += s.size()-1 - cur;
			cur = s.size()-1;
			i--;
		}
	}
	PRINT(cnt);

	// REP(j, 26) {
	// 	REP(i, s.size()) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }


	return 0;
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	sort (a + 1, a + n + 1);
	cout << a[n/2+1] - a[n/2];




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<iostream>
#include<sstream>
using namespace std;
typedef long long ll;

int main(){
    string se;
    cin>>se;
    int n;
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++){
        string ins;
        cin>>ins;
        ins+=ins;
        if(ins.find(se)!=string::npos)sum++;
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 0
N = int(input())
c = [0 for i in range(101)]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

for i in range(2,N+1):
    factors = prime_factorize(i)
    for factor in factors:
        c[factor] += 1
c = [e+1 for e in c]

ans = 0
#75 = 5*5*3
more75 = len(list(filter(lambda x:x>=75,c)))
more25 = len(list(filter(lambda x:x>=25,c)))
more15 = len(list(filter(lambda x:x>=15,c)))
more5 = len(list(filter(lambda x:x>=5,c)))
more3 = len(list(filter(lambda x:x>=3,c)))

ans += more75
if more25:
    ans += more25*(more3-1)
if more15:
    ans += more15*(more5-1)
if more5 >= 2 and more3 >= 3:
    ans += (more3-2)*(more5*(more5-1))//2
print(ans)



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

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

    int count = 0;

    if(s[0] == '1'){
        ++count;
    }
    if(s[1] == '1'){
        ++count;
    }
    if(s[2] == '1'){
        ++count; 
    }
    cout << count << endl;
}

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

int main(){
    string s;
    cin >> s;
    if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3)){
        cout << "Bad" << endl;
        return 0;
    }
    cout << "Good"<< endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0) cout<<(a+b)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;

  return 0;
}


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

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  int c1 = ((x + 999) / 1000) * a;
  int c2 = (x / 1000) * a + ((x % 1000 + 499) / 500) * b;
  int c3 = ((x + 499) / 500) * b;
  cout << min({ c1,c2,c3 }) << "\n";
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }
ll a, b, c, d, ans;

int main()
{
    cin >> a >> b >> c >> d;
    a--;
    ll l = lcm(c, d);
    ans = (b - b / c - b / d + b / l) - (a - a / c - a / d + a / l);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main(){

    int K; cin >> K; K--;
    Out(a[K]);

    return 0;
}


Measured memory_bytes: 764
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String S  = keyboard.next();
		
		String X1 = S.replace('A', '#');
		String X2 = X1.replace('T', '#');
		String X3 = X2.replace('G', '#');
		String X4 = X3.replace('C', '#');
		X4 = X4 + "?"; 
		String[] Y = X4.split("");
		
		int count = 0;
		int ans = 0;
		
		for(int i = 0; i<X4.length(); i++){
			if(Y[i].equals("#")){
				count++;
			}else{
				ans = (count > ans) ? count : ans;
				count = 0;
					}
			}

		System.out.println(ans);
		keyboard.close();	
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int n,u,v,lab[N];
VI e[N],par[2];
queue<int> q[3];
void dfs(int u,int f,int d) {
	par[d].pb(u);
	for (auto v:e[u]) {
		if (v==f) continue;
		dfs(v,u,d^1);
	}
}

int main() {
	scanf("%d",&n);
	rep(i,1,n) {
		scanf("%d%d",&u,&v);
		e[u].pb(v); e[v].pb(u);
	}
	dfs(1,0,0);
	int x=n/3;
	if (SZ(par[0])>SZ(par[1])) swap(par[0],par[1]);
	rep(i,1,n+1) q[i%3].push(i);
	if (SZ(par[0])<=n/3) {
		for (auto x:par[0]) {
			lab[x]=q[0].front();
			q[0].pop();
		}
		for (auto x:par[1]) {
			rep(j,0,3) if (!q[j].empty()) {
				lab[x]=q[j].front();
				q[j].pop();
				break;
			}
		}
	} else {
		for (auto x:par[1]) {
			if (!q[1].empty()) {
				lab[x]=q[1].front();
				q[1].pop();
			} else {
				lab[x]=q[0].front();
				q[0].pop();
			}
		}
		for (auto x:par[0]) {
			if (!q[2].empty()) {
				lab[x]=q[2].front();
				q[2].pop();
			} else {
				lab[x]=q[0].front();
				q[0].pop();
			}
		}
	}
	rep(i,1,n+1) printf("%d ",lab[i]); puts("");
}


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

int main(){
    typedef long long ll;
    ll n, ans, count=0,temp;
    cin >> n;
    vector<ll> A(n);

    for(ll i=0;i<n;i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    while(count+1<n){
        while(A[count+1]!=0){
            A[count+1] = A[count+1]%A[0];
            if(A[0]>A[count+1] && A[count+1]!=0){
                temp = A[0];
                A[0] = A[count+1];
                A[count+1] = temp;
            }
        }
        count++;
    }
    cout << A[0] << endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
	long long int n,m;
	long long int k;
	cin>>n>>m>>k;
	long long int arr[n+1]={0};
	long long int brr[m+1]={0};
	int note_a=0;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
		arr[i]+=arr[i-1];
		if(arr[i]<=k)
		note_a=i+1;
	}
	int note_b=0;
	for(int i=1;i<=m;i++){
		cin>>brr[i];
		brr[i]+=brr[i-1];
		if(brr[i]<=k)
		note_b=i+1;
	}
	int i=0,j=1;
	int ans=0;
	long long int fake=0;
	while(i<note_a){
		fake=INT_MAX;
		j=note_b-1;
		while(fake>k&&j>=0){
			fake=arr[i];
			fake+=brr[j];
			//cout<<fake<<endl;
			j--;
		}
		j++;
		ans=max(ans,i+j);
		note_b=j+1;
		i++;
		//cout<<i<<" "<<j<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//educational dp contest, task a, 2020/09/14
//ms,

/*
*/

int main(void){
  vector<int64_t> d(100000);
  vector<int> h(100000);
  int N;

  cin >>N;
  for(int i=0;i<N;i++) cin>>h[i];

  d[0]=0; d[1]=abs(h[1]-h[0]);
  for(int i=2;i<N;i++){
    d[i]=min(d[i-2]+abs(h[i-2]-h[i]), d[i-1]+abs(h[i-1]-h[i]));
  }

  cout <<d[N-1]<<endl;

  return 0;
}
/*
*/


Measured memory_bytes: 4576
#include<stdio.h>
int main(void){

	int m,f,r;

	while(1){

	scanf("%d %d %d",&m,&f,&r);

	if(m==-1 && f==-1 && r==-1)break;

	if(m==-1 || f==-1){

		printf("F\n");

	}

	else if(80<=m+f){

		printf("A\n");

	}

	else if(65<=m+f && m+f<80){

		printf("B\n");

	}

	else if(50<=m+f && m+f<65){

		printf("C\n");

	}

	else if(30<=m+f && m+f<50 && 50<=r){

		printf("C\n");

	}

	else if(30<=m+f && m+f<50){

		printf("D\n");

	}

	else if(m+f<30){

		printf("F\n");

	}
	}
	return 0;

}

Measured memory_bytes: 584
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
fl = True

#右
cur = sc
for i in range(n):
    if s[i] == "R":
        cur += 1
    if cur > w:
        fl = False
    if t[i] == "L" and cur > 2:
        cur -= 1
        
#左
cur = sc
for i in range(n):
    if s[i] == "L":
        cur -= 1
    if cur <= 0:
        fl = False
    if t[i] == "R" and cur < w:
        cur += 1
        
#上
cur = sr
for i in range(n):
    if s[i] == "U":
        cur -= 1
    if cur <= 0:
        fl = False
    if t[i] == "D" and cur < h:
        cur += 1
        
#下
cur = sr
for i in range(n):
    if s[i] == "D":
        cur += 1
    if cur > h:
        fl = False
    if t[i] == "U" and cur > 2:
        cur -= 1
        
if fl:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 74264
n, m = map(int, input().split(' '))

def nCr(n, r):
    if n < r:
        return 0
    ans = 1
    for i in range (r):
        ans *= (n-r+i+1)
        ans = ans // (i+1)

    return ans

print(nCr(n, 2) + nCr(m, 2))

Measured memory_bytes: 9052
use proconio::input;
use std::cmp;
use superslice::*;

fn main() {
    input! {
        a: usize,
        b: usize,
        q: usize,
        s: [isize; a],
        t: [isize; b],
        x: [isize; q],
    }

    let min = 10isize.pow(11) * -1;
    let max = 10isize.pow(11);
    for &nx in &x {
        let index_s = s.lower_bound(&nx);
        let index_t = t.lower_bound(&nx);
        let left_s = if index_s == 0 { min } else { s[index_s - 1] };
        let left_t = if index_t == 0 { min } else { t[index_t - 1] };
        let right_s = if index_s == a { max } else { s[index_s] };
        let right_t = if index_t == b { max } else { t[index_t] };
        let left_dis_s = (left_s - nx).abs();
        let right_dis_s = (right_s - nx).abs();
        let left_dis_t = (left_t - nx).abs();
        let right_dis_t = (right_t - nx).abs();
        let mut ans = std::isize::MAX;
        ans = cmp::min(ans, cmp::max(left_dis_s, left_dis_t));
        ans = cmp::min(ans, cmp::max(right_dis_s, right_dis_t));
        ans = cmp::min(
            ans,
            cmp::min(left_dis_s, right_dis_t) * 2 + cmp::max(left_dis_s, right_dis_t),
        );
        ans = cmp::min(
            ans,
            cmp::min(left_dis_t, right_dis_s) * 2 + cmp::max(left_dis_t, right_dis_s),
        );

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


Measured memory_bytes: 7488
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 1e5+4;

ll n,m;

void solve(){
	vector<int>d;
	cin>>n>>m;
	for(int i=1;i*i<=m;++i){
		if(m%i==0){
			d.pb(i);
			if(m/i!=i)d.pb(m/i);
		}
	}
	sort(all(d));
	reverse(all(d));
	rep(i,sz(d)){
		if(n*d[i]<=m){
			cout<<d[i];
			return;
		}
	}
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3664
/*
 ============================================================================
 Name        : atcorder_002.c
 Author      :
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int n,k;
	int l[50];
	int i, j, t, tmp, total = 0;

	scanf("%d", &n);
	if(n > 50 || n <= 0) {
		printf("1-50の整数を入力ください\n");
		return EXIT_FAILURE;
	}

	scanf("%d", &k);
	if(k > 50 || k <= 0) {
		printf("1-50の整数を入力ください\n");
		return EXIT_FAILURE;
	}


	if(n < k) {
		printf("エラー。N < K になっています。最初の入力値 >= 後の入力値 にしてください。\n");
		return EXIT_FAILURE;
	}
	for (i = 0; i < n; ++i) {
		scanf("%d", &l[i]);

		if(l[i] > 50){
			printf("エラー。棒の長さは50以下を指定ください。\n");
			return EXIT_FAILURE;
		}
	}


	/* 数値を昇順にソート */
	for (t = 0; t < n; ++t) {
		for (j = t + 1; j < n; ++j) {
			if (l[t] > l[j]) {
				tmp = l[t];
				l[t] = l[j];
				l[j] = tmp;
			}
		}
	}
	/*
	printf("昇順sortした数値\n");
	for (i=0; i<n; ++i){
	    printf("%d\n", l[i]);
	}
	*/
	for (int t = n-1; 0 < k ; --t, --k) {
		total += l[t];
	}
	printf("%d\n", total);

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int l, r, d;
    cin >> l >> r >> d;
    cout << r/d - (l-1)/d << endl;
    return 0;
}


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

typedef long long int ll;

int main(){
	ll n;
	cin>>n;
	ll val[n][3];
	for(ll i=0;i<n;i++){
		cin>>val[i][0]>>val[i][1]>>val[i][2];
	}
	ll ans[n][3];
	//memset(ans,0,sizeof(ans));
	memcpy(ans[n-1],val[n-1],3*sizeof(ll));
	for(ll i=n-2;i>=0;i--){
		ans[i][0]=val[i][0]+max(ans[i+1][1],ans[i+1][2]);
		ans[i][1]=val[i][1]+max(ans[i+1][0],ans[i+1][2]);
		ans[i][2]=val[i][2]+max(ans[i+1][0],ans[i+1][1]);
	}
	cout<<max(max(ans[0][0],ans[0][1]), max(ans[0][0],ans[0][2]));
}

Measured memory_bytes: 4864
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

k = ni()
a, b = nm()
for i in range(a, b+1):
    if i % k == 0:
        print('OK')
        break
else:
    print('NG')


Measured memory_bytes: 9248
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(){
    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    Rep(i,n) cin >> t[i];
    sort(t.begin(),t.end());
    ll ans = 1ll;
    ll m = 0ll;
    ll flag = t[0ll];
    Rep(i,n){
        if(flag+k>=t[i] && m<c){
            m++;
        }
        else{
            flag = t[i];
            m = 1;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			int[]A = new int[N];
			for(int i = 0;i<N;i++)A[i] = scan.nextInt();
			
			
			Arrays.sort(A);
			
			
			for(int i = 0;i<N-1;i++) {
				if(A[i]<0&&A[i+1]<0) {
					A[i]=-1*A[i];
					A[i+1]=-1*A[i+1];
				}else if(A[i]<0&&A[i+1]==0) {
					A[i]=-1*A[i];
				}else if(A[i]<0&&A[i+1]>0) {
					if(A[i]+A[i+1]<-A[i]-A[i+1]) {
						A[i]=-1*A[i];
						A[i+1]=-1*A[i+1];
					}
				}
	
			}
			
			
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				goukei+=A[i];
			}
			
			System.out.println(goukei);
			
			
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 59268
// URL: https://atcoder.jp/contests/abc131/tasks/abc131_b

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

version(unittest) {} else
void main()
{
  int n, l; io.getV(n, l);

  auto t = new int[](n);
  foreach (i; 0..n) t[i] = l+i;

  auto m = 1000;
  foreach (j, ti; t)
    if (ti.abs < m.abs) m = ti;

  io.put(t.sum - m);
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, T v)
  {
    v = new T(r, c);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }
}


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

int main() {
	int a, b, c;
  	cin >> a >> b >> c;
 
  	if(a*b*c==175 && a!=1 && b!=1 && c!=1)
      cout << "YES" <<endl;
  	else
      cout << "NO" << endl;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k; cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	for (int i = k; i < n; i++) {

		if (a[i - k] < a[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}




	return 0;
}


Measured memory_bytes: 3968