akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

struct BIT{
    int N;
    vi dat;
    void init(int _N){
        N=_N;
        dat=vi(N+1,0);
    }
    void add(int k,int val){
        k++;
        while(k<=N){
            dat[k]+=val;
            k+=k&-k;
        }
    }
    int getSum(int k){
        k++;
        int ret=0;
        while(k){
            ret+=dat[k];
            k-=k&-k;
        }
        return ret;
    }
};

int main(){
    int N,Q;
    scanf("%d%d",&N,&Q);
    BIT bit;
    bit.init(N);
    while(Q--){
        int t,x,y;
        scanf("%d%d%d",&t,&x,&y);
        if(t){
            printf("%d\n",bit.getSum(y-1)-bit.getSum(x-2));
        }
        else{
            bit.add(x-1,y);
        }
    }

    return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int a[33] = {0, 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};
int main() {
  int k;
  cin >> k;
  cout << a[k] << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
int N, bit[200010]; 
long long K; 
void add(int a, int b){
	int x = a; 
	while(x <= N+1){
		bit[x] += b; x += x & -x; 
	}
}
int sum(int a){
	int res = 0; 
	int x = a; 
	while(x > 0){
		res += bit[x]; x -= x & -x;
	}
	return res; 
}
int main(){
	cin >> N >> K; 
	long long A[200010] = {}; 
	long long S[200010] = {}; 
	int Z[200010] = {}; 
	set<long long> T; map<long long, int> M; 
	T.insert(0LL); 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; A[i] -= K; 
		S[i] = S[i-1] + A[i]; T.insert(S[i]); 
	}
	int now = 0; 
	for(auto it = T.begin(); it != T.end(); it++){
		M[*it] = ++now; 
	}
	for(int i = 0; i <= N; i++) Z[i] = M[S[i]]; 
	long long ans = 0; 
	for(int i = 0; i <= N; i++){
		ans += (long long) sum(Z[i]);
		add(Z[i], 1);
	}
	cout << ans << endl; 
}

Measured memory_bytes: 26752
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int N, A;
	cin >> N >> A;
	if (N % 500 <= A) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int MAX = 1000005;
const ll MOD = 1000000007;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

Measured memory_bytes: 1792
countNum = gets.to_i
aryNums = gets.split.map(&:to_i);
 
maxNum = aryNums[0];
minNum = aryNums[0];
sum = 0;
 
for num in 0..countNum-1 do
 
	if maxNum < aryNums[num] then
 
    	 maxNum = aryNums[num];
 
	end
 
    if minNum > aryNums[num] then
 
        minNum = aryNums[num];
 
    end
 
    sum += aryNums[num];
 
end
 
puts minNum.to_s + " " + maxNum.to_s + " " + sum.to_s

Measured memory_bytes: 9104
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int n,dp[3][R],t[3][R];

int main()
{
	scanf("%d", &n);
	for(int i=0;i<n;++i)
	{
		scanf("%d%d%d", &t[0][i], &t[1][i], &t[2][i]);
	}
	dp[0][0]=t[0][0];
	dp[1][0]=t[1][0];
	dp[2][0]=t[2][0];
	for(int i=1;i<n;++i)
	{
		dp[0][i]=max(dp[1][i-1],dp[2][i-1]) + t[0][i];
		dp[1][i]=max(dp[0][i-1],dp[2][i-1]) + t[1][i];
		dp[2][i]=max(dp[1][i-1],dp[0][i-1]) + t[2][i];
	}
	printf("%d\n", max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1])));
	return 0;
}


Measured memory_bytes: 6128
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,K;
int A[200005];
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,N)scanf("%lld",&A[i]);
    sort(A,A+N);
    if(K==1){
        printf("%lld\n",A[N-1]);
        return 0;
    }
    if(A[N-1]<0&&K%2==1){//全て負かつKが奇数の時
        int prod=1;
        rep(i,K){
            prod*=A[N-i-1];
            prod%=mod;
        }
        printf("%lld\n",(prod%mod+mod)%mod);
        return 0;
    }
    //非負にできるので、負にならない追加方法を繰り返す
    int cnt=0;
    int left=-1;
    int right=N;
    int prod=1;
    while(cnt<K){
        if(K-cnt==1){//あと一つしか入れられない時は非負の要素を入れる
            prod*=A[right-1];
            prod%=mod;
            break;//終わり
        }
        if(A[left+2]>=0){//負の数が足りない時は必ず非負の数を入れる
            prod*=A[right-1];
            prod%=mod;
            right-=1;
            cnt+=1;
            continue;
        }
        if(A[right-2]<0){//非負の数が足りない時は必ず負の数2つを入れる
            prod*=(A[left+1]*A[left+2])%mod;
            prod%=mod;
            left+=2;
            cnt+=2;
            continue;
        }
        //非負の数2つまたは正の数1つを入れる
        int p1=A[left+1]*A[left+2];
        int p2=A[right-1]*A[right-2];
        if(p1>p2){
            prod*=(A[left+1]*A[left+2])%mod;
            left+=2;cnt+=2;
        }else{

            prod*=A[right-1];
            right-=1;cnt+=1;
        }
        prod%=mod;
    }
    printf("%lld\n",(prod%mod+mod)%mod);
    return 0;
}

