akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;
 

void solveCase() {

   vector <int> v(3);
   for(auto &e: v) {
      cin >> e;
   }
   sort(v.begin(), v.end());

   ll ans = LONG_MAX;
   do {
      if(v[0] % 2 == 0) {
         ans = min(ans, 0LL);
      } else {
         ans = min(ans, v[1] * 1LL * v[2]);
      }
   } while(next_permutation(v.begin(), v.end()));
   cout << ans << endl;
}
 
int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

Measured memory_bytes: 3648
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1])
    t = list(input()[:-1])
    s_len = len(s)
    t_len = len(t)
    print('Yes') if s_len + 1 == t_len and s == t[0:s_len] else print('No')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 61684
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
			int n,x,y,z,i,t,ans=0;
			cin>>n;
			int a[n]={0},b[n]={0},c[n]={0};
			cin>>x;
			for(i=0;i<x;++i){
				cin>>t;
				a[t-1]=1;
			}
			cin>>y;
			for(i=0;i<y;++i){
				cin>>t;
				b[t-1]=1;
			}
			cin>>z;
			for(i=0;i<z;++i){
				cin>>t;
				c[t-1]=1;
			}
			for(i=0;i<n;++i){
				if( a[i]==0 && c[i]==1 || b[i]==1 && c[i]==1)ans++;
		}

	cout<<ans<<endl;
}


Measured memory_bytes: 3108
#include <iostream>

int gcd(int a,int b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}

int main(){
    int K;
    std::cin >> K;
    int sum=0;
    int num=0;
    
    for(int i=1;i<=K;++i){
        for(int j=1;j<=K;++j){
            num=gcd(i,j);
            for(int h=1;h<=K;++h){
                sum+=gcd(num,h);
            }
        }
    }
    std::cout << sum << std::endl;
    return 0;
}


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

typedef long long ll;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int c = 0;
  ll res = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'B') {
      res += n - 1 - i - c;
      c++;
    }
  }
  cout << res << endl;
  
}



Measured memory_bytes: 640
s = input()
l = len(s)

ans = 0

for bit in range(1 << l - 1):
    f = s[0]

    for i in range(l - 1):
        if bit & (1 << i):
            f += '+'
        f += s[i + 1]
    ans += sum(list(map(int, f.split('+'))))

print(ans)

Measured memory_bytes: 3064
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
STX = [tuple(lr()) for _ in range(N)]
STX.sort(key=lambda x: x[2], reverse=True)
event = []
for s, t, x in STX:
    event.append((s-x, 0, x))
    event.append((t-x, -1, x))

for i in range(Q):
    d = ir()
    event.append((d, 1, i))

event.sort()
answer = [-1] * Q
cur = set()
flag = False
INF = 10 ** 10
min_x = INF
for a, b, c in event:
    if b == 0:
        cur.add(c)
        if c < min_x:
            min_x = c
            flag = True
    elif b == -1:
        cur.remove(c)
        if min_x == c:
            flag = False
    elif b == 1:
        if cur:
            if not flag:
                min_x = min(cur)
                flag = True
            answer[c] = min_x

print('\n'.join(map(str, answer)))
# 19


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

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

    ll n;
    cin >> n;
    vector<ll> a(n);

    map<ll, ll> mp;
    rep(i, n){
        cin >> a[i];
        ++mp[a[i]];
    }

    ll sm = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        sm += itr->first * itr->second;
    }

    int q;
    cin >> q;

    rep(_, q){
        ll b, c;
        cin >> b >> c;

        sm -= b*mp[b];
        sm += c*mp[b];

        mp[c] += mp[b];
        mp[b] = 0;

        cout << sm << "\n";
    }



    return 0;
}

Measured memory_bytes: 10120
N, M = gets.split.map(&:to_i)
edges = Array.new(N+1){Array.new}

M.times do |i|
    a, b = gets.split.map(&:to_i)
    edges[a].push(b)
    edges[b].push(a)
end

path = 0
stack = [1]
visited = {[1] => true}
while stack.length > 0 do
    if stack.length == N
        path += 1
        stack.pop
        next
    end
    s = stack[-1]
    update = false
    edges[s].each do |d|
        next if stack.include?(d)
        n = stack + [d]
        unless visited[n]
            stack = n
            visited[stack.dup] = true
            update = true
            break
        end
    end
    unless update
        stack.pop
    end
end

puts path

Measured memory_bytes: 5756
import sys

def swap(A, i, j):
    x = A[i]
    A[i] = A[j]
    A[j] = x

