akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
links = [set() for i in range(n)]
for i in range(m):
	a,b = [int(i)-1 for i in input().split()]
	links[a].add(b)
	links[b].add(a)

ans = 0
pre = [-1]*n
low = [-1]*n
 
def dfs(v,p,a):
	global ans
	if pre[v] != -1:
		low[a] = min(low[a],low[v])
		return low[a]
	pre[v] = p
	low[v] = p
	for u in links[v]:
		if u == a:
			continue
		low[v] = min(low[v],dfs(u,p+1,v))
	if pre[v] == low[v]:
		ans += 1
	return low[v]
 
dfs(0,0,None)
print(ans-1)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
enum order{
    preorder=0,
    inorder=1,
    postorder=2,
};
class BinaryTree{
private:
    int numVertex;
    int *parent, *left, *right;
public:
    BinaryTree(int v);
    ~BinaryTree();
    void init();
    void dfs(int v,order flag);
    std::vector<int> root();
};
BinaryTree::BinaryTree(int v){
    numVertex=v;
    parent = new int[v];
    left = new int[v];
    right = new int[v];
    for(int i=0;i<v;i++){
        parent[i]=-1;
        left[i]=-1;
        right[i]=-1;
    }
}
BinaryTree::~BinaryTree(){
    //delete[] parent;
    //delete[] left;
    //delete[] right;
}
void BinaryTree::init(){
    for(int i=0;i<numVertex;i++){
        int id,l,r;
        scanf("%d%d%d",&id,&l,&r);
        parent[l]=id;
        parent[r]=id;
        left[id]=l;
        right[id]=r;
    }
}
std::vector<int> BinaryTree::root(){
    std::vector<int> vec;
    for(int i=0;i<numVertex;i++){
        if(parent[i]==-1)vec.push_back(i);
    }
    return vec;
}
void BinaryTree::dfs(int v,order flag){
    if(v>=0){
        if(flag==preorder)printf(" %d",v);
        dfs(left[v],flag);
        if(flag==inorder)printf(" %d",v);
        dfs(right[v],flag);
        if(flag==postorder)printf(" %d",v);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    BinaryTree t(n);
    t.init();
    std::vector<int> v=t.root();
    printf("Preorder\n");
    t.dfs(v[0],preorder);
    printf("\nInorder\n");
    t.dfs(v[0],inorder);
    printf("\nPostorder\n");
    t.dfs(v[0],postorder);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2684
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String str = reader.nextLine();

		if (str.length() == 2) {
			System.out.println(str);
		} else {
			System.out.print(str.substring(2));
			System.out.print(str.substring(1, 2));
			System.out.println(str.substring(0, 1));
		}

		reader.close();

	}

}


Measured memory_bytes: 23636
#include <stdio.h>

int main()
{
	long long int a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	long long int s = a*c;
	long long int ans = s;
	s = a*d;
	ans = ans>s?ans:s;
	s = b*c;
	ans = ans>s?ans:s;
	s = b*d;
	ans = ans>s?ans:s;
	printf("%lld",ans);
}

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

using namespace std;

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

    vector<int> l(n);
    for (int i = 0; i < n; ++i)
        cin >> l[i];

    sort(l.begin(), l.end());

    int count = 0;
    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            // subtract l.begin() iterator to get the index
            int k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            count += (k - 1) - j;
        }
    }

    cout << count << '\n';
}


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int v[100009];

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

   int Max = -1;
   for (int i = 1; i < 100000; i++) {
      Max = max(Max, v[i-1] + v[i] + v[i+1]);
   }

   cout << Max << endl;

   return 0;
}