Measured memory_bytes: 3272
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n;

int main()
{
	cin>>n;
	if(n==7||n==5||n==3) puts("YES");
	else puts("NO");
	rt0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
  
        static void Main(string[] args)
        {
            int[] HW = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int H = HW[0];
            int W = HW[1];
            char[,] hairetu = new char[H, W];
            for(int i = 0; i < H; i++)
            {
                char[] tmp = Console.ReadLine().ToCharArray();
                for (int j = 0; j < W; j++)
                {
                    hairetu[i, j] = tmp[j];
                }
            }
            List<int> num = new List<int>();
            Boolean[,] yoko = new Boolean[H, W];
            Boolean[,] tate = new Boolean[H, W];
            for (int i = 0; i < H; i++)
            {
                Boolean flg = false;
                for (int j = 0; j < W; j++)
                {
                    if(hairetu[i,j] == '#')
                    {
                        num.Add(j);
                        flg = true;
                    }
                }
                if (flg)
                {
                    for (int j = 0; j < W; j++)
                    {
                        yoko[i, j] = true;
                    }
                }
            }
            if(num.Count != 0)
            {
                for (int j = 0; j < num.Count; j++)
                {
                    for (int i = 0; i < H; i++)
                    {
                        tate[i, num[j]] = true;
                    }
                }
            }
            string ans = "";
            for (int i = 0; i < H; i++)
            {
                Boolean f = false;
                for (int j = 0; j < W; j++)
                {
                    if (tate[i,j] && yoko[i, j])
                    {
                        ans += hairetu[i, j].ToString();
                        f = true;
                    }
                }
                if (f)
                {
                    ans += "\n";
                }
            }
            Console.WriteLine(ans);
        }
    }
}




//int n = int.Parse(Console.ReadLine());
//int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

Measured memory_bytes: 37076
def helper(dataArr):
  minCount = 0
  for number in dataArr:
    num = int(number)
    count = 0
    while (num % 2 == 0):
      num = num / 2
      count += 1
      if (minCount >= 1 and count >= minCount):
      	break
    minCount = count
    if (minCount == 0):
      return 0
  return minCount;

input()
data = input()
toOut = helper(data.split(" "))
print(toOut)

Measured memory_bytes: 3060
N=int(input())
*p,=map(float,input().split())
dp=[[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0]=1

for i in range(1,N+1):
    for j in range(N+1):
        if j:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
        else:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])

t=N//2+1 if N%2 else N//2
ans=0
for i in range(t,N+1):
    ans+=dp[N][i]

print(ans)

Measured memory_bytes: 259848
#include <stdio.h>

int main(void)
{
  int a,b,c,max=0,mid=0,min=0,ans=0;

  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  max=a;
  if(b>max){
    mid=a;
    max=b;
  }else{
    mid=b;
  }
  if(c>max){
    min=mid;
    mid=max;
    max=c;
  }else if(c>mid){
    min=mid;
    mid=c;
  }else{
    min=c;
  }

  ans=max*10+mid+min;
  printf("%d\n",ans);

  return(0);
}


Measured memory_bytes: 128
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '?') S[i] = 'D';
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 3756
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int i,j,width,height;
      while(true){
        height = sc.nextInt();
        width = sc.nextInt();
        if(height == 0 && width == 0){
          break;
        }
        for(i = 1;i <= height;i++){
          for(j = 1;j <= width;j++){
            if((i + j) % 2 == 0){
              System.out.print("#");
            }
            else{
              System.out.print(".");
            }
          }
          System.out.println();
        }
        System.out.println();
      }
  }
}

Measured memory_bytes: 35196
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;

/*
vector<int> z_algorithm(const string& s) {
	vector<int> prefix(s.size());
	for (int i = 1, j = 0; i < s.size(); i++)
	{
		if (i + prefix[i - j] < j + prefix[j]) {
			prefix[i] = prefix[i - j];
		}
	}
}
*/

