akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int tle = sc.nextInt();
        int ac = n-tle;        
        System.out.println((int)((ac*100 + tle*1900)*Math.pow(2,tle)));
    }
}

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

using namespace std;
int a[200005] = {0};
int main()
{
    int n;

    cin>>n;
    for(int i = 0; i<n-1; i++)
    {
        int cnt;
        cin>>cnt;
        a[cnt]++;
    }
    for(int i= 1 ; i<=n; i++)
    {
        cout<<a[i]<<endl;
    }
}


Measured memory_bytes: 4412
#include<stdio.h>
#include<stdlib.h>
int sort(const int *a,const int *b){
return *a-*b;
}
int main(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int p[n];
  for(int i=0;i<n;i++){
	scanf("%d",&p[i]);
  }
  qsort(p,n,sizeof(int),sort);
  int sum=0;
  for(int i=0;i<k;i++){
    	sum+=p[i];
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1748
H = int(input())
W = int(input())
N = int(input())

painted = 0
cnt = 0
while(True):
    painted += max(H,W)
    cnt += 1
    if painted >= N:
        break
    
    if painted + min(H,W) -1 >= N:
        cnt += 1
        break

print(cnt)

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

#define lli long long int
#define pb push_back
#define pii pair <int, int>
#define pll pair <lli, lli>
#define _F first
#define _S second
#define mset(x) memset(x, 0, sizeof(x))
#define fastio() ios_base::sync_with_stdio(0)

using namespace std;

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

	int e = 0, o = 0;

	while(n--)
	{
		int x;
		cin >> x;

		if(x%2)
			o++;
		else
			e++;
	}

	if(o%2)
	{
		if(e == 0 && o == 1)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else
		printf("YES\n");
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N,max=0;
  scanf("%d", &N);
  int a[2][N],p[N];
  for(int i=0;i<N;i++) scanf("%d", &a[0][i]);
  for(int i=0;i<N;i++) scanf("%d", &a[1][i]);
  
  for(int i=0;i<N;i++) p[i]=0;
  
  for(int k=0;k<N;k++){
    for(int i=0;i<=k;i++) p[k]+=a[0][i];
    for(int j=k;j<N;j++) p[k]+=a[1][j];
  }
  for(int i=0;i<N;i++){
		if(max<p[i])
			max=p[i];
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

std::vector<std::vector<int>> edges_from;
std::vector<bool> visited;
int n,k;
ll ans;

void dfs(int nd, int possibility, int depth){

    visited[nd] = true;

    if(depth >= 1) possibility = k-1;


    rep(i,edges_from[nd].size()){
        int next_nd = edges_from[nd][i];
        if(visited[next_nd]) continue;


        possibility -= 1;
        //cout << next_nd << " " << possibility << endl;
        ans *= possibility;
        ans %= MOD;

        dfs(next_nd, k-edges_from[next_nd].size()+1, depth+1);

    }

    return;
}

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

    cin >> n >> k;
    edges_from = std::vector<std::vector<int>>(n);
    visited = std::vector<bool>(n, false);

    rep(i,n-1){
        int a,b; cin >> a >> b; a--; b--;
        edges_from[a].push_back(b);
        edges_from[b].push_back(a);
    }

    ans = 1LL;

    dfs(0,k,0);
    cout << (ans*k)%MOD << endl;

    return 0;
}

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

using namespace std;

int main() {
  int h, w, n;
  scanf("%d %d %d", &h, &w, &n);
  int ans = min((n + w - 1) / w, (n + h - 1) / h);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
n=int(input())
A=[[0,0,0]]
for i in range(n):
    a=list(map(int,input().split()))
    A.append(a)
for i in range(1,n+1):
    b=abs(A[i-1][1]+A[i-1][2]-A[i][1]-A[i][2])
    if b>A[i][0]-A[i-1][0] or (b+A[i][0]-A[i-1][0])%2==1:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 27300
n = int(input())
a = list(map(int, input().split()))
a.sort()
N = [a[0]]
for i in range(1, n):
    if a[i] % a[0] != 0:
        N.append(a[i]%a[0])
N.sort()
while sum(N) > N[0]:
    N1 = N.copy()
    N = [N1[0]]
    for s in N1:
        if s == N[0]: continue
        if s%N[0] != 0: N.append(s%N[0])
    N.sort()
print(N[0])

Measured memory_bytes: 14252
#include<iostream>
using namespace std;
int main(){
  int a;
  cin >> a;
  a = a % 1000;
  if(a > 1000){
    return a;
  }
  if(a != 0){
  cout << 1000 - a << "\n";
  return 0;
  }
  cout << a << "\n";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
char s[N];
int a[N];
int main(){
    scanf("%s",s);
    int n = strlen(s);
    long long ans = 0;
    for(int i=n-1;i>=0;i--){
        ans += n-1-i-a[s[i]-'a'];
        a[s[i]-'a']++;
    }
    printf("%lld\n",ans+1);
}


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

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

    ll n;
    cin >> n;

    vector<ll> p(n+1, 2);
    p[0] = 0;
    p[1] = 1;
    for(int i = 2; i < n+1; ++i){
        for(int j = 2*i; j < n+1; j += i){
            ++p[j];
        }
    }

    ll res = 0;
    rep1(i, n+1) res += i*p[i];

    cout << res << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<string> dicti(n);
  for(int i = 0;i < n;i++){
    vector<char> s(10);
    for(int j = 0;j < 10;j++){
      cin >> s.at(j);
    }
    sort(s.begin(),s.end());
    string t;
    for(int j = 0;j < 10;j++){
      t += s.at(j);
    }
    dicti.at(i) = t;
  }
  sort(dicti.begin(),dicti.end());
  long cur = 0,result = 0;
  string curs = dicti.at(0);
  for(int i = 0;i < n;i++){
    if(dicti.at(i) == curs){
      cur++;
    }
    else{
      if(cur != 1){
        result += cur*(cur-1)/2;
      }
      cur = 1;
      curs = dicti.at(i);
    }
    if(i == n-1){
      if(cur != 1){
        result += cur*(cur-1)/2;
      }
    }
  }
  cout << result << endl;
}

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

int main() {
  int NUM, count, start, last, ppl_num = 0;
  
  cin >> NUM;
  for (int iter = 0; iter < NUM; iter++) {
    cin >> start >> last;
    ppl_num += last - start + 1;
    count++;
  }
  cout << ppl_num << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, A[50];

// 入力値のMから選んだ要素を引いていく再起関数

int solve(int i, int m) {
	if(m==0) return 1;
	if(i>=n) return 0;
	int res = solve(i+1,m       ) ||
	          solve(i+1,m - A[i]);
	return res;
}

int main(void) {
	int q, M, i;
	
	scanf("%d",&n); /* データ数 */
	for(i=0;i<n;i++) scanf("%d",&A[i]);

	scanf("%d",&q); /* 作りたい整数の数 */
	for(i=0;i<q;i++) {
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}


Measured memory_bytes: 2608
#include <cstdio>

int main(){
    char s1[100],s2[100],s3[100];
    scanf("%s",s1);
    scanf("%s",s2);
    scanf("%s",s3);
    printf("%c%c%c\n",s1[0],s2[0],s3[0]);

    return 0;
}

Measured memory_bytes: 504
def main():

    import itertools
    n = int(input())
    permutation_lis = []
    a = 0
    b = 0
    ans_a = 0
    ans_b = 0

    p_lis = list(input().split())
    q_lis = list(input().split())

    permutation_lis = list(itertools.permutations(p_lis))
    permutation_lis.sort()
    #print(permutation_lis)

    for wordorder in permutation_lis:
        a += 1
        b += 1
        #print(p_lis, list(wordorder), p_lis == list(wordorder))
        if p_lis == list(wordorder):
            ans_a = a
        if q_lis == list(wordorder):
            ans_b = b
    print(abs(ans_a-ans_b))




if __name__ == "__main__":
    main()

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

int Aout(vector <double> &A, int n);
int insertionsort(vector <double> &A, int n);

int main(void){
	int n;

	cin>>n;
	vector <double> A(n);

	for (int i=0; i<n; i++)
		cin>>A[i];
	Aout(A, n);
	insertionsort(A, n);

	return 0;
}

int Aout(vector <double> &A, int n){
	for (int i=0; i<n; i++){
		if (i!=0) cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	return 0;
}

int insertionsort(vector <double> &A, int n){
	double key;
	int i;
	for (int j=1; j<n; j++){
		key = A[j];
		i = j-1;
		while (i>=0){
			if (A[i] <= key) break;
			A[i+1] = A[i];
			i--;
		}
		A[i+1] = key;
		Aout(A, n);
	}
	return 0;
}

Measured memory_bytes: 1288
#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>;
int main() {
	int n;
	cin >> n;
	vector<ll> fa(n+1);

	rep(i,n) {
		for (int j=1; j * (i+1) <= n;j++) {
			fa[(i+1)*j]++;
		}
	}
	ll ans=0;
	for (int k=1;k<=n;k++) {
		ans += k*fa[k];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 81400
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    from_one = set([])
    to_n = set([])
    for _ in range(M):
        a, b = map(int, input().split())
        if a == 1:
            from_one.add(b)
        elif b == N:
            to_n.add(a)
    if len(from_one & to_n) > 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 92244
from math import sqrt
n = input()
ps = [map(float, raw_input().split()) for i in xrange(n)]
ps.sort()
INF = 10**9

def cp_rec(ps, i, n):
    if n <= 1:
        return INF, [ps[i]]
    m = n/2
    x = ps[i+m][0]
    d1, qs1 = cp_rec(ps, i, m)
    d2, qs2 = cp_rec(ps, i+m, n-m)
    d = min(d1, d2)
    # merge
    qs = [None]*n
    s = t = idx = 0
    while s < m and t < n-m:
        if qs1[s][1] < qs2[t][1]:
            qs[idx] = qs1[s]; s += 1
        else:
            qs[idx] = qs2[t]; t += 1
        idx += 1
    while s < m:
        qs[idx] = qs1[s]; s += 1
        idx += 1
    while t < n-m:
        qs[idx] = qs2[t]; t += 1
        idx += 1
    b = []
    for i in xrange(n):
        ax, ay = q = qs[i]
        if abs(ax - x) >= d:
            continue
        for j in xrange(len(b)-1, -1, -1):
            dx = ax - b[j][0]
            dy = ay - b[j][1]
            if dy >= d: break
            d = min(d, sqrt(dx**2 + dy**2))
        b.append(q)
    return d, qs
def closest_pair(ps):
    n = len(ps)
    return cp_rec(ps, 0, n)[0]
print "%.09f" % closest_pair(ps)

Measured memory_bytes: 24512
N=int(input())
W=list(map(int,input().split()))

S1=sum(W)
S2=0
for i in range(N):
    if S1<=S2:break
    S1-=W[i]
    S2+=W[i]
A1=abs(S1-S2)
S1+=W[i-1]
S2-=W[i-1]
A2=abs(S1-S2)

print(min(A1,A2))

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

int main(){
  int k, n, i, max;
  int r;
  scanf("%d %d", &k, &n);
  int a[n];

  for(i=0; i<n; i++)scanf("%d", &a[i]);

  max = 0;
  for(i=0; i<n-1; i++){
    if(max < a[i+1]-a[i])max = a[i+1] - a[i];
  }

  r = a[0] + k - a[n-1];
  if(max < r)max = r;

  //printf("%d %d %d\n", k, n, max);
  //for(i=0; i<n; i++)printf("%d ", a[i]);
  //printf("\n");
  printf("%d\n", k-max);
  return 0;
}


Measured memory_bytes: 896
#!/usr/bin/env python3
import sys


def f(N, M, a, b, skip):
    uf = UnionFind(N)
    for i, (aa, bb) in enumerate(zip(a, b)):
        if i == skip:
            continue
        uf.union(aa-1, bb-1)
    return uf.size(0) != N

def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    def g(skip):
        return f(N, M, a, b, skip)
    return sum(map(g, range(M)))
        


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    print(solve(N, M, a, b))

# https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3316
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll a, b;
    cin >> a >> b;

    if(a * b % 2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }

}

Measured memory_bytes: 256
k,t = map(int,input().split())
lst1 = list(map(int,input().split()))

if t == 1:
    print(lst1[0]-1)

elif max(lst1) - (sum(lst1) - max(lst1)) > 0:
    print(max(lst1) - (sum(lst1) - max(lst1))-1)

else:
    print(0)

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

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

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

  vector<int> square(128);
  for (int i = 0; i < 128; i++) {
    square[i] = i * i;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      int x = 0;
      for (int k = 0; k < d; k++) {
        int t = p[i][k] - p[j][k];
        x += t * t;
      }
      if (binary_search(begin(square), end(square), x)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
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; }

const int MOD = 998244353;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
  long long N, M, K;
  cin >> N >> M >> K;

  // 前処理
  COMinit();

  long long ans = 0;

  REP(k, K+1) {
    long long temp = modpow(M - 1, N - 1- k, MOD) * COM(N-1, k);
    temp %= MOD;
    temp *= M;
    temp %= MOD;
    // cout << temp << endl;
    ans += temp;
    ans % MOD;
  }
  while (true) {
    if (0 <= ans && ans < MOD) break;
    ans %= MOD;
  }
  cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 15660
n = int(input())
l = list(map(int, input().split()))

print(*l)


def insertionsort(a, n):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v
        print(*a)


insertionsort(l, n)



Measured memory_bytes: 5980
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[,]A = new int[N,2];
		string[]S = new string[N];
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			A[i,0] = int.Parse(str[0]);
			A[i,1] = int.Parse(str[1]);
			S[i] = str[2];
		}
		double uymax = -999999999;
		double uymin = 999999999;
		double dymax = -999999999;
		double dymin = 999999999;
		double oymax = -999999999;
		double oymin = 999999999;
		double rxmax = -999999999;
		double rxmin = 999999999;
		double lxmax = -999999999;
		double lxmin = 999999999;
		double oxmax = -999999999;
		double oxmin = 999999999;
		for(var i=0;i<N;i++){
			if(S[i]=="U"){
				uymax = Math.Max(uymax,A[i,1]);
				uymin = Math.Min(uymin,A[i,1]);
			} else if(S[i]=="D"){
				dymax = Math.Max(dymax,A[i,1]);
				dymin = Math.Min(dymin,A[i,1]);
			} else {
				oymax = Math.Max(oymax,A[i,1]);
				oymin = Math.Min(oymin,A[i,1]);
			}
			if(S[i]=="R"){
				rxmax = Math.Max(rxmax,A[i,0]);
				rxmin = Math.Min(rxmin,A[i,0]);
			} else if(S[i]=="L"){
				lxmax = Math.Max(lxmax,A[i,0]);
				lxmin = Math.Min(lxmin,A[i,0]);
			} else {
				oxmax = Math.Max(oxmax,A[i,0]);
				oxmin = Math.Min(oxmin,A[i,0]);
			}
		}
		var list = new List<double>();
		list.Add(0);
		if(dymax>oymax){
			list.Add(dymax-oymax);
		}
		if(oymax>uymax){
			list.Add(oymax-uymax);
		}
		if(dymax>uymax){
			list.Add((dymax-uymax)/2);
		}
		if(dymin>oymin){
			list.Add(dymin-oymin);
		}
		if(oymin>uymin){
			list.Add(oymin-uymin);
		}
		if(dymin>uymin){
			list.Add((dymin-uymin)/2);
		}
		if(lxmax>oxmax){
			list.Add(lxmax-oxmax);
		}
		if(oxmax>rxmax){
			list.Add(oxmax-rxmax);
		}
		if(lxmax>rxmax){
			list.Add((lxmax-rxmax)/2);
		}
		if(lxmin>oxmin){
			list.Add(lxmin-oxmin);
		}
		if(oxmin>rxmin){
			list.Add(oxmin-rxmin);
		}
		if(lxmin>rxmin){
			list.Add((lxmin-rxmin)/2);
		}
		double ans = 999999999999999999;
		for(var i=0;i<list.Count;i++){
			double t = list[i];
			double xmax = -999999999;
			double xmin = 999999999;
			double ymax = -999999999;
			double ymin = 999999999;
			for(var j=0;j<N;j++){
				double x = A[j,0];
				double y = A[j,1];
				if(S[j]=="U"){
					y += t;
				} else if(S[j]=="D"){
					y -= t;
				} else if(S[j]=="R"){
					x += t;
				} else {
					x -= t;
				}
				xmax = Math.Max(xmax,x);
				xmin = Math.Min(xmin,x);
				ymax = Math.Max(ymax,y);
				ymin = Math.Min(ymin,y);
			}
			ans = Math.Min(ans,(xmax-xmin)*(ymax-ymin));
			Console.Error.WriteLine(t);
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 22984
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		long a = stdIn.nextLong();
		long b = stdIn.nextLong();
		long c = stdIn.nextLong();
		long d = stdIn.nextLong();
		long ans[] = new long[4];
		ans[0] = a*c;
		ans[1] = a*d;
		ans[2] = b*c;
		ans[3] = b*d;
		long max = ans[0];
		for(int i = 0; i < 4; i++){
			if(max <= ans[i]){
				max = ans[i];
			}
		}
		System.out.println(max);
		stdIn.close();
	}
}

Measured memory_bytes: 35656
import java.util.*;
import java.lang.*;

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

        out_of_loop: while (true) {
            int n = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());

            // zńúťiăŠçlŚÄ˘éj
            int[] list = new int[n];
            for (int i = 0; i < n; i++) {
                list[i] = n - i;
            }

            if (n == 0 && r == 0)
                break out_of_loop;

            for (int i = 0; i < r; i++) {
                int p = Integer.parseInt(sc.next());
                int c = Integer.parseInt(sc.next());

                int newarray[] = new int[n];
                System.arraycopy(list, p - 1, newarray, 0, c);
                System.arraycopy(list, 0, newarray, c, p - 1);
                System.arraycopy(list, p + c - 1, newarray, p + c - 1, n - (p + c - 1));

                list = newarray.clone();
            }

            System.out.println(list[0]);
        }
    }
}


Measured memory_bytes: 36936
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


k = int(data())
a, b = sp()
for i in range(a, b+1):
    if i % k == 0:
        out("OK")
        exit()
out("NG")


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll INF=1000000000000000;

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

int main(){
	ll N,K; cin>>N>>K;
	string s; cin>>s;
	//'1'を並べる
	//0の区間のうちK個まで1にすることが出来る
	vector<ll>z;
	if(s[0]=='0') z.pb(0);
	ll L=0;
	char mem=s[0];
	rep(i,sz(s)){
		if(mem!=s[i]){
			z.pb(L);
			mem=s[i];
			L=1;
		}
		else L++; 
	}
	z.pb(L);
	if(s[sz(s)-1]=='0') z.pb(0);

	ll ans=z[0];
	vector<ll>zs(sz(z)+1,0);
	rep1(i,sz(z)){
		zs[i]=zs[i-1]+z[i-1];
	}
	
	for(int i=1;i<=sz(z)-2;i+=2){
		//終点 min(i-1+2*K,sz(z)-1)
		chmax(ans,zs[min(i-1+2*K,sz(z)-1)+1]-zs[i-1]);
	}
	cout<<ans;
}

Measured memory_bytes: 2164
function main()
  
  N = parse(Int,readline())
  (D,X) = map(x -> parse(Int,x), split(readline()))
  
  count = 0
  
  for i in 1:N
    
    A = parse(Int,readline())
    
    for j in 0:D
      
      if A*j + 1 <= D
        count += 1
      else
        break
      end
      
    end
    
  end
  
  println(count + X)
  
end

main()

Measured memory_bytes: 112392
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N);
    for(auto& in:a) cin >> in;
    ll res = LINF;
    vector<ll> cusum(N,0);
    cusum[0] = a[0];
    for(int i = 1; i < N;i++){
        cusum[i] = cusum[i-1] + a[i];
    }
    for(int i = 0; i < N-1;i++){
        res = min(res,abs(cusum[i] - (cusum[N-1] - cusum[i])));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3456
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int ans = 0;
		
		for(int i = a;i <= b; i++){
	        if(c % i == 0) ans++;
	    }
		System.out.println(ans);
	}
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	ll x, y;
	inc(x, y);

	vl v(1, x);

	ll ans = 1;

	ll i = 1;
	while (true)
	{
		ll tmp = v[i - 1] * 2;

		if (tmp > y) break;
		
		ans++;
		i++;
		v.push_back(tmp);
	}
	ANS(ans);
}

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

int main() {
  ll Q,H,S,D,N;cin>>Q>>H>>S>>D>>N;
  if(N%2==0) cout << min(min(8*Q,4*H),min(2*S,D))*N/2 << endl;
  else cout << min(min(8*Q,4*H),min(2*S,D))*(N/2) + min(4*Q,min(2*H,S)) << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9+7;

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

    ll n; cin>>n;
    vll a(n);
    REP(i,n) cin >>a[i];
    vll b(n+1);
    ll sum = accumulate(ALL(a), 0LL);
    ll sum2 = 0;
    REP(i,n){
        if (i%2!=0) sum2 += 2*a[i];
    }
    b[0] = sum-sum2;
    b[n] = b[0];
    for(int i=0;i<n;i++){
        b[i+1] = 2*a[i]-b[i];
    }
    REP(i,n) cout << b[i] << endl;
    return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int x, y ,z;

  cin >> x >> y >> z;

  int n = (x - z) / (z + y);
  printf("%d\n", n);
}


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

int main(){
  string S,T;
  cin >> S >> T;
  int i = 0;
  bool finish = true;
  while(i < S.size()){
    if(S.at(i) != T.at(i)){
      finish = false;
      break;
    }
    i++;
  }
  if(finish){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
//@sushkov.pv

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned short int usi;

using namespace std;


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

    int n, s;
    cin >> n >> s;
    vector<ll> w(n);
    vector<ll> c(n);
    for(int i = 0; i < n; ++i)
        cin >> w[i] >> c[i];

    vector<ll> dp(s + 1, -1);
    dp[0] = 0;

    for(int i = 0; i < n; ++i)
    {
        vector<ll> tmp = dp;
        for(int j = w[i]; j <= s; ++j)
          {
            if(dp[j - w[i]] != -1)
            {
                ll nw = dp[j - w[i]] + c[i];
                if(tmp[j] < nw)
                {
                    tmp[j] = nw;
                }
            }
        }
        dp = tmp;
    }

    ll mx = 0;
    for(int i = 0; i <= s; ++i)
        mx = max(mx, dp[i]);

    cout << mx;
}
























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


void main() {
    int n;
    scan(n);
    auto a = iota(n).map!(i => readln.chomp.to!int).array;

    long ans;

    foreach (i ; 0 .. n) {
        ans += a[i] / 2;
        a[i] %= 2;
        if (i < n - 1 && a[i] && a[i+1]) {
            ans++;
            a[i+1]--;
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

bool ok(const vector<ll>& x, const vector<ll>& y, const vector<ll>& h, const ll cx, const ll cy, const ll H)
{
    int N = x.size();

    for (int i = 0; i < N; ++i) {
        ll hh = max(H - abs(x[i]-cx) - abs(y[i]-cy), (ll)0);

        if (hh != h[i]) {
            return false;
        }
    }

    return true;
}

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

    ll max_h = 0;

    vector<ll> x(N), y(N), h(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];

        max_h = max(max_h, h[i]);
    }

    while (true) {
        for (ll cx = 0; cx <= 100; ++cx) {
            for (ll cy = 0; cy <= 100; ++cy) {
                if(ok(x, y, h, cx, cy, max_h)) {
                    cout << cx << ' ' << cy << ' ' << max_h << endl;
                    return 0;
                }
            }
        }

        ++max_h;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int n, sum = 0;
	int a[210];
	scanf("%d", &n);
	for(int i = 0; i < 2*n; i++)
		scanf("%d", &a[i]);
	sort(a, a+2*n);
	for(int i = 0; i < 2*n; i += 2)
		sum += a[i];
	printf("%d", sum);
}

Measured memory_bytes: 256
#include<stdio.h>
#define mod 1000000007
long long a[300000];
int main(){
	int n;
	long long sum=0;
	long long sumsq=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum=(sum+a[i])%mod;
		long long  sq=(a[i]*a[i])%mod;
		sumsq=(sumsq+sq)%mod;
	}
	long long sqsum=(sum*sum)%mod;
	long long minus=(sqsum-sumsq)%mod;
	if (minus<0) minus=minus+mod;
	if (minus%2==1) minus=minus+mod;
	minus=minus/2;
	printf("%lld",minus);
}

Measured memory_bytes: 3292
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = 0;
		int h = 0;
		
		for(int i=0; i < n; i++) {
			String ta = sc.next();
			String ha = sc.next();
			if(ta.compareTo(ha) > 0)
				t += 3;
			else if(ta.compareTo(ha) < 0)
				h += 3;
			else {
				t++;
				h++;
			}
		}
		System.out.println(t + " " + h);
	}
}


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

int main() {
  // 入力
  int card_sum;
  std::cin >> card_sum;
  std::vector<int> card_num(100);
  for (int i = 0; i < card_sum; i++) {
    std::cin >> card_num.at(i); 
  }

  // ソート
  std::sort(card_num.begin(), card_num.end());
  std::reverse(card_num.begin(), card_num.end());

  // 計算
  int ans = 0;
  for (int i = 0; i < card_sum; i++) {
    if (i % 2 == 0) {
      ans += card_num.at(i);
    } else {
      ans -= card_num.at(i);
    }
  }
  std::cout << ans << std::endl;

  return 0;
}


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


        int ans = 0;
        int mindiff = 100000000;
        for(int i = 0;i<n;i++){
            if (abs(s-n*a[i]) < mindiff){
                mindiff = abs(s-n*a[i]);
                ans = i;
            }
        }
        cout << ans << endl;
}




Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long a[7];
    for(int i=0;i<7;i++){
        cin>>a[i];
    }
    long long ans=0;
    ans+=a[1];
    int c=0;
    if(a[0]%2==1) c++;
    if(a[3]%2==1) c++;
    if(a[4]%2==1) c++;
    if(c>1 && a[0]&& a[4]&&a[3]) ans+=3,a[0]--,a[3]--,a[4]--;
    ans+=a[0]/2*2;
    ans+=a[3]/2*2 + a[4]/2*2;
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <optional>
#include <limits>

using namespace std;
using u = uint_fast32_t;
using U = uint64_t;

optional<U> checked_mul(const optional<U> &a, const U b) {
  if(!a) return nullopt;
  const auto a_ = a.value();
  U ans = a_ * b;
  return (a_ == 0 || b <= numeric_limits<U>::max() / a_) ? make_optional(ans) : nullopt;
}

int main() {
  u n;
  cin >> n;
  optional<U> ans = 1;
  for(u i = 0; i < n; ++i) {
    U a;
    cin >> a;
    if(a == U(0)) {
      cout << "0\n";
      return 0;
    }
    ans = checked_mul(ans, a);
    if(ans && ans.value() > U(1000'000'000'000'000'000)) {
      ans = nullopt;
    }
  }
  if(!ans) {
    cout << "-1\n";
  } else {
  	cout << ans.value() << '\n';
  }
  return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e3+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n, m;
ll dp[N][N];
void init() {
	mt(dp, 0);
}
int s[N], t[N];
int main() {
	// dp[i][j] 表示以s[i]和t[j]结尾的相同子序列的个数
	// 到后面就是前缀和了
	while(~scanf("%d%d", &n, &m)) {
		init();
		rep(i, 1, n + 1) scanf("%d", s + i);
		rep(i, 1, m + 1) scanf("%d", t + i);
		rep(i, 1, n + 1) rep(j, 1, m + 1) {
			if(s[i] != t[j]) dp[i][j] = 0;
			else {
				dp[i][j] = (dp[i-1][j-1] + 1) % mod;
			}
			// dd(i), dd(j), de(dp[i][j]);
			dp[i][j] += (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]);
			dp[i][j]  = (dp[i][j] + mod) % mod;
		}
		printf("%lld\n", (dp[n][m] + 1) % mod);
	}
    return 0;
}


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

struct union_find {
  union_find (int n) : par(n), rank(n, 0) {
    for (int i = 0; i < n; i++)
      par[i] = i;
  }

  int find (int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  bool same (int x, int y) {
    return find(x) == find(y);
  }

  void unite (int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y)
      return;

    if (rank[x] < rank[y])
      par[x] = y;
    else {
      par[y] = x;
      if (rank[x] == rank[y])
        rank[x]++;
    }
  }

  private:
  vector<int> par;
  vector<int> rank;
};

int main (void) {
  int N, M;
  cin >> N >> M;
  // A[i]がわかったとき，かつそのときに限りA[j]がわかる
  union_find uf(N);

  for (int i = 0; i < M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    uf.unite(x, y);
  }

  set<int> s;

  for (int i = 0; i < N; i++)
    s.insert(uf.find(i));

  cout << s.size() << endl;
  return 0;
}


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

int main(){
  string N;
  cin >> N;
  char N1 = N[0], N3 = N[2];
  string ans;
  if(N1 == N3) ans = "Yes";
  else ans = "No";
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a;i<(a+n);i++)
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint pow_(int base, int n) {
  if (n == 0) return 1;
  mint x = pow_(base, n/base);
  x *= x;
  if (n%base == 1) x *= mint(base);
  return x;
}

mint nCr(int n, int r) {
  mint x = 1, y = 1;
  rep(i, 0, r) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  mint ans;
  ans += pow_(2, n);
  ans -= 1;
  ans -= nCr(n, a);
  ans -= nCr(n, b);
  // mint ans = pow(2, n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod);
  cout << ans.x << endl;
}


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

using namespace std;

typedef pair<int, int> Point;
typedef pair<Point, Point> State;

const int N = 50;

int w, h;
char room[2][N][N];
bool vis[N][N][N][N];
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};

void check(int& y, int& x){
  if(y < 0) y = 0;
  if(y >= h) y = h-1;
  if(x < 0) x = 0;
  if(x >= w) x = w-1;
}

bool bfs(Point l, Point r){
  queue<State> q;
  State u;
  vis[l.first][l.second][r.first][r.second] = true;
  q.push(State(l, r));
  while(!q.empty()){
    u = q.front(); q.pop();
    l = u.first;
    r = u.second;
    if(room[0][l.first][l.second] == '%' && room[1][r.first][r.second] == '%'){
      return true;
    }else if(room[0][l.first][l.second] == '%' || room[1][r.first][r.second] == '%'){
      continue;
    }else{
      for(int i=0;i<4;i++){
        Point nl = Point(l.first + dy[i], l.second + dx[i]);
        Point nr = Point(r.first + dy[i], r.second - dx[i]);
        check(nl.first, nl.second);
        check(nr.first, nr.second);
        if(room[0][nl.first][nl.second] == '#') nl = l;
        if(room[1][nr.first][nr.second] == '#') nr = r;
        if(vis[nl.first][nl.second][nr.first][nr.second]) continue;
        vis[nl.first][nl.second][nr.first][nr.second] = true;
        q.push(State(nl, nr));
      }
    }
  }
  return false;
}

main(){
  Point l, r;
  while(cin >> w >> h && (w|h)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> room[0][i][j];
        if(room[0][i][j] == 'L'){
          l = Point(i, j);
          room[0][i][j] = '.';
        }
      }
      for(int j=0;j<w;j++){
        cin >> room[1][i][j];
        if(room[1][i][j] == 'R'){
          r = Point(i, j);
          room[1][i][j] = '.';
        }
      }      
    }
    fill(vis[0][0][0], vis[N][0][0], false);
    cout << (bfs(l, r) ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 7904
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

class edge{
public:
	Int cost;
	size_t from, to;
	edge(Int c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<edge> edges;
typedef vector<edges> graph;
void readgraph(graph &g, size_t E, bool D, bool C, bool Z){ // E:num_of_edges, D:directed, C:costed, Z:already 0-indexed
	for(size_t i=0; i<E; ++i){
		edge e(1, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		if(!Z){
			--e.from;
			--e.to;
		}
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
class unionfind{ // 0-indexed
public:
	vector<int> parent;
	vector<size_t> size;
	size_t num_of_disjointsets;
	unionfind(size_t n){
		parent.resize(n, -1);
		size.resize(n, 1);
		num_of_disjointsets = n;
	}

	size_t find(size_t x){
		if(parent[x] == -1) return x;
		return parent[x] = find(parent[x]);
	}

	size_t unite(size_t x, size_t y){
		x = find(x);
		y = find(y);
		if(x == y) return -1;
		if(size[x] < size[y]){
			parent[x] = y;
			size[y] += size[x];
			size[x] = 0;
			--num_of_disjointsets;
			return y;
		}else{
			parent[y] = x;
			size[x] += size[y];
			size[y] = 0;
			return x;
			--num_of_disjointsets;
		}
	}

	bool united(size_t x, size_t y){
		return find(x) == find(y);
	}
};
bool operator < (const edge &e, const edge &f){
	return e.cost != f.cost ? e.cost > f.cost : e.from != f.from ? e.from < f.from : e.to < f.to;
}
vector<edge> kruskal(graph &g){
	priority_queue<edge> pq;
	for(size_t i=0; i<g.size(); ++i)
		for(size_t j=0; j<g[i].size(); ++j)
			if(i < g[i][j].to && g[i][j].cost >= 0)
				pq.push(g[i][j]);
	unionfind uf(g.size());
	vector<edge> res;
	while(!pq.empty()){
		edge e = pq.top(); pq.pop();
		if(!uf.united(e.from, e.to)){
			uf.unite(e.from, e.to);
			res.push_back(e);
		}
		if(uf.num_of_disjointsets == 1) break;
	}
	return res;
}

Int solve(Int n, Int m){
	graph g(n);
	readgraph(g, m, false, true, false);
	vector<Int> v(1, 0);
	for(auto i:g)
		for(auto j:i)
			v.push_back(j.cost);
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	vector<edge> mst = kruskal(g);
	Int ans = 0;
	if(mst.size() < (size_t)n-1) ans = -1;
	else{
		Int mi = 1e9, ma = 0;
		for(auto i:mst){
			mi = min(mi, i.cost);
			ma = max(ma, i.cost);
		}
		ans = ma - mi;
	}
	for(size_t i=1; i<v.size(); ++i){
		for(auto &j:g) for(auto &k:j) k.cost -= v[i] - v[i-1];
		mst = kruskal(g);
		if(mst.size() < (size_t)n-1) break;
		Int ma = 0;
		for(auto j:mst) ma = max(ma, j.cost);
		ans = min(ans, ma);
//		cout << i << " " << "\n";
//		for(auto i:mst) cout << i.cost << " " << i.from << " " << i.to << "\n";
	}
	return ans;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		Int n, m; cin >> n >> m;
		if(n == 0) return 0;
		cout << solve(n, m) << "\n";
	}
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<string> data(N);
  for (int i=0;i<N;i++){
    cin>>data[i];
  }
  vector<bool> row(N,false);
  vector<bool> col(M,false);
  for (int i=0;i<N;i++){
    for (int j=0;j<M;j++){
      if(data.at(i).at(j)=='#'){
        row.at(i)=true;
        col.at(j)=true;
      }
    }
  }
  
  for (int i=0;i<N;i++){
    if(row.at(i)){
      for (int j=0;j<M;j++){
        if(col.at(j)){
          cout << data.at(i).at(j);
        }
      }
    cout<< endl;
    }
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
print(*a)
for i in range(1,n):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(*a)



Measured memory_bytes: 5976
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
    map<char, string> S; cin >> S['a']; cin >> S['b']; cin >> S['c'];
    map<char, int> cnt; cnt['a'] = 0; cnt['b'] = 0; cnt['c'] = 0;

    char c = S['a'][cnt['a']]; cnt['a']++;
    while(1){
        if(cnt[c] < S[c].length()){
            cnt[c]++;
            c = S[c][cnt[c]-1];
        }
        else{
          	c -= 32;
            cout << c;
            break;
        }
    }
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int x, count = 1;
        try {
            while(true) {
                x = Integer.parseInt(reader.readLine());
                if(x == 0) {
                    break;
                }
                System.out.println("Case " + count + ": " + x);
                count++;
            }
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 31908
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N, H;
    cin >> N >> H;
    vector<ll> A(N) , B(N);
    REP(i, N) cin >> A[i] >> B[i];

    sort(A.begin(), A.end(), std::greater<ll>());
    sort(B.begin(), B.end(), std::greater<ll>());

    ll tmp = A[0];
    ll s = 0;
    int cnt = 0;
    REP(i, N){
        if (B[i] > tmp && s < H) {
            s += B[i];
            cnt++;
            }
        else break;
    }
    if (s < H){
        cnt += ceil((double)(H - s) / (double) tmp);
    }
    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 1792