akhauriyash/Code-Regression huggingface dataset:
import Data.Char
import Data.List
main = do
 abcd<-getLine
 let a = digitToInt (abcd !! 0)
 let b = digitToInt (abcd !! 1)
 let c = digitToInt (abcd !! 2)
 let d = digitToInt (abcd !! 3)
 putStrLn $ snd(head (filter (\s->(fst s)==7) [(g z (g y (g x a b) c) d, show a ++ f x ++show b ++ f y ++show c ++ f z ++ show d)|x<-[0,1],y<-[0,1],z<-[0,1]])) ++ "=7"
 
f::Int->String
f 0 = "+"
f 1 = "-"
f _ =""
g::Int->Int->Int->Int
g 0 = (+)
g 1 = (-)

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

int main() {
  int x , y;
  cin >> x >> y;
  
  int a[] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  
  cout << (a[x] == a[y] ? "Yes" : "No") << endl ;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> d;
  for (int i = 1; i <= min(a, b); i++) {
    if (a % i == 0 && b % i == 0) d.push_back(i);
  }
  reverse(all(d));
  cout << d[k - 1] << endl;

  return 0;
}


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

#define int long long
#define inf 1e11
int n, m, a[1<<18], t[1<<20] ;

void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(v*2, tl, tm);
        build(v*2+1, tm+1, tr);
        t[v] = t[v*2] + t[v*2+1];
    }
}

int sum(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return sum(v*2, tl, tm, l, min(r, tm))
           + sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}

void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = t[v*2] + t[v*2+1];
    }
}

int  q;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n >> q;

for(int i =0; i<n; i++){
    a[i]=0;
}
build(1,0,n-1);
while(q--){

    int x,l,r;
    cin >> x;
    if(x){
        cin >> l >> r;
        l--;r--;
        cout << sum(1,0,n-1,l,r) << endl;
    }
    else {
        cin >> l >> r;
        l--;
        a[l]+=r;
        update(1,0,n-1,l,a[l]);
    }


}





return 0;}



Measured memory_bytes: 6032
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstring>
#include<vector>
#define pii pair<int, int>
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define debug puts("???");
#define br puts("")
#define ALL(x) x.begin(),x.end()
#define sc(x) scanf("%d", &x)
#define sz(x) int((x).size())
using namespace std;
typedef long long LL;
const LL INF64 = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;

const int maxn = 1e5+10;
char s[maxn];
int n;

int check(){
    if(s[n]=='1' || s[1]=='0' || s[n-1]=='0') return 0;
    for(int i = 2; i < n; i++){
        if(s[i]!=s[n-i]) return 0;
    }
    return 1;
}
vector<pii> ans;

int main(){
    scanf("%s",s+1); n = strlen(s+1);
    if(check()==0) return puts("-1"),0;
    for(int i = n/2+1; i < n; i++) ans.pb(mk(n,i));
    int rt = n;
    for(int i = n/2; i >= 1; i--){
        if(s[i]=='0') ans.pb(mk(rt,i));
        else{
            ans.pb(mk(rt,i));
            rt = i;
        }
    }
    for(pii x: ans){
        printf("%d %d\n", x.fi, x.se);
    }
    return 0;
}


Measured memory_bytes: 2548
#include <cassert>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); puts("");}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v;}
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) {cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}

#define all(x)  (x).begin(),(x).end()
#define tr(c, it)   for(auto it=c.begin(); it!=c.end(); it++)
#define clr(a, b)   memset(a, b, sizeof(a))
#define forn(i, n)   for(int i=0; i<n; i++)

const double eps = 1e-5;
const int INF = 0x3f3f3f3f;


const int N = 100010;

int head[N], e;
struct E{
    int v, next;
}edge[N << 1];

void addedge(int u, int v){
    edge[e].v = v, edge[e].next = head[u];
    head[u] = e++;
}

int n;
int dp[N];

int dfs(int u, int f)
{
    int val = 0;
    for(int i=head[u]; ~i; i=edge[i].next)
    {
        int v = edge[i].v;
        if(v == f) continue;

        val ^= (dfs(v, u) + 1);
    }
    return dp[u] = val;

}