Measured memory_bytes: 640
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int n;
  cin >> n;
  vl a(n, 0);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  ll sum = a[0];
  int arrived = 2;
  for(int i = 1; i < n && arrived <= n; i++) {
    if (arrived + 1 <= n) {
      sum += a[i];
      arrived++;
    }
    if (arrived + 1 <= n) {
      sum += a[i];
      arrived++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 4840
import math
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

arr = factorization(N)
sum = 0
for s in arr:
    if s[0] == 1:
        print(0)
        exit()
    sum += math.floor((-1+math.sqrt(1+8*s[1]))/2)
print(sum)

Measured memory_bytes: 9484
# 3本の柱が等間隔に並んでいます。柱の高さは左から順に
# a メートル,b メートル,c メートル です。
# 柱の先端が同一直線上に並んでいる時、つまり
# b − a = c − b を満たしているとき、
# この柱の並び方を美しいと呼びます。
# 柱の並び方が美しいかどうかを判定してください。

# 標準入力から a, b, c を取得する
a, b, c = map(int, input().split())

# 柱の並びが美しいかどうかを判定して結果を出力する

if (b - a) == (c - b):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var map = Enumerable.Repeat(0, hw[0]).SelectMany(_ => Console.ReadLine()).ToArray();
        var chars = Enumerable.Range(0, 26).Select(x => map.Count(y => y - 'a' == x)).ToArray();
        bool cond;
        if (hw[0] % 2 == 0 && hw[1] % 2 == 0)
        {
            cond = chars.All(x => x % 4 == 0);
        }
        else if (hw[0] % 2 == 0 && hw[1] % 2 == 1 || hw[0] % 2 == 1 && hw[1] % 2 == 0)
        {
            var even = hw[1] % 2 == 1 ? hw[0] : hw[1];
            cond = chars.All(x => x % 2 == 0) && chars.Count(x => x % 4 != 0) <= even / 2;
        }
        else
        {
            var ind = chars.TakeWhile(x => x % 2 == 0).Count();
            if (ind == 26) cond = false;
            else
            {
                chars[ind]--;
                cond = chars.All(x => x % 2 == 0) && chars.Count(x => x % 4 != 0) <= (hw[0] / 2) + (hw[1] / 2);
            }
        }

        Console.WriteLine(cond ? "Yes" : "No");
    }
}


Measured memory_bytes: 13472
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	
	int A,B,C;
	cin>>A>>B>>C;
	int ans=0;
	if(C-1<=A+B){
		ans+=C+B;
	}
	else{
		ans+=B*2;
		ans+=A+1;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int n,m,x,c[15],a[15][15],ans=inf;
int main()
{
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++)cin>>a[i][j];
    }
    for(int i=0;i<1<<n;i++){
        int d[15]={},sum=0,flag=1;
        for(int j=0;j<n;j++)if(i>>j&1){for(int k=0;k<m;k++)d[k]+=a[j][k];sum+=c[j];}
        for(int j=0;j<m;j++)if(d[j]<x)flag=0;
        if(flag&&sum<ans)ans=sum;
    }
    cout<<(ans==inf?-1:ans);
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ld long double

/* 幾何ライブラリ */
// 2次元座標, 2次元ベクトル
using pos = pair<ld, ld>;

// 加算
pos add(pos p1, pos p2) {
	return { p1.first + p2.first, p1.second + p2.second };
}
// 減算
pos sub(pos p1, pos p2) {
	return { p1.first - p2.first, p1.second - p2.second };
}
// 内積
ld inner_product(pos p1, pos p2) {
	return p1.first * p2.first + p1.second * p2.second;
}
// 定数倍
pos mul(ld c, pos p) {
	return { c * p.first, c * p.second };
}

// ノルムの2乗
ld norm2(pos p) {
	return p.first * p.first + p.second * p.second;
}
// ノルム
ld norm(pos p) {
	return sqrt(norm2(p));
}

// 射影
// pをp1, p2を通る直線に射影する
// 検証済み(https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/all/CGL_1_A)
pos projection(pos p1, pos p2, pos p) {
	pos q = sub(p2, p1);
	pos tmp = mul(inner_product(q, sub(p, p1)) / norm2(q), q);
	return add(p1, tmp);
}

// 反射
// pをp1, p2を通る直線に関して対称移動する
pos reflection(pos p1, pos p2, pos p) {
	pos tmp = projection(p1, p2, p);
	return add(p, mul(2.0, sub(tmp, p)));
}

int main() {
	cout << setprecision(15);
	pos p1, p2;
	cin >> p1.first >> p1.second >> p2.first >> p2.second;
	int q; cin >> q;
	while (q--) {
		pos p; cin >> p.first >> p.second;
		pos res = reflection(p1, p2, p);
		cout << res.first << " " << res.second << endl;
	}
	return 0;
}


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

int n, a, b;

int main() {
    std::cin >> n;
    if (n == 1) {
        std::cout << "Hello World" << std::endl;
        return 0;
    }
    std::cin >> a >> b;
    std::cout << a + b << std::endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n, tp = 0, hp = 0;
    string t,h;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> t >> h;
        if(t > h){
            tp +=3;
        } else if(t == h){
            tp +=1;
            hp +=1;
        } else {
            hp += 3;
        }
    }
    cout << tp << " " << hp << endl;
    return 0;
}