int main() {
	
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << 0.5 << endl;
	}
	else {
		double x = 0.5 + (0.5 / (double)n);
		cout << x << endl;
	}

	return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    sort(A.rbegin(), A.rend());

    int64_t ans = 0;
    for(int i=1; i<N; i++) {
        ans += A[i/2];
    }

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


Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> x(m);
  for(Int i=0;i<m;i++) cin>>x[i];
  sort(x.begin(),x.end());
  if(m==1){
    cout<<0<<endl;
    return 0;
  }
  vector<Int> v(m-1);
  for(Int i=0;i+1<m;i++) v[i]=x[i+1]-x[i];
  sort(v.rbegin(),v.rend());
  Int ans=0;
  for(Int i=n-1;i+1<m;i++) ans+=v[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
/*
g++ -std=c++11 -o2 -Wall ABC102D.cpp -o ./out/ABC102D.out
./out/ABC102D.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n;
int a[200005];
ll ss[200005];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  ss[0] = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ss[i+1] = ss[i] + a[i];
  }
  ll ans = 10000000000000000;
  int lb, rb, mid;
  ll p, q, r, s;
  for (int m = 2; m <= n - 2; ++m) {
    int t1 = (int)(upper_bound(ss+1, ss+m, ss[m]/2) - ss);
    int t2 = (int)(upper_bound(ss+m+1, ss+n, (ss[n] - ss[m])/2 + ss[m]) - ss);
    for (int i = t1 - 1; i <= t1 + 1; ++i) for (int j = t2 - 1; j <= t2 + 1; ++j) for (int k = m - 1; k <= m + 1; ++k) {
      lb = i;
      rb = j;
      mid = k;
      if (1 <= lb && lb < mid && mid < rb && rb <= n - 1) {
//        cout << lb << " " << mid << " " << rb << "\n";
        p = ss[lb];
        q = ss[mid] - ss[lb];
        r = ss[rb] - ss[mid];
        s = ss[n] - ss[rb];
        ans = min(ans ,max({p, q, r, s}) - min({p, q, r, s}));
      }
    }
    /*
    cout << m << " " << t1 << " " << t2 << " " << m1 << " " << m2 << "\n";
    cout << p << " "<< q << " "<< r << " "<< s << " "<< "\n";
    */
  }
  cout << ans << "\n";
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Val, class Cmp, long long Inv>
struct StarrySkyTree {
    StarrySkyTree() {}
    StarrySkyTree(int n_) {
        for (n = 1; n < n_; n <<= 1);
        data = datb = vector<Val>(n << 1);
    }
    void add(int L, int R, Val x, int l, int r, int k) {
        if (L <= l && r <= R) {
            data[k] += x;
        } else if (l < R && L < r) {
            int mid = (l + r) >> 1;
            add(L, R, x, l, mid, (k << 1) + 1);
            add(L, R, x, mid, r, (k << 1) + 2);
            Val a = data[(k << 1) + 1] + datb[(k << 1) + 1];
            Val b = data[(k << 1) + 2] + datb[(k << 1) + 2];
            datb[k] = cmp(a, b) ? a : b;
        }
    }
    void add(int L, int R, Val x) {
        add(L, R, x, 0, n, 0);
    }
    Val query(int L, int R, int l, int r, int k) {
        if (L <= l && r <= R) {
            return data[k] + datb[k];
        } else if (l < R && L < r) {
            int mid = (l + r) >> 1;
            Val a = query(L, R, l, mid, (k << 1) + 1);
            Val b = query(L, R, mid, r, (k << 1) + 2);
            Val res = (cmp(a, b) ? a : b) + data[k];
            return res;
        } else {
            return Inv;
        }
    }
    Val query(int L, int R) {
        return query(L, R, 0, n, 0);
    }
    int n;
    vector<Val> data, datb;
    Cmp cmp;
};



void solve() {
    int N, M;
    cin >> N >> M;
    
    const int NN = 200005;
    static vector<pii> I[NN], O[NN];
    rep(i, M) {
        int l, r, a;
        cin >> l >> r >> a;
        I[l].emplace_back(r, a);
        O[r].emplace_back(l, a);
    }

    ll ans = 0;
    StarrySkyTree<ll, greater_equal<ll>, LLONG_MIN / 3> sst(N + 1);
    for (int i = 1; i <= N; ++i) {
        each(p, I[i]) {
            sst.add(0, i, p.second);
        }

        ll x = sst.query(0, i);
        smax(ans, x);
        sst.add(i, i + 1, x);

        each(p, O[i]) {
            sst.add(0, p.first, -p.second);
        }
    }

    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

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

typedef long long ll;
using namespace std;
const int maxn = 1e6+5;
void tlfclwx()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int k[maxn];
int main()
{
   int n;
   cin >> n;
   for(int i = 1; i <= n; i++)  cin >> k[i];
   int sum = 1;
   int flag = k[1];
   for(int i = 2; i <= n; i++) {
     if(k[i]<flag) {
        sum++;
        flag = k[i];
     }
   }
   cout << sum << endl;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split())) # list()
