akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string str;
int S[MAX_N];
pi D[MAX_N];

void solve() {
	cin >> str;
	N = sz(str);
	rep(i, 0, 26) {
		memset(S, 0, sizeof(S));
		rep(j, 0, N) {
			if(str[j] - 'a' == i) {
				S[j + 1]++;
			}
			else S[j + 1]--;
		}
		D[0] = pi(0, 0);
		rep(j, 0, N) {
			S[j + 1] += S[j];
			D[j + 1] = pi(S[j + 1], j + 1);
		}
		rer(j, N + 1, 1) {
			MAX(D[j - 1], D[j]);
		}
		// debug(vi(S, S + N + 1));
		// debug(vector<pi>(D, D + N + 1));
		rep(j, 0, N - 1) {
			pi p2 = D[j + 2];
			if(p2.fst - S[j] > 0) {
				cout << j + 1 << " " << p2.sec << "\n";
				return;
			}
		}
	}
	cout << "-1 -1\n";
	
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 2000
#sed "s/ /\n/g" | sort -nr | tr "\n" " " | head -c 5

#echo $(sed "s/ /\n/g" | sort -n | tr "\n" " ")
if echo $(sed "s/ /\n/g" | sort -n | tr "\n" " ") | grep "5 5 7" --silent --line-regex;then
    echo "YES"
else
    echo "NO"
fi



Measured memory_bytes: 2732
while True:
    try:
        n = input()
        if n == 0:
            break
        else:
            before = []
            after = []
            for i in range(n):
                lst = raw_input().split(' ')
                before.append(lst[0])
                after.append(lst[1])
            m = input()
            ans = ''
            for i in range(m):
                value = raw_input()[0]
                try:
                    ans += after[before.index(value)]
                except ValueError:
                    ans += value
            print ans
    except EOFError:
        break

Measured memory_bytes: 7364
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();

        if (a == b) {
            System.out.println(a);
            System.exit(0);
        }

        int k = s.nextInt();
        boolean f = true;
        Set<Integer> set = new TreeSet<>();

        for (int i = 0; i < k; i++) {
            if (a+i > b) {
                f = false;
                break;
            }
            set.add(a + i);

        }
        if (f) {
            for (int i = k - 1; i >= 0; i--) {
                if (b - i < a) {
                    break;
                }
                set.add(b - i);
            }
        }
        for (Integer integer : set) {
            System.out.println(integer);
        }
    }
}


Measured memory_bytes: 21716
#include<stdio.h>
typedef long long LL;
#define REP(j,k,n) for(LL j=k;j<(LL)n;j++)
#define rep(i,N) REP(i,0,N)
const int MOD=998244353;
inline LL Pow(LL x,LL y){LL z=1;x%=MOD;while(y){if(y&1){z=(z*x)%MOD;}x=(x*x)%MOD;y>>=1;}return z%MOD;}
int main(void)
{
  int A,B,C,D,ans=0,dp[3001]={0};LL sum;
  if(!scanf("%d %d %d %d",&A,&B,&C,&D))return 0;
  dp[A]=1;
  rep(i,D-B)
  {
    sum=0;
    REP(j,1,C+1)
    {
      sum=(sum*(B+i)%MOD+dp[j])%MOD;
      dp[j]=(dp[j]*(j-1)+sum)%MOD;
    }
  }
  rep(i,C+1)ans=(ans+dp[i]*Pow(D,C-i)%MOD)%MOD;
  return printf("%lld\n",ans<0?ans+MOD:ans),0;
}

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

typedef long long ll;
#define pii pair<int, int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 4005

int s[5][MAXX];

int main() {
    _FastIO;
    int n;
    cin >> n;
    string str;
    cin >> str;
    for(int i = 0; i < n; i++) {
        if(i) {
            s[0][i] += s[0][i-1];
            s[1][i] += s[1][i-1];
            s[2][i] += s[2][i-1];
        }
        if(str[i] == 'R') {
            str[i] = 0;
            s[0][i]++;
        }
        if(str[i] == 'G') {
           str[i] = 1;
           s[1][i]++;
        }
        if(str[i] == 'B'){
         str[i] = 2;
         s[2][i]++;
        }
    }
 
    ll ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n-1; j++) {
            if(str[i] == str[j])
                continue;
            for(int k = 0; k < 3; k++) {
                if(k == str[i] || k == str[j])
                    continue;
                ans += s[k][n - 1] - s[k][j];
                if((2 * j - i) < n && str[(2 * j - i)] == k) 
                    ans--;
            }
        }
    cout << ans << endl;
    return 0;
}

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

