akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;
const int MOD=1000000007;

int main() {
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  double ans=(w*h)/2.0;
  if(w%2==0 && w/2==x && h%2==0 && h/2==y)
  cout << ans << " " << 1 << endl;
  else
  cout << ans << " " << 0 << endl;
}

Measured memory_bytes: 3780
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int n,A,B,C;
const int inf=1e9;
vector<int> l;
int dfs(int cur,int a,int b,int c)
{
	if(cur==n)
	{	if(min({a,b,c})>0)
		return(abs(C-c)+abs(B-b)+abs(A-a)-30);
		else return inf;
	}
	int r1=dfs(cur+1,a,b,c);
	int r2=dfs(cur+1,a+l[cur],b,c)+10;
	int r3=dfs(cur+1,a,b+l[cur],c)+10;
	int r4=dfs(cur+1,a,b,c+l[cur])+10;
	return min({r1,r2,r3,r4});
}
int32_t main()
{
	n=in();A=in();B=in();C=in();
	l=vector<int>(n);
	trav(i,l){i=in();}
	cout<<dfs(0,0,0,0);
	
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPR(i, N) for (ll i = (N)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  ll N, W;
  std::cin >> N >> W;
  ll w[N];
  ll v[N];
  REP(i, N) { std::cin >> w[i] >> v[i]; }
  ll dp[100001];
  REP(i, 100001) { dp[i] = -1; }
  dp[0] = 0;
  ll M = 0;
  REP(i, N) {
    REPR(j, M + 1) {
      if (dp[j] == -1)
        continue;
      if (dp[j + v[i]] == -1) {
        dp[j + v[i]] = w[i] + dp[j];
      } else {
        dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
      }
      M = max(M, j + v[i]);
    }
  }
  ll ans = 0;
  REPR(i, M + 1) {
    if (dp[i] <= W && dp[i] != -1) {
      ans = max(ans, i);
    }
  }
  // std::cout << M << '\n';
  std::cout << ans << '\n';
  // REP(i, M + 1) { std::cout << dp[i] << ' '; }
  // std::cout << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }



int main() {
	int n, m, s, t;
	cin >> n >> m;
	vector<int> u(m);
	vector<int> v(m);
	vector<bool> v1(n,false);
	vector<bool> v2(n,false);
	vector<int> d(n,INT_MAX);
	vector<vector<int>> path(n);
	REP(i, m) {
		cin >> u[i] >> v[i];
		u[i]--;
		v[i]--;
		path[u[i]].push_back(v[i]);
	}
	cin >> s >> t;
	s--; t--;
	queue<int> q;
	q.push(s);
	d[s] = 0;
	while (!q.empty()){
		int p = q.front();
		q.pop();
		REP(i, path[p].size()) {
			if (!v1[path[p][i]]) {
				v1[path[p][i]] = true;
				REP(j, path[path[p][i]].size()) {
					if (!v2[path[path[p][i]][j]]) {
						v2[path[path[p][i]][j]] = true;
						REP(k, path[path[path[p][i]][j]].size()) {
							int temp = path[path[path[p][i]][j]][k];
							if (d[temp] == INT_MAX) {
								d[temp] = d[p] + 1;
								q.push(temp);
							}
						}
					}
				}
			}
			
		}
	}
	if (d[t] == INT_MAX) {
		put(-1);
	}
	else {
		put(d[t]);
	}
	return 0;
}


Measured memory_bytes: 6912
using System;

class Atcoder116
{
    public static void Main()
    {
        string b = Console.ReadLine();

        if (b == "A")
            Console.WriteLine("T");
        else if (b == "T")
            Console.WriteLine("A");
        else if (b == "G")
            Console.WriteLine("C");
        else
            Console.WriteLine("G");
    }
}

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

long long int kansu( string s, long long int k ) {

  if ( s[k] != 'm' ) return -1;
  k++;
  if ( s[k] == 'm' ) k = kansu( s, k );
  if ( k == -1 ) return -1;
  if ( s[k] != 'e' ) return -1;
  k++;
  if ( s[k] == 'm' ) k = kansu( s, k );
  if ( k == -1 ) return -1;
  if ( s[k] != 'w' ) return -1;

  return k + 1;

}

int main() {

  string s;
  cin >> s;

  if ( kansu( s, 0LL ) == s.size() ) {
    cout << "Cat" << endl;
  }else {
    cout << "Rabbit" << endl;
  }


  return 0;

}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  vector<int> m(N);
  for (int i = 0; i+1 < N; i++){
    m.at(i) = A.at(i+1) - A.at(i);
  }
  m.at(N-1) = (K - A.at(N-1)) + A.at(0);
  sort(m.begin(), m.end());
  int result = 0;
  for (int i = 0; i+1 < N; i++){
    result += m.at(i);
  }
  cout << result << endl;
}

Measured memory_bytes: 1792
from itertools import permutations
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
a1=sorted(a)
b1=sorted(b)
a2=list(permutations(a1))
b2=list(permutations(b1))
ans1=a2.index(tuple(a))
ans2=b2.index(tuple(b))
print(abs(ans1-ans2))


Measured memory_bytes: 50928
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ans = 0
minui = 1000000
u = [a,b,c,e,d]
for i in range(len(u)):
    if u[i]%10==0:
        ans += u[i]
        # print(u[i])
    else:
        if (minui>u[i]%10)and(u[i]!=0):
            minui=u[i]%10
        ans += u[i]-u[i]%10+10
        # print(u[i]-u[i]%10+10)


if(minui == 1000000):
    minui=10


     


print(ans-10+minui)

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

using namespace std;

long long int N, H, sord[200001] = {}, a, b, ans = 0;

int main() {
	cin >> N >> H;
	for (int i = 1; i <= N; i++) {
		cin >> a >> b;
		sord[i * 2 - 1] = a * 10;
		sord[i * 2] = b * 10 + 5;
	}
	stable_sort(sord, sord + N * 2 + 1);
	for (int i = 2 * N; i >= 1; i--) {
		if (sord[i] % 10 == 5) {
			H -= sord[i] / 10;
			ans++;
		}
		else {
			if (H % (sord[i] / 10) == 0) {
				cout << ans + H / (sord[i] / 10) << endl;
			}
			else {
				cout << ans + H / (sord[i] / 10) + 1 << endl;
			}
			return 0;
		}
		if (H <= 0) {
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 2560
from functools import lru_cache


def get_bit(n, d):
    return (n >> d) & 1


@lru_cache(maxsize=None)
def xor(bit, digit):
    """
    A の各要素について右から digit 桁目を bit で XOR した合計
    :param int bit:
    :param int digit:
    :return:
    """
    assert bit in [0, 1]
    # bit <<= digit
    # mask = 1 << digit
    # return sum([(a ^ bit) & mask for a in A])
    if bit == 0:
        return bit_counts[digit] << digit
    else:
        return (N - bit_counts[digit]) << digit


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

DIGIT = 50
bit_counts = [sum([get_bit(a, d=d) for a in A]) for d in range(DIGIT)]

# [桁][k 未満の桁をえらんだことがあるか]
dp = [[-float('inf') for _ in range(2)] for _ in range(DIGIT + 1)]
# dp = np.empty([DIGIT + 1, 2], dtype=int)
# dp.fill(-np.inf)

dp[-1][0] = 0
for d in reversed(range(DIGIT)):
    k = get_bit(K, d=d)
    # bit=k
    dp[d][0] = max(dp[d][0], dp[d + 1][0] + xor(bit=k, digit=d))
    # k==1 なら bit=0 も OK
    if k == 1:
        dp[d][1] = max(dp[d][1], dp[d + 1][0] + xor(bit=0, digit=d))
    # k 未満の桁をえらんだことがあるなら bit にどっちを選んでも OK
    dp[d][1] = max(dp[d][1], dp[d + 1][1] + xor(bit=0, digit=d))
    dp[d][1] = max(dp[d][1], dp[d + 1][1] + xor(bit=1, digit=d))

print(max(dp[0]))


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

int main() {
  int N, cnt=0;
  cin >> N;
  for(int i=1; i<=N; i++){
    if(1<=i && i<=9) cnt++;
    else if(100<=i && i<=999) cnt++;
    else if(10000<=i && i<=99999) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define int long long
const int maxn=100001;
int n,m,x,y,link,ans,c[maxn];
vector<pair<int,int>>e[maxn];
int col[maxn],sum,flag,cnt[4];
void dfs(int x)
{
    sum++;
    for(auto now:e[x])
    {
        int v=now.first,w=now.second;
        link++;
        if(col[v])
        {
            if(col[v]!=(col[x]-1+3+w)%3+1)flag=1;
        }
        else
        {
            col[v]=(col[x]-1+w+3)%3+1,cnt[col[v]]++;
            dfs(v);
        }
    }
}
signed main()
{
	cin>>n>>m;
    for(int i=1;i<=m;i++)
        cin>>x>>y,
        e[x].push_back(make_pair(y,1)),
        e[y].push_back(make_pair(x,-1));
    for(int i=1;i<=n;i++)
    if(!col[i])
    {
        cnt[1]=cnt[2]=cnt[3]=link=sum=flag=0;
        col[i]=1;cnt[1]++;
        dfs(i);link/=2;
        //cout<<cnt[1]<<" "<<cnt[2]<<" "<<cnt[3]<<endl;
        //cout<<flag<<" "<<sum<<" "<<link<<endl;
        if(flag==1)ans+=sum*sum;
        else if(cnt[1]&&cnt[2]&&cnt[3])ans+=cnt[1]*cnt[2]+cnt[2]*cnt[3]+cnt[3]*cnt[1];
        else ans+=link;
    }
    cout<<ans;


}
/*
30 10
2 4
2 5
12 13
21 12
24 5
1 27
21 7
27 3
18 35
3 6
我知道，我会，这是套路，二分之后变01。
然后陷入了沉默
30min之后自暴自弃打了个表
又看了30min，各种数据都打出来还是不会做
最后看题解去了
？？？？？
真就打表大胜利啊？
为什么这个规律是视觉意义上的啊？？？

快乐连边。
一旦有两条首尾相连的边，就连回来。
然后把所有联通块分开考虑。
一个点的一轮贡献是它出度和入度的混搭对吧。如果是DAG就直接倒过来转移更新就好。
可是不是DAG，所以会出现后效性。
……
三染色是聪明的方案。令答案只有三种，红->绿 绿->蓝 蓝->红
如果染色失败，红点A连向红点B，红点B存在一堆绿出边，这些绿点回到红点A，绿点又有蓝出边，总之最后无限循环。完全图。
否则，红点连向所有绿点，其他情况也是。
这容易证明对吧。如果一个红点x不和一个绿点y链接：
红点存在绿出边，绿点存在蓝出边集合，蓝点存在红出边集合。
1：这个集合为当前红点集合
y的连边在蓝点集合中，此时y->蓝->x->y，联通。
y的连边不在蓝集合中，此时从x出发所有点都已经遍历，若如此，则xy不在同一联通块。
2：这个集合存在其他红点
重复这个过程，把其他红点加入红点集合，不断遍历点，直到回到1情况。
如果存在不合法边，那么根据这个理，整个图会彼此联通。
然后这个题就做完了。
*/ 

Measured memory_bytes: 17656
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007;

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    int r = n%10;
    if(r == 2 || r == 4 || r == 5 ||r == 7 ||r == 9)
        cout<<"hon";
    else if( r== 3)
        cout<<"bon";
    else
        cout<<"pon";

    return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//入力を受け取るためのScanner型インスタンスscanner
		Scanner scanner = new Scanner(System.in);

		//価格を格納する変数
		int price = scanner.nextInt();
		//嫌いな数字の個数を格納する変数
		int numOfElements = scanner.nextInt();
		//嫌いな数字を格納する配列
		int[] dislikeNums = new int[numOfElements];

		//配列に格納
		for (int i = 0; i < dislikeNums.length; i++) {
			dislikeNums[i] = scanner.nextInt();
		}
		scanner.close(); //scannerに使用しているメモリを解放

		/*支払額の候補を1円ずつ増加させて、
		 条件を満たしているかどうか確認する*/
		boolean flag = false; //条件を満たしているかどうかを管理する変数
		String stringPay; //payをString型に変換したものを格納する変数
		ArrayList<Integer> payArray = new ArrayList<Integer>();// 支払予定額に使われている数字を格納するArrayList
		int pay = 0; //支払予定額を格納する変数

		updateLoop: //支払予定額を更新するループ
		for (pay = price;; pay++) {

			//flagの初期値を設定（支払予定額が条件に合致すると仮定する)
			flag = false;

			//payを分解して、配列payArrayに1文字ずつ格納する
			stringPay = String.valueOf(pay);//payを分解する準備として、int型をString型に変換する

			for (int i = 0; i < stringPay.length(); i++) {
				//char型をInt型に変換することで、Integer型のArrayListに格納する
				payArray.add(Character.digit(stringPay.charAt(i), 10));
			}

			detectLoop: //要素を照合するループ
			for (Integer dislikeNum : dislikeNums) {
				flag = payArray.contains(dislikeNum);
				/*もし支払予定額に嫌いな数字が含まれていたならば、
				照合ループを抜けて支払予定額を更新する*/
				if (flag == true) {
					break detectLoop;
				}
			}
			/*flagが更新されなかったら（支払予定額が条件に合致すれば）、
			ループを抜ける */
			if (flag == false) {
				break updateLoop;
			}
			payArray.clear(); //次のループに持ち越されないように、ArrayListの中身を空にする

		}
		System.out.println(pay);
	}

}

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

struct node{
  int val;
  node* prv;
  node* nxt;
  node():prv(nullptr),nxt(nullptr){}
  node(int v):val(v),prv(nullptr),nxt(nullptr){}
};
struct mylist{
  node* head;
  node* tail;
  node* cur;
  mylist(){
    head = new node;
    tail = new node;
    head->nxt = tail;
    tail->prv = head;
    cur = tail;
  }
  void insert(int v){
    node* add = new node(v);
    cur->prv->nxt = add;
    add->prv = cur->prv;
    add->nxt = cur;
    cur->prv = add;
    cur = add;
  }
  void dump(){
    node* tmp = head->nxt;
    while(tmp->nxt!=nullptr){
      cout<< tmp->val <<endl;
      tmp = tmp->nxt;
    }
  }
  void move(int d){
    while(d){
      if(d<0){
        cur = cur->prv;
        d++;
      }else{
        cur = cur->nxt;
        d--;
      }
    }
  }
  void erase(){
    cur->prv->nxt = cur->nxt;
    cur->nxt->prv = cur->prv;
    cur = cur->nxt;
  }
};

signed main(){

  mylist lis;
  int q;cin>>q;
  while(q--){
    int com;cin>>com;
    if(com==0){
      int x;cin>>x;
      lis.insert(x);
    }
    else if(com==1){
      int d;cin>>d;
      lis.move(d);
    }
    else{
      lis.erase();
    }
  }
  lis.dump();

}


Measured memory_bytes: 18660
package main

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

type item struct {
  data int
  prev *item
  next *item
}

type doublyLinkedList struct {
  origin *item
}

func newDoublyLinkedList() *doublyLinkedList {
  origin := &item{}

  origin.prev = origin
  origin.next = origin

  return &doublyLinkedList{
    origin: origin,
  }
}

func (d *doublyLinkedList) insert(x int) {
  newItem := &item{
    data: x,
    prev: d.origin,
    next: d.origin.next,
  }

  d.origin.next.prev = newItem
  d.origin.next = newItem
}

func (d *doublyLinkedList) deleteItem(it *item) {
  if it == d.origin {
    return
  }

  it.next.prev = it.prev
  it.prev.next = it.next

  it = nil
}

func (d *doublyLinkedList) deleteX(x int) {
  it := d.origin
  for {
    it = it.next
    if it.data == x {
      d.deleteItem(it)
      return
    } else if it == d.origin {
      return
    }
  }
}

func (d *doublyLinkedList) deleteFirst() {
  d.deleteItem(d.origin.next)
}

func (d *doublyLinkedList) deleteLast() {
  d.deleteItem(d.origin.prev)
}

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())

  dll := newDoublyLinkedList()

  for i := 0; i < n; i++ {
    sc.Scan()
    command := strings.Fields(sc.Text())

    switch command[0] {
    case "insert":
      x, _ := strconv.Atoi(command[1])
      dll.insert(x)
    case "delete":
      x, _ := strconv.Atoi(command[1])
      dll.deleteX(x)
    case "deleteFirst":
      dll.deleteFirst()
    case "deleteLast":
      dll.deleteLast()
    }
  }

  buf := bytes.Buffer{}
  it := dll.origin.next
  if it == dll.origin {
    return
  }
  for {
    buf.WriteString(strconv.Itoa(it.data))
    it = it.next
    if it == dll.origin {
      break
    }
    buf.WriteString(" ")
  }
  fmt.Println(buf.String())
}


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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
 
#define INF 10e17
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
 
int main() {
    long long int n;
    cin >> n;

    vector<long long int> v(n);
    long long int i, j;
    for(i = 0; i < n; i++){
        cin >> v[i];
    }

    long long int l, r, mid;
    long long int dp[400][400];

    for(i = 0; i < n; i++){
        for(j = i; j < n; j++){
            dp[i][j] = INF;
        }
    }

    for(i = 0; i < n; i++){
        dp[i][i] = 0;
        dp[i][i+1] = v[i] + v[i+1];
    }

    long long int cumsum[n+1];
    cumsum[0] = 0;
    for(i = 0; i < n; i++){
        cumsum[i+1] = cumsum[i] + v[i];
    }

    for(i = 3; i <= n; i++){
        for(j = 0; j <= n-i; j++){
            l = j;
            r = l + i - 1;

            for(mid = l; mid < r; mid++){
                dp[l][r] = min(dp[l][r], dp[l][mid]+dp[mid+1][r]+(cumsum[mid+1]-cumsum[l])+(cumsum[r+1]-cumsum[mid+1]));
            }
        }
    }

    /*
    for(i = 0; i < n; i++){
        for(j = i; j < n; j++){
            cout << "(" << i << " " << j << "):";
            cout << dp[i][j] << endl;
        }
    }
    */

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


Measured memory_bytes: 1536
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int h, a;
    scanf("%d%d", &h, &a);
    int ans = h / a;
    if (h % a)
    {
        ans ++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int N;
  	cin >> N;
  	int A[N], B[N], C[N];

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

  	int ans = 0;
  	for(int i=0;i<N;i++){
  		ans += B[A[i]-1];
  	}
  	for(int i=0;i<N-1;i++){
  		if(A[i]+1==A[i+1]) ans += C[A[i]-1];
  	}

  	cout << ans <<endl;

  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main(int argc, char *argv[]){
        long long sum = 0;
        long long len = 0;
        scanf("%lld",&len);
        for(int i = 0; i <= len;i++){
                if((i % 3) == 0 || (i % 5) == 0){
                        continue;
                }
                else{
                        sum += i;
                }
        }
        printf("%lld\n",sum);
        return 0;
}

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

// 0-based numbering; O(E*V^2);
template<class Numeric> struct Dinic {
    struct edge {
        int to; Numeric cap; int rev;
        edge(int t, Numeric c, int r){
            to = t; cap = c; rev = r;
        }
        void print() {
            cout << to << "\t" << cap << "\t" << rev << endl;
        }
    };
    vector< vector<edge> > g; vector<int> iter, level;
    int N; Numeric INF;
    Dinic(int n) {
        N = n; g.resize(N); iter.resize(N); level.resize(N);
        INF = numeric_limits<Numeric>::max();
    }
    void add(int from, int to, Numeric cap) {
        g[from].push_back(edge(to, cap, (int) g[to].size()));
        g[to].push_back(edge(from, 0, (int) g[from].size()-1));
    }
    void bfs(int s){
        level.assign(N,-1);
        queue<int> q;
        level[s] = 0; q.push(s);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for(int i = 0; i < (int) g[v].size(); i++){
                edge &e = g[v][i];
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }
    Numeric dfs(int v, int t, Numeric f) {
        if (v == t) return f;
        for (int i = iter[v]; i < (int) g[v].size(); i++) {
            edge &e = g[v][i];
            if (e.cap > 0 && level[v] < level[e.to]){
                Numeric d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    Numeric solve(int s, int t) {
        Numeric flow = 0;
        while(true){
            bfs(s);
            if (level[t] < 0) return flow;
            iter.assign(N, 0);
            Numeric f;
            while ((f = dfs(s, t, INF)) > 0){
                flow += min(f, INF-flow);
                if (flow == INF) return flow;
            }
        }
    }
};

int main() {
    int h, w; cin >> h >> w;
    queue<int> x, y;
    int n = h + w;
    Dinic<int> f(n+2);
    for (int i = 0; i < h; i++) {
        string s; cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == 'o') {
                f.add(i, h+j, 1);
                f.add(h+j, i, 1);
            }
            if (s[j] == 'S') {
                f.add(n, i, f.INF);
                f.add(n, h+j, f.INF);
            }
            if (s[j] == 'T') {
                f.add(i, n+1, f.INF);
                f.add(h+j, n+1, f.INF);
            }
        }
    }
    int ans = f.solve(n, n+1);
    if (ans == f.INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)
*/

f(A, B, C, D, "Yes") :- C =< 0, !.
f(A, B, C, D, "No") :- A =< 0, !.
f(A, B, C, D, X) :- A2 is A - D, C2 is C - B, f(A2, B, C2, D, X).

main :-
    get_number(A, B),
    get_number(C, D),
    f(A, B, C, D, X),
    writeln(X).


Measured memory_bytes: 8084
# A106633
def f(n):
  res=1+2*n
  i=1
  while i*i<=n:
    res+=1+(n-i*i)//i*2
    i+=1
  return res

while 1:
  n=int(input())
  if n==0: break
  print(8*f(n//2-1)+8*n)

Measured memory_bytes: 6720
#include<stdio.h>

main(){
  int i,n,v,j,k;
    
    scanf("%d",&n);
    
    int A[n];
    
    for(i=0;i<n;i++)
      {
	scanf("%d",&A[i]);
      }
    
    
    for(i=1;i<n;i++)
      {
	for(k=0;k<n;k++)
	  {
	    printf("%d",A[k]);
	    if(k+1!=n){
	        printf(" ");
	    }
	  }
	printf("\n");
	
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v)
        {
	  A[j+1]=A[j];
	  j--;
	}
	A[j+1]=v;
      }
    
    for(i=0;i<n;i++)
      {
        printf("%d",A[i]);
        if(i+1!=n){
            printf(" ");
        }
        
	}
   printf("\n");
}




Measured memory_bytes: 2124
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void*b){
   if(*(int *)a<*(int *)b) return 1;
   return -1;
}
int main()
{   int h,n,ans=0;
    scanf("%d%d",&n,&h);
    int a[n],b[n];
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    qsort(a,n,sizeof(int),compare);
    qsort(b,n,sizeof(int),compare);
    int k=0;
    
    while(h>0){
        if(k>=n||a[0]>=b[k]){
            ans+=(h%a[0]==0?h/a[0]:h/a[0]+1);
            break;
        }else{
            h-=b[k];
            ans++;
            k++;
        }
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 1404
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;

}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;
}


Node treeSearch(Node x, int k){
  while(x!=NIL&&k!=x->key){
    if(k<x->key)
      x=x->left;
    else
      x=x->right;
  }
    return x;
  
}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)
    y=z;
  else
    y=treeSuccessor(z);
  if(y->left!=NIL)
    x=y->left;
  else
    x=y->right;
  if(x!=NIL)
    x->parent=y->parent;
  if(y->parent==NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right=x;

  if(y!=z)
    z->key=y->key;
  


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }

  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else
    y->right=z;


}


void inorder(Node x){
  if(x!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}

void preorder(Node x){
  if(x!=NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
  
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
import bisect

N = int(input())

v_list = list(map(int, input().split()))

v_list = sorted(v_list)

while(1):
    if len(v_list) == 1:
        break
    v1 = v_list.pop(0)
    v2 = v_list.pop(0)
    v = (v1+v2) / 2

    index = bisect.bisect_left(v_list, v)
    v_list.insert(index, v)

print(v_list[0])

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

int main(){
  int r, c, temp, sum;
  int col_sum[100] = {};
  cin >> r >> c;
  for(int i=0; i<r; i++){
    sum=0;
    for(int j=0; j<c; j++){
        cin >> temp;
        cout << temp << " ";
        sum += temp;
        col_sum[j] += temp;
    }
    cout << sum << endl;
    sum = 0;
  }
  for(int i=0; i<c; i++){
      cout <<  col_sum[i] << " ";
      sum += col_sum[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
#define MAX 100001
int ord[MAX],low[MAX],cost[MAX],a[MAX],n,m,x,y,o;
vector<int>v[MAX],v_[MAX];
int lowlink_ant_Lib(int p, int par) {
	int res=a[p];
    low[p]=ord[p]=o++;
    r(i,v[p].size()){
        if(ord[v[p][i]]==-1) {
        	v_[p].push_back(v[p][i]);
            res+=lowlink_ant_Lib(v[p][i],p);
            low[p]=min(low[p],low[v[p][i]]);
        }
        else if(v[p][i]!=par)
        	low[p]=min(low[p],ord[v[p][i]]);
    }
    return cost[p]=res;
}
main(){
	memset(ord,-1,sizeof(ord));
	cin>>n>>m;
	r(i,n)scanf("%ld",&a[i]);
	r(i,m){
		scanf("%ld%ld",&x,&y);
		v[--x].push_back(--y);
		v[y].push_back(x);
	}
	lowlink_ant_Lib(0,-1);
	r(i,n){
		int sum=cost[0]-cost[i],ans=0;
		r(j,v_[i].size()){
			if(ord[i]>low[v_[i][j]])sum+=cost[v_[i][j]];
			else ans=max(ans,cost[v_[i][j]]);
		}
		printf("%ld\n",max(ans,sum));
	}
}

Measured memory_bytes: 16648
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=60;

int n,a[maxn];

int main(){
    n=read();
    int mx=-1,mxi=0;
    for(int i=1;i<=n;i++){a[i]=read();if(abs(a[i])>mx){mx=abs(a[i]);mxi=i;}}
    printf("%d\n",n*2-2);
    for(int i=1;i<=n;i++)if(i!=mxi)printf("%d %d\n",mxi,i);
    if(a[mxi]>=0){
    	for(int i=2;i<=n;i++)printf("%d %d\n",i-1,i);
    }
    else{
    	for(int i=n-1;i>=1;i--)printf("%d %d\n",i+1,i);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define fir first
#define sec second 
#define fast ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
using namespace std;
ll t,n,m,k,x,y,sum,con,ans;
ll a[2020202],b[2020202],frq[2020202];
pair<ll,ll>p;
vector<ll>v;
map<ll,ll>mp;
//set<ll>s;
string s;
int main(){
	fast;
	for(int i=1;i<=5;i++)
		cin>>a[i];
	for(int i=1;i<=5;i++)
		if(!a[i])	
			cout<<i;
	
}

Measured memory_bytes: 3652
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, D;
    cin >> N >> D;

    int cnt = 0, v = 0;
    while(v < N) cnt++, v += 2 * D + 1;

    print(cnt);
    
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    vector<int> l(n);

    REP(i, n)
    {
        cin >> l[i];
    }
    int ans = 0;
    FOR(i,0, n)
    {
        FOR(j, i+1, n)
        {
            FOR(k, j+1, n)
            {
                if (l[i] == l[j])continue;
                if (l[j] == l[k])continue;
                if (l[k] == l[i])continue;
                if (l[i] + l[j] > l[k] &&
                    l[i] + l[k] > l[j] &&
                    l[k] + l[j] > l[i])
                {
                    ans++;
                }
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) {
    if(b==0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
    return a/gcd(a,b)*b;
}
int main() {
    int n; cin >> n;
    vector<ll> T(n);
    rep(i, n) cin >> T[i];
    ll ans = 1;
    rep(i, n) {
        ans = lcm(ans, T[i]);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>a,b;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
		b.push_back(x);
	}
	sort(b.begin(),b.end());
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now=a[i];
		auto itr=lower_bound(b.begin(),b.end(),now);
		ll iti=itr-b.begin();
		//cout << iti<<endl;
		if(abs(iti-(i))%2!=0){
			ans++;
		}
	}
	cout <<ans/2;
	// your code goes here
	return 0;
}

Measured memory_bytes: 2036
#include<iostream>
#include<queue>
using namespace std;
int main(){
  int n, x, cnt=1;
  cin >> n;
  queue<int> que;

  	for(int i=0; i<n; i++){
      cin >> x;
      if(cnt == x){
        que.push(x);
        cnt += 1;
      }
    }
  	
	if(cnt==1){
      cout << -1 << endl;
    }else{
      cnt = n - (cnt-1);
      cout << cnt << endl;
    }
  

}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b;
   cin >> a >> b;
   cout << max(0, a - 2 * b) << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i,N){
    cin >> p.at(i);
  }
  int ans = 0;
  sort(p.begin(), p.end());
  rep(i,K){
    ans += p.at(i);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>

int main(){

int cnt = 0;//カウント
char S[3] = {};
std::cin >> S[0] >> S[1] >>S[2];

if (S[0] == 'o'){

cnt += 1;

}if (S[1] == 'o'){

cnt += 1;

}if (S[2] == 'o'){

cnt += 1;

}

std::cout << 700+cnt*100<<std::endl;

return 0;

}

Measured memory_bytes: 256
package main

import (
  "math"
  "fmt"
)

func ShiftOnly(A []int) int{
	var counts, tmp int

	for A[0] % 2 != 1 {
		A[0] /= 2
		counts++
	}

	tmp = int(math.Pow(2.0, float64(counts)))

	for i := 1; i < len(A); i++ {
		for A[i] % tmp != 0 {
			tmp /=2
			counts--
		}
	}
	return  counts
}

func main(){
  	var N, num int
	A := []int{}
	fmt.Scan(&N)
	for i := 0; i< N; i++ {
		fmt.Scan(&num)
		A = append(A, num)
	}
	shift := ShiftOnly(A)
	fmt.Println(shift)
}

Measured memory_bytes: 512
CARDS = [input(), input(), input()]

n = 0
while True:
	#print(n, CARDS)
	if 0==len(CARDS[n]):
		print("ABC"[n])
		exit()
	tn = ord(CARDS[n][0]) - ord("a")
	CARDS[n] = CARDS[n][1:]
	n = tn


Measured memory_bytes: 3060
##入力は以下の形式で標準入力から与えられる。
##N M
##a1 b1
##:
##aM bM
n, m = gets.chomp.split(" ").map(&:to_i)
a_ab = []
m.times do
  a_ab << gets.chomp.split(" ").map(&:to_i)
end
# p a_ab

##N個の都市があり、 M本の道路があります。
##i (1 ≦ i ≦ M)番目の道路は、
##都市 ai と 都市 bi (1 ≦ ai,bi ≦ N)を双方向に結んでいます。
##同じ 2つの都市を結ぶ道路は、1本とは限りません。
##各都市から他の都市に向けて、何本の道路が伸びているか求めてください。

##制約
##2 ≦ N,M ≦ 50
##1 ≦ ai, bi ≦ N
##ai ≠ bi
##入力は全て整数である。

##答えを N行に出力せよ。
##i (1 ≦ i ≦ N)行目には、都市 iから他の都市に向けて、
##何本の道路が伸びているかを出力せよ。

a_n = []
1.upto(n) do |i|
  num = 0
  a_ab.each do |a|
    num += 1 if i == a[0] || i == a[1]
  end
  
  a_n << num
end

a_n.each do |v|
  p v
end

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

using ll = long long;
const int mod = 1e9 + 7;

template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return is;
    }

    static int get_mod() { return mod; }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    ModInt<mod> ans = ModInt<mod>(2).pow(n) - 1;
    ModInt<mod> comb_a = 1, comb_b = 1;
    for (int i = 1; i <= a; i++) {
        comb_a *= (n - i + 1);
        comb_a /= i;
    }
    for (int i = 1; i <= b; i++) {
        comb_b *= (n - i + 1);
        comb_b /= i;
    }
    ans -= comb_a;
    ans -= comb_b;
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}


const int inf = 1e9 + 7;

int32_t SALI()
{

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

    vector<int> dp(n, inf);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; ++i) {
        dp[i] = min({dp[i], dp[i-1] + abs(h[i] - h[i-1]) ,dp[i-2] + abs(h[i] - h[i-2])});
    }
    
    cout << dp[n-1] << endl;
}


/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    lli p = min({A, B, C, D, E});
    cout << 4ll + (lli)ceil(N * 1.0 / p) << "\n";
    //A -- N/A+1
}

Measured memory_bytes: 256
n = int(input())

factors = [0 for i in range(n+1)]

for i in range(1, n+1):
    for j in range(2, int(i**0.5)+1):
        cnt = 0
        while i % j == 0:
            cnt += 1
            i //= j
        factors[j] += cnt
    if i > 1:
        factors[i] += 1

ans = 1

for f in factors:
    if f > 0:
        ans *= f+1
        ans %= 10**9+7

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

int main(void){
	
	long long a, b, c;

	std::cin >> a >> b >> c;

	if (a > c || a + b < c) {
		std::cout << "NO" << std::endl;
	}
	else {
		std::cout << "YES" << std::endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;++i){
    cin>>s[i];
  }
  for(int i=0;i<h;++i){
    cout<<s[i]<<endl;
    cout<<s[i]<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[]$) {
        Scanner c=new Scanner(System.in);
        char[] x=c.next().toCharArray();
        int s=0;
        for(char t:x) s+=t=='S'?2:s>0?-2:0;
        System.out.print(s);
    }
}

Measured memory_bytes: 25272
#include <bits/stdc++.h>
using namespace std;
#define max 200009
map<long,long>mp;

int main()
{
    long i,j,t,a,b,n,c,temp,m;
    t=1;
    // cin>>t;
    while(t--)
    {
       cin>>n>>m;
       if(n%3==0 || m%3==0 ||(n+m)%3==0)
       cout<<"Possible";
       else cout<<"Impossible";
      
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
x = [0]*n

apm = [(-1)**i*a[i] for i in range(n)]
x[0] = sum(apm)//2
for i in range(1,n):
    x[i] = a[i-1] - x[i-1]

ans = ' '.join([str(2*x[i]) for i in range(n)])
print(ans)

Measured memory_bytes: 76132
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
using namespace std;

const int MAX_N = 4e5 + 15;
int r, g, b, n, ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++) {
			int tmp = r * i + g * j;
			if (tmp > n)
				continue;

			if ((n - tmp) % b)
				continue;

			ans++;
		}

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

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

using namespace std;
using ll = long long;

int main() {
    multiset<ll> ms;
    multiset<ll>::iterator it;
    ll sum = 0;
    ll lc = 0, rc = 0, lt = 0, rt = 0;
    ll bs = 0;
    int n;
    scanf("%d", &n);
    while (n--) {
        int type;
        scanf("%d", &type);
        if (type == 1) {
            ll a, b;
            scanf("%lld %lld", &a, &b);
            a += 1e9;
            bs += b;

            ms.insert(a);
            if (ms.size() == 1) {
                it = ms.begin();
            } else {
                if (a < *it) {
                    lc++;
                    lt += a;
                    if (ms.size() % 2 == 0) {
                        rt += *it;
                        it--;
                        lt -= *it;
                        lc--;
                        rc++;
                    }
                } else {
                    rc++;
                    rt += a;
                    if (ms.size() % 2) {
                        lt += *it;
                        it++;
                        rt -= *it;
                        lc++;
                        rc--;
                    }
                }
            }
        } else {
            ll res = bs;

            res += (*it) * lc - lt;
            res += rt - (*it) * rc;

            printf("%lld %lld\n", *it - (long long) 1e9, res);
        }
    }
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(max(a*c,a*d),max(b*c,b*d)) << endl;
  return 0;
}

Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

//Alien's Counting
public class Main{

	Set<Integer>[] e, rev, in, out;
	int N, M;
	long MOD = 1000000007;
	
	int[] scc;
	boolean[] u;
	List<Integer> list;
	
	long[][] dp;
	
	void dfs(int k){
		u[k] = true;
		for(int v:e[k])if(!u[v])dfs(v);
		list.add(k);
	}
	void rdfs(int k, int id){
		u[k] = true;
		scc[k] = id;
		for(int v:rev[k])if(!u[v])rdfs(v, id);
	}

	long get(int k){
		if(dp[k][0]!=-1)return (dp[k][0]+dp[k][1])%MOD;
		dp[k][0] = dp[k][1] = 1;
		for(int v:out[k]){
			dp[k][1]*=get(v);
			dp[k][1]%=MOD;
			dp[k][0]*=dp[v][0];
			dp[k][0]%=MOD;
		}
		return (dp[k][0]+dp[k][1])%MOD;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		e = new Set[N];
		rev = new Set[N];
		for(int i=0;i<N;i++){
			e[i] = new HashSet<Integer>();
			rev[i] = new HashSet<Integer>();
		}
		while(M--!=0){
			int s = sc.nextInt()-1, t = sc.nextInt()-1;
			e[s].add(t);
			rev[t].add(s);
		}
		list = new ArrayList<Integer>();
		u = new boolean[N];
		for(int i=0;i<N;i++)if(!u[i])dfs(i);
		Arrays.fill(u, false);
		int ID = 0;
		scc = new int[N];
		for(int i=list.size()-1;i>=0;i--){
			int j = list.get(i);
			if(u[j])continue;
			rdfs(j, ID);
			ID++;
		}
		in = new Set[ID];
		out = new Set[ID];
		for(int i=0;i<ID;i++){
			in[i] = new HashSet<Integer>();
			out[i] = new HashSet<Integer>();
		}
		for(int i=0;i<N;i++){
			for(int v:rev[i]){
				if(scc[i]==scc[v])continue;
				out[scc[i]].add(scc[v]);
				in[scc[v]].add(scc[i]);
			}
		}
		dp = new long[ID][2];
		for(long[]d:dp)Arrays.fill(d, -1);
		long res = 1;
		for(int i=0;i<ID;i++)if(in[i].isEmpty()){
			res*=get(i);
			res%=MOD;
		}
		System.out.println(res);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const ll mod = 1000000000+7;

ll mod_pow(ll a, ll n, ll p)
{
    if(n == 0){
        return 1;
    }
    if(n%2 == 1){
        return (a*mod_pow(a, n-1, p)) % p;
    }
    ll t = mod_pow(a, n/2, p);
    return (t*t) % p;
}

ll inv_pow(ll a, ll p)
{
    return mod_pow(a, p-2, p);
}

ll nCr(ll n, ll r)
{
    ll ret = 1;
    for(ll i = n; i >= n-r+1; i--){
        //(ret *= i) %= mod;
        ret=(ret*i)%mod;
    }
    for(int i = 1; i <= r; i++){
        //(ret *= inv_pow(i, mod)) %= mod;
        ret=(ret*(inv_pow(i,mod)))%mod;
    }
    return ret;
}

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = 0;
    ans = mod_pow(2, n, mod) - 1;
    ans = (ans + mod - nCr(n, a)) % mod;
    ans = (ans + mod - nCr(n, b)) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 384