Measured memory_bytes: 3144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BichromeCells
{
    class BichromeCells
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int NN = N * N;

            int A = int.Parse(Console.ReadLine());

            int Ans = NN - A;

            Console.WriteLine(Ans);

            return;

        }
    }
}


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

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();

        long x = n;
        long ans = 0;

        HashMap<Long, Long>map = new HashMap<Long, Long>();
        for (long i = 2; i <= Math.sqrt(n);) {
            if (x % i == 0) {

            	x /= i;

            	if (map.containsKey(i)){
            		map.put(i, map.get(i)+1);
            	} else {
            		map.put(i, 1L);
            	}

            } else {
            	i++;
            }
        }
        if (x > 1){
        	map.put(x, 1L);
        }

        for (Entry<Long,Long> entry : map.entrySet()){
        	long value = entry.getValue();
        	for (int i=1; value > 0; i++){
        		if (value >= i){
        			ans++;
        		}
        		value -= i;
        	}
        }

        System.out.println(ans);
	}

}

Measured memory_bytes: 37448
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int N, m;
    cin >> N >> m;
    vector<Pii> v(m);
    rep(i, m) cin >> v[i].first >> v[i].second;

    sort(all(v));
    vector<Pii> u;
    rep(i, m) {
        if (!u.empty() && v[i].first <= u.back().second) {
            u.back().second = max(u.back().second, v[i].second);
        }
        else u.emplace_back(v[i]);
    }

    int ans = N + 1;
    for (auto p : u) {
        ans += 2 * (p.second - p.first);
    }
    cout << ans << endl;
}

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