def partition(A, p, r, idx):
    x = A[r][idx]                # 1 x = A[r]
    i = p - 1                    # 2 i = p-1
    for j in range(p, r):        # 3 for j = p to r-1
        if A[j][idx] <= x:       # 4     if A[j] <= x
            i += 1               # 5        then i = i+1
            if(i != j):
                swap(A, i, j)    # 6        exchange A[i] and A[j] 
    i += 1 
    swap(A, i, r)                # 7 exchange A[i+1] and A[r]
    return i                     # 8 return i+1

def quickSort(A, p, r, idx):
    if p < r:
        q = partition(A, p, r, idx)
        quickSort(A, p, q - 1, idx)
        quickSort(A, q + 1, r, idx)

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cards = list(istr.splitlines())
    
    A = [[0,0] for i in range(num)]
    B = [[0,0] for i in range(num)]
    
    for i in range(num):
        A[i][0] = cards[i][0]
        A[i][1] = int(cards[i][2:])
        B[i][0] = cards[i][0]
        B[i][1] = int(cards[i][2:])

    quickSort(A, 0, num-1,1)
    B.sort(key = lambda d:d[1])
    res = "Stable"
    for i in range(num):
        if A[i][0] != B[i][0] or A[i][1] != B[i][1]:
            res = "Not stable"
            break

    print(res)
    for x in A:
        print(" ".join(map(str, x)))

if __name__ == '__main__':
    main()

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


