akhauriyash/Code-Regression huggingface dataset:
class Mint:
    MOD = 1000000007  # Must be a prime
    CACHE_FACTORIALS = [1, 1]
 
    def __init__(self, v):
        if self.__isally(v):
            self.v = v.v
        else:
            self.v = v % self.MOD
 
    @property
    def inv(self):
        return Mint(self.__minv(self.v))
 
    @classmethod
    def factorial(cls, v):
        for i in range(len(cls.CACHE_FACTORIALS), int(v) + 1):
            cls.CACHE_FACTORIALS.append(cls.CACHE_FACTORIALS[-1] * i % cls.MOD)
        return Mint(cls.CACHE_FACTORIALS[int(v)])
 
    @classmethod
    def perm(cls, n, r):
        if n < r or r < 0:
            return 0
        return cls.factorial(n) // cls.factorial(n - r)
 
    @classmethod
    def comb(cls, n, r):
        if n < r or r < 0:
            return 0
        return cls.perm(n, r) // cls.factorial(r)
 
    @classmethod
    def __isally(cls, v) -> bool:
        return isinstance(v, cls)
 
    @classmethod
    def __minv(cls, v) -> int:
        return pow(v, cls.MOD - 2, cls.MOD)
 
    @classmethod
    def __mpow(cls, v, w) -> int:
        return pow(v, w, cls.MOD)
 
    def __str__(self):
        return str(self.v)
    __repr__ = __str__
 
    def __int__(self):
        return self.v
 
    def __eq__(self, w):
        return self.v == w.v if self.__isally(w) else self.v == w
 
    def __add__(self, w):
        return Mint(self.v + w.v) if self.__isally(w) else Mint(self.v + w)
    __radd__ = __add__
 
    def __sub__(self, w):
        return Mint(self.v - w.v) if self.__isally(w) else Mint(self.v - w)
 
    def __rsub__(self, u):
        return Mint(u.v - self.v) if self.__isally(u) else Mint(u - self.v)
 
    def __mul__(self, w):
        return Mint(self.v * w.v) if self.__isally(w) else Mint(self.v * w)
    __rmul__ = __mul__
 
    def __floordiv__(self, w):
        return Mint(self.v * self.__minv(w.v)) if self.__isally(w) else Mint(self.v * self.__minv(w))
 
    def __rfloordiv__(self, u):
        return Mint(u.v * self.__minv(self.v)) if self.__isally(u) else Mint(u * self.__minv(self.v))
 
    def __pow__(self, w):
        return Mint(self.__mpow(self.v, w.v)) if self.__isally(w) else Mint(self.__mpow(self.v, w))
 
    def __rpow__(self, u):
        return Mint(self.__mpow(u.v, self.v)) if self.__isally(u) else Mint(self.__mpow(u, self.v))

n, k = map(int,input().split())    
for i in range(1, k+1):
    print(Mint.comb(n-k+1, i) * Mint.comb(k-1, i-1))

Measured memory_bytes: 71716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  while(test--)
  {
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vi red(a),green(b),colorless(c);
  for(int i=0;i<a;i++)cin>>red[i];
    for(int i=0;i<b;i++)cin>>green[i];
      for(int i=0;i<c;i++)cin>>colorless[i];
        sort(all(red));
      sort(all(green));
      sort(all(colorless));

      vi ans;
      for(int i=a-1;i>=a-x;i--)ans.pb(red[i]);
        for(int i=b-1;i>=b-y;i--)ans.pb(green[i]);
          for(int i=c-1;i>=0;i--)ans.pb(colorless[i]);
            sort(all(ans));
          int sum=0;
          for(int i=ans.size()-1;i>=ans.size()-x-y;i--)sum+=ans[i];
            cout<<sum;
  //while loop ending 
  }

return 0;
}

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

int main(){
    int n;
    cin >> n;
    if(n % 2 == 0){
        printf("%.10f\n", ((double)n / 2.0) / n);
    }else if(n % 2 != 0){
        printf("%.10f\n", (((double)n / 2) + 0.5) / n);
    }
    return 0;
}

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

const ll INF = ll(1e+18) + 1;

int main(){
    int n; ll k;
    cin >> n >> k;
    vector<ll> ary(n);
    rep(i, n) cin >> ary[i];
    sort(ary.begin(), ary.end());

    ll left = -INF, right = INF;
    while(left + 1 < right){
        ll x = (left + right) / 2;
        ll total = 0;
        rep(i, n){
            if(ary[i] < 0){
                int l = -1, r = n;
                while(l + 1 < r){
                    int m = (l + r) / 2;
                    if(ary[i] * ary[m] < x) r = m; else l = m;
                }
                total += n - r;
            } else {
                int l = -1, r = n;
                while(l + 1 < r){
                    int m = (l + r) / 2;
                    if(ary[i] * ary[m] < x) l = m; else r = m;
                }
                total += r;
            }
            if(ary[i] * ary[i] < x) total--;
        }
        total /= 2;
        if(total < k) left = x; else right = x;
    }

    cout << left << endl;

    return 0;
}

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

