akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
# abc144/abc144_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    A,B=i2nn()
    if (A<10 and B<10):
        print(A*B)
    else:
        print(-1)
    return

main()


Measured memory_bytes: 3064
def abc165_c():
  n, m, q = map(int, input().split())
  query = [tuple(map(int, input().split())) for _ in range(q)]
  ans = 0

  def dfs(arr):
    # 得点計算
    if len(arr) == n:
      calc_score(arr)
      return
    # それ以外は後ろに追加して次へ
    if len(arr) == 0: start = 1
    else: start = arr[-1]
    for i in range(start, m+1):
      dfs(arr + [i])

  def calc_score(arr):
    nonlocal ans
    score = 0
    for a, b, c, d in query:
      if arr[b-1] - arr[a-1] == c:
        score += d
    if score > ans: ans = score

  dfs([])
  print(ans)

abc165_c()

Measured memory_bytes: 9220
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int x, y; cin >> x >> y;
    int a(abs(abs(x)- abs(y))); int ans(a + 4);
    REP(i, 4){
        int b(a), X(x);
        if(i & 2){
            ++b; X *= -1;
        }
        X += a;
        if(i & 1){
            ++b; X *= -1;
        }
        if(X == y) chmin(ans, b);
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

const int N = 3000;
ll dp[N][N];

void solve() {

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


	// dp[i][j] = max(score of frts person - score of second person) for interval (i,j);

	for (int i = n - 1; i >= 0; i--) {
		for (int j = i; j < n; j++) {
			if (i == j) {
				dp[i][j] = a[i];
			} else {
				dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1]);
			}
		}
	}

	cout << dp[0][n-1] << endl;

}

int32_t main()
{
	IOS
	// int T; cin >> T; while (T--)
	solve();
	return 0;
}


Measured memory_bytes: 49784
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
long long f[302][301];
int h[302];

int main()
{
    int n,k;scanf("%d%d",&n,&k);
    for (int i=1;i<=n;++i)
        scanf("%d",&h[i]);
    h[0]=h[n+1]=0;

    for (int i=1;i<=n+1;++i){
        for (int j=0;j<=min(i-1,k);++j){
            f[i][j]=f[i-1][min(j,max(i-2,0))]+max(h[i]-h[i-1],0);
            for (int t=1;t<=j;++t)
                f[i][j]=min( f[i][j],f[i-t-1][j-t]+max(h[i]-h[i-t-1],0) );
            //printf("%d %d %d\n",i,j,f[i][j]);
        }
        if(i<=k) for (int j=i;j<=k;++j) f[i][j]=f[i][j-1];
    }

    printf("%lld\n",f[n+1][k]);
}




Measured memory_bytes: 896
import sys
input = sys.stdin.readline

N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353

ans = pow(3, N, mod)
S = sum(a)
M = 300 * N

dp1 = [0] * (M + 1)
dp1[0] = 1
for i in a:
    ndp1 = [0] * (M + 1)
    for j in range(i, M + 1)[::-1]:
        ndp1[j] = (ndp1[j] + dp1[j - i]) % mod
    for j in range(M + 1):
        ndp1[j] = (ndp1[j] + dp1[j] * 2) % mod
    dp1 = ndp1
tmp = 0
for j in range((S + 1) // 2, M + 1):
    tmp = (tmp + dp1[j]) % mod
ans = (ans - 3 * tmp) % mod

dp2 = [0] * (2 * M + 1)
dp2[0] = 1
for i in a:
    ndp2 = [0] * (2 * M + 1)
    for j in range(i - M, M - i + 1):
        ndp2[j - i] = (ndp2[j - i] + dp2[j]) % mod
        ndp2[j + i] = (ndp2[j + i] + dp2[j]) % mod
    dp2 = ndp2
ans = (ans + 3 * dp2[0]) % mod

print(ans)


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

const long long p = 1000000007;

int main(){
    long long N;
    cin >> N;
    long long pow9 = 1;
    long long pow10 = 1;
    long long pow8 = 1;
    for(int i = 0; i < N; i++){
        pow9 = pow9*9%p;
        pow8 = pow8*8%p;
        pow10 = pow10*10%p;
    }
    long long ans = (2*p + pow10 + pow8 - 2*pow9)%p;
    cout << ans << endl;
}

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

using namespace std;

#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db long double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
#define ls ch[now][0]
#define rs ch[now][1]
const ll mod = 998244353;
const ll maxn = 2e5 + 10;


ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }

}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