int main(){
    string s; cin >> s;
    if (s == "RRR"){
        cout << 3 << endl;
    }
    else if(s == "RRS" || s == "SRR"){
        cout << 2 << endl;
    }
    else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR"){
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
using System;
class Program
{
    static void Main(string[] args)
    {
        int H, W, A, B;

        //string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        string str = Console.ReadLine();
        int N = int.Parse(str);

        if (N % 2 == 0)
        {
            Console.Write("0.5");
        }
        else
        {
            double cal = N / 2;
            int kisuu = (int)Math.Ceiling(cal);
            double ans = (double)(kisuu + 1) / N;
            Console.Write(ans.ToString());
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
#define LL long long
const int MAX = 1e5+10;
LL n,m,x,y;
LL a[4];
int main ()
{
    cin>>a[1]>>a[2]>>a[3];
    cin>>x;
    sort(a+1,a+4);
    for(int i=1;i<=x;i++)
    {
        a[3]*=2;
    }
    cout<<a[1]+a[2]+a[3]<<endl;
    return 0;
}


Measured memory_bytes: 256
w = input()
wl = list(w)
wu = list(set(wl))
wu_len  = len(wu)
counter = 0
for wo in wu:
  if wl.count(wo) % 2 == 0:
    counter+=1
  else:
    break
if counter == int(wu_len):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
vector<long long> N;
map<pair<long long, long long>, long long> memo;
long long pow_mod(long long a, long long b) {
    if (b == 0) return 1;
    if (memo.find(make_pair(a, b)) != memo.end()) return memo[make_pair(a, b)];
    long long k = pow_mod(a, b/2);
    long long kk = (k * k) % mod;
    if (b & 1) {
        return memo[make_pair(a, b)] = (kk * a) % mod;
    }
    return memo[make_pair(a, b)] = kk;
}
long long nCr (long long n, long long r) {
    if (r == 0 || r == n) {
        return 1;
    }
    if (r < 0 || r > n) {
        return 0;
    }
    long long res = N[n];
    res *= pow_mod(N[r], mod-2);
    res %= mod;
    res *= pow_mod(N[n-r], mod-2);
    res %= mod;
    return res;
}
int main () {
    int n, k;
    cin >> n >> k;
    N.push_back(1);
    for (int i = 1; i < n; i++) {
        N.push_back((N.back() * i) % mod);
    }
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    long long ans = 0;
    sort(A.begin(), A.end());
    for (int i = 0; i < n; i++) {
        ans += (nCr(i, k-1) - nCr(n-1-i, k-1)) * A[i];
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 95220
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    vl xs(5); REP(i, 5) cin >> xs[i]; ll k; cin >> k;
    ll ans = 0;
    REP(i, 5){
        FOR(j, i+1, 5)
        {
            if(abs(xs[i] - xs[j]) > k) ans++;
        }
    }
    cout << (ans > 0 ? ":(" : "Yay!") << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 3010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

double dp[N][N] ;
double a[N] ;
double ans ;
int n ;

signed main(){
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i++) scanf("%lf", &a[i]) ;
	for (int i = 0; i <= n; i++)
	for (int j = 0; i + j <= n; j++)
	dp[i][j] = 0.00 ;
	dp[0][0] = 1.00 ;
	for (int i = 1; i <= n; i++) // play i round
	for (int j = 0; j <= i; j++) { // and have j coins head
		int x = j, y = i - j ; // in all coins, x is head, y is tail
		if (x) dp[x][y] += dp[x - 1][y] * a[i] ;
		if (y) dp[x][y] += dp[x][y - 1] * (1 - a[i]) ;
//		cout << x << " " << y << " " << dp[x][y] << endl ;
	}
	int l = n, r = 0 ;
	while (l > r) {
		ans += dp[l][r] ;
		l--, r++ ;
	}
//	for (int i = 0; i <= n; i++)
//	for (int j = 0; i + j <= n; j++) cout << i << " " << j << " " << dp[i][j] << endl ;
	printf("%.10lf\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 70016
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>

using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define repe_r(i,s,n)for(int i = n;i>=s;i--)

static const ll FACT_SIZE = 1000000;
ll fact[FACT_SIZE] = {};

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
void factorial(ll f) {
	fact[0] = fact[1] = 1;
	rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i % MOD;
}

ll nCr(ll n, ll r) {
	if (fact[0] == 0)	factorial(1000000);
	return ((fact[n] * (Pow(fact[r], MOD - 2) % MOD)) % MOD * Pow(fact[n - r], MOD - 2)) % MOD;
}

int main() {
	factorial(10000);
	ll n, k; cin >> n >> k;
	repe(i, 1, k) {
		if (i > n - k + 1) {
			cout << 0 << endl;
		}
		else {
			cout << nCr(n - k + 1, i) % MOD * nCr(k - 1, i - 1) % MOD << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 8064
def main():
    N = int(input())
    if N == 0: return "0"
    s = ""
    i = 0
    while N != 0:
        if i % 2 == 0:
            s += str(N % 2)
            N = N // 2
        else:
            N = - N
            s += str(N % 2)
            N = N // 2
            N = - N
        i += 1

    return s[::-1]



if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long  int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */

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


  ll a[n+1];
  f(i,1,n) cin >> a[i];  

  sort(a+1,a+n+1);

  ll ans=0;
  f(i,1,n-k)
  ans+=a[i];

  cout << ans << endl;
   
}

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

int main()
{
  int n;
  cin >> n;
  vector<int64_t> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  int64_t ans = 0;
  for (int i = 1; i < n; i++) {
    int64_t t = a[i - 1] - a[i];
    if (t > 0) {
      ans += t;
      a[i] += t;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int h1,w1,h2,w2,k;
    cin >> h1 >> w1 >> h2 >> w2 >> k;
    cout<<(h2-h1)*60+w2-w1-k<<endl;   
}

Measured memory_bytes: 3612
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,m, xn,yn = f()
    x = f()
    y = f()

    xmax = max(x)
    ymin = min(y)

    for i in range(xmax+1, ymin+1):
        if xmax< ymin and xmax+1>xn and xmax+1<=yn:
            print('No War')
            return
    
    print('War')


solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mx = 1e5+5;
const int md = 1e9+7;

int dp[mx][2];
int n, vis[mx];
vector<int> g[mx];

int fun(int u, int c){
    int &ans = dp[u][c];
    if(ans != -1) return ans;

    vis[u] = 1; ans = 1;
    for(int v : g[u])
    if(!vis[v]){
        long long res = 0;
        res += fun(v, 0); ans %= md;
        if(c == 0)
            res += fun(v, 1), ans %= md;
        ans = (ans * res) % md;
    }vis[u] = 0; return ans;
}

int main(){

    cin.tie( nullptr );
    ios_base::sync_with_stdio(0);

    cin >> n;
    memset(dp, -1, sizeof dp);
    for(int u, v, i=1; i<n; i++){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }cout << (fun(1,0)+fun(1,1))%md << "\n";

    return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 5010;

ll dp[N][N];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    ll inf = 1e9;
    inf *= inf;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dp[i][j] = inf;
        }
    }
    sort(a.begin(), a.end(), [](pair<int, int> &p1, pair<int, int> &p2) { return p1.first + p1.second < p2.first + p2.second; });
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        dp[i][1] = min(ll(a[i - 1].second), dp[i - 1][1]);
        for (int j = 2; j <= i; ++j) {
            if (dp[i - 1][j - 1] > a[i - 1].first) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + a[i - 1].second);
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (dp[n][i] < inf) {
            ans = i;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 196352
#include<stdio.h>

int fibonacci(int);

int main()
{
  int n,ret;

  scanf("%d",&n);

  ret = fibonacci(n);
  printf("%d\n",ret);

  return 0;
}

int fibonacci(int n)
{
  int F[45],i;

  F[0] = 1;
  F[1] = 1;

  for(i = 2; i <= n; i++){
    F[i] = F[i - 2] + F[i - 1];
  }

  return F[n];
}



Measured memory_bytes: 2112
package main

import "fmt"

func main() {
	var n, x int
	tmp := 0
	fmt.Scan(&n, &x)

	var L = make([]int, n)
	for i := range L {
		fmt.Scan(&L[i])
	}

	count := 1
	for i := 0; i < n; i++ {
		tmp += L[i]
		if tmp <= x {
			count++
		} else {
			fmt.Println(count)
			return
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007;
int main()
{
    long long n,i,ans = 0,m;;
    cin>>n>>m;
    if(m - 2*n < 0)
    {
        cout<<(m / 2)<<endl;
    }
    else
    {
        ans = n;
        m = m - 2*n;
        ans += m/4;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;
using vi = vector<int>;

int V, E;
vi G[100010];
int indeg[100010];
bool used[100010];

void bfs(int u, vi &ans)
{
    queue<int> que;
    que.push(u);

    ans.push_back(u);
    used[u] = true;

    while ( !que.empty() ) {
        int u = que.front(); que.pop();
        for (const auto &e : G[u]) {
            --indeg[e];
            if (indeg[e]==0 && !used[e]) {
                used[e] = true;
                ans.push_back(e);
                que.push(e);
            }
        }
    }

    return;
}

void topologicalSort(vi &ans)
{
    memset(indeg, 0, sizeof(indeg));
    memset(used, false, sizeof(used));
    ans.reserve(V+1);

    rep(i, V) {
        for (const auto &to : G[i]) {
            ++indeg[to];
        }
    }

    rep(i, V) {
        if (indeg[i] == 0 && !used[i]) bfs(i, ans);
    }
    return;
}


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

    cin >> V>> E;

    rep(i, E) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }

    topologicalSort(ans);

    for (const auto &e: ans)
        outl(e);

    return (0);
}




Measured memory_bytes: 6260
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

const int INF = (1LL << 31) - 1;

template<class T> class SegT {

   int N;
   vector<T> node;

   public:
      SegT(vector<T> v) {
         int SIZE = v.size();
         N = 1;
         while (N < SIZE) N *= 2;
         node.resize(2 * N - 1);

         // lowest level
         for (int i = 0; i < SIZE; i++) 
            node[i + N - 1] = v[i];
         // others
         for (int i = N - 2; i >= 0; i--) 
            node[i] = node[2 * i + 1] > node[2 * i + 2] ? node[2 * i + 2] : node[2 * i + 1];
      }
      
      // x: 0-indexed
      void update(int x, T val) {
         // go to the lowest
         x += (N - 1);
         node[x] = val;
         // got to the parent
         while (x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2 * x + 1] > node[2 * x + 2] ? node[2 * x + 2] : node[2 * x + 1];
         }
      }
      
      // get min in [a, b)
      // k: current node index, 0-indexed
      
      T getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
         if (r < 0) r = N;
         // no crossing
         if (r <= a || b <= l) return INF;
         // covering
         if (a <= l && r <= b) return node[k];

         T vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
         T vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
         return vl > vr ? vr : vl;
      }
      
};

int main() {
   int n, Q;
   cin >> n >> Q;
   SegT<int> segt( vector<int>(n, INF) );
   int c, x, y;
   for (int q = 0; q < Q; q++) {
      cin >> c >> x >> y;
      if (c == 0) segt.update(x, y);
      else cout << segt.getmin(x, y + 1) << endl;
   }
   return 0;
}



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

int main()
{
    int n,k,q;
    cin >> n >> k >> q;
    int a[q],b[n];
    for(int i=0;i<n;i++)
        b[i]=k;
    for(int i=0;i<q;i++)
        cin >> a[i];
    int c[n]={};
    for(int i=0;i<q;i++)
        c[a[i]-1]++;
    for(int i=0;i<n;i++){
        b[i]-=(q-c[i]);
    }
    for(int i=0;i<n;i++){
        if(b[i]>0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)
#include <climits>

using namespace std;
#define ll long long

pair<ll, int> minimum(vector<ll>& A) {
  ll tmp = LLONG_MAX;
  int idx = -1;
  for(int i=0; i<A.size(); i++) {
    if(A[i] != 0 && A[i] < tmp) {
      tmp = A[i];
      idx = i;
    }
  }
  return make_pair(tmp, idx);
}

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  ll tmp = LLONG_MAX;
  pair<ll, int> next;
  while((next = minimum(A)).first != tmp) {
    for(int i=0; i<N; i++) {
      if(i != next.second)
	A[i] %= next.first;
    }
    tmp = next.first;
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 1024
def solve(c):
    alpha = "abcdefghijklmnopqrstuvwxyz"
    i = alpha.index(c)
    return alpha[i + 1]


def main():
    c = input()
    res = solve(c)
    print(res)


def test():
    assert solve("a") == "b"
    assert solve("y") == "z"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 2940
k,n=gets.split.map &:to_i
arr=gets.split.map &:to_i
diff_arr = []
n.times do |i|
  diff = (i >= (n-1)) ? (k - arr[i] + arr[0]).abs : (arr[i+1] - arr[i])
  diff_arr << diff
end
puts diff_arr.inject(:+) - diff_arr.max


Measured memory_bytes: 17028
#include <iostream>
#include <vector>
#include <string>
#include <array>

const int MAXN = 2e5;
const int MOD = 1e9 + 7;

std::array<int, MAXN> C;
std::array<int, MAXN+1> next;
std::array<int, MAXN+1> dp;

int main(int argc, char* argv[])
{
  using std::cin;
  using std::cout;
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> C[i];
    next[C[i]] = -1;
  }

  dp[N] = 1;
  for (int i = N-1; i >= 0; --i)
  {
    dp[i] = dp[i + 1];
    if (next[C[i]] > i+1)
    {
      dp[i] += dp[next[C[i]]];
      dp[i] %= MOD;
    }

    next[C[i]] = i;
  }

  cout << dp[0] << "\n";

  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL a, b;cin >> a >> b;
    LL d = b-a;
    cout << d*(d-1)/2-a << endl;
    return 0;
}


Measured memory_bytes: 256
class Dice():
    def __init__(self,numlist):
        self.lst=numlist
    
    def roll(self,direction):
        if direction=="S" : self.lst=[self.lst[4],self.lst[0],self.lst[2],self.lst[3],self.lst[5],self.lst[1]]
        elif direction=="N" : self.lst=[self.lst[1],self.lst[5],self.lst[2],self.lst[3],self.lst[0],self.lst[4]]
        elif direction=="W" : self.lst=[self.lst[2],self.lst[1],self.lst[5],self.lst[0],self.lst[4],self.lst[3]]
        elif direction=="E" : self.lst=[self.lst[3],self.lst[1],self.lst[0],self.lst[5],self.lst[4],self.lst[2]]        

lst=list(map(int,input().split()))
directions=input()

d1=Dice(lst)
for direction in directions:
    d1.roll(direction)

print(d1.lst[0])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+7;
set<int> se;
int n;
LL k;
int a[maxn];
int mp[maxn];
int pos[maxn];
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int p=0;
    int pre=1;
    while(1){
        pre=a[pre];
        if(mp[pre]==0){
            pos[++p]=pre;
            mp[pre]++;
        }
        else{
            pos[++p]=pre;
            mp[pre]++;
            break;
        }
    }
    int l;
    for(int i=1;i<=n;i++){
        if(mp[i]==2){
            l=i;break;
        }
    }
   /* for(int i=1;i<=p;i++){
        printf("%d ",pos[i]);
    }
    printf("\n");*/
    int T=0;
    int q;
    for(int i=1;i<=p;i++){
        if(pos[i]==l){
            q=i-1;
            T=p-i;break;
        }
    }
  //  printf("T:%d\n",T);
    if(k<=q){
        printf("%d\n",pos[k]);
    }
    else{
        k-=q;
        k%=T;
       // printf("%lld\n",k);
        if(k==0){
            printf("%d\n",pos[p-1]);
        }
        else{
            printf("%d\n",pos[q+k]);
        }
    }
    return 0;
}


Measured memory_bytes: 6056
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;

#define rep(i, s, c) for (int i = s; i < c; i++)

#define INF 100000005

int main()
{
    int H, N;
    cin >> H >> N;
    // A、Bというリストにそれぞれ格納
    int A[N], B[N];
    rep(i, 0, N)
    {
        cin >> A[i] >> B[i];
    }

    int dp[H + 1];
    dp[0] = 0;

    rep(h, 1, H + 1)
    {
        dp[h] = INF;
    }

    rep(h, 1, H + 1)
    {
        rep(n, 0, N)
        {
            dp[h] = min(dp[h], B[n] + dp[max(h - A[n], 0)]);
        }
    }
    cout << dp[H] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int K = cin.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextInt();
            B[i] = cin.nextInt();
        }

        long ans = 0;
        for (int i = -1; i < 30; i++)
        {
            int P = K;
            if(i != -1)
            {
                if ((K >> i) % 2 == 0) continue;
                P = K & ~((1 << (i + 1)) - 1);
                P += (1 << i) - 1;
            }
            long tmp = 0;
            for (int j = 0; j < N; j++)
            {
                if ((A[j] & P) == A[j]) tmp += B[j];
            }
            ans = Math.Max(ans, tmp);
        }
        Console.WriteLine(ans);
    }
    
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

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

    public long nextLong()
    {
        return long.Parse(next());
    }

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

    public double nextDouble()
    {
        return double.Parse(next());
    }


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

Measured memory_bytes: 17860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int res = N;
		for (int i = 0; i <= N; i++) {
			int cc = 0;
			int t = i;
			while(t > 0) {
				cc += t%6;
				t /= 6;	
			}
			t = N - i;
			while(t > 0) {
				cc += t%9;
				t /= 9;
			}
			if (res > cc) {
				res = cc;
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 22612
import java.util.Arrays
import java.util.ArrayList

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (n, T) = reader.readLine()!!.split(" ").map{it.toInt()}
    val t = reader.readLine()!!.split(" ").map{it.toInt()}

    var res = 0
    for (i in 0..n-1) {
        if (i < n-1 && t[i] + T >= t[i+1]) {
            res += t[i+1] - t[i]
        } else {
            res += T
        }
    }

    println(res)
}


Measured memory_bytes: 80692
import sys
from itertools import permutations


def main():
    input = sys.stdin.readline
    n = int(input())
    cache = {}
    ans = 0

    for i in range(1, n+1):
        if (int(str(i)[0]), int(str(i)[-1])) in cache.keys():
            cache[(int(str(i)[0]), int(str(i)[-1]))] += 1
        else:
            cache[(int(str(i)[0]), int(str(i)[-1]))] = 1

    for k, v in cache.items():
        if k[0] == k[1] and v == 1:
            ans += v**2
        
        elif (k[1], k[0]) in cache.keys():
            ans += cache[(k[1], k[0])] * v

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 42476
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, S):
    S = [c for c in S]

    idx = []
    p = (None, -1)
    for i, c in enumerate(S):
        if p[0] != c:
            idx.append([p[0], i-p[1]])
            p = (c, i)
    idx.append([p[0],len(S)-p[1]])
    idx.pop(0)
    
    
    ans = [idx[0]]
    for i in range(1, len(idx)):
        if i % 2 == 0:
            if ans[-1][0] == idx[i][0]:
                ans[-1][1] += idx[i][1]
            else:
                ans.append(idx[i])
        else:
            if K > 0:
                ans[-1][1] += idx[i][1]
                K -= 1
            else:
                ans.append(idx[i])
    a = 0
    for _, v in ans:
        a += v - 1
    return a


def main():
    N, K = read_int_n()
    S = read_str()
    print(slv(N, K, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17360
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
import std.math;

void main()
{
    immutable long N = 1000;
    foreach(n;stdin.byLine().map!(to!long))
        iota(max(0,n-2*N),min(2*N,n)+1).map!(i=>(N-abs(N-i)+1)*(N-abs(N-(n-i))+1)).reduce!"a+b"().writeln();
}

Measured memory_bytes: 1056
import Control.Monad

main :: IO ()
main = do
  wl <- replicateM 10 readLn
  kl <- replicateM 10 readLn
  putStrLn $ solve wl kl

solve :: [Int] -> [Int] -> String
solve l1 l2 = (show $ top3 l1) ++ " " ++ (show $ top3 l2)
  where
    top3 :: [Int] -> Int
    top3 = sum . take 3 . sort
      where
        sort :: [Int] -> [Int]
        sort [] = []
        sort (x:xs) = (sort [i | i <- xs, i >= x] ++ [x]) ++ (sort [j | j <- xs, j < x])

Measured memory_bytes: 3716
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    string ans="No";
    cin >> a >> b >> c;
    
    if(a==b){
        if(b!=c){
            ans="Yes";
        }
    }
    if(b==c){
        if(a!=c){
            ans="Yes";
        }
    }
    if(a==c){
        if(a!=b){
            ans="Yes";
        }
    }
    
    
    
    
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(){
	string s,t;cin>>s;
	for(int i=0;i<s.size();i+=2){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 576
# -*- coding: utf-8 -*-
"""
C - 一次元リバーシ / 1D Reversi
https://atcoder.jp/contests/abc047/tasks/arc063_a

"""
import sys


def solve(S):
    prev = S[0]
    ans = 0
    for ch in S:
        if ch != prev:
            ans += 1
        prev = ch
    return ans


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3188
import java.util.*;

 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sum = 0;
    int n = N;
    while(N > 0){
        sum = sum + N%10; 
        N /= 10; 
    }
    if(n%sum == 0){
        System.out.println("Yes"); 
    }else{
        System.out.println("No"); 
    }
    }    
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
 
int main () {
    int A,B,C;
    cin >> A >> B >> C;

    if(A+B >= C)cout << "Yes" << endl;
    else cout << "No" << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif // LOCAL


int main(){
    int x, y;
    cin >> x >> y;
    int res = 0;
    res += (x <= 3) ? ((3 - x + 1) * 100000) : 0;
    res += (y <= 3) ? ((3 - y + 1) * 100000) : 0;
    if(x == 1 &&  y ==1)
        res += 400000;
    cout << res << endl;
}

/*
    Long time no see!
    Atcoder...
*/


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	int N;
	cin >> N;
	int a[110];
	for (int i = 0; i < N;++i) cin >> a[i];
	
	int Alice = 0, Bob = 0;
	sort(a, a  + N, greater<int>());
	for (int i = 0; i < N; i += 2) Alice += a[i];
	for (int i = 1; i < N; i += 2) Bob += a[i];
	cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
x, y = [int(x) for x in input().split()]

if x == 0:
    ans = abs(y) + (y < 0)
else:
    ans = 1 if (x < 0 and abs(x) < abs(y)) or (x > 0 and abs(x) > abs(y)) else 0
    ans += abs(abs(y) - abs(x))
    ans += 1 if (-1 if (x < 0 and abs(x) < abs(y)) or (x > 0 and abs(x) > abs(y)) else 1) * x * y < 0 else 0

print(ans)


Measured memory_bytes: 38256
#include <stdio.h>

int main(){
  int n, m;  scanf("%d%d", &n, &m);
  int food[40] = {0};
  for(int i=0; i<n; i++){
    int tmp;  scanf("%d", &tmp);
    for(int j=0; j<tmp; j++){
      int foodid;  scanf("%d", &foodid);
      food[foodid]++;
    }
  }
  int ans = 0;
  for(int i=1; i<=m; i++)
    if(food[i] == n)
      ans++;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInt()
	b := scanInt()

	// facInit(2*100000)

	com := make([]int, b+1)
	com[0] = 1
	for i := 0; i < b; i++ {
		com[i+1] = mmul(com[i],mdiv(msub(n,i), madd(i,1)))
	}

	ans := msub(mpow(2,n),1)
	ans = msub(ans,com[a])
	ans = msub(ans, com[b])
	fmt.Fprintln(wr,ans)
}


const mod = 1000000007

func mpow(a,n int) int {
	res := 1
	for n>0 {
		if n&1 == 1 { res = res*a%mod }
		a = a*a%mod; n >>= 1
	}
	return res
}

func madd(b,c int) int { a := (b+c)%mod; if a<0 { a += mod }; return a }
func msub(b,c int) int { a := (b-c)%mod; if a<0 { a += mod }; return a }
func mmul(b,c int) int { a := (b*c)%mod; if a<0 { a += mod }; return a }
func mdiv(b,c int) int {
	a, p, x, y := c, mod, 1, 0
	for p != 0 {
		t := a/p
		a -= t*p; a,p = p,a
		x -= t*y; x,y = y,x
	}
	res := b*x%mod
	if res<0 { res+= mod }
	return res
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Inarr(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;

int main(){
    string s;
    cin>>s;
    //ans==7
    int bit_num=pow(2,3);
    rep(i,bit_num){
        int tmp=s[0]-'0';
        rep(j,3){
            if(i&(1<<j)){
                tmp+=s[j+1]-'0';
            }
            else {
                tmp-=s[j+1]-'0';
            }
        }
        //cout<<tmp<<endl;
        if(tmp==7){
            cout<<s[0];
            rep(j,3){
                if(i&(1<<j)){
                    cout<<'+'<<s[j+1];
                }
                else {
                    cout<<'-'<<s[j+1];
                }
            }
            cout<<"=7"<<endl;
            break;
        }
    }

}



Measured memory_bytes: 256
const M:u64=1000000007;
fn pow(a:u64,b:u64)->u64{return if b!=0{if b%2==1{pow(a,b-1)*a%M}else{pow(a*a%M,b/2)}}else{1}}
fn main(){
    proconio::input!{
        n:usize,
        abs:[(i64,i64);n]
    }
    let mut o=M-1;
    let mut mp=Vec::new();
    for ab in abs{
        let (mut a,mut b)=ab;
        if a==0&&b==0{o+=1}
        else
        {
            let g=num::integer::gcd(a,b);
            a/=g;
            b/=g;
            if a<0||a==0&&b>0{a=-a;b=-b}
            let mut f=0;
            if b<0{
                let t=a;
                a=-b;
                b=t;
                f=1;
            }
            mp.push((a,b,f))
        }
    }
    mp.sort();
    let mut i=0usize;
    let mut ans=1;
    while i<mp.len(){
        let j=i;
        let mut x=0;
        let mut y=0;
        while i<mp.len()&&mp[j].0==mp[i].0&&mp[j].1==mp[i].1{
            if mp[i].2==0{x+=1}else{y+=1}
            i+=1
        }
        ans=ans*(pow(2,x)+pow(2,y)-1)%M;
    }
    println!("{}",(ans+o)%M)
}


Measured memory_bytes: 17516
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

use std::cmp::min;

fn coins(c: &mut Vec<usize>, vals: &Vec<usize>, v: usize) -> usize {
    if c[v] != std::usize::MAX { return c[v]; }

    let mut m = std::usize::MAX;
    for &val in vals.iter() {
        if val > v {
            continue;
        } else if val == v {
            return 1;
        } else {
            m = min(m, coins(c, vals, v-val)+1);
        }
    }

    c[v] = m;
    return m;
}

fn main() {
    scan!(n, _m; usize);
    scan!(values; Vec<usize>);

    let mut coins_vec = vec![std::usize::MAX; n+1];

    println!("{}", coins(&mut coins_vec, &values, n));
}



Measured memory_bytes: 4584
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)(N);i++)
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define p(s) cout<<(s)<<endl
#define F first
#define S second
typedef long long ll;
using namespace std;

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

int H, W, C, P[10][10];
int tans = 0, ans = 0;

bool flag[10][10], visited[10][10];

void drow(int y, int x, int col){
	int precol = P[y][x];
	P[y][x] = col;

	visited[y][x] = true;

	REP(k,0,4){
		int ny = y + dy[k], nx = x + dx[k];
		if(!ck(ny,0,H) || !ck(nx,0,W)) continue;
		if(P[ny][nx] == precol && !visited[ny][nx]){
			drow(ny, nx, col);
		}
	}
	return;
}

void cnt(int y, int x, int col){
	if(P[y][x] != col) return;
	tans++;
	visited[y][x] = true;
	REP(k,0,4){
		int ny = y + dy[k], nx = x + dx[k];
		if(!ck(ny,0,H) || !ck(nx,0,W)) continue;
		if(P[ny][nx] == col && !visited[ny][nx]){
			//p('e');
			cnt(ny, nx, col);
		}
	}
	return;
}

void dfs(int step, int col){

	if(step == 5){
		tans = 0;
		REP(i,0,H)REP(j,0,W) visited[i][j] = false;
		cnt(0,0,C);
		ans = max(ans, tans);
		return;
	}

	REP(i,1,7){
		//?????¶???????????£????????????
		int cp[10][10];
		REP(k,0,H)REP(l,0,W){
			cp[k][l] = P[k][l];
		}
		REP(k,0,H) REP(l,0,W) visited[k][l] = false;
		drow(0,0,i);
		dfs(step+1, i);
		//????????????
		REP(k,0,H)REP(l,0,W){
			P[k][l] = cp[k][l];
		}
	}
	return;
}

int main() {
	while(1){
		cin>>H>>W>>C;
		if(H==0) break;
		REP(i,0,H){
			REP(j,0,W){
				cin>>P[i][j];
			}
		}
		ans = 0;
		dfs(0,C);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

int main() {
    string s, t, u;
    long long a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s){
        a = a - 1;
    }else if(u == t){
        b = b - 1;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256