int mn[200001], fr[200001], same[200001], fc[200001], inv[200001], fci[200001], md = 1e9 + 7, n, X, Y;
pair<int, int> b[200001], mna(1e9, 0), mnb(1e9, 0);

int ch(int n, int r) { return (ll)fc[n] * fci[r] % md * fci[n - r] % md; }

int main(){
	scanf("%d%d%d", &n, &X, &Y);
	fc[0] = 1;
	f(i, 1, n + 1)fc[i] = (ll)i * fc[i - 1] % md;
	inv[1] = 1;
	f(i, 2, n + 1)inv[i] = md - md / i * (ll)inv[md % i] % md;
	fci[0] = 1;
	f(i, 1, n + 1)fci[i] = (ll)inv[i] * fci[i - 1] % md;
	f(i, 1, n + 1)mn[i] = 1e9;
	f(i, 0, n){
		scanf("%d%d", &b[i].first, &b[i].second);
		if (b[i].second < mna.first)mnb = mna, mna = make_pair(b[i].second, b[i].first);
		else if (b[i].second < mnb.first)mnb = make_pair(b[i].second, b[i].first);
		mn[b[i].first] = min(mn[b[i].first], b[i].second);
	}
	int S = 0, an = 1;
	f(i, 0, n){
		if (mn[b[i].first] + b[i].second <= X)++same[b[i].first];
		if (mna.second == b[i].first) { if (mnb.first + b[i].second <= Y)++fr[b[i].first]; }
		else if (mna.first + b[i].second <= Y)++fr[b[i].first];
	}
	f(i, 1, n + 1)if (mna.second != i && mna.first + mn[i] <= Y || mna.second == i && mnb.first + mn[i] <= Y)same[i] = max(same[i], fr[i]), an = (ll)an * ch(S + same[i], same[i]) % md, S += same[i];
	printf("%d\n", an);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
//#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef vector<string> vi;
typedef pair<int,int> pi;

 struct node{
        int roll;
        node *next;
 }root;


int main()
{
     int t=1,caseno = 0;

     while(t--){
      int n;
      string s;
      cin >> s;
      string ss = "hi";
      for(int i  = 1; i<=20; i++){
        if(s==ss){
            cout << "Yes" << endl;
            return 0;
        }
        ss+="hi";
      }
      cout << "No" << endl;

    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fifo ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define ll long long int
#define w(t) ll t; cin>>t; while(t--)
#define pb push_back
#define vll vector<long long int>
#define vi vector<int>
#define mp make_pair
/*
ll GCD(ll a,ll b)
{
	if(b==0)
	return a;
	else
	return GCD(b,a%b);
}

ll LCM(ll a,ll b){return a/GCD(a,b)*b;}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}

ll x,y,d;       //d is gcd x and y are coefficients
void exten_euclid(ll a,ll b)
{	ll temp;
	if(b==0)
	{
		d=a;
		x=1;
		y=0;	
	}
	else
	{
		exten_euclid(b,a%b);
		temp=x;
		x=y;
		y=temp-(a/b)*y;	
	}
return;
}

ll fastModExp(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		res=(res*a)%m;
	a=(a*a)%m;
	b=b>>1;	
	}
return res;
}


bool isPrime(ll n) {
	if(n==1)
      return false;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;               //O(root(N))
        }
    }
    return true;
}

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

/*************FACTORIZE IN 0(LOG(N)) PROVIDED N IS INTEGER**************

int minPrime[100000];

void modified_sieve(int n){
for (int i = 2; i * i <= n; ++i) {
    if (minPrime[i] == 0) {         //If i is prime
        for (int j = i * i; j <= n; j += i) {
            if (minPrime[j] == 0) {
                minPrime[j] = i;
            }
        }
    }
}
for (int i = 2; i <= n; ++i) {
    if (minPrime[i] == 0) {
        minPrime[i] = i;
    }
}
}

vector<int> factorize(int n) {
    vector<int> res;
    while (n != 1) {
        res.push_back(minPrime[n]);
        n /= minPrime[n];
    }
    return res;
}

/*************************************************
void sieve(int N) {
        bool isPrime[N+1];
        for(int i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }


ll binomialCoeff(ll n, ll k)  
{  
     ll res = 1; 
	if(n<k)
	return 0; 
  
    // Since C(n, k) = C(n, n-k)  
    if ( k > n - k )  
        k = n - k;  
  
    // Calculate value of  
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]  
    for (ll i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
}  

*/
int main()
{
fifo;
string s;
cin>>s;
if(s.length()<6)
cout<<"No"<<endl;
else{
if(s[2]==s[3] && s[4]==s[5])
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}

Measured memory_bytes: 256
n=int(input())
lis=[]
for i in range(n):
  a=int(input())
  shogen=[]
  for i in range(a):
    shogen.append(list(map(int,input().split())))
  lis.append(shogen)

    
kouho=[]
for i in range(0,2**n):
  liis=[]
  for j in range(0,n):
    j=n-j-1
    onezero=i//(2**j)
    liis.append(onezero)
    i-=onezero*(2**j)
  kouho.append(liis)

maxx=0
for i in range(0,2**n):
  keep=0
  for j in range(0,n):
    usohonto=kouho[i][j]
    for k in range(0,len(lis[j])):
      shoge_hito=lis[j][k][0]
      shoge_data=lis[j][k][1]
      if usohonto==1:
        if not kouho[i][shoge_hito-1]==shoge_data:
          keep=1
          break
    if keep==1:
      break
  if keep==0:
    temp=kouho[i].count(1)
    if temp>maxx:
      maxx=temp
print(maxx)

Measured memory_bytes: 9972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int maxN = 100 * 1000 + 9;
const int MOD = 1e9 + 7;
const double EPS = 1e-18;

int n, k;
string s;

void read(){
  cin >> n >> k;
  cin >> s;
}

void solv(){
  k--;
  for(int i = 0; i < n; i++){
    if(i == k)  s[i] = s[i] - 'A' + 'a';
    cout << s[i];
  }
  cout << '\n';
}

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

  read();
  solv();

  return 0;
}


Measured memory_bytes: 256
//Created by Aashray Agarwal urf maniAC
/*MY ATTITUDE ISN'T BAD,IT'S IN BETA.

YOU BETTER BE NICE TO ME,I COULD BE YOUR BOSS IN A FEW YEARS.

I TURN COFFEE INTO CODE,JUST BE ABLE TO AFFORD MORE COFFEE.*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll k,a,b;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll inc,ans;
    cin>>k>>a>>b;
    k-=a;
    ans=1;
    inc=a-b;
    if(k<=0)
    cout<<"1\n";
    else if(inc<=0)
    cout<<"-1\n";
    else
    {
        ans+=2*(k/inc);
        if(k%inc!=0)
        ans+=2;
        cout<<ans<<"\n";
    }
    return 0;
}

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);
 

void solve() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    int dis[N+1][N+1];
    REP(i, R) {
        cin >> r[i];
    }
    REP(i, N){
        REP(j, N){
            dis[i+1][j+1] = 1000000000;
        }
    }
    REP(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        dis[a][b] = c;
        dis[b][a] = c;
    }


    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                if(dis[i][j] > dis[i][k] + dis[k][j]) dis[i][j] = dis[i][k] + dis[k][j];
            }
        }
    }

    sort(r.begin(), r.end());
    ll ans = 200000000ll;
    do {
        ll subAns = 0ll;
        REP(i, R-1){
            subAns += (ll)dis[r[i]][r[i+1]];
        }
        ans = min(ans, subAns);
    } while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 384
import scala.io.Source.stdin

object Main {
  def main(args: Array[String]) = {
    val list = stdin.getLines().map { _.toInt }
    val n = list.next()
    val r0 = list.next()
    val r1 = list.next()
    var max = r1 - r0
    var min = if(r0 > r1) r1 else r0
    for( m <- list ) {
      if( max < m - min) {
        max = m - min
        if( min > m )
          min = m
      }
      else if( min > m ) {
        min = m
      }
    }
    println(max)
  }
}

Measured memory_bytes: 64628
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

unsigned gcd(unsigned a, unsigned b) {
	if (a < b) gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
char tolower(char c) {
	return (c + 0x20);
}
ld num(ld a,ld b) {
	ld c = 1;
	while (b > a) {
		a *= 2;
		c*=2;
	}
	return c;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 1000000007;

const int MAX_N = 200010;
long long fac[MAX_N + 1], finv[MAX_N + 1];

struct init_fac {
    long long mod_inv(long long a, long long m) {   // gcd(a, m) = 1
        long long b = m, x = 1, y = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(x -= t * y, y);
        }
        x = (x % m + m) % m;
        return x;
    }

    init_fac() {
        fac[0] = 1;
        for (int i = 1; i <= MAX_N; ++i) fac[i] = i * fac[i - 1] % MOD;
        finv[MAX_N] = mod_inv(fac[MAX_N], MOD);
        for (int i = MAX_N - 1; i >= 0; --i) finv[i] = (i + 1) * finv[i + 1] % MOD;
    }
} init_fac;

long long nPk(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
}

long long nCk(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return nPk(n, k) * finv[k] % MOD;
}

long long nHk(int n, int k) {
    if (n < 0 || k < 0) return 0;
    return nCk(n + k - 1, k);
}

void _main() {
    int N, K;
    cin >> N >> K;
    FOR (i, 1, K + 1) cout << nCk(K - 1, i - 1) * nCk(N - K + 1, i) % MOD << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define DOUBLE fixed << setprecision(10)
#define fi first
#define se second
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
template <typename T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
};
template <typename T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
};
void Pvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void Pvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

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

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

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

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

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

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}


ll  n, m, r, l, k, h, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;

void INIT() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << DOUBLE;
}

vll p(int n){
    vll mp;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            mp.pb(i);n /= i;
        }
    }
    if(n!=1)mp.pb(n);
    return mp;
}

int main() {
    INIT();
    int n;cin>>n;
    auto m=p(n);
    cout<<n<<":";
    for(auto q:m)cout<<" "<<q;
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
char str[210][210];
int main()
{
	int n, m, kk;int ans = 0;
	scanf("%d%d%d", &n, &m, &kk);
	for(int i = 1; i <= n; i ++) scanf("%s", str[i] + 1);
	for(int i = 0; i <= (1 << n) - 1; i ++)
	{
		for(int j = 0; j <= (1 << m) - 1; j ++)
		{
			int cnt = 0;
			for(int x = 1; x <= n; x ++)
			{
				for(int y = 1; y <= m; y ++)
				{
					if(i & (1 << (x - 1)) || j & (1 << (y - 1))) continue;
					if(str[x][y] == '#') cnt ++;
				}
			}
			if(cnt == kk){
				ans ++;
				//cout <<i<<" "<<j<<"\n";
			} 
		}
	}
	printf("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 3764
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long i64;

const int NR = 4e5 + 10;

vector<int> vec[NR];
int x[NR], y[NR], li[NR], v[NR];
int n, len;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &x[i], &y[i]);
		li[++len] = x[i];
		li[++len] = y[i];
	}

	sort(li + 1, li + len + 1);

	len = unique(li + 1, li + len + 1) - li - 1;

	int l0 = li[1], r1 = li[len];
	int r0 = l0, l1 = r1;


	for (int i = 1; i <= n; ++i) {
		r0 = max(r0, min(x[i], y[i]));
		l1 = min(l1, max(x[i], y[i]));

		x[i] = lower_bound(li + 1, li + len + 1, x[i]) - li;
		y[i] = lower_bound(li + 1, li + len + 1, y[i]) - li;

		//printf("%d %d\n", x[i], y[i]);

		vec[x[i]].push_back(i);
		vec[y[i]].push_back(i);
	}

	int j = 0, cnt = 0;
	i64 ans = 1ll * (r0 - l0) * (r1 - l1);
	for (int i = 1; i <= len; ++i) {
		while (cnt < n && j < len) {
			++j;
			for (int k : vec[j]) {
				if (v[k] == 0) ++cnt;
				++v[k];
			}
		}
		if (cnt == n) ans = min(ans, 1ll * (r1 - l0) * (li[j] - li[i]));
		//printf("%d %d %d\n", i, j, cnt);
		for (int k : vec[i]) {
			--v[k];
			if (v[k] == 0) --cnt;
		}
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 27648
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//using namespace __gnu_pbds;
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 


int main(){
	IOS;
	ll n;
	cin >> n;
	ll a[n] = {0};
	loop(i, 0, n)
		cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	ll ans = 0;
	loop(i, 0, n){
		ans += a[i / 2];
		debug(i, ans);
	}
	ans -= a[0];
	cout << ans << endl;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  string s;
  string t;
  string flag = "No";
  cin >> s >> t;
  int n = s.size();
  if(s.size()+1==t.size()){
    rep(i,n){
      if(s.at(i)!=t.at(i)){
        flag = "No";
        break;
      }
      flag = "Yes";
    }
  }
  cout << flag << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long LL;
const int N = 2005;

int n, m;
int first[55], tot;

struct Edge {
    int y, nex;
}edge[100000];

void addedge(int x, int y) {
    edge[tot] = (Edge) {y, first[x]};
    first[x] = tot++;
}

int val[100];

LL mask1[100];
int bo[55];

LL getMask(int x) {
    LL ans = mask1[x];
    bo[x]++;
    if (x == n - 1) return ans;
    for (int k = first[x]; k != -1; k = edge[k].nex) {
        int y = edge[k].y;
        if (bo[y]) continue;
        LL q = getMask(y);
        if (q != -1) {
            return ans | q;
        }
    }
    return -1;
}

int ans = 0;

int getVal(LL x) {
    int res = 0;
    for (int i = 0; i < n; ++i)
        if (x >> i & 1) res += val[i];
    return res;
}

int vis[100];

int DFS(int x) {
    if (x == n - 1) return 1;
    if (vis[x]) return 0;
    vis[x] = 1;
    for (int k = first[x]; k != -1; k = edge[k].nex)
        if (DFS(edge[k].y)) return 1;
    return 0;
}

void dfs(int x, LL mask, int res, int dep) {
    if (res >= ans) return ;
    if (x == n - 1) {
        ans = min(ans, res);
        return ;
    }
    memcpy(vis, bo, sizeof(int) * n);
    vis[x] = 0;
    if (!DFS(x)) return ;
    for (int k = first[x]; k != -1; k = edge[k].nex) {
        int y = edge[k].y;
        //if (bo[y]) continue;
        ++bo[y];
        if (bo[y] > 1) continue;
        dfs(y, mask1[y] | mask, getVal(mask1[y] | mask), dep + 1);
        //bo[y] = 1;
    }
    for (int k = first[x]; k != -1; k = edge[k].nex) {
        int y = edge[k].y;
        --bo[y];
    }
}

int main() {
    srand(time(0));
    //freopen("1", "r", stdin);
    scanf("%d%d", &n, &m);
    // n = 40, m = 1000;
    //freopen("out.txt", "w", stdout);
    //printf("%d %d\n", n, m);
    memset(first, -1, sizeof(first));
    for (int i = 0; i < n; ++i) {
        scanf("%d", &val[i]);        
        //  val[i] = rand() % 100 + 1;
        //printf("%d\n", val[i]);
        mask1[i] = 1LL << i;
    }
    tot = 0;
    for (int i = 1; i <= m; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        //x = rand() % n + 1;
        //y = rand() % n + 1;
        //printf("%d %d\n", x, y);
        --x;
        --y;
        addedge(x, y);
        addedge(y, x);
        mask1[x] |= 1LL << y;
        mask1[y] |= 1LL << x;
    }
    memset(bo, 0, sizeof(bo));
    ans = 1 << 30;
    bo[0] = 1;
    dfs(0, mask1[0], getVal(mask1[0]), 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>

int main(void){
    int x,y;
    while(1){
    scanf("%d %d",&x,&y);
    if(x==0&&y==0)
        break;
    if(x<y){
        printf("%d %d\n",x,y);
    }else{
        printf("%d %d\n",y,x);
    }
}
    return 0;
}



Measured memory_bytes: 2068
#include <stdio.h>

int linearsearch(int N, int Q, int n[], int q[]){
	int i, j;
	int count = 0;
	for(i = 0; i < Q; i++){
		j = 0;
		n[N - 1] = q[i];
		while(q[i] != n[j]){
			j++;
		}
		if(j != N - 1){
			count++;
		}
	}
	return count;
}

int main(void){
	int N, Q, i;
	int n[10000], q[500];
	
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &n[i]);
	}
	scanf("%d", &Q);
	for(i = 0; i < Q; i++){
		scanf("%d", &q[i]);
	}
	printf("%d\n", linearsearch(N, Q, n, q));
	return 0;
}


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

int main() {
  string s;
  cin >> s; 
  int res = 114514;
  for (int i = 0; i < s.size() - 2; i++){
    int x = (s[i] - '0')*100;
    int y = (s[i+1] - '0')*10;
    int z = (s[i+2] - '0');
    res = min(abs(x + y + z - 753), res);
  }
  cout << res << endl;
  return 0;
}

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

int kuru(int S){
  int s=1;
  for(int l=0;l<S;l++){
    s*=2;
  }
  return s;
}

int check(int a,int b,int c,int i,int K){
  int ans=0;
  if(i==0||i==K){
    if(a<b && b<kuru(K)*c)
      ans ++;
    return ans;
  }
  if(a<kuru(i)*b && b*i*2<c*kuru(K-i))
     ans++;
  return ans;
}


int main()
{
  int a,b,c,K;
  cin >> a >> b >> c >> K;
  
  for(int i=0;i<K;i++){
  	if(check(a,b,c,i,K)){
    	cout << "Yes" << endl;
    	return 0;
  	}
  }
  
  
  cout << "No" << endl;
 
return 0;
}

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

using namespace std;

int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  n--;
  b -= a;
  d -= c;
  for (int i = 0; i <= n; i++) {
    long long cur = c * (n - 2 * i);
    long long low = cur - d * i, up = cur + d * (n - i);
    if (low <= b && b <= up) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}

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

int64_t gcd(int64_t A, int64_t B){
  if (A%B==0){
    return B;
  }
  else{
    return gcd(B,A%B);
  }
}

int64_t lcm(int64_t A, int64_t B){
  return A*B/gcd(A,B);
}

int main(){
  int64_t A, B;
  cin >> A >> B;
  cout << lcm(A,B) << endl;
}

Measured memory_bytes: 256
#c
n,k,q=map(int,input().split())
a=[0]*q
for i in range(q):
    a[i] = int(input())

point= [k-q]*n
for aa in a:
    point[aa-1]+=1

for i in [i>0 for i in point]:
    if i:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 53208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=505,mod=1e9+7;
int n,x,a[N];
ll dp[105][105][N];
int main()
{
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    reverse(a+1,a+1+n);
    dp[0][0][0]=1;
    for(int i=0;i<n;i++)
    {
        int m=min(i,x/a[i+1]);
        for(int j=0;j<=m;j++)
            for(int k=0;k<=x;k++)
                if(dp[i][j][k])
        {
            if(k+a[i+1]<=x)
                (dp[i+1][j+1][k+a[i+1]]+=dp[i][j][k]*(j+1))%=mod;
            (dp[i+1][j][k]+=dp[i][j][k]*(k-j*(a[i+1]-1)))%=mod;
            for(int h=1;h<a[i+1];h++)
                if(k+h<=x)
                (dp[i+1][j][k+h]+=dp[i][j][k]*2*j)%=mod;
            if(j-1>=0)
            for(int h=0;h<a[i+1]-1;h++)
                if(k+h<=x)
                (dp[i+1][j-1][k+h]+=dp[i][j][k]*(a[i+1]-1-h)%mod*(j-1))%=mod;
        }
    }
    ll ans=0;
    for(int i=0;i<=min(n,x/a[n]);i++)
        ans=(ans+dp[n][i][x])%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 41216
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
int main() {
    int i, a, b, c, x;
    int ans=0;
    int i1, i2, i3;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    for(i1=0;i1<=a;i1++) {
        for(i2=0;i2<=b;i2++) {
            for(i3=0;i3<=c;i3++) {
                if ((i1*500)+(i2*100)+(i3*50) == x) {
                    ans+=1;
                }
            }
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

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

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,a,b;
	cin >> n >> a >> b;
	if((b - a) % 2 == 0 && !(a == 1 && b == 2)){
		ANS("Alice");
	}else{
		ANS("Borys");
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int m=scn.nextInt();
		int [][]arr=new int[m][2];
		for(int i=0;i<m;i++) {
			arr[i][0]=scn.nextInt();
			arr[i][1]=scn.nextInt();
		}
		
		int left=arr[0][0],right=arr[0][1];
		for(int i=1;i<m;i++) {
			if(arr[i][1]<left||arr[i][0]>right) {
				System.out.println(0);
				return;
			}else {
					if(right<=arr[i][1]) {
						if(left<arr[i][0])
						left=arr[i][0];
					}else if(right>arr[i][1]){
						right=arr[i][1];
						if(arr[i][0]>left)
							left=arr[i][0];
					}
			
			}
		}
		System.out.println(right-left+1);
	}

}


Measured memory_bytes: 90616
N, Q = map(int, input().split())
S = input()

# S         * A C * A C C
# sumlist   0 0 1 1 1 2 2
sumlist = [0]
for i in range(1, len(S)):
	sumlist.append(sumlist[-1])
	if S[i - 1] == "A" and S[i] == "C":
		sumlist[-1] += 1

query = []
for i in range(Q):
	l, r = map(int, input().split())
	query.append(dict(l=l-1, r=r-1))

for q in query:
	print(sumlist[q["r"]] - sumlist[q["l"]])


Measured memory_bytes: 43216
using System;

namespace ConsoleApp40
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if (x == 1)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}


Measured memory_bytes: 27336
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

ll dp[3002][3002][4];

int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll R,C,K;
	cin>>R>>C>>K;
	ll v[R+1][C+1];
	fill(v,0);
	// dbg(v[1][1]);
	rep(i,K){
		ll r,c,val;
		cin>>r>>c>>val;
		v[r][c] = val;
	}
	repA(i,1,R){
		repA(j,1,C){
			ll up = max4(dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]);
			if(!v[i][j]){
				rep(k,4){
					dp[i][j][k] = max(dp[i][j-1][k],up);
				}
			}
			else{
				dp[i][j][0] = max(dp[i][j-1][0],up);
				dp[i][j][1] = max3(dp[i][j-1][0]+v[i][j],up+v[i][j],dp[i][j-1][1]);
				dp[i][j][2] = max3(dp[i][j-1][1]+v[i][j],dp[i][j][1],dp[i][j-1][2]);
				dp[i][j][3] = max3(dp[i][j-1][2]+v[i][j],dp[i][j][2],dp[i][j-1][3]);
			}
		}
	}
	cout<<max4(dp[R][C][0],dp[R][C][1],dp[R][C][2],dp[R][C][3]);
	return 0;
}


Measured memory_bytes: 355360
#include <iostream>
#include <iomanip>

int main() {
    int n; std::cin >> n;
    double d = 0;
    for (int i = 0; i < n ;i++) {
        int v; std::cin >> v;
        d += (1.0/v);
    }
    std::cout << std::fixed << std::setprecision(15) << (1/d) << std::endl;
    return 0;
}

Measured memory_bytes: 3216
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int n; cin>>n;
    int arr[n];
    int ans = 0;
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int tar = arr[i]+arr[j];
            int ind = lower_bound(arr+j+1,arr+n,tar)-arr;
            ind--;
            //cout<<ind<<endl;
            ans += (ind-j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
using namespace std;
const int N = 6;
struct T{string f[N];}c,d,e;

bool operator<(const T&l,const T&r)
{
	for(int i=0;i<N;++i)
	{
		if(l.f[i]<r.f[i]) return true;
		else if(l.f[i]>r.f[i]) return false;
	}
	return false;
}
void r(T&r,int a[4])
{
	string t = r.f[a[0]];
	for(int i=1;i<4;++i) r.f[a[i-1]] = r.f[a[i]];
	r.f[a[3]]=t;
}
int main()
{
	int n,i,j,k,a[N][4]={
		{1,2,4,3},
		{0,2,5,3},
		{0,1,5,4},
		{0,1,5,4},
		{0,2,5,3},
		{1,2,4,3},
	};
	while(cin>>n,n)
	{
		set<T>s;
		for(i=0;i<n;++i)
		{
			for(j=0;j<N;++j)cin>>c.f[j];
			
			d=c;
			for(j=0;j<4;++j)
			{
				r(d, a[0]);
				for(k=0;k<4;++k)
				{
					r(d,a[1]);
					s.insert(d);
				}
			}
			for(j=0;j<4;++j)
			{
				r(d,a[2]);
				for(k=0;k<4;++k)
				{
					r(d,a[1]);
					s.insert(d);
				}
			}
			;
		}
		printf("%d\n",n-s.size()/24);
	}
	return 0;
}

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

int main(){
    double pai=3.141592653589;
    int h,w;
    for(;;){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

long long n, ans = 2000000000000005;
long long a[200005] = {0};
vector<long long> v;

int main() {
  long long i, j;
  cin >> n;
  for(i = 1; i <= n; ++i) {
    cin >> j;
    v.push_back(j - i);
  }
  sort(v.begin(), v.end());
  for(int k = -2; k < 3; ++k) {
    if((n / 2) + k < 0 || (n / 2) + k > v.size() - 1)
      continue;
    long long ans2 = 0;
    j = v[(n / 2) + k];
    for(i = 0; i < n; ++i) ans2 += abs(v[i] - j);
    ans = min(ans, ans2);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2420
def move
  $arr.sort { |a, b| b[0] <=> a[0] }.each do |e|
    if $pos == e[1]
      $pos = e[2]
    elsif $pos == e[2]
      $pos = e[1]
    end
  end
end

loop do
  n, m, $pos = gets.split.map(&:to_i)
  break if n == 0 && m == 0 && $pos == 0
  $arr = []
  m.times do
    $arr << gets.split.map(&:to_i)
  end
  move
  puts $pos
end

Measured memory_bytes: 6116
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
S=int(input())
U=S//100
L=S%100
#M 01 12
#Y 00 99
if U==0 or U>12: # U=Y
    if L ==0 or L>12: # L=Y
        print("NA")
    else:
        print("YYMM")
else: # U=YorM
    if L==0 or L>12: #L=Y
        print("MMYY")
    else:
        print("AMBIGUOUS")


Measured memory_bytes: 2940
use std::io::*;
use std::str::*;

const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let mut n: u64 = read().unwrap();
    //    let mut n = 939587134549734843;
    let mut l0 = 2;
    let mut l1 = 1;

    if n == 1 {
        println!("{}", 1);
        return;
    }

    for _ in 1..n {
        let mut tmp: u64 = l1;
        l1 = l1 + l0;
        l0 = tmp;
    }
    println!("{}", l1);
}


Measured memory_bytes: 4476
/*
Original problem: https://atcoder.jp/contests/abc137/tasks/abc137_d
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

namespace SOLVE {
	struct job {
		ll t, v;
		job(ll a, ll b) {
			t = a, v = b;
		}
	};

	struct sortjob {
		// sort by value, then by time
		bool operator()(job & a, job & b) {
			if (a.v == b.v) {
				return a.t > b.t;
			}
			return a.v > b.v;
		}
	};

	VLL value(100005); // value[i] is the value of the job, days counts down from m to 0
	VLL next(100005, -1); // points to the next lower day

	int nextday(int x) {
		if (next[x] == -1) {return -1;} // if parent is -1, x is also -1
		if (next[x] == x) {return x;} // otherwise return parent
		next[x] = nextday(next[x]);
		return next[x];
	}

    void main() {
    	ll n, m, a, b;
    	cin >> n >> m;
    	vector<job> J(n, job(-1, -1));

    	REP(i, 0, n) {
    		cin >> a >> b;
    		J[i] = job(a, b);
    	}
    	sort(J.begin(), J.end(), sortjob());

    	// set up next: from 0->m it is good, rest is -1
    	REP(i, 0, m + 1) {
    		next[i] = i;
    	}

    	for (job j: J) {
    		int day = nextday(j.t);

    		if (day == -1) { // this job cannot fit
    			continue;
    		}

    		value[day] = j.v;
    		next[day] = day + 1;
    	}

    	ll ans = 0;
    	REP(i, 0, m + 1) {
    		ans += value[i];
			// cout << i << ' ' << value[i] << endl;
    	}
    	cout << ans << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();
		Set<String> set = new TreeSet<>();
		for(int i = 0 ; i < s.length() ; i++) {
			for(int j = i + 1 ; j < s.length() + 1 ; j++) {
				if(j - i <= 5) set.add(s.substring(i, j));
			}
		}
		int i = 0;
		for(String x : set) {
			i++;
			if(i == k) {
				System.out.println(x);
				return;
			}
		}
	}
}


Measured memory_bytes: 24856
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		int m, f, r;
		Scanner sc = new Scanner(System.in);

		while(true) {
		m = sc.nextInt();
		f = sc.nextInt();
		r = sc.nextInt();
		if(m==-1 && f==-1 && r==-1) break;

		if(m==-1 || f==-1) {
			System.out.println('F');
		}else if((m + f)>=80) {
			System.out.println('A');
		}else if((m + f)>=65 && (m+f)<80) {
			System.out.println('B');
		}else if((m + f)>=50 && (m+f)<65 ||r>=50) {
			System.out.println('C');
		}else if((m+f)>=30 && (m+f)<50) {
			System.out.println('D');
		}else if((m+f)<30) {
			System.out.println('F');
		}
		}

	}

}


Measured memory_bytes: 26148
function main(input) {
  var N = input[0].split(" ")[0]-0;
  var M = input[0].split(" ")[1]-0;
  var list = [];
  for(var i=1;i<=M;i++){
    list.push(input[i].split(" ").map(v=>v-0));
  }
  list = list.sort((a,b)=>(a[0]-b[0])||(a[1]-b[1]));
  var map = {};
  list.forEach((v,i)=>{
    var c = v[0];
    var y = v[1];
    if(!map[c]){
      map[c] = {len:0};
    }
    map[c][y] = ++map[c].len;
  });
  for(var i=1;i<=M;i++){
    var c = input[i].split(" ")[0];
    var y = input[i].split(" ")[1];
    var num = map[c][y];
    console.log(("000000"+c).slice(-6) + ("000000"+num).slice(-6));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 74368
#include<iostream>
#include<string>
#include<algorithm>

static const int N = 1000;
int c[N+1][N+1];

int lcs(std::string X, std::string Y) {
    int m = X.size();
    int n = Y.size();
    for(int i = 0; i <= m; i++) {
        for(int j = 0; j <= n; j++) {
            c[i][j] = 0;
        }
    }

    X = ' ' + X;
    Y = ' ' + Y;

    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= n; j++) {
            if(X[i] == Y[j]) {
                c[i][j] = c[i-1][j-1] + 1;
            } else {
                c[i][j]= std::max(c[i-1][j], c[i][j-1]);
            }
        }
    }
    return c[m][n];
}

int main() {
    std::string s1, s2;
    int n; std::cin >> n;
    for(int i = 0; i < n; i++) {
        std::cin >> s1 >> s2;
        std::cout << lcs(s1, s2) << std::endl;
    }
    return 0;
}


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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n = I()
    a = sorted(LI())
    q = [a[-1]]
    a = a[:-1][::-1]
    for i in range(n):
        # print(i,q,a)
        nq = []
        qi = 0
        na = []
        for ai in range(len(a)):
            c = a[ai]
            if q[qi] > c:
                nq.append(c)
                qi += 1
                if qi == len(q):
                    na += a[ai+1:]
                    break
            else:
                na.append(c)
        if qi < len(q):
            return 'No'
        a = na
        q = sorted(q + nq, reverse=True)

    return 'Yes'


print(main())



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	fx(H) {
		fy(W) {
			if ((x<B&&y<A)||x>=B&&y>=A) {
				cout << 1;
			}
			else {
				cout << 0;
			}
		}
		cout << endl;
	}

    return 0;
}



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


int main() {
    int n,m;
    cin >> n >> m;
    int s[m], c[m];
    vector<P> p(m);
    rep(i,m) cin >> p[i].first >> p[i].second;

    rep(x,1000) {
        int keta=1;
        int nx = x/10;
        vector<int> d(1,x%10);
        while(nx) {
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }
        if(keta != n) continue;
        bool ok = true;
        reverse(d.begin(), d.end());
        rep(i,m) {
            if(d[p[i].first-1] != p[i].second) ok = false;
        }
        if(ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
A, B, K = map(int, input().split())
if B - A <= 2 * K-1:
    for i in range(A, B + 1):
        print(i)
else:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)


Measured memory_bytes: 3060