#define repr(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define irepr(i,a,b) for(int i=(a), i##_len=(b); i>=i##_len; --i)
#define irep(i,n) for(int i=(n), i>=0; --i)

#define all(arr) begin(arr), end(arr)

#define printline(str) cout << str << "\n"

#define lint long long
#define ulint unsigned long long

template<class T>
void printArray(const T& arr, string del = string(", ")){
  for( auto it = begin(arr); it != end(arr); it++){
    cout << (it != cbegin(arr) ? del : "") << *it;
  }
  cout << "\n";
}

class BIT
{
private:
  int n;
  vector<int> nodes;
public:
  BIT(vector<int> v){
    int size = v.size();
    n = 1;
    while(n < size){
      n *= 2;
    }
    nodes.resize(n, 0);
    rep(i, size){
      add(i, v[i]);
    }
  }

  void add(int i, int val){
    ++i;
    while(i <= n){
      nodes[i] += val;
      i += i&-i;
    }
  }

  int sum(int i){
    ++i;
    int ret = 0;
    while(i > 0){
      ret += nodes[i];
      i -=i&-i;
    }
    return ret;
  }
};


struct point{
  int x;
  int y;
};

point operator+(const point lhs, const point rhs){
  return {lhs.x+rhs.x, lhs.y+rhs.y};
}
point operator-(const point lhs, const point rhs){
  return {lhs.x-rhs.x, lhs.y-rhs.y};
}


constexpr ulint maxInt = 998244353;

template<size_t num>
struct Pof2{
  ulint val[num];
  constexpr Pof2():val(){
    val[0] = 1;
    repr(i, 1, num){
      val[i] = (val[i-1]*2)%maxInt;
    }
  }
  constexpr int operator[](size_t i)const{
    return val[i];
  }
};

constexpr int maxN = 2*100000;

constexpr auto pof2 = Pof2<maxN + 1>();




int main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vector<point> p;
  vector<int> ind(N);
  iota(all(ind), 0);
  p.reserve(N);
  rep(i,N){
    int x, y;
    cin >> x >> y;
    p.push_back({x, y});
  }
  sort( all(p), [](const auto& lhs, const auto& rhs){ return lhs.x < rhs.x;});
  sort( all(ind), [&](int lhs, int rhs){ return p[lhs].y < p[rhs].y;});

  BIT f( vector<int>(N,1));
  BIT b( vector<int>(N,0));
  lint s = 0;
  rep(i,N){
    f.add(ind[i], -1);
    int yMaxNum = f.sum(N-1) - f.sum(ind[i]);
    int yMinNum = b.sum(ind[i]);
    b.add(ind[i], 1);

    if( i == 0 || i == N-1){
      s = (s + pof2[N-1])%maxInt;
      continue;
    }
    ulint pn, pN, pm, pM;
    pn = pof2[yMinNum];
    pM = pof2[i-yMinNum];
    pN = pof2[yMaxNum];
    pm = pof2[(N-1-i)-yMaxNum];
    ulint a = pof2[N-1]%maxInt;
    ulint b = ( (pn-1ULL)*( (pM*pm)%maxInt )%maxInt )*(pN-1ULL)%maxInt;
    ulint c = ((pM-1ULL)*(b==0?pn*pN:(pn+pN-1) )%maxInt)*(pm-1ULL)%maxInt;
    s = (s + a + b + c)%maxInt;
  }
  printline(s);
}

Measured memory_bytes: 5488
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  int a, b, n;
  cin >> a >> b >> n;
  int ans = INF;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (b * j % i) continue;
      cmin(ans, abs(a - b * j / i));
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3092
#include"bits/stdc++.h"
using namespace std;

#define MAX 1<<16
#define MOD 1000000007

int n;
int m;

vector<int> v;

long long int dp[18][1 << 16];

long long int ppow(long long int i, long long int j) {
	long long int res = 1;
	while (j) {
		if (j & 1LL) {
			res *= i;
			if (res >= MOD)res %= MOD;
		}
		i *= i;
		if (i >= MOD)i %= MOD;
		j >>= 1LL;
	}
	return res;
}

long long int k2[MAX];  //k1
long long int r[MAX];