a.sort(reverse = True)
hanbun = a[0]/2
sa = []

for i in range(n):
    sa.append(abs(hanbun-a[i]))

num = sa.index(min(sa))
if(num == 0):
    num = 1
'''
print(hanbun)
print(sa)
print(num)
'''
print(a[0], end=' ')
print(a[num])


Measured memory_bytes: 14428
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
def resolve():
    S=input()
    st=set()
    for s in S:
        if s in st:print("no");return
        st.add(s)
    print("yes")
    
        
#%%submit!    
resolve()

Measured memory_bytes: 64080
;; F - Playing Tag on Tree

(defun main ()
  (let* ((N (read))  ; 頂点数
         (u (read))  ; 高橋君の位置
         (v (read))  ; 青木君(鬼)の位置
         (tree (read-tree N)))
    (princ (solve (1- u) (1- v) tree))
    (fresh-line)))

(defun solve (u v tree)
  (let* ((distance (distances-from v tree)) ; vから各頂点までの距離
         (dist-v-u (aref distance u)) ; vからuまでの距離
         (margin (floor (1- dist-v-u) 2)) ; 捕まらずにvまで近づける距離
         (max-dist (max-distance u margin tree distance)))
    (1- max-dist))) ; 最大距離-1 の頂点で捕まる