int main() {
  int a, b; char op;
  while (true) {
    cin >> a >> op >> b;
    if (op == '?') break;
    int ans;
    if (op == '+') ans = a + b;
    else if (op == '-') ans = a - b;
    else if (op == '*') ans = a * b;
    else ans = a / b;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3076
#include<stdio.h>

int main(){
	int N,Y,frag = 0,tmp,frag10000,frag5000,frag1000,a,b,c,A = -1,B = -1,C = -1,x,y = -1;
	scanf("%d %d",&N,&Y);
	frag10000 = Y / 10000;
	frag5000 = Y / 5000;
	frag1000 = Y / 1000;
	for(a = 0; a <= N; a++){
		for(b = 0; b <= N; b++){
			c = N - a - b;
			if(c < 0){
				continue;
			}
				x = (a * 10000) + (b * 5000) + (c * 1000);
				if(x == Y){
					frag++;
					A = a;
					B = b;
					C = c;
					break;
				}
			/*for(c = 0; c < frag1000; c++){
				tmp = a + b + c;
				x = (a * 10000) + (b * 5000) + (c * 1000);
				if((tmp == N) && (x == Y)){
					frag++;
					A = a;
					B = b;
					C = c;
					break;
				}
			}*/
		}
	}
	printf("%d %d %d",A,B,C);
	return 0;
}

Measured memory_bytes: 1704
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def gcd(a, b):
    if a == 0:
        return b
    if b == 0:
        return a

    if a > b:
        return gcd(b, a % b)
    else:
        return gcd(a, b % a)


def gcd_multi(nums):
    if len(nums) == 0:
        return 0
    if len(nums) == 1:
        return nums[0]

    ret = gcd(nums.pop(), nums.pop())
    while len(nums) > 0:
        ret = gcd(ret, nums.pop())
    return ret


def solve(inputs):
    sides = string_to_int(inputs[0])
    max_i = -1
    for i, s in enumerate(sides):
        if max_i == -1 or s > sides[max_i]:
            max_i = i
    max_len = sides.pop(max_i)

    return "Yes" if max_len < sum(sides) else "No"


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
const int M = 1e5 + 50;
int a[M];
int main(){
	string s;
	cin>>s;
	for(int i = 0; i < s.length();i++){
		a[i] = 0;
	}
	int rs = 0;
	for(int i = 0; i < s.length();i++){
		if(s[i] == 'R')
			rs++;
		else{
			if(rs!=0){
				a[i-1] = rs; 
				rs = 0;
			}
		}
	}
	int ls = 0;
	for(int i = s.length() -1; i >=0 ;i--){
		if(s[i] == 'L')
			ls++;
		else{
			if(ls!=0){
				a[i+1] = ls;
				ls = 0;
			}
		}
	}
	for(int i = 0; i < s.length() ; i++){
		if(s[i] == 'R' && s[i+1] == 'L'){
			if((a[i]+a[i+1])%2 == 0){
				int sum = a[i]+a[i+1];
				a[i] = sum/2;
				a[i+1] = sum/2;
			}
			else{
				if(a[i]%2 == 1){
					int sum = a[i]+a[i+1];
					a[i] = sum/2+1;
					a[i+1] = sum/2;
				}
				else{
					int sum = a[i]+a[i+1];
					a[i] = sum/2;
					a[i+1] = sum/2+1;
				}
			}
			i++;
		}
	}
	for(int i = 0; i < s.length() ;i++){
		if(i != 0)
			cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1024
X = input().split()
K = int(X[0])
N = int(X[1])
Y = input().split()
Z = []
for i in range(N):
    Z.append(int(Y[i]))
result = Z[0]+ K - Z[N-1]

for i in range(N):
    if result < Z[i] - Z[i-1]:
        result = Z[i] - Z[i -1]
    i = i + 1
print(K - result)


Measured memory_bytes: 25644
import java.util.Scanner;

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

		boolean flg = true;
		int cnt = 0;
		if(s.charAt(0) != 'A') flg = false;
		for (int i = 1; i < s.length(); i++) {
			if('A' <= s.charAt(i) && s.charAt(i) <= 'Z') {
				if(i < 2 || i > s.length() - 2 || s.charAt(i) != 'C') {
					flg = false;
				}
				if(s.charAt(i) == 'C') cnt++;
			}
		}
		if(cnt != 1) flg = false;

		System.out.println(flg ? "AC" : "WA");
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int flag;
int main(){
	int a,b;
	cin>>a>>b;
	if((a+b)%3==0)flag=1;
	if(a%3==0)flag=1;
	if(b%3==0)flag=1;
	if(flag)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

if k - q > 0:
  res = ['Yes'] * n
else:
  res = ['No'] * n
  ans = [0] * n
  for i in range(len(a)):
    ans[a[i]-1] += 1
  for i in range(n):
    if k - q + ans[i] > 0:
      res[i] = 'Yes'
print('\n'.join(map(str, res)))

Measured memory_bytes: 63064
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int n, m;
    cin >> n >> m;
    int a[n], sum = 0;
    rep(i, 0, n) {
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    rep(i, 0, n) {
        if (a[i] >= (float)sum / (4*m))
            cnt++;
    }
    if (cnt >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll min(ll a,ll b){
    if(a>b)
	return b;
    return a;
}

ll abs(ll a){
    if(a<0)
	return -a;
    return a;
}
const ll inf = (1e9+7);

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    vector<int>h(n);
    for(int&x :h)
	scanf("%d",&x);

    vector<ll>d(n,inf);
    d[0]=0;
    for(int i=0;i<n;i++){
	for(int j=i+1;j<=i+k;j++){
	    if(j<n){
		d[j]=min(d[j],d[i]+abs(h[i]-h[j]));
	    }
	}
    }
    cout<<d[n-1]<<endl;
}


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

int main(){
    vector<int> num(3);
    int N;
    cin >> N;
    for (int i=0; i<3; i++){
        num.at(i) = N % 10;
        N /= 10;
    }

    for (int i=0; i<3; i++){

        if (num.at(i)==9){
            num.at(i)=1;
        }

        else if (num.at(i)==1){
            num.at(i)=9;
        }

    }

    reverse(num.begin(),num.end());
    
    for(int i=0; i<3; i++){
        cout << num.at(i);
    }

    cout << endl;
    
}

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

#define INF 1000000000

using namespace std;

int main() {
    int n, ans = INF, c, a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        c = 0;
        while ((a & 1) == 0) {
            a >>= 1;
            ++c;
        }
        ans = min(c, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;

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

const int B = 200;
int color[100010],  par[100010], depth[100010];
int top[100010];
int goUp[100010];
bool vis[100010];
int n;
vector<vector<int>> g;

void decomp(int root){
    rep(i,n) vis[i] = false, par[i] = -1;
    queue<int> q;
    q.push(root);
    vector<int> tord;
    while(q.size()){
        int v = q.front(); q.pop();
        vis[v] = true;
        tord.push_back(v);
        for(int c : g[v]){
            if(!vis[c]){
                q.push(c);
                par[c] = v;
                depth[c] = depth[v] + 1;
            }
        }
    }
    rep(i,n) vis[i] = false;
    int c = 0;
    for(int u : tord){
        if(vis[u]) continue;
        q.push(u);
        int k = 0;
        while(q.size() && k < B){
            int v = q.front(); q.pop();
            vis[v] = true;
            color[v] = c;
            goUp[v] = par[u];
            top[v] = u;
            k++;
            for(int c : g[v]){
                if(!vis[c]) q.push(c);
            }
        }
        while(q.size()) q.pop();
        c++;
    }
    // rep(i,n) printf("v:%d col:%d dep:%d\n", i, color[i], depth[i]);
}

int solve(int u, int v){
    while(color[u] != color[v]){
        // cout << u << " " << v << endl;
        assert(u != -1 && v != -1);
        if(depth[top[u]] > depth[top[v]]) u = goUp[u];
        else v = goUp[v];
    }
    while(u != v){
        assert(u != -1 && v != -1);
        if(depth[u] > depth[v]) u = par[u];
        else v = par[v];
    }
    return u;
}

int main(){
    cin >> n;
    g.assign(n,{});
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            g[i].push_back(c);
            par[c] = i;
        }
    }
    decomp(0);
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        cin >> u >> v;
        cout << solve(u,v) << endl;
    }
}

Measured memory_bytes: 9088
H,W=map(int,input().split())
S=[input()+'.'for _ in range(H)]+['.'*(W+2)]
print(('Yes','No')[any(S[y-1][x]==S[y+1][x]==S[y][x-1]==S[y][x+1]=='.'for y in range(H)for x in range(W)if S[y][x]=='#')])

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

#define N_MAX 100000

int  H[N_MAX + 1], root[N_MAX + 1][2];
set<int> st;
set<int> er;
set<int> num;

int main() {
	int N, M;
	
	cin >> N >> M;
	for (int i = 1;i <= N;i++) {
		cin>>H[i];
		num.insert(i);
	}
	for (int i = 1;i <= M;i++) {
		cin >> root[i][0] >> root[i][1];
		num.erase(root[i][0]);
		num.erase(root[i][1]);
		if (H[root[i][0]] > H[root[i][1]]) {
			st.insert(root[i][0]);
			er.insert(root[i][1]);
		}
		else if (H[root[i][1]] > H[root[i][0]]) {
			st.insert(root[i][1]);
			er.insert(root[i][0]);
		}
		if (H[root[i][1]] == H[root[i][0]]) {
			er.insert(root[i][0]);
			er.insert(root[i][1]);
		}
	}

	for (auto x : er) {
		st.erase(x);
	}
	for (auto x : num) {
		st.insert(x);
	}
	cout << st.size();
}

Measured memory_bytes: 10408
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> dp(n), input(n);
  for (int i = 0; i < n; i++)
    cin >> input[i];

  dp[0] = 0;
  dp[1] = abs(input[0] - input[1]);
  if (n == 2)
  {
    cout << dp[1];
    return 0;
  }
  for (int i = 2; i < n; i++)
  {
    dp[i] = min(dp[i - 2] + abs(input[i] - input[i - 2]), dp[i - 1] + abs(input[i] - input[i - 1]));
  }
  cout << dp[n - 1];
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,k,s;
int main(){
    cin >> n >> k >> s;
    for(int i = 1;i <= k;i++) printf("%d ",s);
    if(s < 1000000000){
        for(int i = k + 1;i <= n;i++) printf("1000000000 ");
    }
    else for(int i = k + 1; i<= n;i++)printf("1 ");
    putchar(10);
    return 0;
}

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

int main(){
	map<char,char> table;
	int n;
	char s,t;
	while(cin>>n&&n){
		table.clear();
		while(n--){
			cin>>s>>t;
			table[s] = t;
		}
		cin>>n;
		while(n--){
			cin>>s;
			if(table.find(s)!=table.end())cout<<table[s];
			else cout<<s;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int N;
    cin >> N;
    vector<double> v(N);
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double ave=(v[0]+v[1])/2;
    for(int i=2;i<N;i++){
        ave+=v[i];
        ave/=2;
    }
    printf("%.7f\n", ave);
    //cout <<ave << endl;
    return 0;
}
/*REの時vectorのoverflow確認*/

Measured memory_bytes: 3828
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, K;
  cin >> N >> K;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N);
  int64_t min_value = INT64_MAX;
  int64_t min_index = -1;
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
    if (A[i] < min_value) {
      min_value = A[i];
      min_index = i;
    }
  }
  int64_t result = INT64_MAX;
  for (int64_t start = max(min_index - K + 1, 0L); start <= min_index; ++start) {
    const int64_t right = N - 1 - (start + K - 1);
    const int64_t left = start;
    result = min(1 + (right + K - 2) / (K - 1) + (left + K - 2) / (K - 1), result);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

typedef long long ll;

int main(){

	ll x;

	scanf("%lld",&x);

	ll ans;

	if(x%11ll==0ll){
		ans=x/11ll;
		ans*=2ll;
	}
	else{
		ans=x/11ll;
		ans*=2ll;
		x%=11ll;
		if(x<=6ll){
			ans+=1ll;
		}
		else{
			ans+=2ll;
		}
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 128
K = int(input())
list_ = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list_[K-1])

Measured memory_bytes: 3060
a=input()
lista=list(a)
j=1
listodd=['R','U','D']
listeven=['L','U','D']

for i in lista:
    if j%2==1:
        if i not in listodd:
            print('No')
            break
    elif j%2==0:
        if i not in listeven:
            print('No')
            break
    j=j+1
if j==len(lista)+1:
    print('Yes')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		HashSet<Integer> set = new HashSet<>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
		    set.add(sc.nextInt());
		}
		int m = sc.nextInt();
		TreeSet<Integer> result = new TreeSet<>();
		for (int i = 0; i < m; i++) {
		    int x = sc.nextInt();
		    if (set.contains(x)) {
		        set.remove(x);
		    } else {
		        result.add(x);
		    }
		}
		result.addAll(set);
		StringBuilder sb = new StringBuilder();
		for (int x : result) {
		    sb.append(x).append("\n");
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 195536
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
typedef long long LL;
const int N=100005;
vector<int> vec[N];
int n,m;
bool f[N][2];
bool in[N];
void bfs ()
{
	memset(f,false,sizeof(f));
	memset(in,false,sizeof(in));
	queue<int> q;
	q.push(1);f[1][0]=true;in[1]=true;
	while (!q.empty())
	{
		int x=q.front();q.pop();
		int siz=vec[x].size();in[x]=false;
		for (int i=0;i<siz;i++)
		{
			int y=vec[x][i];bool tf=false;
			if (f[x][0]&&!f[y][1])	{f[y][1]=true;tf=true;}
			if (f[x][1]&&!f[y][0])	{f[y][0]=true;tf=true;}
			if (tf) 
			{
				if (!in[y])	q.push(y);
				in[y]=true;
			}
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int u=1;u<=m;u++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);vec[y].push_back(x);
	}
	bfs();
	int cnt=0,cnt1=0,cnt2=0;
	for (int u=1;u<=n;u++)
	{
		if (f[u][0]&&f[u][1]) cnt++;
		else if (f[u][1]) cnt1++;
		else cnt2++;
	}
	//printf("%d %d %d\n",cnt,cnt1,cnt2);
	LL ans=(LL)cnt1*cnt2+(LL)cnt*cnt2+(LL)cnt*cnt1+(LL)cnt*(cnt-1)/2;
	printf("%lld\n",ans-m);
	return 0;
}


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

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

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long X = in.Long();
            long y = 0;
            long z = 100;
            while (z < X) {
                z = (long) (z * 1.01);
                y++;
            }
            out.println(y);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public long Long() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 32804
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
        long d = long.Parse(input[3]);

        long r = long.MinValue;

        long ac = a * c;
        long bc = b * c;
        long ad = a * d;
        long bd = b * d;

        r = ac;
        if (bc > r)
        {
            r = bc;
        }

        if (ad > r)
        {
            r = ad;
        }

        if (bd > r)
        {
            r = bd;
        }

        Console.WriteLine(r);
    }
}

Measured memory_bytes: 17876
import sys
input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15


def main():
    n,m = getlist()
    nums = getlist()

    cnt = Counter(nums)
    mod = [0 for i in range(m)]
    same = [0 for i in range(m)]

    for k, v in cnt.items():
        mod[k%m] += v
        same[k%m] += v // 2

    ans = mod[0] // 2
    for i in range(1, int((m+2) // 2)):
        if i == m / 2:
            ans += mod[i] // 2
        else:
            other = m - i
            ans += min(mod[i], mod[other])
            if mod[i] > mod[other]:
                ans += min(same[i], (mod[i] - mod[other]) // 2)
            if mod[i] < mod[other]:
                ans += min(same[other], -(mod[i] - mod[other]) // 2)

    print(ans)

    # print(same, mod)

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Measured memory_bytes: 58908
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, t, x, y, ans = INT_MAX;

    cin >> n >> t;

    while (n--) {

        cin >> x >> y;

        if (y <= t) ans = min(ans, x);
    }

    if (ans == INT_MAX) cout << "TLE";
    else cout << ans;

    return 0;
}


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

int main(){
    int x; cin >> x;
    int y = (x % 100);
    if(y % 5 == 0){
        y = y/5;
    }else{
        y = y/5+1;
    }
    x = x / 100;
    if(x >= y){
        cout << 1 << endl;
        return 0;
    }else{
        cout << 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n / 2)
    {
        if (s[i] != s[n - 1 - i])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import heapq

N = int(input())
v = [int(v) for v in input().split()]

# v[0] <= v[1] <= ...<= v[N]となるように並べ替えた時、
# ( v[0] + v[1] + 2 * v[2] + ... + 2^(i-1) * v[i] + ... + 2^(N-2) * v[N-1] ) / 2^(N-1)
# が最大値

heapq.heapify(v)
sum = heapq.heappop(v)

for i in range(1, N):
    sum += 2 ** (i - 1) * heapq.heappop(v)

print(sum / (2 ** (N - 1)))


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

int main() {
  string s;
  cin >> s;
  int i = 0, j = s.size() - 1;

  while (true) {
    if (s.at(i) == 'A') {
      break;
    }
    i ++;
  }
  while (true) {
    if (s.at(j) == 'Z') {
      break;
    }
    j --;
  }

  cout << j - i + 1 << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


Int combination(Int n, Int r) {
    if(n == 1){return 0;}
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

unsigned GetDigit(Int num){
    return std::to_string(num).length();
}
int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}

int ans =0;

void dfs(string bit, int length,vector<vector<pii>> &answers){
    if(bit.size() == length){
        int tmp_ans = 0;
        int count_shoujiki = 0;
        rep(i,length){
            if(bit[i] =='1'){
                count_shoujiki++;
                bool goal = true;
                rep(j,answers[i].size()){
                    int x = answers[i][j].first;
                    int y = answers[i][j].second;

                    if (ctoi(bit[x]) != y) {goal = false;}
                }

                if(goal){
                    tmp_ans++;
                }
            }
        }
        if(tmp_ans == count_shoujiki){
            ans = max(ans,count_shoujiki);
        }

        return;
    }
    dfs(bit+"1", length, answers);
    dfs(bit+"0", length, answers);
    return ;
}

int main() {
    Int N;
    Int ans = 0;
    cin >>N;

    vi P = vi(N);

    rep(i,N){
        cin >> P[i];
    }

    Int min_num = 9999999;

    rep(i,N){
        if(P[i]<=min_num){
            ans++;
            min_num = min(min_num,P[i]);
        }
    }

    cout << ans <<endl;



    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int[] abcdef = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int i,j,k,l;
    int maxwater=abcdef[5]*100/(100+abcdef[4]);
    int maxsugar=0;
    double maxpercent=(double)100*abcdef[4]/(100+abcdef[4]);
    int sumwater=0;
    int sumsugar=0;
    double percent=0;
    int anssugar=0;
    int anssum=0;
    double anspercent=0;
    for(i=0;i*100*abcdef[0]<abcdef[5];i++)
    {
      for(j=0;j*100*abcdef[1]<abcdef[5];j++)
      {
        sumwater=(i*abcdef[0]+j*abcdef[1])*100;
        for(k=0;k*abcdef[2]<=abcdef[5]-sumwater;k++)
          for(l=0;l*abcdef[3]<=abcdef[5]-sumwater;l++)
          {
            sumsugar=k*abcdef[2]+l*abcdef[3];
            if(sumwater==0)break;
            percent=(double)100*sumsugar/(sumsugar+sumwater);
            if(sumwater+sumsugar<=abcdef[5]&&percent<=maxpercent&&percent>=anspercent)
            {
              anspercent=percent;
              anssum=sumwater+sumsugar;
              anssugar=sumsugar;
            }
          }
      }
      if(anssugar==0&&abcdef[5]>100*abcdef[0])anssum=100*abcdef[0];
    }Console.WriteLine(anssum+" "+anssugar);
  }
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  double sum = 0;
  vector<int> t(n);
  iota(t.begin(), t.end(), 0);

  do {
    for (int i = 1; i < n; i++) {
      sum +=
          sqrt(pow(x[t[i]] - x[t[i - 1]], 2) + pow(y[t[i]] - y[t[i - 1]], 2));
    }
  } while (next_permutation(t.begin(), t.end()));

  int ex = 1;
  for (int i = 1; i < n + 1; i++) {
    ex *= i;
  }

  cout << sum / ex << endl;
}

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

  solve();
  return 0;
}


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

const long long MOD = 1000000007;

int modPow(long long a, long long n, long long p){
    if(n == 1) return a % p;
    if(n % 2 == 1) return (a * modPow(a, n-1, p) % p);
    long long t = modPow(a, n/2, p);
    return (t * t) % p;
}

int COMMOD(int n, int k, int p){
    long long X = 1; 
    long long Y = 1;
    REP(i, 0, k){
        X = (X * (n - i)) % p;
        Y = (Y * (i + 1)) % p;
    }
    return (X*modPow(Y, p-2, p)) % p;
}

int main() {
    long long n, a, b;
    long long ans = 1;
    cin>>n>>a>>b;
    ans = modPow(2, n, MOD)-1;
    ans = (ans + MOD*2 - COMMOD(n, a, MOD) - COMMOD(n, b, MOD)) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<int> ans(n,0);
    int even=1,odd=0;
    for(int i=1;i<n;i++){
        if(s[i]=='L'&&i%2==0){
            ans[i-1]+=odd;
            ans[i]+=even;
            even=0;
            odd=0;
        }
        else if(s[i]=='L'&&i%2!=0){
            ans[i-1]+=even;
            ans[i]+=odd;
            even=0;
            odd=0;
        }
        else if(i%2==0)even++;
        else odd++;
    }
    if(n%2==0){
        even=0;
        odd=1;
    }
    else{
        even=1;
        odd=0;
    }
    for(int i=n-2;i>=0;i--){
        if(s[i]=='R'&&i%2==0){
            ans[i+1]+=odd;
            ans[i]+=even;
            even=0;
            odd=0;
        }
        else if(s[i]=='R'&&i%2!=0){
            ans[i+1]+=even;
            ans[i]+=odd;
            even=0;
            odd=0;
        }
        else if(i%2==0)even++;
        else odd++;
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
    int n;
    cin >> n;
    vector<ll> cnt(5);
    rep(i, n) {
        string s;
        cin >> s;
        char c = s[0];
        if (c == 'M') cnt[0]++;
        if (c == 'A') cnt[1]++;
        if (c == 'R') cnt[2]++;
        if (c == 'C') cnt[3]++;
        if (c == 'H') cnt[4]++;
    }

    ll ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i+1; j < 5; j++) {
            for (int k = j+1; k < 5; k++) {
                ans += cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

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

	int t[102];
	for (int i = 0;i < m;i++){
		cin >> t[i];
	}

	int d[101][101];
	int p[101]; memset(p,0,sizeof(p));

	for (int i = 0;i < m;i++){
		int nt = t[i];
		for (int j = 0;j < n;j++){
			cin >> d[i][j];
			if(d[i][j] == nt) p[j]++;
			else p[nt-1]++;
		}
	}

	for (int i = 0;i < n;i++){
		cout << p[i] << endl;
	}

	return 0;

}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    int ans = 0;
    int mx = 0;
    rep(i,n){
        int p; cin >> p;
        ans += p;
        mx = max(mx,p);
    }

    ans -= mx/2;

    dunk(ans);
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
const int MAXN = 50 ; 
int main(){
    int n , m ; 
    cin >> n >> m ; 
    vector<int> cnt(m+1) ; 
    for(int i=0;i<n;i++){
    	int k ; 
    	cin >> k ; 
    	for(int j=0;j<k;j++){
    		int x ; 
    		cin >> x ; 
    		cnt[x]++ ; 
    	}
    }
    int ans = 0 ; 
    for(int i=1;i<=m;i++){
    	if ( cnt[i] == n ) ans++ ; 
    }
    cout << ans << endl;
    return 0 ;
}


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

using namespace std;
typedef long long unsigned int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll w; cin >> w;
    ll h; cin >> h;
    ll x; cin >> x;
    ll y; cin >> y;
    double two = 2.0;
    int is_fukusu;
    if (w/two == x && h/two == y){
        is_fukusu = 1;
    } else {
        is_fukusu = 0;
    }
    cout << w*h/two << " " << is_fukusu << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define MAX 1005
const ll MOD=1e9+7;
using namespace std;
//以後、合成魔法を使用しないような竹に対してのみ、延長、縮小魔法を利用
int N,A,B,C;
int l[10];
int dfs(int cur,int a,int b,int c){
  if(cur==N) {
    if(a>0&&b>0&&c>0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
    else return A+B+C;
  }
  int ret0=dfs(cur+1,a,b,c);
  int ret1=dfs(cur+1,a+l[cur],b,c)+10;
  int ret2=dfs(cur+1,a,b+l[cur],c)+10;
  int ret3=dfs(cur+1,a,b,c+l[cur])+10;
  int retM=min(ret0,ret1);
  retM=min(retM,ret2);
  retM=min(retM,ret3);
  return retM;
}
int main() {
  cin >> N >> A >> B >> C;
  rep(i,N){
    cin >> l[i];
  }
  cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256