akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
int main(){
    string s;cin >> s;
    int n=s.size();
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for(int i=0;i<n-2;i++){
        if(s[i]==s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){

	int a,b,c;
	cin >> a >> b >> c;
	if(c>=a && c<=b) cout << "Yes" << endl;
	else cout << "No" << endl;

	          return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#define INF 100000000
#define EPS 1e-9

using namespace std;

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

vector<string> ans;
string maze[3];

int main() {

	maze[0] = "ABC";
	maze[1] = "DEF";
	maze[2] = "GHI";

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

	for (int i = 0; i < 1000; i++){
		cin >> str;
		int sx, sy;
		for (int i = 0; i < 3; i++){
			for (int j = 0; j < 3; j++){
				if (maze[i][j] == str[0]){
					sx = j;
					sy = i;
				}
			}
		}
		queue<P> que;
		queue<int> num;
		que.push(P(sx, sy));
		num.push(0);
		bool flag = false;
		while (que.size()){
			P p = que.front();
			int n = num.front();
			que.pop();
			num.pop();

			n++;
			if (n == str.length()){
				flag = true;
				break;
			}

			int x = p.first;
			int y = p.second;

			for (int i = 0; i < 4; i++){
				int nx = x + dx[i];
				int ny = y + dy[i];
				if (nx >= 0 && nx < 3 && ny >= 0 && ny < 3 && maze[ny][nx] == str[n]){
					que.push(P(nx, ny));
					num.push(n);
				}
			}
		}

		if (flag)
			ans.push_back(str);
	}

	for (int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1248
k, n = map(int, input().split())
a = list(map(int, input().split()))
A_list =[]
for i in range(n-1):
    A_list.append(a[i+1]-a[i])

A_list.append(a[0] + (k - a[n-1]))
print(k - max(A_list))

Measured memory_bytes: 86140
import Data.List

ans' x =
  let v = map (\ (n:v) -> (n,map read v) ) x :: [(String,[Int])]
      s = map (\ (n,v) -> let x = map (\x -> length $ filter (==x) v ) [0,1,2]
                          in
                            (n,x) ) v
      r = sortBy (\ (a,[s1,s2,s3]) (b,[t1,t2,t3]) -> let c = compare t1 s1
                                                     in
                                                       if c /= EQ
                                                       then c
                                                       else compare s2 t2 ) s

  in
    map fst r

ans ("0":_) = []
ans (x:xs) =
  let n = read x :: Int
      d = map words $ take n xs
      r = drop n xs
  in
    (ans' d) ++ (ans r)

main = do
  c <- getContents
  let i = lines c
      o = ans i
  mapM_ putStrLn o

Measured memory_bytes: 4236
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef unsigned int uint;
typedef unsigned long long uint64;
const int N=1<<18,P=998244353;
int n,m;
inline uint norm(uint x){return x<P?x:x-P;}
struct Z{
    uint x;
    Z(uint _x=0):x(_x){}
}a[N],c,sum;
inline Z operator +(const Z a,const Z b){return norm(a.x+b.x);}
inline Z operator -(const Z a,const Z b){return norm(a.x+P-b.x);}
inline Z operator *(const Z a,const Z b){return static_cast<uint64>(a.x)*b.x%P;}
inline Z operator -(const Z a){return norm(P-a.x);}
inline Z operator +=(Z &a,const Z b){return a=a+b;}
inline Z operator -=(Z &a,const Z b){return a=a-b;}
inline Z operator *=(Z &a,const Z b){return a=a*b;}
inline Z ksm(Z a,int b){
    Z ans(1);
    for(;b;b>>=1,a=a*a) if(b&1) ans*=a;
    return ans;
}
inline Z inv(Z a){return ksm(a,P-2);}
void fwt(Z *a,int k){
    for(int mid=1;mid<m;mid<<=1)
        for(int R=mid<<1,j=0;j<m;j+=R){
            Z *l=a+j,*r=a+j+mid,x;
            for(int k=0;k<mid;++k,++l,++r)
                x=*r,*r=*l-x,*l+=x;
        }
    if(k==-1){
        Z iv=inv(m);
        rep(i,0,m-1) a[i]*=iv;
    }
}
int main(){
    scanf("%d",&n);m=1<<n;
    rep(i,0,m-1) scanf("%d",&a[i].x),sum+=a[i];
    Z iv=inv(sum);a[0]=(sum-a[0])*iv;
    rep(i,1,m-1) a[i]*=-iv;fwt(a,1);c=Z(P-m);
    rep(i,1,m-1) a[i]=inv(a[i])*c,a[0]-=a[i];
    fwt(a,-1);
    rep(i,0,m-1) printf("%d\n",a[i].x);
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a+b >= 10) cout << "error" << endl;
  else cout << a+b << endl;
}

Measured memory_bytes: 3616
N, M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 1
for i in range(2,N+1):
  if (i-2 in a) and (i-1 in a):
    dp[-1] = 0
    break
  elif i-2 in a:
    dp[i] = dp[i-1]
  elif i-1 in a:
    dp[i] = dp[i-2]
  else:
    dp[i] = dp[i-1] + dp[i-2]

print(dp[-1]%(7+10**9))

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

int main() {
    int W;
    int H;
    int x;
    int y;
    int r;
    string yn;
    cin >> W >> H >> x >> y >> r;
    
    if((W - r) >= x && x >= r && (H - r) >= y && y >= r){
        yn = "Yes";
    }else{
        yn = "No";
    }

    cout << yn << endl;
}


Measured memory_bytes: 3212
#include<stdio.h>

int main(void)
{
  char str[201];
  int len=0,i=0,frag=1;
  scanf("%s",str);
  while(str[i] != '\0')
    {
      len++; i++;
    }
  if(len % 2 != 0)
    {
      len--;
    }
  else
    {
      len -= 2;
    }
  while(len > 0)
    {
      for(i=0;i<len/2;i++)
	{
	  if(str[i] != str[i+(len/2)])
	    {
	      len -= 2;
	      break;
	    }
	  else
	    {
	      if(i == (len/2)-1)
		{
		  frag = 0;
		}
	    }
	}
      if(frag == 0)
	{
	  printf("%d",len);
	  return 0;
	}
    }
}

Measured memory_bytes: 128
n,m = map(int,input().split())
l = sorted(list( list(map(int,input().split())) for _ in range(m)), key=lambda x: x[1])
br = -1
ans = 0
for i in l:
    head, tail = i[0], i[1]
    if head < br:
        continue
    else:
        br = tail
        ans += 1
print(ans)


Measured memory_bytes: 29500
#include <cstdio>
int m, d, s;
int main(){
	scanf("%d%d", &m, &d);
	for (register int i = 1; i <= m; ++i)
		for (register int j = 1; j <= d; ++j)
			if (j / 10 >= 2 && j % 10 >= 2 && (j / 10) * (j % 10) == i) ++s;
	printf("%d\n", s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;

const ll MOD=998244353;
const int MAX_N=200010;
ll n;
vector<P> p;
vector<ll> ld, lu, rd, ru;
struct BIT{
    ll bit[MAX_N+1], n;
    
    void init(ll x){
        n=x;
        rep(i,1,n+1){
            bit[i]=0;
        }
    }
    
    ll sum(ll i){
        ll s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    
    void add(ll i, ll x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};
BIT bit;
ll po2[200010];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    map<ll,ll> xs, ys;
    p.resize(n); ld.resize(n); lu.resize(n); rd.resize(n); ru.resize(n);
    rep(i,0,n){
        cin>>p[i].fr>>p[i].sc;
        xs[p[i].fr]=1;
        ys[p[i].sc]=1;
    }
    ll t=1;
    for(auto itr=xs.begin(); itr!=xs.end(); ++itr){
        itr->second=t;
        t++;
    }
    t=1;
    for(auto itr=ys.begin(); itr!=ys.end(); ++itr){
        itr->second=t;
        t++;
    }
    rep(i,0,n){
        p[i].fr=xs[p[i].fr]; p[i].sc=ys[p[i].sc];
    }
    sor(p);
    bit.init(n);
    rep(i,0,n){
        ld[i]=bit.sum(p[i].sc-1);
        lu[i]=i-ld[i];
        bit.add(p[i].sc,1);
    }
    bit.init(n);
    rer(i,n,0){
        rd[i]=bit.sum(p[i].sc-1);
        ru[i]=n-1-i-rd[i];
        bit.add(p[i].sc,1);
    }
    ll ans=0;
    po2[0]=1;
    rep(i,1,200010){
        po2[i]=po2[i-1]*2%MOD;
    }
    rep(i,0,n){
        ans+=po2[n]-(po2[ld[i]+lu[i]]+po2[lu[i]+ru[i]]+po2[ru[i]+rd[i]]+po2[rd[i]+ld[i]]-po2[ld[i]]-po2[lu[i]]-po2[ru[i]]-po2[rd[i]]+1);
        ans%=MOD;
    }
    cout <<(ans+MOD)%MOD<<"\n";
}

Measured memory_bytes: 37760
#include <stdio.h>

main(){
  int i,j,n,a[10001],c;
  for(i=0;i<10001;i++) a[i] = 1;
  a[0] = 0;
  a[1] = 0;
  for(i=2;i<10001;i++){
    if(a[i] == 1){
      for(j=i*2;j<10001;j+=i) a[j] = 0;
    }
  }

  while(scanf("%d",&n) != EOF){
    c = 0;
    for(i=2;i<n;i++){
      if(a[i] == 1 && a[n-i+1]) c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
    int n,x[101],i,min,max,p,d,dm=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&x[i]);
    max=x[2]; min=x[1];
    for(i=1;i<=n;i++){
        if(max<x[i])
            max=x[i];
        if(min>x[i])
            min=x[i];
    }
    for(i=1;i<=n;i++)
        dm+=(x[i]-min)*(x[i]-min);
    for(p=min+1;p<=max;p++){
        d=0;
        for(i=1;i<=n;i++)
            d+=(x[i]-p)*(x[i]-p);
        if(dm>d)
            dm=d;
    }
    printf("%d\n",dm);
    return 0;
}

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

int		main(void)
{
	int a, b;
	cin >> a >> b;
	if (a <= 5)
	{
		cout << 0 << endl;
		return 0;
	}
	cout << (a <= 12 ? b / 2 : b) << endl;
}

Measured memory_bytes: 256
q,w,e=input,range,int
n,m=map(e,q().split())
V=n+m
p,s=[i for i in w(V)],[1]*V
def f(x):
    if x==p[x]:
        return x
    p[x]=f(p[x]);return p[x]


def u(x, y):
    x, y = f(x), f(y)
    if x==y:
        return
    if s[x] < s[y]:
        x, y = y, x
    p[y] = x
    s[x] += s[y]


[u(i,l-1+n)for i in w(n)for l in [e(k)for k in q().split()][1:]]
print("NO"if len([i for i in w(n)if f(i)!=f(0)])>0 else"YES")


Measured memory_bytes: 12676
N, T = gets.split.map(&:to_i)
Tn = gets.split.map(&:to_i)

current = Tn[0]
sum = 0
Tn[1..-1].each do |t|
  if current + T > t
    sum += t - current
    current = t
  else
    sum += T
    current = t
  end
end

puts sum + T


Measured memory_bytes: 16004
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	int A;
	string s;
	cin>>A>>s;
	string t=s.substr(0,len(s)-3)+s.substr(len(s)-2);
	int B=stoi(t);
	cout<<A*B/100<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll X;cin>>X; 
  map<ll,ll>mp;
  for(ll i=0;pow(i,5)<pow(10,18);i++){
    mp[pow(i,5)]=i;
    mp[-pow(i,5)]=-i;
  }

  if(mp[X]!=0){
    cout<<mp[X]<<" "<<0<<endl;
      return false;

  }
  if(mp[-X]!=0){
    cout<<0<<" "<<mp[-X]<<endl;
    return false;
  }

  for(ll b=0;pow(b,5)<pow(10,18);b++){
    ll num=pow(b,5)+X;
    if(mp[num]!=0){
      cout<<mp[num]<<" "<<b<<endl;
      return false;
    }
    num=pow(-b,5)+X;
    if(mp[num]!=0){
      cout<<mp[num]<<" "<<-b<<endl;
      return false;
    }
  }

  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <utility>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N, 0);
  for (int i=0; i<N; i++) std::cin >> A[i];
  
  int cnt = 0;
  for (int i=0; i<N; i++) {
    int mini = i;
    for (int j=i; j<N; j++) {
      if (A[mini] > A[j]) mini = j;
    }
    std::swap(A[i], A[mini]);
    if (i != mini) cnt++;
  }
  
  for (int i=0; i<N-1; i++) std::cout << A[i] << ' ';
  std::cout << A[N-1] << std::endl;
  std::cout << cnt << std::endl;
  
  return 0;
}


Measured memory_bytes: 3108
from collections import deque
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

sm=a[0]
i=1
c=n-2
while c>0:
  if c>=2:
    sm+=2*a[i]
    c-=2
  elif c==1:
    sm+=a[i]
    break
  else:
    break
 
  i+=1
print(sm)

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

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  bool isStrong = true;
  for (int i = 0; i < n / 2; i++)
  {
    if (s[i] != s[n - 1 - i])
    {
      isStrong = false;
      break;
    }
  }

  for (int i = 0; i < (n - 1) / 4; i++)
  {
    if (s[i] != s[(n - 1) / 2 - 1 - i])
    {
      isStrong = false;
      break;
    }
  }

  for (int i = 0; i < n - (n + 3) / 2 + 1; i++)
  {
    if (s[(n + 3) / 2 - 1 + i] != s[n - 1 - i])
    {
      isStrong = false;
      break;
    }
  }

  if (isStrong)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  return 0;
}

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

int calc(int a, int b, int c) {
	return abs(a - b) + abs(a - c);
}

int main () {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	int ans = min({ calc(a, b, c), calc(b, a, c), calc(c, a, b) });
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    long long int h,w;
    cin >> h >> w;

    if(h==1 ||  w ==1){
        cout << 1 << endl;
    }
    else{
        cout << h*w -(h*w/2) << endl;
    }
}
        


Measured memory_bytes: 3644
import sys

sys.setrecursionlimit(10000)
mod = 1000000007


def mul(a, b):
    return ((a % mod) * (b % mod)) % mod


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, y / 2) ** 2 % mod
    else:
        return power(x, y / 2) ** 2 * x % mod


def div(a, b):
    return mul(a, power(b, mod - 2))


# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]
#
#
# class UnionFind:
#     def __init__(self, n):
#         self.par = [i for i in range(n+1)]
#         self.rank = [0] * (n+1)
#
#     # 検索
#     def find(self, x):
#         if self.par[x] == x:
#             return x
#         else:
#             self.par[x] = self.find(self.par[x])
#             return self.par[x]
#
#     # 併合
#     def union(self, x, y):
#         x = self.find(x)
#         y = self.find(y)
#         if self.rank[x] < self.rank[y]:
#             self.par[x] = y
#         else:
#             self.par[y] = x
#             if self.rank[x] == self.rank[y]:
#                 self.rank[x] += 1
#
#     # 同じ集合に属するか判定
#     def same_check(self, x, y):
#         return self.find(x) == self.find(y)


ans = 0
N = int(input())
X = [0 for _ in range(N)]
Y = [0 for _ in range(N)]
for i in range(N):
    X[i], Y[i] = map(int, input().split())

ans = 0

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x = X[i] - X[j]
        y = Y[i] - Y[j]
        ans_loop = 0

        for first in range(N):
            for second in range(N):
                if first == second:
                    continue
                if X[first] == X[second] - x and Y[first] == Y[second] - y:
                    ans_loop += 1
                    break

        ans = max(ans, ans_loop)

print(N-ans)


Measured memory_bytes: 43116
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, K;
int h[100010];

int main()
{
  scanf( "%d%d", &N, &K );
  rep( i, N )
    scanf( "%d", h+i );

  std::sort( h, h+N );

  int ans = 1<<30;

  rep( i, N )
  {
    if( i+K-1 < N )
      ans = std::min( ans, h[i+K-1]-h[i] );
  }

  printf( "%d\n", ans );

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int n,i,j,cnt=0,tmp;
  scanf("%d",&n);
  int a[2][n];
  for(i=0;i<2;i++)
    for(j=0;j<n;j++)
      scanf("%d",&a[i][j]);

  for(i=0;i<n;i++){
    tmp=0;
    for(j=0;j<=i;j++)
      tmp+=a[0][j];
    for(j=i;j<n;j++)
      tmp+=a[1][j];
    if(tmp>cnt)
      cnt=tmp;    
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	step := 0
	pre := 0
	for i := 0; i < n; i++ {
		if i == 0 {

			pre = a[i]
		} else {
			if pre <= a[i]{
				pre = a[i]
			} else {
				add :=  pre - a[i]
				pre = a[i] + add
				step = step + add
			}
		}
	}
	fmt.Println(step)
}


Measured memory_bytes: 6488
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
	SPEED
	int n, l;
	cin >> n >> l;
	vector<int> v;
	for (int i = 1; i <= n; ++i)
	{
		v.push_back(l+i-1);
	}
	int sum = 0;
	sum = accumulate(v.begin(), v.end(), sum);
	int diff = 20000000;
	int ans;
	for (vector<int>::iterator i = v.begin(); i != v.end(); ++i)
	{
		if (abs(sum - (sum-(*i))) < diff)
		{
			diff = abs(sum - (sum-(*i)));
			ans = sum - (*i);
		}
		
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = list(map(str,input().split()))
for i in range(N):
    A[i].append(str(i+1))
for i in range(N):
    A[i][1] = int(A[i][1]) 


B = sorted(A, key=lambda x: x[1], reverse=True)

C = sorted(B, key=lambda x: x[0])

for i in range(N):
    print(int(C[i][2]))


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;
int n;
LL re[100];
int main() {
	while(~scanf("%d", &n)) {
		if(n < 1 || n > 86) break;
		re[0] = 2;
		re[1] = 1;
		for(int i = 2; i <= n; i++) re[i] = re[i - 1] + re[i - 2];
		printf("%lld\n", re[n]);
	}
	return 0;
}

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

int main(){
    vector<int> A(5);
    for(int i=0;i<5;i++) cin>>A[i];

    int min=10,l,sum=0;
    for(int i=0;i<5;i++){
        if(A[i]%10!=0){
            if(min>A[i]%10){
                min=A[i]%10;
                l=i;
            }
            sum+=(A[i]+9)/10*10;
        }else sum+=A[i];
    }
    cout<<sum-((A[l]+9)/10*10)+A[l]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int state = 0, num;
  int train[100];
  while(scanf("%d", &num) != EOF){
    if(num != 0){
      train[state] = num;
      state += 1;
    }else{
      state -= 1;
      printf("%d\n", train[state]);
    }
  }
  return 0;
}

Measured memory_bytes: 600
/*
Saurabh Joshi
IIIT Jabalpur
*/
#include<bits/stdc++.h>
#define LL long long int
#define M 1000000007
#define endl "\n"
#define eps 0.00000001
LL pow(LL a,LL b,LL m){ a%=m;LL x=1,y=a;while(b > 0){if(b%2 == 1){x=(x*y);if(x>m) x%=m;}y = (y*y);if(y>m) y%=m;b /= 2;}return x%m;}
LL gcd(LL a,LL b){if(b==0) return a; else return gcd(b,a%b);}
LL gen(LL start,LL end){LL diff = end-start;LL temp = rand()%start;return temp+diff;}
using namespace std;
LL a[100001];
LL dp[101][100001];
LL psum[100001];
LL getsum(int l,int r) {
    if(l == 0)
        return psum[r];
    else
        return ((psum[r] - psum[l - 1]) % M + M) % M;
}
int main()	{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) 
        cin >> a[i];
    dp[0][0] = 1;
    for(int i = 0; i <= k; i++)
        psum[i] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= k; j++) {
            int r = j;              
            int l = j - min(a[i] , (LL)j);
            dp[i][j] += getsum(l , r);
            dp[i][j] %= M;
        }
        psum[0] = dp[i][0];
        for(int j = 1; j <= k; j++) {
            psum[j] = psum[j - 1] + dp[i][j];
            psum[j] %= M;
        }
    }
    
    cout << dp[n][k] << endl;
}

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

int main(void){
  int x,a,b;
  cin >> x >> a >> b;
  if(b <= a){
    cout << "delicious" << endl;
  }else if(b <= x+a){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

char s[N];
int n;
int sum[N][27];

int main()
{
	//File("");
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i+=1)
	{
		for (int j = 0; j < 26; j+=1) sum[i][j] = sum[i - 1][j];
		++sum[i][s[i] - 'a'];
	}
	for (int i = 0; i < 26; i+=1)
	{
		int id = 0;
		for (int j = 1; j <= n; j+=1)
		{
			if (sum[j][i] * 2 - j > 2 * sum[id][i] - id && id != j - 1) {cout << id + 1 << ' ' << j << endl; return 0;}
			if (sum[j][i] * 2 - j < 2 * sum[id][i] - id) id = j;
		}
	}
	puts("-1 -1");
	return 0;
}


Measured memory_bytes: 14408
from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = map(int,input().split())
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1,10**6] for i in range(H+1)]
for i in range(m):
    a,b = map(int,input().split())
    h[a] += 1
    w[b] += 1
    c[a].append(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H+1):
    if h[i] == mh:
        hkouho.append(i)
for i in range(W+1):
    if w[i] == mw:
        wkouho.append(i)
for i in hkouho:
    c[i] = set(c[i])
    for j in wkouho:
        # if c[i][bisect_left(c[i],j)] != j:
        if j not in c[i]:
            print(mh+mw)
            exit()
print(mh+mw-1)

Measured memory_bytes: 196704
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
const int IMAX = 600000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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

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

	ll kotae = 0;
	const int mod = 1e9 + 7;

	//水コーダーと申します

	rep(i, N + 1) {
		int j = N - i;

		ll tmp = 1ll * f.fac[M - i] * f.ifac[M - i - j] % mod;
		tmp = tmp * f.comb(N, i) % mod;

		if (i % 2) tmp = (mod - tmp) % mod;
		kotae += tmp;
	}
	co(kotae% mod * f.fac[M] % mod * f.ifac[M - N] % mod);


	Would you please return 0;
}

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

int main() {
    int n,ans=0;
    cin>>n;
    vector<int> a(n),b(n),c(n-1);

    rep(i,n) {
        cin>>a[i];
        a[i]--;
    }

    rep(i,n) cin>>b[i];
    rep(i,n-1) cin>>c[i];

    rep(i,n) {
        ans+=b[a[i]];
        if (i != 0 && (a[i]-a[i-1]) == 1) ans+=c[a[i-1]];
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;

const int N = 1e6+5;
int t;
int a[N], b[N];

int main()
{
	int n;
	while (cin >> n)
	{
		ll sum = 0;
		f(i, 1, n)
		{
			if (i % 3 == 0 || i % 5 == 0)continue;
			sum += i;
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        UL N; cin >> N;
        vector<UL> A(N); rep(i, N) cin >> A[i];
        reverse(A.begin(), A.end());
        rep(i, N) {
            if (i) cout << " ";
            cout << A[i];
        } cout << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include <iomanip>

using namespace std;
int main(){
    int N , K;
    cin >> N >> K;

    int jou = 0;
    while(pow(2, jou) < K)jou++;

    int n_j = jou;
    float node = 1.0;
    long double ans = 0.0;
    for(int i = 1; i <= N; i++){
        //cout << float(1.0/N) * powf(0.5, n_j) << endl;;
        ans += double(1.0/N) * powf(0.5, n_j);
        if((i+1)*pow(2, n_j-1) >= K)n_j--;
        if(n_j <0)n_j = 0;
    }
    cout << setprecision(19) << ans;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	buf := make([]byte, 100000)
	scanner.Buffer(buf, 100001)

	s := getString()
	s = reverse(s)

	ans := "YES"
L:
	for i := 0; i < len(s); {
		switch {
		case len(s)-i >= 5 && (s[i:i+5] == "maerd" || s[i:i+5] == "esare"):
			i += 5
		case len(s)-i >= 6 && s[i:i+6] == "resare":
			i += 6
		case len(s)-i >= 7 && s[i:i+7] == "remaerd":
			i += 7
		default:
			ans = "NO"
			break L
		}
	}

	fmt.Println(ans)
}

func reverse(s string) string {
	rs := []rune(s)
	n := len(rs)

	for i := 0; i < n/2; i++ {
		rs[i], rs[n-i-1] = rs[n-i-1], rs[i]
	}

	return string(rs)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

int main (void){
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n / 2 << endl;
    } else {
        cout << n / 2 + 1 << endl;
    }
}

Measured memory_bytes: 3596
table = [[[0] * 10 for i in range(0, 3)] for k in range(0, 4)]

n = int(input())

for i in range(n):
    house_id, floor, room, add = map(int, input().split())
    table[house_id - 1][floor - 1][room - 1] += add

x = 0

for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()



Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='7')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }

        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MOD 1000000007

ll mod_pow(ll base, ll pow, ll m = MOD)
{
    if (pow == 0)
        return 1;

    ll res = mod_pow(base, pow / 2);
    res = res * res % m;
    if (pow % 2)
        res *= base;
    return res % m;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> dp = {};
    dp.resize(k + 1, 0);

    ll ans = 0;
    for (auto g = k; g >= 1; g--)
    {
        dp[g] = mod_pow(k / g, n);
        for (auto gg = 2 * g; gg <= k; gg += g)
        {
            dp[g] -= dp[gg];
        }

        ans += g * dp[g];
        ans %= MOD;
    }

    if (ans < 0)
    {
        ans += MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3988
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    #s = x+ y+ z
    ret =[0]*(N+1)
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                n = x**2+y**2+z**2+x*y+y*z+z*x
                if n<=N:
                    ret[n] += 1
    for i in ret[1:N+1]:
        print(i)

if __name__ == '__main__':
    main()

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

int main() {
  int A;
  int B;
  int C;
  int D;
  
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D)
    cout << "Left" << endl;
  else if(A + B == C + D)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int gcd(int a,int b){return (!b)?a:gcd(b,a%b);}

int main()
{
	int maxx=0,n,d;
	scanf("%d%d",&n,&d);
	int ans=0;
	for(int i=1;i<=n;++i){
		int x;scanf("%d",&x);
		maxx=max(maxx,x);
		if(i==1)ans=x;
		else ans=gcd(ans,x);		
	}
	if(d<=maxx&&(d%ans)==0)cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 256
function memoization(f) {
  const cache = {};
  return (...param) => {
    const c = cache[param];
    return typeof c === 'undefined' ? cache[param] = f(...param) : c;
  };
}

class _Node {
  constructor(id, parentId, leftId, rightId) {
    this.id = id;
    this.parentId = parentId;
    this.leftId = leftId;
    this.rightId = rightId;
  }
  get type() {
    return this.parentId === -1
        ? 'root'
        : this.leftId === -1 && this.rightId === -1
            ? 'leaf'
            : 'internal node'}
}

class BinaryTree {
  constructor() {
    this.nodes = [];
    this._nodeInfo = [];
    this.getDepth = memoization(this.getDepth.bind(this));
    this.getHeight = memoization(this.getHeight.bind(this));
  }
  static get Node() {return _Node;}

  add(id, leftId, rightId) {this.nodes[id] = new BinaryTree.Node(id, -1, leftId, rightId);}

  connect() {
    for (let i = 0; i < this.nodes.length; i++ ) this._nodeInfo[i] = {node:null, sibling:-1, degree:0};
    this.nodes.forEach(n => {
      if (n.leftId !== -1) {
        this.nodes[n.leftId].parentId = n.id;
        this._nodeInfo[n.leftId].sibling = n.rightId;
      }
      if (n.rightId !== -1) {
        this.nodes[n.rightId].parentId = n.id;
        this._nodeInfo[n.rightId].sibling = n.leftId;
      }
    });
    this.nodes.forEach(n => {
      this._nodeInfo[n.id] = {sibling: this._nodeInfo[n.id].sibling, node: n, degree: (n.leftId !== -1) + (n.rightId !== -1)}
    });
  }

  getDepth(id, i = 0) {
    let pid = this.find(id).parentId;
    return pid === -1 ? i : this.getDepth(pid, i + 1);
  }

  getHeight(id, i = 0) {
    if (id === -1) return i - 1;
    let n = this.find(id);
    let [lid, rid] = [n.leftId, n.rightId];
    return Math.max(this.getHeight(lid, i + 1), this.getHeight(rid, i + 1))
  }

  find(id) {return this.nodes[id]}

  print() {
    console.log(this._nodeInfo.map(o =>
      `node ${o.node.id}: parent = ${o.node.parentId}, sibling = ${o.sibling}, degree = ${o.degree}, depth = ${this.getDepth(o.node.id)}, height = ${this.getHeight(o.node.id)}, ${o.node.type}`
    ).join('\n'));
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  let tree = new BinaryTree();

  let id, l, r;
  lines.map(l => l.split(' ').map(Number)).forEach(function(line) {
    tree.add(...line);
  });
  tree.connect();
  tree.print();
})();



Measured memory_bytes: 16508
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int A = int.Parse(str[0]);
		int B = int.Parse(str[1]);
		int M = int.Parse(str[2]);
		int[]AA = new int[A];
		int[]BB = new int[B];
		string[] str2 = Console.ReadLine().Split();
		int Amin = 999999999;
		for(var i=0;i<A;i++){
			AA[i] = int.Parse(str2[i]);
			Amin = Math.Min(AA[i],Amin);
		}
		string[] str3 = Console.ReadLine().Split();
		int Bmin = 999999999;
		for(var i=0;i<B;i++){
			BB[i] = int.Parse(str3[i]);
			Bmin = Math.Min(BB[i],Bmin);
		}
		int ans = Amin+Bmin;
		for(var i=0;i<M;i++){
			string[] str4 = Console.ReadLine().Split();
			int a3 = int.Parse(str4[0]);
			int b3 = int.Parse(str4[1]);
			int c3 = int.Parse(str4[2]);
			int d3 = AA[a3-1]+BB[b3-1]-c3;
			ans = Math.Min(d3,ans);
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 33628
#include <cstdio>
#include <algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

constexpr int MAX_N = 40, INF = std::numeric_limits<int>::max()>>2;

int N, Ma, Mb;
int a[MAX_N], b[MAX_N], c[MAX_N];
int dp[MAX_N+1][401][401];

int main()
{
  scanf( "%d%d%d", &N, &Ma, &Mb );
  rep( i, N )
    scanf( "%d%d%d", a+i, b+i, c+i );

  std::fill( (int*)dp, (int*)(dp+N+1), INF );
  dp[0][0][0] = 0;

  rep( i, N ) rep( j, 401 ) rep( k, 401 )
  {
    dp[i+1][j][k] = std::min( dp[i+1][j][k], dp[i][j][k] );

    if( j-a[i] >= 0 && k-b[i] >= 0 )
      dp[i+1][j][k] = std::min( dp[i+1][j][k], dp[i][j-a[i]][k-b[i]]+c[i] );
  }

  int ans = INF;
  rep( i, 401 ) if( i && i*Mb%Ma == 0 && i*Mb/Ma <= 400 )
    ans = std::min( ans, dp[N][i][i*Mb/Ma] );

  printf( "%d\n", ans==INF?-1:ans );

  return 0;
}

Measured memory_bytes: 25856
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC
{
	class QuestionC
	{
		public static void Main(string[] args)
		{
			var scanner = new Scanner();
			(BigInteger, BigInteger) a = scanner.Long2();

			var x = a.Item1;
			var y = a.Item2;

			var sum = 0L;

			while (x <= y) {
				sum++;
				x *= 2;
			}

			Console.WriteLine(sum);
		}

		public class Scanner
		{
			private readonly char[] delimiter_ = new char[] { ' ' };
			private readonly string filePath_;
			private readonly Func<string> reader_;
			private string[] buf_;
			private int index_;

			public Scanner(string file = "")
			{
				if (string.IsNullOrWhiteSpace(file)) {
					reader_ = Console.ReadLine;
				} else {
					filePath_ = file;
					var fs = new StreamReader(file);
					reader_ = fs.ReadLine;
				}
				buf_ = new string[0];
				index_ = 0;
			}

			public string NextLine() => reader_();
			public string Next()
			{
				if (index_ < buf_.Length) {
					return buf_[index_++];
				}

				string st = reader_();
				while (st == "") {
					st = reader_();
				}

				buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
				if (buf_.Length == 0) {
					return Next();
				}

				index_ = 0;
				return buf_[index_++];
			}

			public int Int() => int.Parse(Next());
			public long Long() => long.Parse(Next());
			public double Double() => double.Parse(Next());

			public int[] ArrayInt(int N, int add = 0)
			{
				int[] Array = new int[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Int() + add;
				}
				return Array;
			}

			public long[] ArrayLong(int N, long add = 0)
			{
				long[] Array = new long[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Long() + add;
				}
				return Array;
			}

			public double[] ArrayDouble(int N, double add = 0)
			{
				double[] Array = new double[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Double() + add;
				}
				return Array;
			}

			public (int, int) Int2(int add = 0)
			{
				var array = ArrayInt(2, add);
				return (array[0], array[1]);
			}

			public (int, int, int) Int3(int add = 0)
			{
				var array = ArrayInt(3, add);
				return (array[0], array[1], array[2]);
			}

			public (long, long) Long2(int add = 0)
			{
				var array = ArrayLong(2, add);
				return (array[0], array[1]);
			}

			public (long, long, long) Long3(int add = 0)
			{
				var array = ArrayLong(3, add);
				return (array[0], array[1], array[2]);
			}

			public (double, double) Double2(int add = 0)
			{
				var array = ArrayDouble(2, add);
				return (array[0], array[1]);
			}

			public (double, double, double) Double3(int add = 0)
			{
				var array = ArrayDouble(3, add);
				return (array[0], array[1], array[2]);
			}

			public void Save(string text)
			{
				if (string.IsNullOrWhiteSpace(filePath_)) {
					return;
				}

				File.WriteAllText(filePath_ + "_output.txt", text);
			}
		}
	}
}


Measured memory_bytes: 27720
#include <iostream>
#include <string>
#include <vector>

#define MAX_H 2000
#define MAX_W 2000

using namespace std;

struct UnionFind
{
private:
    int size;
    vector<int> root;

public:
    UnionFind( int size ) : size( size ) { root.resize( size, -1 ); }

    int find( int x )
    {
        if ( root[x] < 0 ) return x;
        return root[x] = find( root[x] );
    }

    bool same( int x, int y ) { return find( x ) == find( y ); }

    bool unite( int x, int y )
    {
        int rx = find( x );
        int ry = find( y );

        if ( rx == ry ) return false;
        if ( ry < rx ) swap( rx, ry );

        root[rx] += root[ry];
        root[ry] = rx;

        return true;
    }
};

int lenH[MAX_H * MAX_W]; // 縦方向のながさ
int lenW[MAX_H * MAX_W]; // 横方向のながさ

string S[MAX_H];

int main( int argc, char **argv )
{
    // inputs
    int H, W;
    cin >> H >> W;

    for ( int i = 0; i < H; i++ ) cin >> S[i];

    // solve
    UnionFind ufW( H * W + 1 );
    UnionFind ufH( H * W + 1 );

    auto index = [&]( const int h, const int w ) {
        if ( h < 0 || H <= h ) return H * W;
        if ( w < 0 || W <= w ) return H * W;
        return h * W + w;
    };

    // 横方向の長さを計算
    for ( int h = 0; h < H; h++ )
    {
        int len = 0;
        int start = 0;
        for ( int w = 0; w < W; w++ )
        {
            if ( S[h][w] == '#' )
            {
                // 壁
                int idx = index( h, w - 1 );
                lenW[ufW.find( idx )] = len;
                len = 0;
                start = w + 1;
            }
            else
            {
                // 通路
                len++;

                int idx1 = index( h, w );
                int idx2 = index( h, start );
                ufW.unite( idx1, idx2 );
            }
        }

        if ( len > 0 )
        {
            int idx = index( h, W - 1 );
            lenW[ufW.find( idx )] = len;
        }
    }

    // 縦方向の長さ
    for ( int w = 0; w < W; w++ )
    {
        int len = 0;
        int start = 0;
        for ( int h = 0; h < H; h++ )
        {
            if ( S[h][w] == '#' )
            {
                // 壁
                int idx = index( h - 1, w );
                lenH[ufH.find( idx )] = len;
                len = 0;
                start = h + 1;
            }
            else
            {
                // 通路
                len++;

                int idx1 = index( h, w );
                int idx2 = index( start, w );
                ufH.unite( idx1, idx2 );
            }
        }

        if ( len > 0 )
        {
            int idx = index( H - 1, w );
            lenH[ufH.find( idx )] = len;
        }
    }

    int maxLightUp = 0;
    for ( int h = 0; h < H; h++ )
    {
        for ( int w = 0; w < W; w++ )
        {
            int idx = index( h, w );
            int lightUp = lenH[ufH.find( idx )] + lenW[ufW.find( idx )] - 1;

            maxLightUp = max( maxLightUp, lightUp );
        }
    }

    cout << maxLightUp << endl;

    return 0;
}


Measured memory_bytes: 66816
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int ans=1000,num,mm;
	string s;
	string tmp;
	cin>>s;
	for(int i=0;i<s.length()-2;i++){
		for(int j=0;j<3;j++){
			tmp[j]=s[i+j];
		}
		num=stoi(tmp);
		mm=abs(753-num);
		if(ans>mm)ans=mm;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int a, b, c, d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(abs(a-c) <= d){
        printf("Yes\n");
    }else if(abs(a-b) <= d && abs(b-c) <= d){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long T;
 
struct point { 
    T x,y;
    int i; 
    point operator - (const point &rhs) {
        return {x-rhs.x, y-rhs.y};
    }
    T operator * (const point &rhs) {
        return x*rhs.x + y*rhs.y;
    }
    T operator % (const point &rhs) {
        return x*rhs.y - y*rhs.x;
    }
    T len2() {
        return x*x + y*y;
    }
};
 
int compare(T x, T y) {
    if(y - x > 0) return -1;
    if(x - y > 0) return 1;   
    return 0;
}
 
T cross(point p, point q, point r) { return (r-q)%(p-q); }
 
int turn(point p, point q, point r) { return compare(cross(p,q,r), 0); }
 
int cw(point p, point q, point r) { return turn(p,q,r) < 0; }
 
double angle(point a, point o, point b) // angle AOB (in radians)
{
   point u = a - o; // u: vector oa
   point v = b - o; // v: vector ob
   return acos(u * v / sqrt(1.0 * u.len2() * v.len2())); // dot product
}

bool cmp(const point &p, const point &q)
{
    return p.x < q.x || (p.x == q.x && p.y < q.y);
}
 
vector<point> convex_hull(vector<point> &p)
{
    int n = (int)p.size(), k = 0;
    vector<point> h(2 * n);
    sort(p.begin(), p.end(), cmp);
    for(int i = 0; i < n; i++) 
    {
        while(k >= 2 && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    for(int i = n - 2, t = k + 1; i >= 0; i--) 
    {
        while(k >= t && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    h.resize(k); h.pop_back(); 
    return h;
}
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(10);
    int n,m;
    vector<point> p,h;
    double ans[105];
    while(cin >> n)
    {
        p = vector<point>(n);
        for(int i = 0; i < n; i++)
        {
            cin >> p[i].x >> p[i].y;
            p[i].i = i;
        }
        h = convex_hull(p);
        for(int i = 0; i < n; i++)
            ans[i] = 0;
        m = h.size();
        for(int i = 0; i < m; i++)
            ans[h[i].i] = (M_PI - angle(h[(i-1+m)%m], h[i], h[(i+1)%m])) / (2*M_PI);
        for(int i = 0; i < n; i++)
            cout << ans[i] << '\n';
    }
    return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
main()
{
    int n,i,j,k,temp,swap=0,a[105];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=1;i<n;i++)
        for(j=0;j<n-i;j++)
    {
        if(a[j]>a[j+1])
        {
            temp=a[j];
            a[j]=a[j+1];
            a[j+1]=temp;
            swap++;
        }
    }
    for(i=0;i<n-1;i++)
        printf("%d ",a[i]);
    printf("%d\n",a[n-1]);

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

Measured memory_bytes: 1852