long long int C(int a, int b) {
	long long int up = k2[a];
	long long int dw =r[b] * r[a - b];
	dw %= MOD;
	up *= dw;
	return up % MOD;
}

int main() {
	k2[0] = 1;
	for (int i = 1; i < MAX; i++) {
		k2[i] = k2[i - 1] * i;
		k2[i] %= MOD;
	}
	for (int i = 0; i < MAX; i++) {
		r[i] = ppow(k2[i], MOD - 2);
	}
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	dp[0][0] = 1;
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < (1 << n); j++) {
			if (dp[i][j] == 0)continue;
			if (j != (1 << n) - 1) {
				dp[i + 1][j] += dp[i][j];
				if (dp[i + 1][j] >= MOD)dp[i + 1][j] -= MOD;
			}
			else {
				cout << "er" << endl;
			}
			//make new
			int used = j;
			for (int k = 0; k < n; k++) {
				if ((j >> k) & 1) {
					continue;
				}
				int ALL = (1<<n) - v[i] + 1;
				ALL -= used;
				int want = (1 << k);
				if (want <= ALL) {
					dp[i + 1][j + want] += dp[i][j] * C(ALL - 1, want - 1);
					dp[i + 1][j + want] %= MOD;
				}
			}
		}
	}
	long long int ANS = 0;
	for (int j = 0; j < (1 << n); j++) {
		long long int z = dp[m][j];
		int rem = (1 << n) - j - 1;
		bool par = false;
		for (int k = 0; k < n; k++) {
			if ((j >> k) & 1) {
				par ^= true;
			}
			else{
				z *= C(rem, (1<<k) );
				z %= MOD;
				rem -= (1 << k);
			}
			z *= k2[1 << k];
			z %= MOD;
		}
		z *= (1 << n);
		z %= MOD;
		if (par == false) {
			ANS += z;
		}
		else {
			ANS += MOD - z;
		}
	}
	ANS %= MOD;
	printf("%lld\n", ANS);
	return 0;
}

Measured memory_bytes: 9472
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double x, h;
  while (cin >> x >> h, x) {
    cout << prec(8) << x * x + x * hypot(h, x / 2) * 2 << endl;
  }
}

Measured memory_bytes: 3260
N = int(input())
ll = [] #リストのリスト
for i in range(N):
    l = [None]*N
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        l[x-1] = y
    ll.append(l)

ans = 0
for i in range(1, 2**N): #bit全探索
    b = 1
    hon = [0]*N #正直者なら1, 
    for j in range(N):
        if i>>j&1:
            hon[j] = 1
    
    for k in range(N): # llとhonの比較 # 全正直者について
        if hon[k]==1: #正直者のつじつまを合わせる
            for h in range(len(ll[k])): #正直者の全ての証言について	
                if ll[k][h]==None:
                    continue
                if hon[h]!=ll[k][h]:
                    b = 0
                
   
    if b:
        p = hon.count(1)
        ans = max(p, ans)
print(ans)

Measured memory_bytes: 74788
#include <stdio.h>

int main(void) {
  int n;
  scanf("%i", &n);
  
  int colors[10] = {0}; 
  
  int a[n], count = 0;
  for (int i = 0; i < n; i++) {
    scanf("%i", &a[i]);
    if (a[i] <= 399)       colors[0] = 1;
    else if (a[i] <= 799)  colors[1] = 1;
    else if (a[i] <= 1199) colors[2] = 1;
    else if (a[i] <= 1599) colors[3] = 1;
    else if (a[i] <= 1999) colors[4] = 1;
    else if (a[i] <= 2399) colors[5] = 1;
    else if (a[i] <= 2799) colors[6] = 1;
    else if (a[i] <= 3199) colors[7] = 1;
    else count++;
  }
  
  int base = 0;
  for (int i = 0; i < 8; i++) {
    base += colors[i];
  }
  
  printf("%i", (base == 0) ? 1 : base);
  printf(" %i\n", base + count);
    
  return 0;
}

Measured memory_bytes: 128
from scipy.misc import comb
N,*A = map(int,open(0).read().split())
d = {}
for i in A:
    d[i]= d[i]+1 if i in d else 1
count_d = {}
sum = 0
for k,v in d.items():
    count_d[k] = comb(v,2,exact=True)
    sum += count_d[k] 
 
for i in A:
    if count_d[i]>=1:
        print(sum - (d[i]-1))
    else:
        print(sum) 
    