vector<ll> G[maxn];


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    if(x>=30){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int N, M;
vector<vector<int>> G;
bool vis[100000][11];

struct Query {
    int v, d, c;
};

void dfs(int v, int d, int c, vector<int> &color)
{
    if (vis[v][d]) return;
    rep(i, d+1) vis[v][i] = true;
    if (color[v] == 0) color[v] = c;
    if (d == 0) return;

    for (auto u : G[v]) {
        if (vis[u][d-1]) continue;
        dfs(u, d-1, c, color);
    }
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> N >> M;
    G.resize(N);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    int Q; cin >> Q;
    vector<Query> query(Q);

    rep(i, Q) {
        int V, D, C;
        cin >> V >> D >> C;
        V--;
        query[i] = {V, D, C};
    }

    vector<int> color(N);

    reverse(query.begin(), query.end());
    for (auto q : query) {
        dfs(q.v, q.d, q.c, color);
    }

    rep(i, N) {
        cout << color[i] << endl;
    }
}



Measured memory_bytes: 9208
using System;

class MainMethod
{
    static void Main()
    {
        string S = Console.ReadLine();
        int count = 0;

        if (S.Length > 1)
        {
            for(int i = 0; i < S.Length - i; i++)
            {
                if (S[i] != S[S.Length-1 - i])
                    count += 1;
            }
        }
        else
        {
            
        }

        //出力
        Console.WriteLine(count);
    }
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

void Main() {
  int n = read<int>();
  ll mt = 1, ma = 1;
  rep(i, n) {
    ll t = read<int>();
    ll a = read<int>();
    ll xt = (mt + t - 1) / t * t;
    ll xa = (ma + a - 1) / a * a;
    //_p("=====\n");
    //_p("%lld,%lld\n", t, a);
    //_p("%lld,%lld\n", xt, xa);

    ll ta = xt / t * a;
    ll at = xa / a * t;
    //_p("%lld,%lld\n", xt, ta);
    //_p("%lld,%lld\n", at, xa);

    bool bt = xt >= mt && ta >= ma;
    bool ba = at >= mt && xa >= ma;

    if (bt && ba) {
      if (xt + ta < at + xa) {
        mt = xt;
        ma = ta;
      }
      else {
        mt = at;
        ma = xa;
      }
    }
    else if (bt) {
      mt = xt;
      ma = ta;
    }
    else if (ta) {
      mt = at;
      ma = xa;
    }
    else {
      assert(false);
    }
    //_p("%lld,%lld\n", mt, ma);
  }
  _p("%lld\n", mt+ma);
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  string s;
  int n;
long long int ans(vector<int> vec){
  long long int tmp = 0;
  for(int i=0; i<vec.size()-1; i++){
    tmp += stoll(s.substr(vec.at(i),vec.at(i+1)-vec.at(i)));
  }
  return tmp;
}
long long int dfs(int i, vector<int> vec){
  if(i==n){vec.push_back(n);return ans(vec);}
  vector<int> vec2 = vec;
  vec.push_back(i);
  return dfs(i+1,vec) + dfs(i+1,vec2);
}

int main(){
  cin >> s;
  n = s.size();
  vector<int> tmpvec;
  tmpvec.push_back(0);
  cout << dfs(1,tmpvec) << endl;
}
  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            int a = int.Parse(inputStrArray[0]);
            int b = int.Parse(inputStrArray[2]);

            int result;

            if (inputStrArray[1] == "+")
            {
                result = a + b;
            }
            else
            {
                result = a - b;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
lstT = [int(i) for i in input().split()]
m = int(input())

total = sum(lstT)
lst_Ans = []

for i in range(m):
    p,x = map(int,input().split())
    ans = total - lstT[p-1] + x
    lst_Ans.append(ans)

for i in range(m):
    print(lst_Ans[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<double> p(n + 1);
	vector<vector<double>> dp(n + 1, vector<double>(n + 1));
	for(int i = 1; i <= n; ++ i) cin >> p[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; ++ i) {
		for(int j = 0; j <= n; ++ j) {
			dp[i][j] = (j ? dp[i - 1][j - 1] * p[i]:0) + dp[i - 1][j] * (1 - p[i]);
		}
	}
	double answer = 0;
	int idx = n;
	while(idx > n - idx) answer += dp[n][idx], idx--;
	cout << fixed << setprecision(10) << answer << '\n';
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

using namespace std;

vector<bitset<32>> make(int k) {
    bitset<32> b(k);
    vector<bitset<32>> ans = {b};
    FOR(i, 0, 32) {
        if (b[i] == 1) {
            bitset<32> tmp(k);
            FOR(j, 0, i) {
                tmp[j] = true;
            }
            tmp[i] = false;
            ans.emplace_back(tmp);
        }
    }
    return ans;
}

int main(int argc, char *argv[]) {
    int N, K, A, B;
    cin >> N >> K;
    vector<pair<int, int>> v;
    FOR(_, 0, N) {
        cin >> A >> B;
        v.emplace_back(make_pair(A, B));
    }
    
    LL ans = 0;
    FOE(t, make(K)) {
        LL tmp_ans = 0;
        FOE(p, v) {
            bool ok = true;
            bitset<32> b(p.first);
            FOR(i, 0, 32) {
                if (t[i] == 0 and b[i] == 1) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                tmp_ans += p.second;
            }
        }
        ans = max(ans, tmp_ans);
    }
    std::cout << ans << std::endl;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  
  if (L > 0)
    cout << (N - 1) * (L - 1) + (2 + N) * (N - 1) / 2 << endl;
  else if (L + N < 1)
    cout << (N - 1) * (L - 1) + N * (N - 1) / 2 << endl;
  else
    cout << N * (L - 1) + (1 + N) * N / 2 << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
typedef vector<int> V;
typedef pair<int, int> pii;

const int N = 1e5;
int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 100000; i++)
        if (int(i * 0.08) == a && int(i * 0.1) == b) {
            cout << i;
            return 0;
        }
    cout << -1;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll num[30];
int main() {
    int N;
    string S;
    cin >> N >> S;

    for (auto c : S) num[c - 'a']++;

    ll ans = 1;
    for (int i = 0; i < 26; i++) {
        ans *= num[i] + 1;
        ans %= MOD;
    }

    cout << (ans + MOD - 1) % MOD << endl;
}

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

int main()
{
          int W,H,x,y,r;
          scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
          if((x+r>W||y+r>H)||(x<r||y<r))

          {
                    printf("No\n");

          }
          else
          {


                    printf("Yes\n");
          }
          return 0;
}



Measured memory_bytes: 2100
<?php
fscanf(STDIN, "%d", $amout);
$array = explode(' ', fgets(STDIN));

$counter = array();
for($i=0 ; $i < $amout; $i++){
    $value = (int)$array[$i];
    $counter[$value] = !array_key_exists($value, $counter) ? 1 : $counter[$value]+1;
    $counter[$value+1] = !array_key_exists($value+1, $counter) ? 1 : $counter[$value+1]+1;
    $counter[$value-1] = !array_key_exists($value-1, $counter) ? 1 : $counter[$value-1]+1;
}

$answer = 0;
foreach ($counter as $count) {
    $answer = $count > $answer ? $count:$answer;
}

echo $answer;

Measured memory_bytes: 19188
#include<cstdio>
using namespace std;
int a[11],b,c,f;
void dfs(int n){
	int d;
	if(f)
		return;
	if(n==11){
		f=1;
		return;
	}
	if(a[n]>b){
		d=b;
		b=a[n];
		dfs(n+1);
		b=d;
	}
	if(a[n]>c){
		d=c;
		c=a[n];
		dfs(n+1);
		c=d;
	}
}
int main(){
	int t,i;
	scanf("%d",&t);
	while(t--){
		f=0;
		for(i=1;i<=10;i++)
			scanf("%d",&a[i]);
		b=0;
		c=0;
		dfs(1);
		if(f)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

vector<string> split(string s){
    int x = -1;
    vector<string> ret;
    s += " ";
    REP(i,s.size()){
	if(s[i] == ' '){
	    ret.PB( s.substr(x+1,i-x-1) );
	    x = i;
	}
    }
    return ret;
}

void conb(vector<string> &s1,vector<string> &s2){
    REP(i,s2.size()){
	s1.PB(s2[i]);
    }
}

int main(){
    while(true){
	int n;
	string hoge;
	vector< string > words;
	getline(cin,hoge);
	n = stoi(hoge);
	if(n == 0) break;
	REP(i,n){
	    string temp;
	    getline(cin,temp);
	    vector<string> w = split(temp);
	    conb(words,w);
	}
	sort(ALL(words));
	char k;
	vector< string > t = words;
	t.erase(unique(ALL(t)),t.end());
	vector< pair<int,string> > dic;
	REP(i,t.size()){
	    dic.PB(pair<int,string>(INF,t[i]));
	}
	REP(i,dic.size()){
	    REP(j,words.size()){
		if(words[j] == dic[i].second){
		    dic[i].first--;
		}
	    }
	}
	sort(ALL(dic));
	cin >> k;
	int pos = 0;
	RREP(i,dic.size()){
	    if(dic[i].second[0] != k){
		dic.erase(dic.begin()+i);
	    }
	}
	if(dic.size() == pos) cout << "NA" << endl;
	else{
	    cout << dic[0].second;
	    FOR(i,1,min(5,(int)dic.size())){
		if(dic[i].second[0] != k) break;
		cout << " " << dic[i].second;
	    }
	    cout << endl;
	}
	cin.clear();
	cin.ignore();
    }
    return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>

int main(){
	int N,M,ans;
	scanf("%d%d",&N,&M);
	
	if(M%N==0){
		printf("%d\n",M/N);
		return 0;
	}
	
	
	
	for(int i=1;i<=M/N;i++){
		if(M%i==0)ans=i;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  string s; cin>>s;
  int now=0,count=0;
  long long ans=0;
  while(now<s.size()){
    if(s[now]=='W'){
      ans+=count;
    }else{
      count++;
    }
    now++;
  }
  cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, K; cin >> N >> K;
  ll a[N]; rep(i,N) cin >> a[i];
  ll sp[N+1]= {}, sm[N+1]={}; 
  rep(i,N) {
    if (i==0) {
      if (a[i]>=0) sp[i+1] = a[i];
      else sm[i+1] = a[i];
    }
    else {
      sp[i+1] = sp[i]; sm[i+1] = sm[i];
      if (a[i]>=0) sp[i+1] += a[i];
      else sm[i+1] += a[i];
    }
  }
  ll rp = LLINF, rm = -1*LLINF;
  rep(i,N-K+1) {
    rp = min(rp, sp[i+K]-sp[i]);
    rm = max(rm, sm[i+K]-sm[i]);
  }
  ll result = 0; rep(i,N) if (a[i]>=0) result += a[i];
  result -= min(rp, -1*rm);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) {
	a = min(a, b);
}
void mmax(int &a, int b) {
	a = max(a, b);
}
void sor(vel &v) {
	sort(v.begin(), v.end());
}
int ser(vel &v, int tan) {
	int si = v.size() - 1;
	if (tan == v[si]) {
		return si;
	}
	int lo = 0;
	int up = si;
	while (up - lo > 1) {
		int mi = (lo + up) / 2;
		if (v[mi] <= tan) {
			lo = mi;
		}
		else {
			up = mi;
		}
	}
	return lo;
}
signed main() {
	string s;
	cin >> s;
	string t = "keyence";
	if (s == "keyence") {
		cout << "YES" << endl;
	}
	else {
		int n = s.size();
		int i = 0;
		int ok = 0;
		while (i<7 and ok==0) {
			if (s[i] == t[i]) {
				i++;
			}
			else {
				ok++;
			}
		}
		int x = i;
		ok = 0;
		i = 0;
		while (i < 7 and ok == 0) {
			if (s[n - 1 - i] == t[7-1-i]) {
				i++;
			}
			else {
				ok++;
			}
		}
		if (x + i >= 7) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 2e15+7;
const ll mod = 1e9+7;
const int MAX_N = 5e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = ll> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
	int par[MAX_N];
	int rank[MAX_N];
public:
	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

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

int main() {
	int n=in();
	int a[n],b[n];
	REP(i,n) a[i]=in();REP(i,n) b[i]=in();
	int ans=0;
	REP(i,29) {
		int c[n],d[n];
		REP(j,n) {c[j]=a[j]%(1<<(i+1)),d[j]=b[j]%(1<<(i+1));}
		sort(d,d+n);
		int cnt=0;
		REP(j,n) {
			cnt+=(lower_bound(d,d+n,(1<<i)*2-c[j])-lower_bound(d,d+n,(1<<i)-c[j]));
			cnt+=(lower_bound(d,d+n,(1<<i)*4-c[j])-lower_bound(d,d+n,(1<<i)*3-c[j]));
		}
		if (cnt%2) {
			ans+=1<<i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <sstream>
#include <bitset>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
//#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int H, W;
char S[55][55];

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

signed main()
{
    cin >> H >> W;
    REP(i,H) REP(j,W) cin >> S[i][j];

    REP(i,H) REP(j,W) if (S[i][j] == '.') {
        int num = 0;
        REP(k,8) {
            int ny = i + dy[k], nx = j + dx[k];
            if (0<=ny && ny<H && 0<=nx && nx<W && S[ny][nx]=='#') num++;
        }
        S[i][j] = '0' + num;
    }

    REP(i,H) {
        REP(j,W) {
            cout << S[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,K,x;
 int L=0;
 cin>>N>>K;
 for(int i=0;i<N;i++) {
   cin>>x;
   if(x<=(K-x)) 
     L+=x*2;
   else
     L+=(K-x)*2;
 }
  cout<<L<<endl;
}

Measured memory_bytes: 3624
while 1:
	n = input()
	if n == 0: break
	datas = [map(int,raw_input().split()) for i in range(n)]
	maxw = 0
	for d1 in datas:
		w = sum([d2[0] for d2 in datas if d2[1]<=d1[1]<d2[2]])
		maxw = max(w,maxw)
	print "OK" if maxw <= 150 else "NG"

Measured memory_bytes: 4228
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

const int MAX_V = half_inf;
vector<int> G[half_inf];
vl d(half_inf);

ll dfs(ll s) {
    ll res = 0;
    if (d[s] != -1) return d[s];

    rep(i, G[s].size()) {
        res = max(res, dfs(G[s][i]) + 1);
    }
    d[s] = res;
    return res;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif

        int V, E;
        scanf("%d %d", &V, &E);
        for (int i = 0; i < E; ++i) {
            int s, t;
            scanf("%d %d", &s, &t);
            s--, t--;
            G[s].eb(t);
        }
        ll ans = 0;
        rep(i, V) d[i] = -1;
        rep(i, V) ans = max(ans, dfs(i));
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi as(n),bs(n);
		rep(i,n) cin>>as[i]>>bs[i];
		vi is(n); iota(all(is),0);
		sort(all(is),[&](int i,int j){return as[i]+bs[i]>as[j]+bs[j];});
		ll c=1,res=0;
		for(auto i:is){
			res+=c*(c==1?as[i]:bs[i]);
			c*=-1;
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462   
int main(){
    int n;
    int x;
    cin >> n;
    for (int i = 1; i < n + 1; i++){
        x = i;
        if (x % 3 == 0){
            cout << " " << i;
            continue;
        }
        while (1){
            if (x % 10 == 3){
                cout << " " << i;
                break;
            }
            x /= 10;
            if (x == 0) break;
        }
    }
    cout << endl;
    return 0;
}
//AAAAAAAAAAA!

Measured memory_bytes: 1160
a, b, c, x = 4.times.map { gets.strip.to_i }
cnt = 0
(0..a).each do |i|
    (0..b).each do |j|
        (0..c).each do |k|
            cnt += 1 if i * 500 + j * 100 + k * 50 == x
        end
    end
end

puts cnt

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
using namespace std;

int n,rn,fx;
int arx[100005];
vector<int> x;
int ans=1;

int  gcd(int x, int y) {
	if (x == 0 || y == 0) {
		cout << "x=0 or y=0\n";
		return -1;
	}
	if (x%y == 0) return y;
	else gcd(y, x%y);

}

int main() {
	cin >> n >>fx;
	


	rep(i, n) {
		int y;
		cin >> y;
		if(y-fx!=0)	x.pb(abs(y - fx));
	}

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

	rn = x.size();

	rep(i, rn) {
		arx[i] = x[i];
	}

	ans = x[0];
	rep(i, rn-1) {
		ans = gcd(ans, x[i + 1]);
		if (ans == 1) break;
	}

	cout << ans << "\n";

	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



void smain() {

    string s;
    cin>>s;
    if(SZ(s)==2){
        if(s[0]==s[1])
            cout<<"1 2";
        else
            cout<<"-1 -1";
        return;
    }
    for(int i=0;i<SZ(s)-2;i++){
        if(s[i]==s[i+1]||s[i]==s[i+2]||s[i+1]==s[i+2]){
            cout<<i+1<<" "<<i+3;
            return;
        }
    }
    cout<<"-1 -1";


}


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

int main() {
	int n; scanf("%d", &n);
	int a = INT_MAX, b = INT_MIN;
	rep(i, n) {
		int d; scanf("%d", &d);
		b = max(b, d - a);
		a = min(a, d);
	}
	printf("%d\n", b);
}

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

int main() {
    int N, res=0;
    cin >> N;
    vector<int> p(N);
    rep(i, N) {
        cin >> p[i];
        res += p[i];
    }
    sort(p.begin(), p.end(), greater<int>());

    res -= p[0]/2;
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

int main(){
    ll x,y; cin >> x >> y;
    ll ans=1,a=x; 
    while(true){
        a *= 2;
        if(a<=y) ++ans;
        else break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

val mod = (1e9 + 7).toInt()
val fact = Array((2e5 + 1).toInt()) { 1L }
val fact2 = Array((2e5 + 1).toInt()) { 1L }
fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()

    for (i in 2..2e5.toInt()) fact[i] = (fact[i - 1] * i) % mod
    fact2[1] = n.toLong()
    for (i in 2..2e5.toInt()) fact2[i] = (fact2[i - 1] * (n - i + 1)) % mod

    var res = pow(2, n)
    res = minus(res, 1)
    res = minus(res, c(n, a))
    res = minus(res, c(n, b))
    println(res)
}

fun minus(a:Int, b:Int):Int{
    return (a - b + mod) % mod
}
fun c(n: Int, k: Int): Int {
    var res = (fact2[k] * inv(fact[k])) % mod
    return res.toInt()
}
fun inv(x:Long):Int {
    return pow(x, mod - 2)
}

fun pow(a: Long, x: Int): Int {
    var a = a
    var x = x
    var res = 1L
    while (x > 0) {
        if (x % 2 == 1) res = (res * a) % mod
        x /= 2
        a = (a * a) % mod
    }

    return res.toInt()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 44064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		HashMap<Integer,Integer> mochi = new HashMap<>(); 
		for(i=0;i<n;i++) {
			int d = Integer.parseInt(sc.next());
			Integer m = mochi.get(d);
			if(m == null) {
				mochi.put(d, 1);
			} else {
				mochi.put(d, m+1);
			}
		}
		sc.close();
		int ans = mochi.size();
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
//typedef pair<ll,ll> p; 

int main() {
	
int a,b,p=0;
cin>>a>>b;
for(int i=1;i<100000;i++)
{
    if((floor(i*0.08) == a)&&(floor(i*0.1) == b))
    {
        p=1;
    cout<<i<<endl;
    break;
    }
}
if(p==0)
cout<<"-1"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n;
    cin >> n;
    cout << pow(n, 3);
    return 0;
}

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

int main() {
    int a[4], b[4];
    while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
        int hit = 0, blow = 0;

        for (int i = 0; i != 4; ++i) {
        	for (int j = 0; j != 4; ++j) {
        		if (a[i] == b[j]) {        			
                    i == j ? ++hit : ++blow;
        		}
        	}
        }        
        cout << hit << " " << blow << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
#print(A)

ret1 = [0] * (N+2)
ret2 = [0] * (N+2)

for i in range(N):
    ret1[i+1] = gcd(ret1[i], A[i])
for i in range(N-1,-1,-1):
    ret2[i+1] = gcd(ret2[i+2], A[i])
    
#print(ret1)
#print(ret2)

ans = 0
for i in range(N):
    X = gcd(ret1[i], ret2[i+2])
    if X > ans:
        ans = X
        
print(ans)



Measured memory_bytes: 16124
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        char[] s = Console.ReadLine().ToCharArray();

        if (s[0] != 'A')
        {
            Console.WriteLine("WA");
            return;
        }

        int count = 0;
        int index = 2;
        for (int i = 2; i < s.Length - 1; i++)
        {
            if (s[i] == 'C')
            {
                count++;
                index = i;
            }
        }
        if (count != 1)
        {
            Console.WriteLine("WA");
            return;
        }

        for (int i = 1; i < s.Length; i++)
        {
            if (index == i)
                continue;
            if ((int)s[i] < 97 || 122 < (int)s[i])
            {
                Console.WriteLine("WA");
                return;
            }
        }
        Console.WriteLine("AC");
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const LL M = 1000000007;

LL kpw(LL x,LL y){
	LL ans = 1,tmp = x;
	while(y){
		if(y & 1) ans = (ans * tmp) % M;
		tmp = (tmp * tmp) % M;
		y >>= 1;
	}
	return ans;
}

LL n,m,ans = 0;
LL fac[1 << 17],inv[1 << 17],c[25],dp[25][1 << 17];
bool cmp(LL x,LL y){
	return x > y;
}

LL comb(LL a,LL b){
	if(a < b) return 0;
	return ((fac[a] * inv[b] % M) * inv[a - b] % M) % M;
}

LL countone(LL x){
	LL ret = 0;
	while(x){
		if(x & 1) ret ++;
		x >>= 1;
	} return ret;
}

int main(){
	cin >> n >> m;
	fac[0] = 1; for(LL i = 1;i <= (1 << n);i ++) fac[i] = (fac[i - 1] * i) % M;
	for(LL i = 0;i <= (1 << n);i ++) inv[i] = kpw(fac[i],M - 2);
	for(LL i = 1;i <= m;i ++) cin >> c[i];
	sort(c + 1,c + 1 + m,cmp);
	
	memset(dp,0,sizeof(dp)); dp[0][0] = 1;
	for(LL i = 1;i <= m;i ++){
		for(LL j = 0;j < (1 << n);j ++) dp[i][j] = dp[i - 1][j];
		for(LL j = 0;j < (1 << n);j ++){
			for(LL k = 0;k < n;k ++){
				if((j >> k) & 1) continue;
				if((1 << n) - c[i] - j < 0) continue;
				dp[i][j | (1 << k)] += ((dp[i - 1][j] * comb((1 << n) - c[i] - j,(1 << k) - 1)) % M * fac[1 << k]) % M;
				dp[i][j | (1 << k)] %= M;
			}
		}
	}
	for(LL i = 0;i < (1 << n);i ++){
		if(countone(i) & 1) ans = (ans - (dp[m][i] * fac[(1 << n) - 1 - i] % M) + M) % M;
		else ans = (ans + (dp[m][i] * fac[(1 << n) - 1 - i] % M)) % M;
	}
	cout << (ans * (1 << n)) % M << '\n';
	return 0;
}

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

int main(){
	int s ; cin >> s ;
	set<int> f ;
	f.insert(s) ;
	int i = 1 ;
	while(1){
		i++ ;
		if(s%2==0) s /= 2 ;
		else s = 3*s+1 ;
		if(f.count(s)){
			cout << i << endl ;
			return 0 ;
		}else{
			f.insert(s) ;
		}
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 4e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<pair<ld, pair<ld,ld>>> vec;
    int n;
    cin >> n;
    rep(i,n){
        ld x, y;
        cin >> x >> y;
        vec.eb(mp(atan2(y, x), mp(x, y)));
    }
    sort(all(vec));
    ld ans = 0;
    rep(i,n){
        repf(j,i,n){
            //[i,j)と[j,i)を？
            ld x = 0, y = 0;
            repf(k,i,j){
                x += vec[k].S.F;
                y += vec[k].S.S;
            }
            ld z = sqrt((x * x + y * y));
            ans = max(ans, z);
            x = y = 0;
            repf(k,j,n){
                x += vec[k].S.F;
                y += vec[k].S.S;
            }
            rep(k,i)
            {
                x += vec[k].S.F;
                y += vec[k].S.S;
            }
            z = sqrt((x * x + y * y));
            ans = max(ans, z);
        }
    }
    cout << fixed << setprecision(17) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define INF (1<<26)
int M,N;
int K[100];
int s[100][100];
string cond[100][100];
int t[100][100];

int A[100][100];
int B[100];

int check(int a,int b){
  int L[100],R[100];
  for(int i=0;i<100;i++){
    L[i]=0;
    R[i]=INF;
  }
  for(int i=0;i<K[a];i++){
    if(cond[a][i]==">="){
      L[s[a][i]]=max(L[s[a][i]],t[a][i]);
    }else{
      R[s[a][i]]=min(R[s[a][i]],t[a][i]);
    }
  }

  for(int i=0;i<100;i++)
    if(L[i]>R[i])return 0;
  
  for(int i=0;i<K[b];i++){
    if(cond[b][i]==">="){
      L[s[b][i]]=max(L[s[b][i]],t[b][i]);
    }else{
      R[s[b][i]]=min(R[s[b][i]],t[b][i]);
      if(L[s[b][i]] > R[s[b][i]])return 0;
    }
  }


  return 1;
}

int main(){
  cin>>M>>N;
  for(int i=0;i<M;i++){
    cin>>K[i];
    for(int j=0;j<K[i];j++){
      cin>>s[i][j]>>cond[i][j]>>t[i][j];
      s[i][j]--;
    }
  }

  
  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++){
      A[i][j]=check(i,j);
    }
  }

  for(int j=0;j<M;j++){
    B[j]=0;
    for(int k=0;k<M;k++){
      B[j]+=A[j][k];
    }
  }
  
  bool flg=true;

  for(int i=0;i<M;i++){
    
 
      
    int id=-1,maxm=-1;
    for(int j=0;j<M;j++){
      if(maxm<B[j]){
        maxm=B[j];
        id=j;
      }
    }
    
    if(maxm<M-i)flg=false;
    
    for(int j=0;j<M;j++){
      if(A[j][id]==1){
        B[j]--;
      }
      A[j][id]=0;
      A[id][j]=0;
    }
    B[id]=0;
  }

  cout<<(flg?"Yes":"No")<<endl;
  
  return 0;
}

Measured memory_bytes: 1868