(defun max-distance (u margin tree distance)
  "distanceがmargin以下の頂点を通らずに
   uから到達可能な頂点のdistanceの最大値"
  (let* ((m (aref distance u))) ; 現時点の最大値
    (dfs u tree
         #'(lambda (v _) (setf m (max m (aref distance v))))
         #'(lambda (v) (> (aref distance v) margin)))
    m))

(defun distances-from (v tree)
  "頂点vから各頂点までの距離を表す配列を返す"
  (let* ((N (array-dimension tree 0)) ; 頂点数
         (distance (make-array N))) ; 各頂点までの距離
    (dfs v tree
         #'(lambda (u dist) (setf (aref distance u) dist))
         #'(lambda (u) t))
    distance))

(defun dfs (start tree operation next-cond)
  "treeに対して深さ優先探索を行い, 各頂点にoperationを適用.
   隣接頂点のうちnext-condを満たすもののみ選択される."
  (let* ((N (array-dimension tree 0)) ; 頂点数
         (visited (make-array N :initial-element nil))) ; 訪問済?
    (labels ((dfs-body (stack)
               (when stack
                 (let* ((payload (pop stack))
                        (v (car payload))
                        (dist (cdr payload)))
                   (unless (aref visited v)
                     (setf (aref visited v) t)
                     (funcall operation v dist)
                     (loop for next in (aref tree v) ; vの隣接頂点
                       when (funcall next-cond next)
                         do (push (cons next (1+ dist)) stack)))
                   (dfs-body stack)))))
      (dfs-body (list (cons start 0))))))

(defun read-tree (N)
  "N頂点の木をreadして作る. 頂点番号は0〜N-1"
  (let ((tree (make-array N))) ; 隣接リスト
    (loop for i below N do (setf (aref tree i) nil))
    (loop repeat (1- N)
      do (let ((a (read))
               (b (read)))
           (push (1- b) (aref tree (1- a)))
           (push (1- a) (aref tree (1- b)))))
    tree))

(main)


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

using namespace std;
using ll = long long;

int main() {
	ll n, m, ans = 0;
	cin >> n >> m;
	ans += n * (n - 1);
	ans += m * (m - 1);
	ans /= 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3536
import sys

sys.setrecursionlimit(10**8)

INF = int(1e9)

memo = [-1 for i in range(100000)]

def dp(at):
  if at >= n-1: return 0
  if memo[at] != -1: return memo[at]
  memo[at] = min((dp(at+1)+abs(stones[at]-stones[at+1])), (dp(at+2)+abs(stones[at]-stones[at+2])))
  return memo[at]

n = int(sys.stdin.readline())

stones = map(int, sys.stdin.readline().split())
stones.append(INF)
stones.append(INF)
print dp(0)

Measured memory_bytes: 90116
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 






ll calc(ll num,ll pr)
{
     ll res=0LL;
     ll t=pr;
     while((num/t)>0)
     {
          res+=num/t;
          t*=pr;
     }
     return res;
}







int main()
{
     ll n;
     cin>>n;
     ll ct2=0,ct5=0;
     ct2=calc(n/2,2LL);
     ct5=calc(n/2,5LL);
     if(n&1)
     {
          ll oct2=calc(n,2LL);
          ll oct5=calc(n,5LL);
          ll to2=max(0LL,oct2-ct2-n/2);
          ll to5=max(0LL,oct5-ct5);
          ll ans=min(to2,to5);
          cout<<ans;
     }
     else{
          ll ct10=min(ct2+n/2,ct5);
          cout<<ct10;
     }
     
     
}



















 
 
 
 
 

















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

using namespace std;

const int MAXN = 3e5 + 10;
const int MOD = 998244353;

long long n, a, b, k, fac[MAXN], answer;

long long po(long long v, long long u) {
	return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1;
}

long long ente(long long i, long long j) {
	long long res = (po(fac[i] , MOD - 2) * po(fac[j - i] , MOD - 2)) % MOD;
	res = (res * fac[j]) % MOD;
	return res;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> a >> b >> k;
	fac[0] = 1;
	for(int i = 1; i < MAXN; i++) {
		fac[i] = (fac[i - 1] * i) % MOD;
	}

	long long go = k / a;
	for (int i = 0; i <= min(n , go); i++) {
		long long local = k - i * a;
		if (local % b)
			continue;
		local /= b;
		if (local > n)
			continue;
		long long happy = ente(local , n) * ente(i , n);
		answer = (answer + happy) % MOD;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 2560
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

import qualified Data.Array as Arr

------------------------------------------

main :: IO ()
main = do
  [n, k] <- readInts
  if n == 0 && k == 0 then return ()
  else do
  arr <- Arr.listArray (0, n-1) <$> replicateM n readInt
  let s0 = foldl' (\acc idx -> acc + (arr Arr.! idx)) 0 [0..k-1]
      f (cand, prv) idx = let cand' = prv - (arr Arr.! idx) + (arr Arr.! (idx+k))
                          in (max cand cand', cand')
  let ans = fst $ foldl' f (s0, s0) [0..n-k-1]
  print ans
  main

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"

Measured memory_bytes: 44344
n = gets.to_i
a = gets.split.map(&:to_i)
b = []
n.times do |i|
  if i.even?
    b.push(a[i])
  else
    b.unshift(a[i])
  end
end
b.reverse! if n.odd?
b.each_with_index do |x, i|
  print " " unless i == 0
  print x
end
puts

Measured memory_bytes: 23556
#include <bits/stdc++.h>
using namespace std;
constexpr long N = 300000;
constexpr long mod = 998244353;

inline long mpow(long a, long p){
    long x=a;
    long y=1;
    while(p>0){
        if((p&1)==1){
            y=x*y%mod;
        }
        x=x*x%mod;
        p>>=1;
    }
    return y;
}

inline long minv(long a){
    return mpow(a, mod-2);
}

long fact[N+1];
long ncr[N+1];
inline void init_ncr(long n){
    long t=1;
    fact[0]=1;
    for(long i=1; i<=N; i++){
        t=t*i%mod;
        fact[i]=t;
    }
    for(long r=0; r<=n/2; r++){
        ncr[r] = fact[n]*minv(fact[n-r]*fact[r]%mod)%mod;
    }
    for(long r=0; r<=n/2; r++){
        ncr[n-r] = ncr[r];
    }
}

int main(void){
    long n, a, b, k;
    scanf("%ld %ld %ld %ld", &n, &a, &b, &k);
    init_ncr(n);
    long sum = 0;
    long s = max(0l, (k-n*b)/a);
    long e = min(n, k/a);
    for(long i=s; i<=e; i++){
        long q=(k-a*i)/b;
        long m=(k-a*i)%b;
        if(m==0){
            sum = (sum+ncr[i]*ncr[q])%mod;
        }
    }
    if(sum==0)sum++;
    printf("%ld\n", sum);
    return 0;
}


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  vl s, t;
  s.pb(-linf); t.pb(-linf);
  rep(i, a){
    ll z;
    cin >> z;
    s.pb(z);
  }
  rep(i, b){
    ll z;
    cin >> z;
    t.pb(z);
  }
  s.pb(linf); t.pb(linf);

  while(q--){
    ll x;
    cin >> x;

    int ss = lower_bound(all(s), x)-s.begin();
    int tt = lower_bound(all(t), x)-t.begin();

    ll ans = linf;
    rep(i, 2) rep(j, 2){
      ans = min(ans, abs(t[tt-i]-x)+abs(s[ss-j]-t[tt-i]));
      ans = min(ans, abs(s[ss-i]-x)+abs(t[tt-j]-s[ss-i]));
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int INF = INT_MAX / 4;

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

    vector<int> d(n);
    for(int i=0; i<n; ++i)
        cin >> d[i];
    sort(d.begin(), d.end());

    vector<int> x(m), y(m), z(m);
    for(int i=0; i<m; ++i)
        cin >> x[i] >> y[i] >> z[i];

    vector<int> cost(600001, INF);
    for(int i=0; i<n; ++i){
        for(int j=i; j<n; ++j){
            for(int k=d[j]-d[i]; k<=d[j]+d[i]; k+=2)
                cost[k] = 2;
        }
    }
    cost[0] = 0;
    for(int i=0; i<600001; ++i){
        for(int j=0; j<n; ++j){
            int k = i + d[j];
            if(k < 600001)
                cost[k] = min(cost[k], cost[i] + 1);

            k = abs(d[j] - i);
            if(k < 600001)
                cost[k] = min(cost[k], cost[i] + 1);
        }
    }

    vector<vector<int> > dp(1<<m, vector<int>(m, INF));
    for(int i=0; i<m; ++i){
        int dist = abs(x[i]) + abs(y[i]) + abs(z[i]);
        dp[1<<i][i] = cost[dist];
    }
    for(int i=0; i<(1<<m); ++i){
        for(int j=0; j<m; ++j){
            for(int k=0; k<m; ++k){
                int dist = abs(x[j] - x[k]) + abs(y[j] - y[k]) + abs(z[j] - z[k]);
                dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k], dp[i][j] + cost[dist]);
            }
        }
    }

    int ans = *min_element(dp.back().begin(), dp.back().end());
    if(ans < INF)
        cout << ans << endl;
    else
        cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 6804
#include<iostream>
using namespace std;
int DP(int x, int y);
int dp[3001][3001];
int a, b, c, d, e, f;
int main() {


	int i, j;
	for (i = 0; i <= 3000; i++) {
		for (j = 0; j <= 3000; j++) {
			dp[i][j] = -1;
		}
	}
	dp[0][0] = 1;
	cin >> a >> b >> c >> d >> e >> f;
	int maxi=0, maxj=0;
	for (i = 0; i <= f; i++) {
		for (j = 0; j <= f; j++) {
			if ((100+e) * j <= i * e) {
				if ((maxi == 0) && (maxj == 0)) {
					if (DP(i, j) == 1) {
						maxi = i; maxj = j;
					}
				}
				else {
					if (maxj * i < maxi * j) {
						if (DP(i, j) == 1) {
							maxi = i; maxj = j;
						}
					}
				}
			}
		}
	}
	//cout << dp[110][10];
	cout << maxi << ' ' << maxj << endl;
	return 0;

}
int DP(int x, int y) {
	if ((x < 0) || (y < 0)) { return 0; }
	if ((x == y) && (x > 0)) {
		dp[x][y] = 0;
		return 0;
	}
	if (dp[x][y] >= 0) {
		return dp[x][y];
	}
	else {
		if ((DP(x - 100 * a, y) == 1) || (DP(x - 100 * b, y) == 1) || (DP(x-c, y - c) == 1) || (DP(x-d, y - d) == 1)) {
			dp[x][y] = 1;
			return 1;
		}
		else {
			dp[x][y] = 0;
			return 0;
		}
	}
}

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

int n, x;
int a[110000];

int main() {

	cin >> n >> x;
	int leftover = x;
	for ( int i = 0;  i < n ;  i++)
	{
		cin >> a[i];
		leftover -= a[i];
	}
	if (leftover <= 0) {
		cout << n;
		exit(0);
	}
	int INF = 100000000;
	int res = INF;
	int ans;
	for (int i = 0; i < n; i++)
	{
		if (res > a[i]) res = a[i];
	}
	ans = leftover / res;
	cout << ans + n;

}

Measured memory_bytes: 256
# Aizu Problem 0093: Leap Yeark
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def is_leap_year(year):
    return year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)


first = True
while True:
    y1, y2 = [int(_) for _ in input().split()]
    if y1 == y2 == 0:
        break
    if first:
        first = False
    else:
        print()
    leap_years = [year for year in range(y1, y2 + 1) if is_leap_year(year)]
    if len(leap_years) == 0:
        print("NA")
    else:
        for year in leap_years:
            print(year)
        
        

Measured memory_bytes: 7900
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint c(n, 0);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            --a;
            c[a]++;
        }
    }

    int ans = 0;
    rep(i, n) if (c[i]==0) ans++;

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


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
const int inf = 1e+8;
template <typename X>
struct RMinQ{
  vector<X> dat;
  int n;
  X init;
  
  RMinQ(int _n,X _init)
  {
    n = 1;
    init = _init;
    while(n < _n) n *= 2;
    dat.resize(2*n-1);
    rep(i,2*n-1){
      dat[i] = init;
    }
  }
  
  void update(int k,X a)
  {
    k += n - 1;
    dat[k] = a;
    while(k > 0){
      k = (k - 1)/2;
      dat[k] = min(dat[2*k+1],dat[2*k+2]);
    }
  }
  
  X query(int a,int b,int k,int l,int r)
  {
    if(r<=a||b<=l) return init;

    if(a<=l&&r<=b) return dat[k];
    else{
      X vl = query(a,b,2*k+1,l,(l+r)/2);
      X vr = query(a,b,2*k+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
};

template <typename X>
struct RMaxQ{
  vector<X> dat;
  int n;
  X init;
  
  RMaxQ(int _n,X _init)
  {
    n = 1;
    init = _init;
    while(n < _n) n *= 2;
    dat.resize(2*n-1);
    rep(i,2*n-1){
      dat[i] = init;
    }
  }
  
  void update(int k,X a)
  {
    k += n - 1;
    dat[k] = a;
    while(k > 0){
      k = (k - 1)/2;
      dat[k] = max(dat[2*k+1],dat[2*k+2]);
    }
  }
  
  X query(int a,int b,int k,int l,int r)
  {
    if(r<=a||b<=l) return init;

    if(a<=l&&r<=b) return dat[k];
    else{
      X vl = query(a,b,2*k+1,l,(l+r)/2);
      X vr = query(a,b,2*k+2,(l+r)/2,r);
      return max(vl,vr);
    }
  }
};

int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];

  vector<int> rle(0);
  int cnt = 1;
  rep(i,n-1){
    if(p[i]<p[i+1]) cnt++;
    else{
      rle.push_back(cnt);
      cnt = 1;
    }
  }
  rle.push_back(cnt);

  vector<int> len(0);
  rep(i,rle.size()){
    while(rle[i]>0){
      len.push_back(rle[i]);
      rle[i]--;
    }
  }
  
  RMinQ<int> rminq(n,inf);
  RMaxQ<int> rmaxq(n,-1);

  bool f = false;
  if(len[n-k]>=k) f = true;  
  
  rep(i,n){
    rminq.update(i,p[i]);
    rmaxq.update(i,p[i]);    
  }

  int res = 1;
  rep(i,n-k){
    if(len[i]>=k){
      if(!f){
	res++;
	f = true;
      }
      continue;
    }
    int in = rminq.query(i,i+k,0,0,rminq.n);
    int ax = rmaxq.query(i+1,i+k+1,0,0,rmaxq.n);
    if(!(in==p[i]&&ax==p[i+k])) res++;
  }

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 6388
import math
N,K = map(int,input().split())
S = input()
seq = 1
v_seq = 1
down_list = []
count = 0
down_num = 0
ans = 0
chk = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        seq += 1
        v_seq += 1
    elif S[i] == "0":
        down_list.append(seq)
        seq = 1
        v_seq += 1
        count += 1
        if count == K:
            chk = 1
    else:
        if chk == 2:
            v_ans = v_ans + v_seq-down_list[v_count]
            v_count += 1
            ans = max(ans,v_ans)
        v_seq = 1
        seq += 1
        if chk == 1:
            ans = i+1
            v_ans = i+1
            v_count = 0
            chk = 2
if ans == 0:
    print(N)
else:
    v_ans = v_ans + v_seq-down_list[v_count]
    print(max(ans,v_ans))

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int D; cin >> D;
  cout << "Christmas";
  while (D < 25){
    cout << " Eve";
    D++;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define mod 1000000007

#define fi first
#define se second
int power(int x, int y, int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 


int modPow(int a, int x, int p) {
    int res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

int modInverse(int a, int p) {
    return modPow(a, p-2, p);
}
int modBinomial(int n, int k, int p) {

    int numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    int denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    return ( numerator* modInverse(denominator,p) ) % p;
}

int32_t main() 
{
  int n,a,b;
  cin >> n >> a >> b;
  int a1 = power(2, n, mod);
  int b1 = modBinomial(n, a, mod) + modBinomial(n, b, mod) + 1;
  b1 %= mod;
  int ans=a1-b1;
  if(ans<0)
  ans+=mod;
  cout << ans;



} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll h, w;
    cin >> h >> w;
    vector<string> board(h);
    REP(i, h) cin >> board.at(i);
    REP(i, board.size()) {
        if (count(ALL(board.at(i)), '.') == w) {
            board.erase(board.begin()+i);
            i--;
        }
    }

    REP(j, board.at(0).size()) {
        bool is_to_be_removed = true;
        REP(i, board.size()) {
            if (board.at(i).at(j) != '.') {
                is_to_be_removed = false;
                break;
            }
        }
        if (is_to_be_removed) {
            REP(i, board.size()) {
                board.at(i).erase(j, 1);
            }
            j--;
        }
    }

    for (auto elem : board) {
        cout << elem << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long int ll;


ll dp[102][100002];


int main(){
    ll N,W, w,v;
    cin >> N >> W;
    for(int i=1; i<=N; i++){
        cin >> w >> v;
        for(int j=0; j<=W; j++){
            if ((j-w)>=0){
                dp[i][j] = max(dp[i-1][j-w] + v, dp[i-1][j]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    // for(int i=0; i<=N; i++){
    //     cout << dp[i][W] << endl;
    // }
    cout << dp[N][W] << endl;
    return 0;
}

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

ll n;
int ans = 0;

int main() {
  cin >> n;
  vector<int> p(1000000, 0);
  rep (i, 1000000) {
    if (n%(i+2) == 0) {
      n /= (i+2);
      p[i]++;
      i--;
    }
  }
  rep (i, 1000000) {
    rep (j, 50) {
      if (p[i] -j-1 >= 0) {
        p[i] -= j+1;
        ans++;
      }
    }
  }
  if (n != 1) ans++;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);
  string s; cin >> s;

  string tmp;
  REP(i, SZ(s)) {
    if(s[i] != 'x') tmp.pb(s[i]);
  }
  bool ok = true;
  REP(i, SZ(tmp)/2) {
    if(tmp[i] != tmp[SZ(tmp)-1-i]) {
      ok = false;
      break;
    }
  }
  if(!ok) {
    cout << -1 << endl;
    return 0;
  }
  vi v1, v2;
  int ans = 0;
  if(SZ(tmp) % 2) {
    v1.resize(SZ(tmp)/2+1);
    v2.resize(SZ(tmp)/2+1);
  } else {
    v1.resize(SZ(tmp)/2);
    v2.resize(SZ(tmp)/2);
  }
  int l = -1, r = SZ(s);
  while(l < r) {
    int x1 = 0, x2 = 0;
    l++; r--;
    while(s[l] == 'x') {
      x1++;
      l++;
    }
    while(s[r] == 'x') {
      x2++;
      r--;
    }
    if(l <= r) ans += abs(x1 - x2);
    //cout << l << ":" << r << ":" << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main () {
	int N;
	cin >> N;
	int AC=0, WA=0, RE=0, TLE=0;
	string s;
	for (int i=0; i<N; i++) {
		cin >> s;
		if (s.compare("AC")==0) {
			AC++;
		}
		else if (s.compare("WA")==0) {
			WA++;
		}
		else if (s.compare("RE")==0) {
			RE++;
		}
		else {
			TLE++;
		}
	}
	cout << "AC x " << AC << endl << "WA x " << WA << endl << "TLE x " << TLE << endl << "RE x " << RE << endl;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;

    vec<ll> rr(n), cc(n);
    REP(i, n) {
        cin >> rr[i] >> cc[i];
    }

    vec<ll> o(8);
    REP(i, 8) {
        o[i] = i;
    }

    do {
        vec<ll> rc(8, -1);
        vec<bool> flagx(8, false), flagy(8, false), flagr(16, false), flagl(16, false);
        REP(i, n) {
            int r = rr[i];
            int c = cc[i];
            rc[r] = c;
            flagx[r] = true;
            flagy[c] = true;
            flagr[r + c] = true;
            flagl[c - r + 7] = true;
        }
        bool flag = true;
        REP(i, 8) {
            if(rc[i] != -1) {
                if(rc[i] != o[i]) {
                    flag = false;
                    break;
                }
            } else {
                int j = o[i];
                if(flagx[i] or flagy[j] or flagr[i + j] or flagl[j - i + 7]) {
                    flag = false;
                    break;
                }
                flagx[i] = true;
                flagy[j] = true;
                flagr[i + j] = true;
                flagl[j - i + 7] = true;
            }
        }
        if(!flag)
            continue;
        REP(i, 8) {
            string s(8, '.');
            s[o[i]] = 'Q';
            cout << s << en;
        }
        return;
    } while(next_permutation(all(o)));
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}



Measured memory_bytes: 3232
<?php

list($a, $b) = explode(" ", trim(fgets(STDIN)));

function lcm($a, $b) {
    return $a * $b / gcd($a, $b);
}

function gcd($a, $b) {
    if($a < $b) return gcd($b, $a);
    if($b == 0) return $a;
    return gcd($b, $a % $b);
}

echo lcm($a, $b)."\n";

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
int main() {
int A,B,C,D,E,F,sum,hajime,saigo;
cin >> A >> B;
C = A;
while (C <= B) {
  	D = C /10000;
 	E = C /1000 - D*10;
  	F = C /100 - 100 * D - 10 * E;
 	C = 10000*D + 1000*E + 100*F + 10 * E + D;
  	if (C < A) {
      sum --;
    }
    sum ++;
    C += 100;
}
  cout << sum << endl;
}

Measured memory_bytes: 256