Measured memory_bytes: 41236
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = long.Parse(Console.ReadLine());
            Func<long, long> f = n => n % 2 == 0 ? n / 2 : 3 * n + 1;
            var answer = 0L;
            var i = 0L;
            var flag = false;
            var loop = s <= 2 ? s : 4;
            while (true)
            {
                if (s == loop)
                {
                    if (flag)
                    {
                        answer = i + 1;
                        break;
                    }
                    else
                    {
                        flag = true;
                    }
                }
                s = f(s);
                i++;
            }
            Console.WriteLine(answer);
        }
    }
}


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

using namespace std;

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

    sort(s.begin(), s.end());
    if (s[0] == s[1] and s[2] == s[3] and s[1] != s[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int n, m;
  cin >> n >> m;
  cout << ((n == m) ? "Yes" : "No") << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

struct Bipartite_Matching {
  // グラフ表現のベクトル　a->b,a->c etc...
  vector< vector< int > > graph;
  //
  vector< int > match, alive, used;
  int timestamp;

  Bipartite_Matching(int n) {
    timestamp = 0;
    // 要素数の変更
    graph.resize(n);
    // n個に1,0,-1を代入する
    alive.assign(n, 1);
    used.assign(n, 0);
    match.assign(n, -1);
  }

  // 枝を加えて二部グラフを作成
  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  // 深さ優先探索
  bool dfs(int v) {
    used[v] = timestamp;
    for(int i = 0; i < graph[v].size(); i++) {
      int u = graph[v][i], w = match[u];
      if(alive[u] == 0) continue;
      if(w == -1 || (used[w] != timestamp && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return (true);
      }
    }
    return (false);
  }

  // 最大マッチングを求める問題
  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return (ret);
  }
};

int main(){
  int N;
  int a[105],b[105],c[105],d[105];
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<N;++i){
    cin >> c[i] >> d[i];
  }

  Bipartite_Matching flow(N+N);

  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if((a[i] < c[j]) && (b[i] < d[j])){
        flow.add_edge(i,j+N);
      }
    }
  }
  cout << flow.bipartite_matching() <<  endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define inf 1<<31

#define MX 100

int main()
{
    //freopen("input.txt","r",stdin);
    int m;
    cin>>m;

    cout<<24+(24-m)<<endl;


    return 0;
}




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