int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif

    //scanf("%d",&T);


    while(~scanf("%d",&n))
    {
        clr(head, -1), e = 0;
        clr(dp, 0);
        for(int i=1; i<n; ++i)
        {
            int u, v;
            scanf("%d%d",&u,&v);
            addedge(u, v);
            addedge(v, u);
        }

        dfs(1, -1);

        if(dp[1]) puts("Alice");
        else puts("Bob");

    }
    return 0;
}

Measured memory_bytes: 7296
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cassert>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
//typedef pair<int, int> pii;
using pll = pair<ll, ll>;
using pii = pair<short, short>;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<(a);i++)
#define rep1(i,a) for(int i=1;i<=(a);i++)
#pragma warning(disable:4996)
//#define INF 1000000000000000.0
int main() {
	int n;
	while (cin >> n, n) {
		vector<int> num;
		string buf;
		rep(i, n) {
			cin >> buf;
			num.push_back(buf.length());
		}
		rep(i, n) {
			vi sp(5);
			int pos = 0;
			bool f = 1;
			for (int j = i;; j++) {
				f = 1;
				sp[pos] += num[j];
				if (sp[pos] > (pos & 5 ? 7 : 5)) {
					f = 0;
					break;
				}
				if (sp[pos] == (pos & 5 ? 7 : 5)) {
					pos++;
					if (pos == 5)break;
				}
			}
			if (f) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3140
open List 
(* 1行読み込みする関数 *)
(* i_inp : 1行読み込んで整数に変換, f_inp, s_inpもある *)
let inp : unit -> string = fun () -> 
	input_line stdin
let s_inp = inp
let i_inp : unit -> int = fun () ->
	int_of_string (inp ())
let f_inp : unit -> float = fun () ->
	float_of_string (inp ())
 
(* 1行読み込んで、空白で分割する関数 *)
let inp_list : unit -> string list = fun () ->
	Str.split (Str.regexp " ") (inp ())
let s_inp_list : unit -> string list = inp_list
let i_inp_list : unit -> int list = fun () ->
	map (fun x -> int_of_string x) (inp_list ())
let f_inp_list : unit -> float list = fun () ->
  map (fun x -> float_of_string x) (inp_list ())

(* n行読み込む関数 *)
let rec inp_loop : (unit -> 'a) -> int -> 'a list = fun inp_fun n ->
  if n = 0 then []
  else
    let x = inp_fun () in
    x :: inp_loop inp_fun (n - 1)

      
(* 関数本体 *)
let () =
  let [n; m] = i_inp_list () in
  let brokens = Array.make (n + 1) false in
  let rec inp_loop m =
    if m = 0 then ()
    else
      let x = i_inp () in
      (brokens.(x) <- true;
       inp_loop (m - 1)) in
  let () = inp_loop m in
  let memo = Array.make (n + 1) None in
  let rec loop a =
    match memo.(a) with
      None ->
       if brokens.(a) then 0
       else
         if a + 2 <= n then
           let x = (loop (a + 1) + loop (a + 2)) mod 1000000007 in
           memo.(a) <- Some x;
           x
         else if a + 1 <= n then
           let x = (loop (a + 1)) mod 1000000007 in
           memo.(a) <- Some x;
          x
         else
           (memo.(a) <- Some 1;
            1)
    | Some x -> x
  in
  print_int (loop 0);
  print_newline ()


Measured memory_bytes: 7936
import copy


def dfs(i, path, reached, n):
    if reached[i]:
        return n
    reached[i] = True

    if all(reached):
        n += 1
        return n

    for p in path[i]:
        org_reached = copy.deepcopy(reached)
        n = dfs(p, path, org_reached, n)

    return n


def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]

    path = [[] for _ in range(N)]

    for a, b in AB:
        a -= 1
        b -= 1
        path[a].append(b)
        path[b].append(a)

    reached = [False for _ in range(N)]
    n = 0

    n = dfs(0, path, reached, n)
    print(n)


main()


Measured memory_bytes: 9228
#include <iostream>

using namespace std;

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

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

    if (a > b) {
        cout << a + (a-1) << endl;
    }

    else if (a == b) {
        cout << a + b << endl;
    }
    else {
        cout << b + (b-1) << endl;
    }
    
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M;
  cin>>N>>M;
  vector<bool>b(N,true);
  for(int i=0;i<M;i++){
    int a;
    cin>>a;
    b[a]=false;
  }
  vector<ll>dp(N+1,0);
  dp[0]=1;
  for(int i=1;i<=N;i++){
    if(!b[i])continue;
    for(int j=1;j<=2;j++){
      if(i-j>=0&&b[i-j])dp[i]+=dp[i-j]%MOD;
      dp[i]%=MOD;
    }
  }
  cout<<dp[N]<<endl;
  return 0;
}


Measured memory_bytes: 1024
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0315?year=2015

#include <bits/stdc++.h>

using namespace std;

int main() {
    int p, m, c;
    cin >> p >> m >> c;

    cout << p + m + c << endl;
    return 0;
}

/*
 *
 */


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<ll> cumsum(n+1, 0);
    for(int i = 1; i <= n; i++) {
        cumsum[i] = cumsum[i-1] + a[i-1];
    }
    
    ll ans = 0;
    map<ll, ll> freq;
    for(int i = 0; i <= n; i++) {
        if (freq.count(cumsum[i]) == 0)
            freq[cumsum[i]] = 1;
        else {
            ans += freq[cumsum[i]];
            freq[cumsum[i]]++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
a,b=gets.chomp.split()
c,d=gets.chomp.split().map(&:to_i)
e=gets.to_s.chomp
if a.gsub(/[[:space:]]/, '')==e
  puts [c-1,d].join(" ")
else b == e
  puts [c,d-1].join(" ")
end  

Measured memory_bytes: 1916
N=int(input())
S=list(map(int,input().split()))

goukei=0

bar=S[0]

for i in range(N-1):
    if S[i+1]<bar:
        goukei+=bar-S[i+1]
    elif S[i+1]>bar:
        bar=S[i+1]

print(goukei)

Measured memory_bytes: 105232
#include <iostream>
#include <vector>

int main() {
    int N, M, C;
    std::cin >> N >> M >> C;
    std::vector<int> vec2(M, 0);
    for (int i = 0; i < M; i++) {
        std::cin >> vec2[i];
    }
    std::vector<std::vector<int>> vec(N, std::vector<int>(M, 0));
    for (int i = 0; i < N; i++) {
        for (int p = 0; p < M; p++) {
            std::cin >> vec[i][p];
        }
    }
    int counter = 0;
    int accumulator;
    for(int i = 0; i < N; i++) {
        accumulator = 0;
        for (int p = 0; p < M; p++) {
            accumulator += (vec[i][p] * vec2[p]);
        }
        accumulator += C;
        if (accumulator > 0) {
            counter++;
        }
        accumulator = 0;
    }
    std::cout << counter << std::endl;

}


Measured memory_bytes: 256
n= int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

from collections import Counter
C = Counter(D)
for t in T:
    if t not in C:
        print('NO')
        exit()
    else:
        if C[t] == 0:
            print('NO')
            exit()
        else:
            C[t] -= 1
else:
    print('YES')


Measured memory_bytes: 137680
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (mapAccumL, sort)

main :: IO ()
main = do
  (n : d : a : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    -- walk :: Int -> Int -> [(Int, Int)] -> [(Int, Int)] -> [(Int, Int)]
    {-
    walk _ _ [] _ = []
    walk l c ((x, h) : xhs') yks = (x, k') : walk (succ l') (c' + k') xhs' yks'
      where
        (s, t) = splitAt l yks
        (u, v) = span ((< x - 2 * d) . fst) s
        (l', c') = (,) <$> flip subtract l . length <*> flip subtract c . sum . map snd $ u
        k' = (max 0 (h - c' * a) + a - 1) `div` a
        yks' = v ++ t
    -}
    
    {-
    walk _ _ [] _ = []
    walk l c ((x, h) : xhs') yks = (x, k') : walk (succ (l - l')) ((c - c') + k') xhs' yks'
      where
        v = take l yks
        u = takeWhile ((< x - 2 * d) . fst) v
        (l', c') = (,) <$> length <*> sum . map snd $ u
        k' = (max 0 (h - (c - c') * a) + a - 1) `div` a
        yks' = drop l' yks
    -}
    
    walk :: [(Int, Int)] -> [(Int, Int)] -> [(Int, Int)]
    walk = fmap (snd .) $ flip $ mapAccumL step . (,) (0, 0)
      where
        step ((l, c), yks) (x, h) = (((succ (l - l'), c - c' + k'), yks'), (x, k'))
          where
            v = take l yks
            u = takeWhile ((< x - 2 * d) . fst) v
            (l', c') = (,) <$> length <*> sum . map snd $ u
            k' = (max 0 (h - (c - c') * a) + a - 1) `div` a
            yks' = drop l' yks
    
  xhs <- sequence . replicate n $ unsafeListToTuple . map unsafeTextToInt . T.words <$> T.getLine :: IO [(Int, Int)]
  -- print . sum . map snd . fix . walk 0 0 . sort $ xhs
  print . sum . map snd . fix . walk . sort $ xhs

fix :: (a -> a) -> a
fix f = x
  where
    x = f x

unsafeListToTuple :: [Int] -> (Int, Int)
unsafeListToTuple (x : y : _) = (x, y)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 119164
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string  s[200001];
int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> s[i];
	sort(s, s + n);
	int cnt = 1;
	for (int i = 1;i < n;i++) {
		if (s[i - 1] != s[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 9896
import sys
from io import StringIO
import unittest
from math import factorial

div = 10 ** 9 + 7

def cnt_combination(n, r):
    res = 1
    fac = 1

    for i in range(r):
        res *= n - i
        res %= div
        fac *= i + 1
        fac %= div

    return res * pow(fac, div - 2, div) % div


def resolve():
    n, a, b = map(int, input().split())
    ans = pow(2, n, div) - 1
    print((ans - cnt_combination(n, a) - cnt_combination(n, b)) % div)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 1 3"""
        output = """7"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1000000000 141421 173205"""
        output = """34076506"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 5652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), M = getint(), Q = getint();
	int T[502][502] = {};
	rep(i, M) {
		int l = getint(), r = getint();
		T[l][r]++;
	}
	for (int i = N; i >= 1; i--) {
		rep1(j, N) {
			T[i][j] = T[i][j - 1] + T[i + 1][j] - T[i + 1][j - 1] + T[i][j];
		}
	}
	rep(i, Q) {
		int p = getint(), q = getint();
		putint(T[p][q]);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;

    C*=2;

    int ans=1e18;
    for(int c=0;c<=100000;c++){
        int a=max(0LL,X-c);
        int b=max(0LL,Y-c);
        ans=min(ans,A*a+B*b+C*c);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, k, r1, r2, r3, b;
LL res;

int main() {
scanf("%d %d", &n, &k);
if (k == 0) {
	printf("%lld\n", n * 1LL * n);
	return 0;
}
res = 0;
for (b=k+1;b<=n;b++) {
	r1 = (n + 1) / b;
	r2 = (n + 1) % b;
	r3 = b - k;
	//printf("%d %d %d\n", r1, r2, r3);
	res += r1 * 1LL * r3;
	res += max(0, r2 - (b - r3));
}
printf("%lld\n", res);
return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ex = long long;
#define ar(i,n) for(ex i=0;i<(n);++i)
#define ebmr >>
#define ebar <<
ex arsalmal = 1;

int main(){
  ex albio ,ars = 0 ,almal = 0;
  cin ebmr albio;
  ar(ai,albio){
    ex eb, mr;
    cin ebmr eb ebmr mr;
    if(ai==0){
      ars = eb; almal = mr;
    }
    else{
      ex exalbio = max((ars - arsalmal)/ eb + arsalmal,( almal - arsalmal) / mr + arsalmal);
      ars = eb * exalbio;almal = mr * exalbio;
    }
  }
  cout ebar ars + almal ebar endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 pb push_back
using namespace std;

const int maxn = 100005;
int f[maxn], g[maxn], c[maxn], in[maxn], q[maxn], vis[maxn];
int n, x, y, flag = 1, l, r, rt, base, ans = 0;
vector<int> e[maxn];
char col[maxn];

void dfs(int u, int fa) {
	if (fa && in[u] == 1) {
		f[u] = 0;
		return;
	}
	int mx1 = -1e9, mx2 = -1e9,
	 	now = ((in[u]&1) ^ c[u] ? 1 : -1) + 1;
	for (auto v : e[u]) {
		if (vis[v] || v == fa) continue;
		dfs(v, u);
		if (f[v] >= mx1) mx2 = mx1, mx1 = f[v];
		else if (f[v] > mx2) mx2 = f[v];
	}
	ans = max(ans, mx1);
	ans = max(ans, mx1 + now + mx2);
	f[u] = max(0, mx1 + now);
	//printf("%d %d  %d  %d   %d\n", u, f[u], mx1, mx2, ans);
}

int main() {
	scanf("%d", &n);
	rep (i, 2, n) {
		scanf("%d%d", &x, &y);
		e[x].pb(y); e[y].pb(x);
		in[x]++; in[y]++;
	}
	scanf("%s", col + 1);
	rep (i, 1, n) {
		c[i] = (col[i] == 'W');
		if (c[i]) flag = 0;
	}
	if (flag) return puts("0"), 0;
	rep (i, 1, n)
		if (!c[i] && in[i] == 1) q[r++] = i;
	while (l < r) {
		x = q[l++]; vis[x] = 1;
		for (auto y : e[x]) {
			in[y]--;
			if (vis[y]) continue;
			if (c[y]) continue;
			if (in[y] == 1) q[r++] = y;
		}
	}
	rep (i, 1, n) if (!vis[i]) rt = i;
	rep (i, 1, n) if (!vis[i]) {
		base += in[i];
		if ((in[i]&1) ^ c[i]) base++;
	}
	dfs(rt, 0);
	printf("%d\n", base - ans);
	return 0;
}

Measured memory_bytes: 15232
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    string S;
    cin >> S;

    int N = S.size() - 1;

    ll ans = 0;

    rep(bit, (1 << N))
    {
        vi pos;
        rep(i, N)
        {
            // 列挙に i が含まれるか
            if (bit & (1 << i)) pos.push_back(i);
        }

        pos.push_back(N);

        ll tmp = 0;
        int prev = -1;
        for (auto p : pos)
        {
            tmp += stoll(S.substr(prev + 1, p - prev));
            prev = p;
        }
        
        ans += tmp;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
N = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
for j in range(60):
    count = 0
    for i in range(len(a)):
        a[i], pre = divmod(a[i], 2)
        count += pre
    ans += count*(N-count)*2**j
    ans %= MOD
print(ans)

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  while(k > 0) {
    if(a%2 == 1) a--;
    a /= 2;
    b += a;
    k--;
    if(k==0) break;

    if(b%2 == 1) b--;
    b /= 2;
    a += b;

    k--;
  }

  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int minn = inf, maxx = 0;
	FOR(5){
		int x; cin >> x;
		minn = min(minn,x);
		maxx = max(maxx,x);
	}
	int k; cin >> k;
	cout << (maxx - minn > k ? ":(" : "Yay!");
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i+=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF LONG_MAX
#define mod 1000000007
#define print1(a) cout<<a<<"\n";
#define print2(a,b) cout<<a<<" "<<b<<"\n";
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define mt make_tuple
#define eb emplace_back

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> State;

void solve(){
    int n;cin>>n;
    string arr[n];
    rep(i,n) cin>>arr[i];
    int c1=0,c2=0,c3=0,c4=0;
    rep(i,n){
        if(arr[i]=="AC") c1++;
        if(arr[i]=="WA") c2++;
        if(arr[i]=="TLE") c3++;
        if(arr[i]=="RE") c4++;
    }
    cout<<"AC x "<<c1<<"\n";
    cout<<"WA x "<<c2<<"\n";
    cout<<"TLE x "<<c3<<"\n";
    cout<<"RE x "<<c4<<"\n";
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
    return 0;
}

Measured memory_bytes: 6752
package main

// Solution for https://atcoder.jp/contests/abc069/tasks/abc069_a

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n, m int
	con.Scan(&n, &m)
	con.Println((n - 1) * (m - 1))
	return nil
}


Measured memory_bytes: 640
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            int[] V = new int[n];
            for(int i = 0; i < n; i++)
            {
                V[i] = int.Parse(In[i]);
            }
            Array.Sort(V);
            double ans = V[0];
            if (V.Length >= 2)
            {
                for(int i = 1; i < n; i++)
                {
                    ans = (ans + V[i]) / 2;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BSs {
  public : static void solve(std::istream & cin, std::ostream &cout){
      string S;
      cin>>S;
      int N = S.size();
      rep(i, N){
        S.pop_back();
        if (S.size()%2 == 0){
          string temp{};
          rep(j, S.size()/2){
            temp += S[j];
          }
          temp = temp+temp;
          if (temp == S){
            cout<<S.size()<<endl;
            return;
          }
        }
      }
  }
};


signed main() {
  BSs solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(){
  
  int n;
  cin >> n;
  
  long long a[n];
  long long b[n];
  vector<pair<long long,long long>> work(n);
  
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    work.at(i)=make_pair(b[i],a[i]);
  }
  
  sort(work.begin(),work.end());
  
  long long counta=0;
  
  for(int i=0;i<n;i++){
    counta += work[i].second;
    if(counta>work[i].first){
      cout << "No" <<endl;
      return 0;
    }
  }
  
  cout << "Yes" <<endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,day;
    d=0;
    day=0;
    cin>>a>>b>>c;
    while(1){
       if(d>=c){
           break;
       } 
       d=a+d;
       day=day+1;
       if(day%7==0){
           d=d+b;
       }
    }
    cout<<day<<endl;
    
}



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

int main() {
  int x;
  cin >> x;

  rep(a, 1000) {
    ll a5;
    a5 = 1;
    rep(i, 5) a5 *= a;
    for (int b = -1000; b < 1000; b++) {
      ll b5;
      b5 = 1;
      rep(i, 5) b5 *= b;
      if (a5 - b5 == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3656
#include <stdio.h>

int main () {
	char str[10];
	scanf ("%s", str);

	int ans = 0;
	for (int i=0; i<4; i++) {
		if (str[i] == '+')
			ans ++;
		else
			ans --;
	}

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


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

int main() {
  int H, W;
  cin >> H >> W ;
  for(int i=0; i<W+2; i++){
    cout << "#" ;
}
	cout << endl;
  
  for(int k=0; k<H; k++){
    cout << "#";
 	 string x;
 	 cin >> x;
  for(int j=0; j<W; j++){
    cout << x.at(j);}
 
    cout << "#" << endl;
  	}
  
  for(int i=0; i<W+2; i++){
    cout << "#" ;
}
  cout << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> LOC = new ArrayDeque<Integer>();
		Deque<Info> POOL = new ArrayDeque<Info>();

		int tmp_S,tmp_start,tmp_end,sum = 0;

		try {

			char array[] = br.readLine().toCharArray();
			for(int i = 0; i < array.length; i++){
				if(array[i] == '\\'){
					LOC.addFirst(i);
				}else if(array[i] == '/'){

					if(LOC.isEmpty())continue;

					tmp_start = LOC.getFirst();
					LOC.removeFirst();
					tmp_end = i;

					tmp_S = tmp_end-tmp_start;
					sum += tmp_S;

					while(POOL.isEmpty() == false && POOL.getFirst().getStart() > tmp_start && POOL.getFirst().getEnd() < tmp_end){
						tmp_S += POOL.getFirst().getS();
						POOL.removeFirst();
					}

					POOL.addFirst(new Info(tmp_start,tmp_end,tmp_S));

				}else{ //array[i] == _
					//Do nothing
				}
			}

			System.out.println(sum);


			StringBuilder ans = new StringBuilder();

			ans.append(Integer.toString(POOL.size()));

			while(!POOL.isEmpty()){
				ans.append(" ").append(Integer.toString(POOL.getLast().getS()));
				POOL.removeLast();
			}

			System.out.println(ans.toString());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Info{
	private int start;
	private int end;
	private int S;

	Info(int start,int end,int S){
		this.start = start;
		this.end = end;
		this.S = S;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getEnd() {
		return end;
	}

	public void setEnd(int end) {
		this.end = end;
	}

	public int getS() {
		return S;
	}

	public void setS(int s) {
		S = s;
	}
}



Measured memory_bytes: 25504
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;

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

void solve(){
	string s = read;
	string t = read;
	
	long ans = 0;
	foreach(i; 0 .. 3) if(s[i] == t[i]) ans += 1;
	
	ans.writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
int a[3];
signed main(){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]!=a[1]&&a[1]!=a[2])puts("No");
    else if(a[0]==a[2])puts("No");
    else puts("Yes");
    return 0;
}


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

using namespace std;

typedef long long ll;

signed main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 0;
    if(c){
        --c;
        ++ans;
    }
    cout << ans + b + min(c, a + b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, h;
	cin >> n >> h;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(b.begin(), b.end());

	int a_max = a[0];
	for (int i = 1; i < n; i++) {
		if (a_max < a[i]) {
			a_max = a[i];
		}
	}
	int p = 0;
	while (a_max > b[p]) {
		p++;
	}

	int ans = 0;
	for (int i = n - 1; i >= p && h > 0; i--) {
		h -= b[i];
		ans++;
	}
	if (h > 0) {
		ans += (h + a_max - 1) / a_max;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
import sys

def main():
    n = int(sys.stdin.readline().strip())
    task = [tuple(int(i) for i in sys.stdin.readline().strip().split()) for _ in range(n)]
    task.sort(key=lambda x: x[1])
    time = 0
    for t in task:
        time += t[0]
        if time > t[1]:
            return 'No'
    return 'Yes'

print(main())


Measured memory_bytes: 31808
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int main(){
    int n, k;
    cin >> n >> k;
    vll a(n);
    rep(i,n) cin >> a[i];
    ll ans=inf;
    rep(bit, (1<<n)){
        if( (int)bitset<15>(bit).count() != k) continue;
        ll now_h=0;
        ll count=0;
        // cout << bitset<15>(bit) << endl;
        rep(pos,n){
            if( (bitset<15>(bit) & bitset<15>(1<<pos))== bitset<15>(1<<pos)){
                if(now_h >= a[pos]) count += now_h-a[pos]+1;
                now_h++;
            }
            now_h = max(now_h, a[pos]);
            // cout << now_h << endl;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
mod = 10**9 + 7
def cmb(n,r,mod):
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod

n,a,b = map(int,input().split())
count = 0
all = pow(2,n,mod) + mod
nCa = cmb(n,a,mod)
nCb = cmb(n,b,mod)
ans = all - (nCa + nCb)
print((ans-1)%mod)

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    vector<string> dp[15][15];
    cin>>N;
    dp[0][1].push_back("a");
    rep(i, N) rep(j, 15){
        rep(u, dp[i][j].size()){
            string str="a";
            rep(k, j){
                dp[i+1][j].push_back(dp[i][j][u]+str);
                str[0]++;
            }
            dp[i+1][j+1].push_back(dp[i][j][u]+str);
        }
    }
    vector<string> ans;
    rep(j, 15){
        rep(u, dp[N-1][j].size()){
            ans.push_back(dp[N-1][j][u]);
        }
    }
    sort(all(ans));
    rep(i, ans.size()){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 59376
#include<stdio.h>

int main(){
        int n;
        scanf("%d", &n);

        int table[10][10];
        memset(table, 0, 400);
        for(int i=0; i<=n; i++){
                int a, b=i%10;
                char s[7];
                snprintf(s, 7, "%d", i);
                a = s[0]-'0';
                table[a][b]++;
        }

        long ans = 0;
        for(int i=1; i<10; i++){
                for(int j=1; j<10; j++){
                        ans += table[i][j] * table[j][i];
                }
        }
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int H[N+10];
  H[0]=0;
  for(int i=1;i<=N;i++){
    cin >> H[i];
  }
  int ans=0;
  for(int i=1;i<=N;i++){
    bool flag =true;
    for(int j=0;j<i;j++){
      if(H[j]>H[i]){
        flag=false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

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

#define fi first
#define se second

using namespace std;

typedef long long ui;
const ui MOD = 998244353;

ui f[3005][3005][3];
ui g[3005][3005];
ui mul(ui x, ui y) {
	return x * y % MOD;
}
void add(ui &x, ui y) {
	x = (x + y) % MOD;
}

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	/*f[a][b][0] = f[a][b][2] = 1;
	for (int i = a; i <= c; i++)
		for (int j = b; j <= d; j++) {
			add(f[i][j][0], mul(f[i][j - 1][0], i - 1));
			add(f[i][j][1], mul(f[i][j - 1][1], i - 1));
			add(f[i][j][1], f[i][j - 1][0]);
			add(f[i][j][1], f[i - 1][j][2]);
			add(f[i][j][2], mul(f[i][j - 1][2], i));
			add(f[i][j][2], mul(f[i - 1][j][2], j));
			if (i > a && j > b)
				add(f[i][j][2], MOD - mul(f[i][j - 1][1], i - 1));
			//printf("%d %d %lld %lld %lld\n", i, j, f[i][j][0], f[i][j][1], f[i][j][2]);
		}
	printf("%lld\n", f[c][d][2]);*/
	g[a][b] = 1;
	for (int i = a; i <= c; i++)
		for (int j = b; j <= d; j++) {
			add(g[i][j], mul(g[i - 1][j], j));
			add(g[i][j], mul(g[i][j - 1], i));
			add(g[i][j], MOD - mul(g[i - 1][j - 1], mul(i - 1, j - 1)));
		}
	printf("%lld\n", g[c][d]);
	return 0;
}


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

typedef stack<char> P;

int main()
{
     const char s[5] = "()[]";
     string str;
     while (getline(cin, str), str.size() > 1) {
	  P p;
	  bool flag  =true;
	  for (int i = 0; i < str.size(); i++) {
	       if (str[i] == s[0] || str[i] == s[2]) p.push(str[i]);
	       else if (str[i] == s[1] || str[i] == s[3]) {
		    if (p.size() < 1) {
			 flag = false;
			 break;
		    } else if (str[i] == s[1] && p.top() == s[0]) p.pop();
		    else if (str[i] == s[3] && p.top() == s[2]) p.pop();
		    else {
			 flag = false;
			 break;
		    }
	       }
	  }
	  if (flag && p.size() == 0) cout << "yes" << endl;
	  else cout << "no" << endl;
     }

     return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
int main(){
  long long n,m,a,b,s=0;
  scanf("%lld %lld %lld",&n,&m,&a);
  while(--n){
    scanf("%lld",&b);
    s+=MIN(b-a,m);
    a=b;
  }
  printf("%lld\n",s+m);
  return 0;
}


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

int main(void)
{
	int n, x;
	
	while (true)
	{
		int count = 0;
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		for (int i = 1; i <= n; i++)
		{
			for (int j = i + 1; j <= n; j++)
			{
				for (int k = j + 1; k <= n; k++)
				{
					if (i + j + k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<functional>
#include<string.h>
#include<set>

const int MAXN = 1e2;

int degree[MAXN];
int V, E;
std::vector<int> digrath[MAXN];

void init() {
	memset(degree, 0, sizeof(int) * V);
}

void input() {
	scanf("%d%d", &V, &E);
	init();
	for (int i = 0; i < E; i++) {
		int s, t;
		scanf("%d%d", &s, &t);
		digrath[s].push_back(t);
		degree[t]++;
	}
}

void output() {
	std::queue<int> q;
	for (int i = 0; i < V; i++) {
		if (degree[i] == 0) {
			q.push(i);
		}
	}
	int cnt = 0;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		cnt++;
		for (std::vector<int>::iterator it = digrath[u].begin(); it != digrath[u].end(); it++) {
			degree[*it]--;
			if (degree[*it] == 0) {
				q.push(*it);
			}
		}
	}
	if (cnt < V) {
		printf("1\n");
	}
	else {
		printf("0\n");
	}
}

int main() {
	input();
	output();
	return 0;
}


Measured memory_bytes: 2748
#include<stdio.h>

int main(){
int H,W,i,j;

while(1){
  scanf("%d %d",&H,&W);
  if(H == W && H == 0){
  break;
  }else{
    for(j = 0; j < H; j++){
      for(i = 0; i < W;i++){
        if(i == 0 || j == 0 || i == W-1 || j == H-1){
        printf("#");
        }else{
        printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
}

return 0;
}


Measured memory_bytes: 2032
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd
class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()

Measured memory_bytes: 81468
#include<iostream>					
using namespace std;
int main()	
{	long long g,q,k;
cin>>g>>q>>k;
if(g ==0&&q==0){
	cout<<g<<endl<<q;
	return 0;
}
if(k>(g+q)){
	g=0;q=0;
	cout<<g<<endl<<q;
	return 0;
}else if(g>=k){
	g-=k;
	cout<<g<<endl<<q;
	return 0;
}else if(g<k){
	q = (g+q)-k;g =0;
	if(q<0) q =0; 
	cout<<g<<endl<<q;
	return 0;
}
								
 } 

Measured memory_bytes: 256