akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  long long W, weight[110], value[110]; 
  long long dp[110][100100] = {0};
  
    cin >> N >> W;
    for (int i = 0; i < N; ++i) {
      cin >> weight[i] >> value[i];
    }

    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
              dp[i+1][sum_w]=max(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            dp[i+1][sum_w]=max(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
}





Measured memory_bytes: 86272
n = int(input())
a = sorted(list(map(int, input().split())))

x = max(a)
dp = [0] * x
for ai in a:
    i = 1
    while i * ai <= x:
        dp[i * ai - 1] += 1
        i += 1

ans = 0
for ai in a:
    if dp[ai-1] <= 1:
        ans += 1

print(ans)

Measured memory_bytes: 132780
loop do
  arr, ans = 8.times.map{ gets.chomp }, nil
  
  8.times do |i|
    case arr[i].count("1")
    
    when 1
      case arr[i].index("1") - arr[i + 2].index("1")
      when 0
        ans = "B"
      when 1
        ans = "D"
      when -1
        ans = "F"
      end
    
    when 2
      case arr[i].index("1") - arr[i + 1].index("1")
      when 0
        ans = "A"
      when -1
        ans = "E"
      when 1
        ans = "G"
      end
    
    when 4
      ans = "C"
    end
    
    if ans
      puts ans
      break
    end
  end
  
  break unless gets
end

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

int main()
{
  string s;
  cin >> s;
  if(s=="Sunny")cout << "Cloudy" << endl;
  if(s=="Cloudy") cout << "Rainy" << endl;
  if(s=="Rainy") cout << "Sunny" << endl;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  
  int x;
  x = N * A;

  if (x > B) {
    cout << B << endl;
  }
  else {
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int x,y,z;
    cin>>x>>y>>z;
    x-=z;
    int ans=x/(y+z);
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

ll calc(ll x) {
    return x * x * x * x * x;
}

int main() {
    ll X;
    cin >> X;

    ll MAX = 1000;
    ll MIN = -1000;
    for (int a = MIN; a < MAX; a++) {
        for (int b = MIN; b < MAX; b++) {
            if (calc(a) - calc(b) == X) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c;
    bool f = false;
    repi(i,1,10000){
        if((!(i % a)) && (i % b == c))f = true;
    }
    fp(f,"YES","NO");
    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, k;
  cin >> n >> k;
  vvi a(n);
  rep(i, n) {
    int t, d;
    cin >> t >> d;
    a[--t].push_back(d);
  }
  rep(i, n) sort(a[i].begin(), a[i].end(), greater<int>());
  vector<P> p;
  rep(i, n) {
    if (a[i].size() > 0) p.push_back(P(a[i][0], 1));
  }
  rep(i, n) {
    for (int j = 1; j < a[i].size(); j++) p.push_back(P(a[i][j], 0));
  }
  sort(p.begin(), p.end(), greater<P>());
  dump(p);
  ll sum1 = 0;
  ll sum2 = 0;
  ll nk = 0;
  vector<int> q;
  rep(i, k) {
    sum1 += p[i].first;
    nk += p[i].second;
    if (!p[i].second) q.push_back(p[i].first);
  }
  sum2 = nk * nk;
  int idx = k;
  ll ans = sum1 + sum2;
  while (nk < k && idx < n && q.size() > 0) {
    dump(ans, sum1, sum2, idx, nk, q);
    for (; idx < n; idx++) {
      if (p[idx].second) {
        nk++;
        sum2 = nk * nk;
        sum1 += p[idx].first - q.back();
        q.pop_back();
        maxs(ans, sum1 + sum2);
        idx = idx + 1;
        break;
      }
    }
  }
  dump(ans, sum1, sum2, idx, nk, q);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 6904
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  int n, m;
  cin >> n >> m;

  int arr[n];

  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }

  long double ref = (long double)(sum) / (long double)(4 * m);

  // cout << ref << endl;

  int cnt = 0;

  for (int i = 0; i < n; i++) {
    if (arr[i] >= ref) cnt++;
  }

  if (cnt >= m)
    cout << "Yes\n";
  else
    cout << "No\n";
}

Measured memory_bytes: 888
//https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int N, K;
    cin >> N >> K;
    cout << (K == 1 ? 0 : (N - K + 1) - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
h, w, K = map(int, input().split())
C = [list(map(str, input())) for _ in range(h)]

ans = 0
for i in range(2**h):
    for j in range(2**w):
        H = [0]*h
        for k in range(h):
            if (i >> k) & 1:
                H[k] = 1
        W = [0]*w
        for l in range(w):
            if (j >> l) & 1:
                W[l] = 1
        cnt = 0
        for p in range(h):
            for q in range(w):
                if H[p] != 1 and W[q] != 1 and C[p][q] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)


Measured memory_bytes: 68676
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

ll order2(ll n){
  if(n%2!=0)
    return 0;    
  return 1+order2(n/2);
}

ll gcd(ll a,ll b){
  if(a<b){
    ll tmp=a; a=b; b=tmp;
  }
  if(b==0)
    return a;
  return gcd(b,a%b);
}

int main(){
  ll m,n,bunki=0,bunki2=0;
  cin>>n>>m;
  ll a[n],b[n];
  cin>>a[0];
  a[0]/=2;
  b[0]=order2(a[0]);
  rep1(i,n){
    cin>>a[i];
    a[i]/=2;
    b[i]=order2(a[i]);
    if(b[i]!=b[0]){
      bunki=1;
    }
  }
  if(bunki){
    cout<<0;
  }else{
    ll lcm=a[0];
    rep1(i,n){
      lcm/=gcd(lcm,a[i]);
      lcm*=a[i];
      if(lcm>m){
        bunki2=1;
        break;
      }
    }
    if(bunki2==1){
      cout<<0;
    }else{
      cout<<setprecision(12)<<floor(((double)m+lcm)/2/lcm);
    }
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
/* 変数名を被らせない
   デバッグコードを取り除く */
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int MAX_INT = 1000000;
int n,w,ans,cnt=1;
int value[1001],weight[1001],dp[1001][1001];;
int solve(int a,int b);
int main(){
  while(1){
    memset(dp,-1,sizeof(dp));
    cin >> w;
    if(w==0)break;
    cin >> n;
    for(int i=0;i<n;i++){
      scanf("%d,%d",&value[i],&weight[i]);
    }
    ans = solve(0,w);
    for(int i=0;i<=w;i++){
      if(solve(0,i) == ans){
	cout <<"Case " << cnt <<':' << endl <<  ans <<endl << i << endl;
	break;
      }
    }
    cnt++;
  }
}
int solve(int a,int b){
  if(dp[a][b] != -1)return dp[a][b];
  if(a == n)return 0;
    
  else if(b < weight[a])return dp[a][b] = solve(a+1,b);
  else return dp[a][b] = max(solve(a+1,b-weight[a])+value[a],solve(a+1,b));
}

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

bool IsPrime(int n){
    if (n<2) return false;
    else if (n==2) return true;
    else if (n%2==0) return false;
    double q=sqrt(n);
    for(int i=3;i<q+1;i+=2){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    cin>>n>>m;
    bool flag=IsPrime(m);
    while(true){
        if(flag){
            if(n!=1) m=n;
            break;
        }
        if(m%n==0) break;
        n++;
    }
    cout<<m/n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
	}
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
	lli e, n;
	cin>>e>>n;
	lli sum = 0;
	loop(i, 0, n){
		lli temp;
		cin>>temp;
		sum += temp;
	}
	if(sum < e)
		cout<<"No\n";
	else
		cout<<"Yes\n";
	return 0;
}
int main(){
	fastio;
	lli t;
	// cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 256
#include <cstdio>
char str[1001];
int main() {
	scanf("%s",str);
	for(int i=0;str[i];i++) {
		if(str[i]<='C') putchar('Z'+(str[i]-'C'));
		else putchar(str[i]-3);
	}
	putchar('\n');
}

Measured memory_bytes: 932
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    bool f = true;
    for (int i = a - 1; i < c - 2; i++)
        if (s[i] == '#' && s[i + 1] == '#')
            f = false;
    for (int i = b - 1; i < d - 2; i++)
        if (s[i] == '#' && s[i + 1] == '#')
            f = false;
    if (d < c)
    {
        f = false;
        for (int i = b - 2; i < d - 1; i++)
            if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
                f = true;
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 640
# 解説を見た
# https://atcoder.jp/contests/tenka1-2017/submissions/1640474

N, K = map(int, input().split())

bs = {K: 0}
for j in range(K.bit_length()):
    if K & (1 << j) > 0:
        bs[K & ~(1 << j) | ((1 << j) - 1)] = 0
        # Kで立っているbitを消して、下位bitをすべて立てたもの

for _ in range(N):
    num, value = map(int, input().split())
    for b in bs:
        if (b | num) == b:
            bs[b] += value

print(max(bs.values()))

# 累積orで桁繰上りはない
# 二進表記の各桁でbitを立てるかどうかを決めたら、それを満たすように貪欲に整数を買う
# 調べるbitの候補は
# K自身と途中の1を0にして、その下位をすべて1にしたもの
# となり、総数はKの二進表記の桁数になる
# 各候補についてO(N)で貪欲に求まるので、O(30*N)くらい


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
string make_string(T N)
{
    string ret;
    T now = N;
    while (now > 0)
    {
        T x = now % 10;
        ret += (char)('0' + x);
        now /= 10;
    }
    reverse(all(ret));
    return ret;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    loop(i, N)
    {
        cin >> A[i];
        A[i] /= 2;
    }
    ll LCM = 1;
    loop(i, N)
    {
        LCM = lcm(LCM, A[i]);
        if (LCM > M)
        {
            putout(0);
            return 0;
        }
    }
    //LCM,LCM+(2*LCM),LCM+LCM+2*(2*LCM)...
    //LCM,3*LCM,5*LCM...が答え
    ll div = M / LCM;
    loop(i, N)
    {
        if ((LCM / A[i]) % 2 == 0)
        {
            putout(0);
            return 0;
        }
    }
    ll ans = (div + 1) / 2;
    putout(ans);
    return 0;
}


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

int n, num[4];
double dp[303][303][303];

double dfs(int a, int b, int c) {
	if(a == 0 && b == 0 && c == 0) return 0;
	if(dp[a][b][c] >= 0) return dp[a][b][c];
	int sum = a + b + c;
	double ans = 1.0*n/sum;
	if(a) ans += 1.0*dfs(a-1, b, c)*a/sum;
	if(b) ans += 1.0*dfs(a+1, b-1, c)*b/sum;
	if(c) ans += 1.0*dfs(a, b+1, c-1)*c/sum;
	
	return dp[a][b][c] = ans;
}



int main() {
	memset(dp, -1, sizeof(dp));
	scanf("%d", &n);
	for(int i = 1, x;i <= n; i++) {
		scanf("%d", &x);
		num[x]++;
	}
	
	printf("%.15lf\n", dfs(num[1], num[2], num[3]));
}

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

struct node{
  int key;
  struct node *parent,*left,*right;
};

struct node *root,*NIL;
void insert(int);
struct node* search(struct node*, int);
void Inorder(struct node*);
void Preorder(struct node*);

void insert(int);
int main(){
  int i,num,value;
  char command[10];
  struct node  *found;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s",command);
    if(command[0]=='i'){           /*mean insert*/
      scanf("%d",&value);
      insert(value);
    }
    else if(command[0]=='f'){     /*mean find*/
      scanf("%d",&value);
      found=search(root,value);
      if(found!=NIL) printf("yes\n");
      else printf("no\n");
    }
		       
    else if(command[0]=='p'){      /*mean print*/
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}
    
void insert(int k){
  struct node *x=root,*y=NIL,*z;
  z=(struct node*)malloc(sizeof(struct 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;
  }
}
struct node* search(struct node* x, int value){
  while(x!=NIL && value!=x->key){
    if(value<x->key) x=x->left;
    else x=x->right;
  }
  return x;
}

void Inorder(struct node *x){
  if(x==NIL) return;
  Inorder(x->left);
  printf(" %d",x->key);
  Inorder(x->right);
}



void Preorder(struct node *x){
  if(x==NIL) return ;
  printf(" %d",x->key);
  Preorder(x->left);
  Preorder(x->right);
}



Measured memory_bytes: 20472
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

class Rest {
    public int id;
    public String name;
    public int score;

    public Rest(int id, String name, int score) {
        this.id = id;
        this.name = name;
        this.score = score;
    }
}

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

        int N = sc.nextInt();

        List<Rest> rests = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            Rest r = new Rest(i+1, sc.next(), sc.nextInt());
            rests.add(r);
        }

        Collections.sort(rests, (a, b) -> -Integer.compare(a.score, b.score));
        Collections.sort(rests, (a, b) -> a.name.compareTo(b.name));

        for (Rest r : rests) {
            System.out.println(r.id);
        }
    }
}


Measured memory_bytes: 28244
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            int[] A;
            Sort sort = new Sort();
            int n = Integer.parseInt(br.readLine());
            A = new int[n];
            for(int i = 0; i < n; i++){
                A[i] = Integer.parseInt(br.readLine());
            }

            A = sort.shellSort(A,n);
            System.out.println(sort.m);

            for(int g : sort.G){
                System.out.println(g);
            }

            System.out.println(sort.cnt);

            for(int g : A){
                System.out.println(g);
            }

        } catch (Exception e) {
            System.out.println(e);
        }

    }
}

class Sort{
    int cnt ,m;
    int[] G;
    private void insertionSort(int[] A, int n, int g){
        int j, v;
        for(int i = g; i < n; i++){
            v = A[i];
            j = i - g;
            while(j >= 0 && A[j] > v){
                A[j+g] = A[j];
                j = j - g;
                cnt++;
            }
            A[j+g] = v;
        }
    }
    int[] shellSort(int[] A, int n){
        cnt = 0;
        G = arrayForSort(n);
        m = G.length;
        for(int i = 0; i <= m-1; i++){
            insertionSort(A, n, G[i]);
        }
        return A;
    }
    private int[] arrayForSort(int a){
        long[] B = new long[1000];
        long[] C = new long[1000];
        B[0] = 1;
        B[1] = 1;
        long max = 0;
        int i = 2;
        while(max <= a){
            B[i] = B[i-1] + B[i-2];
            C[i-2] = (long)Math.pow(B[i-1], 1 + Math.sqrt(5));
            max = C[i-2];
            i++;
        }
        int[] D = new int[i-3];
        for(int j = 0; j < i-3; j++){
            D[j] = (int)C[i-4-j];
        }
        return D;
    }
}

Measured memory_bytes: 106280
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

struct edge { ll p, q, c; };

int main(void) {
  ll N, M; cin >> N >> M;
  vector<edge> e(M);
  REP(i, 0, M) {
    ll P, Q, C; cin >> P >> Q >> C; P--; Q--;
    e[i] = (edge) { P, Q, C };
  }

  vector<pll> vec;
  REP(i, 0, N) vec.push_back(pll(i, 0));
  REP(i, 0, M) {
    vec.push_back(pll(e[i].p, e[i].c));
    vec.push_back(pll(e[i].q, e[i].c));
  }

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  vector< vector<pll> > E(vec.size());
  REP(i, 0, e.size()) {
    ll u = lower_bound(vec.begin(), vec.end(), pll(e[i].p, e[i].c)) - vec.begin();
    ll v = lower_bound(vec.begin(), vec.end(), pll(e[i].q, e[i].c)) - vec.begin();
    E[u].push_back(pll(v, 0));
    E[v].push_back(pll(u, 0));
  }
  REP(u, 0, vec.size()) {
    if(vec[u].second == 0) continue;
    ll v = lower_bound(vec.begin(), vec.end(), pll(vec[u].first, 0)) - vec.begin();
    E[u].push_back(pll(v, 0));
    E[v].push_back(pll(u, 1));
  }

  ll S = lower_bound(vec.begin(), vec.end(), pll(0, 0)) - vec.begin();
  ll G = lower_bound(vec.begin(), vec.end(), pll(N - 1, 0)) - vec.begin();

  vector<ll> dp(vec.size(), INF);
  priority_queue<pll, vector<pll>, greater<pll> > q;
  q.push(pll(0, S));
  while(q.size()) {
    ll v = q.top().second, d = q.top().first;
    q.pop();

    if(dp[v] <= d) continue;
    dp[v] = d;

    REP(i, 0, E[v].size()) {
      ll nv = E[v][i].first, nd = d + E[v][i].second;
      if(dp[nv] > nd) q.push(pll(nd, nv));
    }
  }
  cout << (dp[G] != INF ? dp[G] : -1) << endl;
}


Measured memory_bytes: 65000
import copy

INF = 10**10
v, e = map(int, input().split())
M = [[INF]*v for i in range(v)]
for i in range(v):
    M[i][i] = 0
for i in range(e):
    s, t, d = map(int, input().split())
    M[s][t] = d

# k:グラフの範囲
ans = copy.deepcopy(M)
for k in range(v):
    for i in range(v):
        if ans[i][k] == INF:
            continue
        for j in range(v):
            if ans[k][j] == INF:
                continue
            # i, jのグラフの最短距離
            ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j])

flag = False
for i in range(v):
    if ans[i][i] < 0:
        flag = True
        break
if flag:
    print('NEGATIVE CYCLE')
else:
    for line in ans:
        line = ['INF' if tmp == INF else tmp for tmp in line]
        print(*line)



Measured memory_bytes: 7204
defmodule Main do
	def main do
    	hoge = IO.gets("") |> String.trim()
        {:ok, s} = hoge <> ".$" |> Regex.compile()
		t = IO.gets("") |> String.trim()

		if String.match?(t, s) do
			IO.puts("Yes")
		else
			IO.puts("No")
		end
    end
end


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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<char> v(K);
	for (int i = 0; i < K; i++) {
		cin >> v[i];
	}
	int res = N;
	bool flag = true;
	for (; flag; res++) {
		flag = false;
		for (int i = 0; i < K; i++) {
			if (to_string(res).find(v[i]) != -1) {
				flag = true;
			}
		}
		if (!flag)
			break;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
count = 0
for n in range(1, N+1):
    n_str = str(n).zfill(4)
    tmp_sum = int(n_str[0])+int(n_str[1])+int(n_str[2])+int(n_str[3])
    if A <= tmp_sum and tmp_sum <= B:
        count += n
    else:
        continue
print(count)

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

int main()
{
 	string a,b;
  	cin >> a >> b;
  	int n = a.length();
  
  	int res = 0;
  	for(int i = 0; i < a.length(); ++i)
      if(a[i] != b[i])
        ++res;
  
  	cout << res;
}

Measured memory_bytes: 3892
from collections import defaultdict
import heapq as hq


def helper(n):
    q = child_L[n]
    del child_L[n]

    hq.heapify(q)
    i = 0
    while q:
        t = hq.heappop(q)
        if i < t:
            break
        else:
            i += (i == t)

    j = i + 1
    while q:
        t = hq.heappop(q)
        if j < t:
            break
        else:
            j += (j == t)

    return (i, j)


if __name__ == '__main__':

    N = int(input())
    P = list(map(lambda x: int(x) - 1, input().split()))
    # D:出している辺の本数
    D = [0] * N
    for p in P:
        D[p] += 1
    # print(D)
    child_L = defaultdict(list)
    # S:辺を出してないものリスト
    S = [p for p in range(N) if D[p] == 0]

    L = [None] * N

    while S:
        # print(child_L)
        n = S.pop()

        q = child_L[n]
        # print(q)
        del child_L[n]

        # listのqをヒープキューに変換
        hq.heapify(q)
        i = 0
        while q:
            t = hq.heappop(q)
            if i < t:
                break
            else:
                i += (i == t)

        L[n] = i
        # print(L)
        m = P[n]
        # print("m:" + str(m))
        child_L[m].append(i)
        D[m] -= 1
        if D[m] == 0:
            S.append(m)

    # print(D)
    # cycle check
    try:
        start = D.index(1)
    except ValueError:
        print('POSSIBLE')
        exit()

    s1, s2 = helper(start)
    G = []
    n = P[start]
    while n != start:
        G.append(helper(n))
        n = P[n]

    # del N, P, D, child_L, S, L

    # 可能な初期値をそれぞれシミュレート
    # 1
    n = s1
    for g in G:
        if g[0] == n:
            n = g[1]
        else:
            n = g[0]
    if n != s1:
        print('POSSIBLE')
        exit()

    # 2
    n = s2
    for g in G:
        if g[0] == n:
            n = g[1]
        else:
            n = g[0]
    if n == s1:
        print('POSSIBLE')
        exit()

    print('IMPOSSIBLE')


Measured memory_bytes: 30288
#include <bits/stdc++.h>
using namespace std;
#define rep(a, n) for (int i = a; i < n; i++)
#define per(a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef double db;
const ll mod = 1000000007;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main() {
    long long D,T,S;
		cin>>D>>T>>S;
		if(D<=T*S){
			cout<<"Yes";
		}
		else{
			cout<<"No";
		}
}

Measured memory_bytes: 3592
import sys
import math
import bisect
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    n, k, q = list(map(int,input().split()))
    t = q - k + 1
    p = [0] * n

    for i in range(q):
        a = int(input())
        p[a-1] += 1

    for i in range(n):
        if p[i] >= t:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 46940
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return 1;} return 0;}
const long long INF = 1000000000;

ll dp[100001];

int main(void){
  int n; cin >> n;
  int h[n]; rep(i,n) cin >> h[i];
  rep(i,100001) dp[i] = INF;
  dp[0] = 0;
  for(int i = 0; i < n; i++){
    chmin(dp[i],dp[i-1]+abs(h[i] -h[i-1]));
    if(i > 1) chmin(dp[i],dp[i-2] + abs(h[i]-h[i-2]));
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


int main() {
  int N, l, r, sum = 0;
  cin >> N;
  REP(i, N) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    """n = int(input())
    v = []
    for i in range(n):
        v.append([])
    for i in range(n):
        A = int(input())
        for j in range(A):
            human,lie = readInts() # human : 人  lie: 1 が正直者 0 が不親切
            v[human-1].append([human - 1,lie]) # human : 0-based index
    print(v)
    def judge(bit):
        # i 人目の証言を検証する
        print(bin(bit))
        for i in range(n):
            # 証言は意味がないな
            #if not (bit & (1<<i)): # フラグのたってるやつだけみてる
                #continue
            for x,y in v[i]:
                print(x,y,bit)
                # y = 1 なのに 不親切 だったらだめ
                if y == 1 and not (bit & (1 << x)):
                    return False
                # y = 0 なのに 正直ならだめ
                if y == 0 and (bit & (1 << x)):
                    return False
        return True
    res = 0
    for bit in range(1 << n):
        if judge(bit):
            count = 0
            for i in range(n):
                if bit & (1 << i):
                    count += 1
            res = max(res,count)
    print(res)
    """
    n = int(input())
    xy = [[] for _ in range(n)]
    for i in range(n):
        A = int(input())
        for j in range(A):
            x,y = readInts()
            xy[i].append([x,y])
    ans = 0
    for b in range(1 << n):
        for m in range(n):
            if (b >> m) & 1:
                for x,y in xy[m]:
                    if y != (b >> (x-1) & 1):
                        break
                else:
                    continue
                break
        else:
            ans = max(ans,bin(b).count("1"))
    print(ans)
if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
/*
	By Milind Lalwani - BahuMajaNu
   	NIT - Tiruchirappalli

        "These violent delights have violent ends" 
                - Dolores Abernathy , WestWorld
    Intern at Morgan Stanley
*/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define p 1000000007
#define test int t; cin >> t; while(t--)
#define For(i,l,n) for(i=l;i<n;i++)
#define Rof(i,l,n) for(i=l;i>n;i--)
#define pb push_back
#define vi vector <int>
#define mp make_pair
#define vp vector < pair <int,int> > 
#define um unordered_map
#define vb vector <bool>
#define di deque <int>
#define dp deque < pair <int,int> >
//					BFS
/* 
vb vis(n+1,true);
	For(i,1,n+1){
		if(vis[i]){
			queue <int> q;
			q.push(i);
			int s;
			while(!q.empty()){
				s=q.front();
				q.pop();
				if(vis[s]){
					vis[s]=false;		
					for(auto j:g[s]){
						if(vis[j])
							q.push(j);
					}
				}
			}
		}
	}
*/
using namespace std;
int i,j,k,l,m,n,ans;
/*int bs(vi &a,int b){
	if(b<=a[0])
    	return -1;
	if(b>a.back())
    	return a.size()-1;
	int s=0,e=a.size(),mid=(s+e)/2;
	while(s<e){
    	mid=(s+e)/2;
    	if(a[mid]<b && a[mid+1]>=b)
        	return mid;
    	if(a[mid]<=b)
        	e=mid;
    	else
        	s=mid;
	}
	return s;
}*/
int main() {
	std::ios::sync_with_stdio(false) ; cin.tie(NULL);
    cin >> n;
    n/=1000;
    string ans="ABC";
    ans[2]=ans[2]+n;
    cout << ans;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 500005
ll dp[N];
ll fac[N], ifac[N];

ll npr(ll n, ll r) {
    ll res = (1ll * fac[n] * ifac[n-r])%mod;
    return res;
}

ll ncr(ll n, ll r) {
    ll res = (1ll * ifac[r] * ifac[n-r])%mod;
    res = (1ll*res*fac[n])%mod;
    return res;
}

ll fun(ll n, ll m) {
    ll res = 0, val;
    ifr(i, 0, n+1) {
        val = i&1?mod-1:1;
        val = (1ll*val*ncr(n, i))%mod;
        val = (1ll*val*fac[m-i])%mod;
        val = (1ll*val*ifac[m-n])%mod;
        res = (res + val)%mod;
    }
    return res;
} 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    #endif
    // int T;cin>>T;while(T--) 
    {
        memset(dp, -1, sizeof dp);
        fac[0] = ifac[0] = ifac[1] = 1;
        ifr(i, 1, N) fac[i] = (1ll*fac[i-1]*i)%mod;
        ifr(i, 2, N) ifac[i] = (mod - (1ll*mod/i * ifac[mod%i])%mod)%mod;
        ifr(i, 2, N) ifac[i] = (ifac[i]*ifac[i-1])%mod;

        ll n, m;
        cin>>n>>m;
        ll ans = (1ll*npr(m, n) * fun(n, m))%mod;
        cout<<ans<<endl;

    }
    return 0;
}

Measured memory_bytes: 15364
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
	long long x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<long long> p(a), q(b), r(c);
	for (int i = 0; i < a; ++i) cin >> p[i];
	for (int i = 0; i < b; ++i) cin >> q[i];
	for (int i = 0; i < c; ++i) cin >> r[i];
	sort(p.begin(), p.end(), greater<long long>());
	sort(q.begin(), q.end(), greater<long long>());

	for (int i = 0; i < x; ++i) r.push_back(p[i]);
	for (int i = 0; i < y; ++i) r.push_back(q[i]);
	sort(r.begin(), r.end(), greater<long long>());

	long long sum = 0;
	for (int i = 0; i < x + y; ++i) {
		sum += r[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <math.h>
#include <map>
#include <set>
using namespace std;
#define Endl '\n'
int main()
{
    int n,m;
    cin>>n>>m;
    int a[101]={0};
    while(m--)
    {
        int k;
        cin>>k;
        int x;
        for (int i = 0; i < k; ++i)
        {
            cin>>x;
            a[x]++;
        }
    }
    int count=0;
    for (int i = 1; i <= n; ++i)
    {
        if (a[i]==0)
        {
            count++;
        }
    }
    cout<<count;
}

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

const ll N=2010,mod=1000000007;
ll n,a[200010],b[200010],ans,js[200010],sj[200010],f[4510][4510];

inline ll read(){
	ll x=0,tmp=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') tmp=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return tmp*x;
}

inline ll C(ll n,ll m){
	return 1ll*js[n]*sj[m]%mod*sj[n-m]%mod;
}

inline ll ksm(ll x,ll y){
	ll ans=1;
	while(y){
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}

inline ll inv(ll x){
	return ksm(x,mod-2);
}

inline void pre(ll n){
	js[0]=1;
	for(ll  i=1; i<n;i++) js[i]=js[i-1]*i%mod;
	for(ll  i=1; i<n;i++) sj[i]=inv(js[i]);
}

int  main(){
	pre(N<<2);
	n=read();
	for(ll i=1; i<=n; i++){
		a[i]=read();
		b[i]=read();
		f[N-a[i]][N-b[i]]++;
	}
	for(ll i=1; i<=N*2; i++){
		for(ll j=1; j<=N*2; j++) f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	}
	for(ll  i=1; i<=n; i++) ans=(ans+f[a[i]+N][b[i]+N])%mod;
	for(ll  i=1; i<=n; i++) ans=(ans+mod-C(2*(a[i]+b[i]),2*a[i]))%mod;
	ans=ans*inv(2)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 148524
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int N;
    string S;
    cin >> N >> S;

    if (N % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < N / 2; i++) {
        if (S[i] != S[i + N/2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[5];
int cnt=0;
int main()
{
	for(int i=1;i<=3;i++)
		scanf("%d",&a[i]);
	int cnt=0;
	int f=1;
	while(f)
	{
		if(a[1]==a[2]&&a[2]==a[3]) break;
		sort(a+1,a+1+3);
		while(a[1]+2<=a[3])a[1]+=2,cnt++;
		if(a[1]==a[2]&&a[2]==a[3]) break;
		while(a[2]+2<=a[3])a[2]+=2,cnt++;
		if(a[1]==a[2]&&a[2]==a[3]) break;
		if(a[2]==a[3]&&a[1]!=a[2]) a[1]+=2,a[2]+=1,a[3]+=1,cnt+=2;\
		if(a[1]==a[2]&&a[2]==a[3]) break;
		if((a[1]+1<=a[3]&&a[2]+1<=a[3]))a[1]+=1,a[2]+=1,cnt++;
	}
	printf("%d",cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n;
signed main(){
	cin>>n;
	if(n==3)puts("2 5 63");
	else{
		int cnt=0;
		if(n%2==0){
			for(int i=0;i<5000;i++){
				if(cnt==n-2)break;
				cout<<6*i+2<<" "<<6*i+4<<" ";
				cnt+=2;
			}
			for(int i=0;i<5000;i++){
				if(cnt==n)break;
				cout<<6*i+3<<" ";
				cnt++;
			}
			for(int i=1;i<=5000;i++){
				if(cnt==n)break;
				cout<<6*i<<" ";
				cnt++;
			}
			cout<<endl;
		}
		else{
			n--;
			for(int i=0;i<5000;i++){
				if(cnt==n-2)break;
				cout<<6*i+2<<" "<<6*i+4<<" ";
				cnt+=2;
			}
			for(int i=0;i<5000;i++){
				if(cnt==n)break;
				cout<<6*i+3<<" ";
				cnt++;
			}
			n++;
			for(int i=1;i<=5000;i++){
				if(cnt==n)break;
				cout<<6*i<<" ";
				cnt++;
			}
			cout<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int bit = 0; bit < (1<<n); bit++)
    {
        vector<int> v;
        //cout << (bitset<8>(bit)) << endl;
        for(int i = 0; i < n; i++)
        {
            if(bit & (1<<i)) v.push_back(i);
        }
        cout << bit << ":";
        for(int i = 0; i < v.size(); i++) cout << " " << v[i];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
import Text.Printf (printf)
-- don't use this signature at home
solve :: [Double] -> [Double]
solve [a,b,c,d,e,f] = let
    det = (a*e-b*d)
    inv = map (map (/det)) [[e,-b],[-d,a]]
    in
        map (sum . zipWith (*) [c,f]) inv

main = getContents >>=
    mapM_ (putStrLn . unwords . map (printf "%.3f") . solve . map read . words) . lines

Measured memory_bytes: 4492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll h, cnt = 0;
  cin >> h;
  while (h > 0) {
    h /= 2;
    cnt++;
  }
  
  ll ans = 1;
  for (ll i = 0; i < cnt; i++) {
    ans *= 2;
  }
  
  cout << ans - 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

int main() {
    using P = tuple<int, int, int>;
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    auto mp = make_v(h + 2, w + 2, '#');
    queue<P> q;
    REP(i, 1, h + 1) {
        REP(j, 1, w + 1) {
            cin >> mp[i][j];
            if (mp[i][j] == '#') {
                q.emplace(j, i, 0);
            }
        }
    }
    const int inf = 1 << 30;
    auto cost = make_v(h + 2, w + 2, inf);
    REP(i, 0, h + 2) {
        REP(j, 0, w + 2) {
            if (mp[i][j] == '#') cost[i][j] = 0;
        }
    }
    const int dx[4] = {0, 1, 0, -1};
    const int dy[4] = {1, 0, -1, 0};
    while (q.size()) {
        int x, y, c;
        tie(x, y, c) = q.front();
        q.pop();
        if (cost[y][x] < c) continue;
        REP(k, 0, 4) {
            int nx = x + dx[k], ny = y + dy[k];
            if (mp[ny][nx] == '#' || cost[ny][nx] <= c + 1) continue;
            cost[ny][nx] = c + 1;
            q.emplace(nx, ny, c + 1);
        }
    }
    int ans = 0;
    REP(i, 0, h + 2) {
        REP(j, 0, w + 2) {
            chmax(ans, cost[i][j]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17296