int main(){
  int n,k,s;
  int dp[30][20][200];

  while(cin >> n >> k >> s,n||k||s){
    memset(dp,0,sizeof(dp));
    dp[0][0][0] = 1;

    rep(i,n){
      rep(j,k+1){
	rep(w,s+1){
	  dp[i+1][j][w] += dp[i][j][w];
	  if(j!=k && w+i+1<=s)dp[i+1][j+1][w+i+1] += dp[i][j][w];
	}
      }
    }

    cout << dp[n][k][s] << endl;
  }
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
int main()
{
    long long int i,a,b,arr[100000],sum;
    scanf("%lld %lld",&a,&b);
    sum=0;
    for(i=0;i<b;i++)
    {
        scanf("%lld",&arr[i]);
        sum+=arr[i];
    }
    if(sum>=a)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        switch(com[0]){
        	case 'f':
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
            break;
            case 'i':
            scanf("%d",&x);
            insert(x);
            break;
            case 'p':
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 20448
// atcoder/code-festival-2016-qualb/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int w, h;
  while (cin >> w >> h) {
    vec<lli> a(h), b(w);
    cin >> b >> a;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());

    lli sum = 0;

    lli x = h + 1;
    lli y = w + 1;

    const lli inf = 1LL << 60;
    while (min(a.back(), b.back()) < inf) {
      if (a.back() < b.back()) {
        sum += y * a.back();
        a.pop_back();
        --x;
      } else {
        sum += x * b.back();
        b.pop_back();
        --y;
      }
      if (a.empty()) a.push_back(inf);
      if (b.empty()) b.push_back(inf);
    }
    cout << sum << endl;
  }

  return 0;
}


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

int Fib(int n){
	double phi = (1+sqrt(5))/2;
	return floor(pow(phi,n)/sqrt(5) + 0.5 );
}

int main() {
	int n;
	
	while(cin>>n){
		cout<<Fib(n+1)<<endl;
	}
	
	
	return 0;
}

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

// 内部定数
#define D_STA_MAX		500										// 最大駅数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, j;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 駅数取得
	int liSCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liSCnt);

	// 移動時間・始発時間・発車間隔取得
	int li1Move[D_STA_MAX], li1First[D_STA_MAX], li1Inter[D_STA_MAX];
	for (i = 0; i < liSCnt - 1; i++) {
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
		sscanf(lc1Buf, "%d%d%d", &li1Move[i], &li1First[i], &li1Inter[i]);
	}
	li1Move[i] = 0;
	li1First[i] = 0;

	// 各時間表示
	for (i = 0; i < liSCnt; i++) {

		// 始発時間 + 移動時間
		int liTime = li1First[i] + li1Move[i];

		// 移動
		for (j = i + 1; j < liSCnt - 1; j++) {

			// 出発時間
			if (liTime <= li1First[j]) {												// 始発時間前
				liTime = li1First[j];
			}
			else {																		// 始発時間以降
				int liCnt = (liTime - li1First[j] + li1Inter[j] - 1) / li1Inter[j];			// 本数
				liTime = li1First[j] + li1Inter[j] * liCnt;
			}

			// 移動時間加算
			liTime += li1Move[j];
		}

		// 結果セット
		sprintf(lc1Out, "%d\n", liTime);

		// 結果表示
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
		if (strcmp(lc1Buf, lc1Out)) {
			siRes = -1;
		}
#else
		printf("%s", lc1Out);
#endif
	}

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(){
    int a[100],d,i,e,x;

    for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
    d=a[0];
     for(i=1;i<3;i++){
        if(d>a[i]){
           d=a[i];
          }
    }
    
    e=a[0];
     for(i=1;i<3;i++){
        if(e<a[i]){
            e=a[i];
        }
  }
    
    x=abs(e-d);
    printf("%d\n",x);

return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> A(N),R(N);
  int upc=1,dwc=N;
  for(int i=0;i<N;i++){
    cin>>A[i];
    A[i]--;
    R[A[i]]=i;
  }
  int cnt=1,ans=0;
  for(int i=1;i<N;i++){
    if(R[i-1]<R[i])cnt++;
    else{
      ans=max(cnt,ans);
      cnt=1;
    }
  }
  ans=max(cnt,ans);
  cout<<N-ans<<endl;
}

Measured memory_bytes: 1920
while True:
    min = 1000000
    n =(int)(input())
    if n==0:
        break
    a = list(map(int, input().split()))

    for i in range (n-1):
        for j in range (i+1,n):
            num = a[i]-a[j]
            if min>abs(num):
                min = abs(num)
    print(min)



Measured memory_bytes: 5624
#include<bits/stdc++.h>
#include<math.h>
#include<string>
using namespace std;
int main(void){
	string s;
	int i;
	cin >> s;
	int result = 0;
	for(i=0;i<s.size();i++){
		if(s.substr(i,1)=="o"){
			result += 1;
		}
	}
	if(result+15-s.size()>= 8){
		cout << "YES";
	}else{
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[33];
int solve(int num) {
  if(num <= 0) return 0;
  int &res = dp[num];
  if(~res) return res;
  res = solve(num-1)*3+1;
  return res;
}
signed main(){
  int n;
  while(cin >> n) {
    memset(dp, -1, sizeof(dp));
    int ans = n;
    for(int i = 0; i < n/2; i++) {
      ans += solve(i)*4;
    }
    if(n%2) cout << ans+solve(n/2)*2 << endl;
    else cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};


signed main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> minus(N + 1, 0);
    UnionFind uf(N + 1);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        uf.unite(A, B);
        minus[A]++;
        minus[B]++;
    }
    for (int i = 0; i < K; i++) {
        int C, D;
        cin >> C >> D;
        if (uf.find(C) == uf.find(D)) {
            minus[C]++;
            minus[D]++;
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << uf.size(i) - minus[i] - 1 << (i == N ? '\n' : ' ');
    }
}

Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long T[100000];
long long A[100000];
bool decided_T[100000];
bool decided_A[100000];
const long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
      cin >> T[i];
  }
  for(int i = 0; i < N; i++){
      cin >> A[i];
  }
  
  decided_T[0] = true;
  decided_A[N - 1] = true;
  for(int i = 1; i < N; i++){
      if(T[i - 1] != T[i]){
          decided_T[i] = true;
      }
  }
  for(int i = N - 2; i >= 0; i--){
      if(A[i] != A[i + 1]){
          decided_A[i] = true;
      }
  }
  
  
  long long ans = 1;
  for(int i = 0; i < N; i++){
      if(decided_T[i] || decided_A[i]){
          if((decided_T[i] && T[i] > A[i]) || (decided_A[i] && T[i] < A[i]) || (decided_T[i] && decided_A[i] && A[i] != T[i])){
              cout << 0 << endl;
              return 0;
          }
      } else {
          ans = (ans * min(A[i], T[i])) % MOD;
      }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1920
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] t = new int[q];
        for (int i = 0; i < q; i++) {
            t[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < q; i++) {
            int l = 0;
            int r = n;
            while(1 < r-l){
                int mid = (r + l) / 2;
                if(t[i] < s[mid]) r = mid;
                else l = mid;
            }
            if(s[l] == t[i]) ans++;
        }
        System.out.println(ans);
        sc.close();

    }

}



Measured memory_bytes: 69056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int total=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    total+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  if(vec.at(m-1)>=(double)total/(4*m)){
    cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3580
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<Integer, Integer>map = new HashMap<>();
        for (int i = 0 ; i < 6 ;i++) {
            int n = sc.nextInt();
            if (map.containsKey(n)) {
                map.put(n, map.get(n) + 1);
            } else {
                map.put(n, 1);
            }

        }

        int mm = map.size();
        int c = 0;
        for (Entry entry :map.entrySet()) {
            c = Math.max(c, (int) entry.getValue());
        }
        if (mm == 4 && c == 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}


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

int main() {
	int a, b;
	cin >> a >> b;
	int p = a * b;
	string ans;
	if (p % 2 == 0) {
		ans = "Even";
	} else {
		ans = "Odd";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static long sum = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long x = sc.nextLong();
		
		long a = Math.max(x, n-x);
		long b = Math.min(x, n-x);

		sum = a + b;
		while(true){
			long c = refrect(a, b);
			if(c==0) break;
			a = b;
			b = c;
		}

		System.out.println(sum);
	}

	static long refrect(long a, long b){
		long rest = a%b;
		long times = a/b;

		sum += b*times*2;
		if(rest==0) sum -= b;

		return rest;
	}
}

Measured memory_bytes: 9556
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        
        int a, b;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            
            String str[] = br.readLine().split(" ");
            a = Integer.parseInt(str[0]);
            b = Integer.parseInt(str[2]);
            
            if(str[1].equals("+")){
                System.out.println(a + b);
            }else if(str[1].equals("-")){
                System.out.println(a - b);
            }else if(str[1].equals("*")){
                System.out.println(a * b);
            }else if(str[1].equals("/")){
                System.out.println(a / b);
            }else if(str[1].equals("?")){
                break;
            }
        }
    }
}

Measured memory_bytes: 24124
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,flag=0,cnt=0;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];

  }
  for(int j=0;j<n;j++)
  {
      if(arr[j]%2==0)
    {
        flag++;
    }
    if(arr[j]%2==0)
    {
        if(arr[j]%3==0 || arr[j]%5==0)
        {
            cnt++;
        }
    }


  }

  if(flag==cnt)
  {
    cout<<"APPROVED"<<endl;
  }
  else
  {
      cout<<"DENIED"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
S = list(map(int, input()))

zero = []
one = []

zerocount = 0
onecount = 0

for i in range(len(S)):
    if i%2 == 0:
        zero.append(0)
        one.append(1)
    else:
        zero.append(1)
        one.append(0)

for i in range(len(S)):
    if zero[i] != S[i]:
        zerocount += 1
    if one[i] != S[i]:
        onecount += 1

if zerocount<onecount:
    print(zerocount)
else:
    print(onecount)


Measured memory_bytes: 5536
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();
        int count = 0;
        char[] ss = s.toCharArray();
        char[] tt = t.toCharArray();

        for (int i = 0; i < s.length(); i++) {
            if (ss[i] != tt[i]) {
                count = count + 1;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 41728
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;




int main(){
  unsigned long long int A, B;
  cin >> A;
  cin >> B;

  // make sure A > B.
  if (A < B) {
    unsigned long long int tmp;
    tmp = B;
    B = A;
    A = tmp;
  }
  unsigned long long int AB = A * B;

  unsigned long long int r = A % B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
  cout << AB / B << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

struct Point {
    double x, y;
    Point(double x = 0.0, double y = 0.0) : x(x), y(y) {}
};

double dis(Point a, Point b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

int n;
vector<Point> v;

double radius(double x, double y) {
    double res = 0;
    for (int i = 0; i < n; ++i) {
        chmax(res, dis(v[i], Point(x, y)));
    }
    return res;
}

double x_fixed(double x) {
    double left = -1000, right = 1000;
    for (int i = 0; i < 100; ++i) {
        double l = (left * 2 + right) / 3;
        double r = (left + right * 2) / 3;
        if (radius(x, l) > radius(x, r)) left = l;
        else right = r;
    }
    return radius(x, left);
}

int main(){
    cin >> n;
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].x >> v[i].y;
    }

    double left = -1000, right = 1000;
    for (int i = 0; i < 100; ++i) {
        double l = (left * 2 + right) / 3;
        double r = (left + right * 2) / 3;
        if (x_fixed(l) > x_fixed(r)) left = l;
        else right = r;
    }

    cout << fixed << setprecision(10) <<  x_fixed(left) << endl;
}

Measured memory_bytes: 3816
n = int(input())
count_dict = dict()
for _ in range(n):
    s = input()
    s = ''.join(sorted(s))
    count_dict.setdefault(s, 0)
    count_dict[s] += 1

ans = 0
for count in count_dict.values():
    ans += count*(count-1)//2
print(ans)


Measured memory_bytes: 22240
#include <bits/stdc++.h>
#define int long long
#define Mod 1000000007
using namespace std;

class BIT{
public:
  typedef long long ll;
  ll n;
  vector<ll> bit;
  BIT():n(-1){};
  BIT(ll n_){
    n=1;
    while(n < n_+2) n *= 2;
    bit.resize(n+1, 0);
  }
  
  //[0, i]までの総和を得る
  ll sum(ll i){
    assert( i >= 0 && i <= n );
    i++;
    
    ll s=0;
    while(i>0){
      s = (s + bit[i]);
      i -= i & -i;
    }
    return s;
  }

  //i番目の要素にx加算(0 オリジン)
  void add(ll i,ll x){
    assert( i >= 0 && i <= n );
    i+=2;
    
    while(i <= n){
      bit[i] = (bit[i] + x) % Mod;
      i += i & -i;
    }
  }
  
  ll sum(int l,int r){ //[l, r) 0オリジン
    assert(l <= r);
    assert( 0 <= l && l <= n);
    assert( 0 <= r && r <= n);
    return sum(r) - sum(l);
  }
};

template <typename T>
class Compress{
public:
  vector<T> X;
  bool ok;
  Compress(){};
  
  int size(){return X.size();}
  void add(T a){ok = false; X.push_back(a); X.push_back(a-1); X.push_back(a+1);}
  void add(const vector<T> a){for(T x:a) add(x);}
  //void add(const vector<T> &a){for(T x:a) add(x);}
  
  void build(){
    ok = true;
    sort(X.begin(),X.end());
    X.erase(unique(X.begin(),X.end()),X.end());
  }
  
  T getL(T x){assert(ok); return lower_bound(X.begin(),X.end(),x) - X.begin();}
  T getU(T x){assert(ok); return upper_bound(X.begin(),X.end(),x) - X.begin();}
};

typedef pair<int,int> P;

int N, M, x[100005];

signed main(){
  
  cin>>N>>M;
  
  for(int i=0;i<N;i++) cin>>x[i];
  
  vector<int> Y;
  
  for(int i=0;i<M;i++){
    int y;
    cin>>y;
    Y.push_back(y);
  }
  
  vector<P> points;
  
  for(int i=0;i<N;i++){
    
    auto ite = lower_bound( Y.begin(), Y.end(), x[i] );
    
    if( ite == Y.begin() || ite == Y.end() ) continue;
    
    points.push_back(P( x[i] - (*(ite-1)), (*ite) - x[i] ));
    
  }
  
  sort( points.begin(), points.end(),  
  
	[](P a, P b){
	  if( a.first != b.first ) return a.first < b.first;
	  return a.second > b.second;
	}
	
  );
  
  points.erase(unique(points.begin(),points.end()),points.end());
  
  Compress<int> R;
  
  R.add(0);
  
  for(int i=0;i<(int)points.size();i++) R.add( points[i].second );
  
  R.build();
  
  BIT bit( R.size() );
  
  bit.add( R.getL(0), 1 );
  
  for(int i=0;i<(int)points.size();i++){
    
    int idx = R.getL( points[i].second );
    
    bit.add( idx, bit.sum( 0, idx ) );
    
  }
  
  cout << bit.sum( 0, R.size() ) % Mod << endl;
  
  return 0;
}


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

// flr(Ax/B) - A * flr(x/B);
// flr(A/B) = (A - A % B) / B;
int main(){
    long long A,B,N;
    cin >> A >> B >> N;

    long long x = N;
    if(N >= B -1) x = B -1;
    long long res = (A * x - A % B) / B - A * (x - x & B) / B;
    printf("%ld\n", res);
    return 0; 
}

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

int digit_sum (int n);

int main () {

    int N;
    cin >> N;

    int ans = INT_MAX;
    for (int a = 1; a <= N - 1; a++) {

        int b = N - a;

        ans = min(ans, digit_sum(a) + digit_sum(b));
    }

    cout << ans << endl;

    return 0;
}

int digit_sum (int n) {

    int sum = 0;

    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using std::sort;
int Abs(int x)
{
    return x>0?x:(-x);
}
int a[100100];
int b[100100],t1=50000,t2=50002;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    b[50001]=a[1];
    for(int l=2,r=n;l<=r;)
    {
        b[t1--]=a[r--];
        if(l<r)
            b[t2++]=a[r--];
        if(l<r)
            b[t1--]=a[l++];
        if(l<r)
            b[t2++]=a[l++];
    }
    long long sum=0;
    for(int i=t1+2;i<t2;++i)
        sum+=Abs(b[i]-b[i-1]);
    long long ans=sum;
    t1=50000,t2=50002;
    b[50001]=a[n];
    for(int l=1,r=n-1;l<=r;)
    {
        b[t1--]=a[l++];
        if(l<r)
            b[t2++]=a[l++];
        if(l<r)
            b[t1--]=a[r--];
        if(l<r)
            b[t2++]=a[r--];
    }
    sum=0;
    for(int i=t1+2;i<t2;++i)
        sum+=Abs(b[i]-b[i-1]);
    printf("%lld\n",ans>sum?ans:sum);
    return 0;
}


Measured memory_bytes: 896
k,q = map(int,input().split())
d = list(map(int,input().split()))
for _ in range(q):
  n,x,m = map(int,input().split())
  x %= m
  dm = []
  for dx in d:
    dm.append((dx-1)%m+1)
  sumd = (n-1)//k * sum(dm) + sum(dm[:(n-1)%k])
  ans = n - 1 - (x+sumd)//m + (x)//m
  #print(n , 1 , (x+sumd)//m , (x)//m)
  #print(sumd)
  #print(dm)
  print(ans)

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

void insertionSort(int a[], int n){
    for(int i = 0; i < n; i++){
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v){
            a[j+ 1 ] = a[j];
            j--;
        }
        a[j + 1] = v;

        for (int i = 0; i < n; i++){
            cout << a[i];
            if (i != n - 1) cout << " ";
            else cout << endl;
        }
    }
}

int main(void){
    int n, a[100];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    insertionSort(a, n);

    return 0;
}



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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
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(){
    int a[3];
    for (int i = 0; i < 3; i++) cin >> a[i];
    cout << min(a[0] + a[1], min(a[1] + a[2], a[2] + a[0])) << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int a, b, t;
	cin >> a >> b >> t;

	int c = t / a;
	out(c * b);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char* argv[])
{

	string S;
	int cnt = 0;

	cin >> S;

	for(int i=0;i<S.length();i++){
		if(S[i]=='+'){
			cnt++;
		}else{
			cnt--;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

/* */

int main(){
    // 入力スタンダード
    string s;
    cin >> s ;

    bool alpha[26] = {false};

    for(int i=0; i<s.size(); i++){
        alpha[s[i]-'a'] = true;
    }

    for(int i=0; i<26; i++){
        if (!alpha[i]){
            cout << char(i + 'a') <<endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
a,b=map(int,input().split())

count=int(0)

for i in range(b-a+1):
    if str(a+i)[0]==str(a+i)[1] and str(a+i)[1]==str(a+i)[3] and str(a+i)[3]==str(a+i)[4]:
        count+=1
    elif str(a+i)[0]==str(a+i)[4] and str(a+i)[1]==str(a+i)[3]:
        count+=1

print(count)


Measured memory_bytes: 3064