akhauriyash/Code-Regression huggingface dataset:
def selectionSort(A, N):
    swapnum= 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i!=minj:
            temp = A[i]
            A[i] = A[minj]
            A[minj] = temp
            swapnum += 1
    return swapnum
def showlist(A):
    for i in range(len(A)):
        if i==len(A)-1:
            print(A[i])
        else:
            print(A[i], end=' ')
N = eval(input())
A = list(map(int, input().split()))
swapnum = selectionSort(A, N)
showlist(A)
print(swapnum)


Measured memory_bytes: 5616
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

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

	int n, m;
	P a[15];
	int match[10] = { 0,2,5,5,4,5,6,3,7,6 };
	string dp[10005];

	cin >> n >> m;
	rep(i, m) {
		cin >> a[i].first;
		a[i].second = match[a[i].first];
	}
	rep(i, n + 1) dp[i] = "#";
	dp[0] = "";
	rep(i, n) {
		if (dp[i] == "#") continue;
		rep(j, m) {
			if (i + a[j].second <= n) {
				string to = dp[i + a[j].second];
				string fr = dp[i] + (char)('0' + a[j].first);
				if (to == "#") dp[i + a[j].second] = fr;
				else if (fr.size() > to.size()) dp[i + a[j].second] = fr;
				else if (fr.size() == to.size()) chmax(dp[i + a[j].second], fr);
			}
		}
	}
	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 44800
N, Y = map(int, input().split())
L = Y // 1000 - N
H = L * 7 % 9
F = (L - 4 * H) // 9
if F < 0 or H + F > N:
    print("-1 -1 -1")
else:
    print("{} {} {}".format(F, H, N - F - H))


Measured memory_bytes: 2940
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
# 0が混ざってる場合に対応して、１ずつ足しておく
a = [i+1 for i in a]

# 10**5だと99999がコーナーケースになる
l = [0] * 10 ** 6
# いもす法
for i in a:
    l[i-1] += 1
    l[i+2] -= 1

b = accumulate(l)
print(max(list(b)))

Measured memory_bytes: 111300
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

var head []byte
var tail []byte

func main() {
	sc.Buffer(make([]byte, 0), 1e6)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	s := next()

	initS := []byte(s)
	q := nextInt()
	reverse := false
	for i := 0; i < q; i++ {
		query := nextInt()
		if query == 1 {
			reverse = !reverse
		} else {
			f := nextInt()
			c := next()
			if (f == 1 && !reverse) || (f == 2 && reverse) {
				// s = c + s
				head = append(head, []byte(c)...)
			} else {
				// s = s + c
				tail = append(tail, []byte(c)...)
			}
		}
	}
	if reverse {
		// s = reverseStr(s)
		swap(initS)
		swap(tail)
		// fmt.Println(s)
		fmt.Println(string(tail) + string(initS) + string(head))
	} else {
		swap(head)
		// fmt.Println(s)
		fmt.Println(string(head) + string(initS) + string(tail))
	}

}

func swap(arr []byte) {
	for i := 0; i < len(arr)/2; i++ {
		arr[i], arr[len(arr)-1-i] = arr[len(arr)-1-i], arr[i]
	}
}

func reverseStr(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 3968
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	public static class Pair implements Comparable<Pair> {
		public final int first;
		public final int second;
	
		public Pair(int first, int second) {
			this.first = first;
			this.second = second;
		}
	
		@Override
		public int compareTo(Pair o) {
			int ord = Integer.compare(this.first, o.first);
			if (ord != 0) return ord;
			ord = Integer.compare(this.second, o.second);
			return ord;
		}
	}
	
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Pair[] P = new Pair[N];
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			P[i] = new Pair(a, i + 1);
		}
		Arrays.sort(P);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			if (i > 0) {
				sb.append(" ");
			}
			sb.append(P[i].second);
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 64904
#include <iostream>
using namespace std;
int main()
{
    int x;
    cin>>x;
    for(int i = 1;i<=9;i++) for(int j = 1;j<=9;j++) if(i*j == x) {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  int n, x, t; cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
     
    #define pii pair<int, int>
    #define f first
    #define s second
    #define pb push_back
    #define mp make_pair
    #define ll long long
    #define ld long double
    #define sz(v) int(v.size())
    #define all(v) v.begin(), v.end()
    #define vec vector<int>
    #define dead not_bad
    #define bad gooood
     
    #define left not_right
    #define y1 what
     
    using namespace std;
     
    const int N = (int) 1e5 + 10;
    const int M = (int) 20;
    const ll LINF = (ll) 1e18;
    const int INF = (int) 1e9 + 7;
    const int ALPHA = 26;
    const int mod = INF + 2;
    const double PI = 3.14159265359;
    const ld EPS = (ld) 1e-12;
     
    const int nx[4] = {0, 0, -1, 1};
    const int ny[4] = {1, -1, 0, 0};
     
    int n;
     
    int get(int x, int k) {
        int y = x;
    	while (y % k) {
    		int d = y / k;
    		/*
    		y - (d + 1) * t > d * k 
    		y - d * k > (d + 1) * t 
    		(y - d * k) / (d + 1) > t
    		*/
    		ll t = (y - d * 1ll * k + d) / (d + 1);
    		y -= (d + 1) * t;
    	}
    	return y / k;
    }
     
    int main() {
      #define fn "saddle"
      #ifdef witch
          freopen("input.txt", "r", stdin);
          freopen("output.txt", "w", stdout);
      #else
          //freopen(fn".in", "r", stdin);
          //freopen(fn".out", "w", stdout);
      #endif
      cin >> n;
      int ans = 0;
      for (int i = 0; i < n; i++) {
      	int x, k;
      	cin >> x >> k;
      	ans ^= get(x, k);
      }
      cout << (ans ? "Takahashi" : "Aoki");
      return 0;
    }

Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] l = new long[n + 1];
		l[0] = 2;
		l[1] = 1;
		for(int i = 2 ; i <= n ; i++) {
			l[i] = l[i - 1] + l[i - 2];
		}
		System.out.println(l[n]);
	}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

#ifdef sarthak
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#else
#define trace(...)
#endif

#ifndef sarthak
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fort(i,v) for(auto i:v)
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) rep(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) rep(i,sizeof(ar)/sizeof(ar[0])) rep(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define sd2(x,y) scanf("%d %d",&x,&y)
#define slld2(x,y) scanf("%lld %lld",&x,&y)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pd2(x,y) printf("%d %d\n",x,y)
#define plld2(x,y) printf("%lld %lld\n",x,y)
#define all(ar) ar.begin(), ar.end()
#define endl '\n'
#define sz(x) (int)x.size()
#define len(x) (int)x.length()

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

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

    ll p[n];
    rep(i,n)
    {
        cin >> p[i];
    }

    ll ans = 0;
    fr(i,1,n-2)
    {
        ll num = 0;
        if(p[i]>p[i-1])
            num++;
        if(p[i]>p[i+1])
            num++;
        if(num==1)
            ans++;
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed;
    cout << setprecision(10);
    #ifdef sarthak
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }

    #ifdef sarthak
    cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    #endif
}



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


int main(){
	int N, D; cin >> N >> D;
	double X, Y;
	int ans = 0;
	for(int i = 0; i < N; ++i) {
		cin >> X >> Y;
		if(sqrt(X*X + Y*Y) <= D) ans++;
	}
	cout << ans << endl;	


}













Measured memory_bytes: 3716
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  unordered_set<string> set;
 
  string w;
  string w_before;
  for (int i = 0; i < n; ++i) {
    cin >> w;
    
    if (!w_before.empty()) {
	    if (w[0] != w_before[w_before.size() - 1]) {
          cout << "No\n";
    	  return 0;
   	 	}
    }
    
    set.insert(w);
    
    if (set.size() != (i + 1)) {
      cout << "No\n";
      return 0;
    }
    
    w_before = w;
  }
  
  cout << "Yes\n";
  return 0;
}

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

using namespace std;
typedef long long LL;

int main() {
  LL N, K;
  cin >> N >> K;
  LL ans = 0;
  for (LL b = K + 1; b <= N; b++) {
    ans += (N / b) * (b - K);
    ans += max(0LL, N - N / b * b - K + 1);
  }
  if (K == 0) ans = N * N;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    REP(i, 0, X) {
        int cnt = 2 * i + (X - i) * 4;
        if(Y == cnt) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3640
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,ti,di
    integer(int32), allocatable:: d(:),t(:)

    read*, n
    allocate(d(n))
    read*, d(:)
    read*, m
    allocate(t(m))
    read*, t(:)
    call merge_sort(d,1,n)
    call merge_sort(t,1,m)
    di=1
    do ti=1,m
        if (t(ti) /= d(di)) then
            do while(t(ti) /= d(di))
                di=di+1
                if (di > n) then
                    print'(a)', 'NO'
                    stop
                end if
            end do
        end if
        di=di+1
    end do
    print'(a)', 'YES'
contains
recursive subroutine merge_sort(ar, fst, lst)
integer(int32),intent(inout):: ar(:)
integer(int32),intent(in):: fst,lst
integer(int32):: mdl

if (lst-fst < 2) then
    if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
    return
end if

mdl = (fst+lst)/2
call merge_sort(ar, fst, mdl)
call merge_sort(ar, mdl+1, lst)
call merge_(ar, fst, mdl, lst)
end subroutine

subroutine merge_(ar, fst, mdl, lst)
integer(int32),intent(inout):: ar(:)
integer(int32),intent(in):: fst, mdl, lst
integer(int32),allocatable:: tmp(:)
integer(int32):: li, ri, ti

allocate(tmp(lst-fst+1))

li=fst
ri=mdl+1   
ti=1

do while (li <= mdl .and. ri <= lst)
    if (ar(li) <= ar(ri)) then
        tmp(ti) = ar(li)
        li=li+1
    else
        tmp(ti) = ar(ri)
        ri=ri+1
    end if
    ti=ti+1
end do

if (li <= mdl) then
    tmp(ti:) = ar(li:mdl)
else
    tmp(ti:) = ar(ri:lst)
end if

ar(fst:lst) = tmp(:)
deallocate(tmp)
end subroutine

subroutine swap(x,y)
integer(int32),intent(inout):: x,y
integer(int32):: tmp
tmp = x
x = y
y = tmp
end subroutine
end program name

Measured memory_bytes: 3508
#include<iostream>

int main(void)
{
	int A,B,X;

	std::cin >> A >> B >> X;

	if( X < A ){
		std::cout << "NO" << std::endl;
	}else{
		if( A+B < X ){
			std::cout << "NO" << std::endl;
		}else{
			std::cout << "YES" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
ar=sorted(list(map(int,input().split())))
re=[]
if(n%2==1):
    re.append(0)
    for e in range(2,n,2):
        re.append(e)
        re.append(e)
else:
    for e in range(1,n,2):
        re.append(e)
        re.append(e)
#print(ar,re)
if(ar!=re):
    print(0)
else:
    print(pow(2,n//2,10**9+7))


Measured memory_bytes: 20488
#include <bits/stdc++.h>
using namespace std;
#define M 2550
#define LL long long
const int mo = 1e9 + 7;
int dp[52][5201][52]; // 放到第i位 在我 之前 的空位有h位.

void Add(int &res,int x) {
	res += x;
	if(res > mo) res -= mo;
	return ;
}
#define debug(x) cout << #x <<" " << x << endl;
main () {
	int n,k;
	cin >> n >> k;
	dp[1][M][0] = 1;
  	for(int i=1;i<=n;i++) {
		for(int j=0;j<=M*2;j++) {
			for(int h=i-1;h>=0;h--) {
				if(!dp[i][j][h]) continue;
				Add(dp[i+1][j][h],1LL*dp[i][j][h]*(h<<1|1)%mo); // 放自己.
				Add(dp[i+1][-2*i+j][h+1],dp[i][j][h]); // 放后面 . 且当前位不放先.
				if(h) Add(dp[i+1][j+2*i][h-1],1LL*dp[i][j][h]*h%mo*h%mo); // 放前面 且当前位放前面空出来的.
			}
		}
	}
	cout<<dp[n+1][M+k][0];
	return 0;
}

Measured memory_bytes: 52608
#include<bits/stdc++.h>
using namespace std;
int n,k,s;
int main(){
	scanf("%d%d%d",&n,&k,&s);
	for(int i = 0; i < n; i ++){
		if(i < k) printf("%d ",s);
		else{
			if(s != 1) printf("%d ",s - 1);
			else printf("2 ");
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
 
int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int x_mx=w;
  int x_mn=0;
  int y_mx=h;
  int y_mn=0;
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1){
      if(x_mn>=x) continue;
      else x_mn=x;
    }
    else if(a==2){
      if(x>=x_mx)continue;
      else x_mx=x;
    }
    else if(a==3){
      if(y_mn>=y)continue;
      else y_mn=y;
    }
    else{
      if(y>=y_mx) continue;
      else y_mx=y;
    }
  }
  int H=y_mx-y_mn;
  int W=x_mx-x_mn;
  if(H<=0||W<=0){
    cout << 0 << endl;
    return 0;
  }
  cout << H*W <<endl;
  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

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

  vector<int> ans(n);

  rep(k, n) {
    int m = b.size();
    bool ok = false;
    for(int i = m-1; i >= 0; --i) {
      if(b[i] == i+1) {
        ans[k] = b[i];
        vector<int> c;
        rep(j, m) if(j != i) c.push_back(b[j]);
        b = c;
        ok = true;
        break;
      }
    }
    if(!ok) {
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(ALL(ans));
  for(auto x : ans) cout << x << endl;
}


Measured memory_bytes: 3596
a = list(map(int, input().split()))
if a[1] <= a[2]:
  print(0)
  exit()
elif a[0]<=a[2] and a[2] <= a[1] and a[1]<=a[3]:
  print(a[1]-a[2])
  exit()
elif a[0]<=a[2] and a[3]<=a[1]:
  print(a[3]-a[2])
  exit()
elif a[2]<=a[0] and a[1]<=a[3]:
  print(a[1]-a[0])
  exit()
elif a[2]<=a[0] and a[0] <= a[3] and a[3]<=a[1]:
  print(a[3]-a[0])
  exit()
else:
  print(0)

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

using namespace std;

int main(int, char**) {
	string s;
	cin >> s;
	int ret = 0;
	int l = s.size();
	for (int i=0; i<l/2; i++) {
		if (s[i]!=s[l - 1 - i]) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int a,b;
  cin >> a >> b;
  if((a%2==0)||(b%2==0))cout << "No"<<endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 101
using namespace std;
int h,w,A;
string mp[101];
int dx[]={0,0,1,-1};//V^><
int dy[]={1,-1,0,0};

void pr(int x,int y,int dir){
  char ch[]={'V','^','>','<'};
  char tmp=mp[y][x];
  mp[y][x]=ch[dir];
  for(int i=0;i<h;i++)cout<<mp[i]<<endl;
  mp[y][x]=tmp;
  cout<<"------"<<endl;
}

int ans=1e9,used[101][101][10][10][4];
void dfs(int x,int y,int p,int q,int dir){
  if(2*A-(p+q)>=ans)return;
  int &u=used[x][y][p][q][dir];
  if(u!=-1&&u<=2*A-(p+q))return;
  u=2*A-(p+q);

  vector<int> X,Y,ch;
  while(1){
    x+=dx[dir];
    y+=dy[dir];
    if(x<0||y<0||x>=w||y>=h||mp[y][x]=='#')break;
    if(mp[y][x]=='S')continue;
    if(mp[y][x]=='G')ans=min(ans,2*A-(p+q));
    X.push_back(x);
    Y.push_back(y);
    ch.push_back(mp[y][x]);
    mp[y][x]='#';
    if(p){
      if(dir==0)dfs(x,y,p-1,q,2); //>
      if(dir==1)dfs(x,y,p-1,q,3); //<
      if(dir==2)dfs(x,y,p-1,q,0); //V
      if(dir==3)dfs(x,y,p-1,q,1); //^
    }
    if(q){
      if(dir==0)dfs(x,y,p,q-1,3); //>
      if(dir==1)dfs(x,y,p,q-1,2); //<
      if(dir==2)dfs(x,y,p,q-1,1); //^
      if(dir==3)dfs(x,y,p,q-1,0); //V
    }
  }
  for(int i=0;i<X.size();i++)mp[Y[i]][X[i]]=ch[i];
}

int main(){
  cin>>h>>w>>A;
  for(int i=0;i<h;i++)cin>>mp[i];

  memset(used,-1,sizeof(used));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j]=='S')dfs(j,i,A,A,0);

  cout<<(ans==1e9? -1:ans)<<endl;
  return 0;
}

Measured memory_bytes: 19172
using System;
using System.Collections;
using System.Linq;
namespace AGC016A
{
    class Program
    {
        private static string alp = "abcdefghijklmnopqrstuvwxyz";
        static int GetIdx(char c)
        {
            for (int i = 0; i < alp.Length; i++)
                if (c == alp[i])
                    return i;
            return -1;
        }
        static void Main()
        {
            string s = Console.ReadLine();
            bool f = true;
            for (int i = 0; i < s.Length - 1; i++)
                f = f && s[i] == s[i + 1];
            if (f)
            {
                Console.WriteLine(0);
                Environment.Exit(0);
            }
            int[] nums = new int[s.Length];
            bool[] exist = new bool[alp.Length];
            for (int i = 0; i < s.Length; i++)
            {
                nums[i] = GetIdx(s[i]);
                exist[nums[i]] = true;
            }
            int[] num2 = new int[s.Length];
            ArrayList al = new ArrayList();
            int j;
            for (int i = 0; i < alp.Length; i++)
            {
                if (exist[i])
                {
                    for (j = 0; j < s.Length; j++)
                        num2[j] = (nums[j] == i) ? 1 : 0;
                    for (j = 0; ; j++)
                    {
                        for (int k = 0; k < s.Length - j - 1; k++)
                            num2[k] = (num2[k] == 1 || num2[k + 1] == 1) ? 1 : 0;
                        for (int k = s.Length - j - 1; k < s.Length; k++)
                            num2[k] = 1;
                        if (num2.Sum() == s.Length)
                        {
                            al.Add(j + 1);
                            break;
                        }
                    }
                }
            }
            int[] ans = (int[])al.ToArray(typeof(int));
            Console.WriteLine(ans.Min());
        }
    }
}

Measured memory_bytes: 11220
from collections import defaultdict
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

#　町iを尋ねた回数
check = {}
check[1] = 0

# cnt[i] i回目に行った町
cnt = [1]

# 回数
i = 0

# 現在地
now = 1
while True:
    cnt.append(a[now])
    i += 1
    now = cnt[-1]
    if now in check.keys():
        ans = (k-i) % (i - check[now])
        print(cnt[check[now]+ans])
        break
    else:
        check[now] = i
    if i == k:
        print(now)
        break

Measured memory_bytes: 33832
N = int(input())
A = list(map(int, input().split()))

right = 0  # 毎回rightを使い回すようにする
res = 0  # 部分列の長さ
xor = 0  # xorも使い回す
s = 0  # sも使い回す

for left in range(N):
    while right < N and (s + A[right] == xor ^ A[right]):  # rightを１個すすめた時に条件を満たす
        s += A[right]
        xor ^= A[right]
        right += 1

    # breakした状態で right は条件を満たす最大
    res += right - left

    # left をインクリメントする準備
    if right == left:  # right が left に重なったら right も動かす
        right += 1
    else:
        # left のみがインクリメントされるので s, xor から A[left] をのぞく
        s -= A[left]
        xor ^= A[left]

print(res)


Measured memory_bytes: 24712
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	char c;
	cin >> c;
	if(isupper(c)) cout << "A" << endl;
	else cout << "a" << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
	int t;
		solve();
	return 0;
}
 















Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
//#define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e5 + 5;

int n;
int a[N];

void run() {
    for(int i = 1; i <= n; i++) cin >> a[i];
    int j = 0;
    ll sum1 = 0, sum2 = 0;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        while(j + 1 <= n) {
            if(sum1 + a[j + 1] == (sum2 ^ a[j + 1])) {
                sum1 += a[++j], sum2 ^= a[j];
            }
            else break;
        }
        ans += j - i + 1;
        sum1 -= a[i]; sum2 ^= a[i];
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../input.in", "r", stdin);
    freopen("../output.out", "w", stdout);
#endif
    while(cin >> n) run();
    return 0;
}


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

w = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]


s = {}
s["a"] = 0
ans = [s]

for i in range(2, n+1):
    new_s = {}
    for t in s.items():
        for j in range(1, i):
            if t[0][-1] == w[j-1]:
                for k in range(t[1] + 2):
                    new_s[t[0] + w[k]]  = max(t[1], k)

    ans.append(new_s)
    s = new_s

answer = sorted(ans[n-1].keys())

for x in answer:
    
    print(x) 


Measured memory_bytes: 21808
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,k;
    cin >> n >> k;
    long long tmp = n%k;
    if(abs(tmp)<abs(tmp-k)){
        cout << abs(tmp) << endl;
    }else{
        cout << abs(tmp-k) << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }else{
        vector <unsigned long long>l;
        l.push_back(2);
        l.push_back(1);//n==1 size==2 
        while(true){
           l.push_back(l[l.size()-1]+l[l.size()-2]);
           //cout << l.size() <<" "<< l.back() << endl;
           if(l.size()==n+1){
               cout << (unsigned long long)l.back() << endl;
               return 0;
           } 
        }
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
 #include <vector>
 #include <map>
 #include <string>
 #include <algorithm>
 using namespace std;

 typedef long long ll;

ll combi(int x)
{
    if(x < 2) return 0;
    else{
        return (ll)x * (x-1) / 2;
    }
}

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

    map<string, int> mp;
    
    for(int i = 0; i < n; i++)
    {
        string y;
        cin >> y;
        sort(y.begin(), y.end());
        mp[y]++;
    }

    ll sum = 0;
    for(auto it = mp.begin(); it != mp.end(); ++it)
    {
        sum += combi(it->second);
    }

    cout << sum << endl;

     
     return 0;
 }

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e5+20;

struct node {
	int v,next,w;
};
node e[maxn<<1];
int cnt,start[maxn];
inline void addedge(int u,int v,int w){ e[++cnt]=(node){v,start[u],w};start[u]=cnt;}

int n,m;

int vis[maxn],dis[maxn];

inline void init()
{
	n=read();m=read();
	REP(i,1,m)
	{
		int u=read(),v=read();
		addedge(u,v,1);
		addedge(v,u,2);
	}
}

int num[3],EDGE;
int flg;

void dfs(int u)
{
	++num[dis[u]]; vis[u]=1;
	EREP(i,u)
	{
		EDGE++;
		int v=e[i].v;
		if(vis[v])
		{
			if(dis[v]==(dis[u]+e[i].w)%3)continue;
			else flg=1;
		}else dis[v]=(dis[u]+e[i].w)%3,dfs(v);
	}
}

ll ans;

inline void doing()
{
	REP(i,1,n)if(!vis[i])
	{
		memset(num,0,sizeof(num));EDGE=0;
		flg=0;
		dfs(i);
		int all=num[0]+num[1]+num[2];
		if(flg)ans+=(ll)all*all;
		else {
			if(num[0] && num[1] && num[2])REP(op,0,2)ans+=(ll)num[op]*num[(op+1)%3];
			else ans+=EDGE>>1;
		}
	}
	printf("%lld\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    int sum = X;
    REP(i, N) {
        int a = 0;
        cin >> a;
        sum += (D - 1) / a;
        sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> a >> b >> c;


    if(b>=c) cout <<  "delicious";
    else{
        if(a>=c-b) cout <<  "safe";
        if(a<c-b) cout <<  "dangerous";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

mint comb(int n, int r) {
    mint ret = 1;
    for (int i = 1; i <= r; ++i) {
        ret *= n - i + 1;
        ret /= i;
    }
    return ret;
}

void solve() {
    int n;
    std::cin >> n;

    mint ans = mint(2).pow(n) - 1;
    for (int i = 0; i < 2; ++i) {
        int a;
        std::cin >> a;
        ans -= comb(n, a);
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
//LLONG_MAX;

int main(void){
	ll N,p[100010]={},cnt=0;
	scanf("%lld",&N);
	reg(i,1,N){
		scanf("%lld",&p[i]);
		if(p[i]==i){
			p[i]=1;
		}else{
			p[i]=0;
		}
	}
	reg(i,1,N){
		if(p[i]==1){
			if(p[i+1]==1){//swapする
				p[i]=0;
				p[i+1]=0;
				cnt++;
			}else{//後ろのやつとswap
				p[i]=0;
				cnt++;
			}
		}
	}
	
	printf("%lld\n",cnt);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll> X(N),Y(N);
  for(int i=0;i<N;i++){
    cin>>X[i]>>Y[i];
  }
  int ans=N;
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      ll p=X[i]-X[j];
      ll q=Y[i]-Y[j];
      int cnt=0;
      for(int ii=0;ii<N;ii++){
        for(int jj=0;jj<N;jj++){
          if(ii==jj)continue;
          if(X[ii]-X[jj]==p && Y[ii]-Y[jj]==q){
            cnt++;
          }
        }
      }
      ans=min(ans,N-cnt);
    }
  }
  if(N==1)ans=1;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import datetime

weekdays = [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
]

while True:
  m, d = map(int, raw_input().strip().split(" "))
  if m == 0:
    break
  print weekdays[datetime.date(2004, m, d).weekday()]

Measured memory_bytes: 4396
import numpy as np
import math


def get_calc_vec(base, a):
    rad = math.radians(a)
    x = np.array([[math.cos(rad), -math.sin(rad)],
                  [math.sin(rad), math.cos(rad)]])
    ans = np.dot(x, base)
    return ans


def main():
    A, B, H, M = map(int, input().split())
    sum_time = H * 60 + M

    # それぞれの角度
    a_H = sum_time / 720 * 360
    a_M = M / 60 * 360
    #print(a_H, a_M)

    base_H_vec = np.array([0, A])
    base_M_vec = np.array([0, B])
    #print(base_H_vec, base_M_vec)
    vec_H = get_calc_vec(base_H_vec, a_H)
    vec_M = get_calc_vec(base_M_vec, a_M)

    ans_vec = vec_H - vec_M
    print(np.linalg.norm(ans_vec, ord=2))


main()

Measured memory_bytes: 27320
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
 
int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> input(n,0);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> input.at(i);
  }
  
  int max = 0;
  for (int i = 0; i < n; i++) {
    if(i < m){
      sum += input[i];
    }else{
      sum = sum - input[i-m] + input[i];
    }
    if(sum > max) max = sum;
  }
  
  cout << setprecision(7) << (max + m)/2.0 << endl;
  
  return 0;
}

Measured memory_bytes: 1024
/* long long or int */
/* xx 396*/

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

int n,a,b;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 55, mod = (int) 0;
int g[N + N][N + N];
int main() {
	long long x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1) {
		cout << "Brown\n";
	} else {
		cout << "Alice\n";
	}
	return 0;
	for (int sum = 0; sum < N + N; ++sum) {
		for (int a = 0; a < N + N; ++a) {
			int b = sum - a;
			set<int> st;
			if (b >= 0 && b < N + N) {
				for (int use = 2; use <= a; use += 2)
					st.insert(g[a - use][use / 2 + b]);
				for (int use = 2; use <= b; use += 2)
					st.insert(g[b - use][use / 2 + a]);
			
			while (st.find(g[a][b]) != st.end()) ++g[a][b];
			if (g[a][b] == 0) cout << a << ' ' << b << ' ' << g[a][b] << endl;
			}
		}
	}
	long long res = x + 2 * y;
	/*while (true) {
		if (x < y) swap(x, y);
		long long t = x >> 1;
		if (!t) break;
		x -= 2 * t;
		y += t;
		++res;
	} */
	if (res % 3 != 0) {
		cout << "Alice" << endl;
	} else {
		cout << "Brown" << endl;
	}
}











Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define qq ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007;
long long gcd(long long a, long long b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
} 
int main()
{
  qq;
  long long a,b,c,d,da,db,dn;
  cin>>a>>b>>c>>d;
  long long lcm = (c*d)/gcd(c,d); 
  db = b/c + b/d -b/lcm  ;
  da = (a-1)/c + (a-1)/d - (a-1)/lcm;
  dn = db-da;
  cout<<(b-a+1) - dn<<endl;
  return 0;
}
 

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char s[] = sc.next().toCharArray();
		
		int cnt = 0;
		for(int i=1;i<s.length;i++){
			if(s[i] != s[i-1])
				cnt++;
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 27800
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

#if 0
所用時間:

感想:

#endif

int solve(int gx, int gy, int p){

  int T[16][16]; //T[y][x]の初期化
  bool Vert[16][16] = {}; //マタタビが上にあるかないか
  bool Horiz[16][16] = {}; //マタタビが左にあるかないか

  for(int i = 0; i < 16; ++i){ //Vertの初期化
    Vert[0][i] = true; //y=0の場合上は通れない
    Horiz[i][0] = true; //x=0の場合左は通れない
  }

  for(int i = 0; i < p; ++i){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    //printf("(x1,y1)=(%d,%d), (x2,y2) = (%d,%d)\n", x1, y1, x2, y2);
    if(x1 == x2) Vert[max(y1,y2)][x1] = true; //上から移動不可
    else if (y1 == y2) Horiz[y1][max(x1,x2)] = true; //左から移動不可
  }

  //テーブルTの更新
  for(int i = 0; i <= gy; ++i){
    for(int j = 0; j <= gx; ++j){
      if((i == 0) && (j == 0)) T[i][j] = 1;
      else if(Vert[i][j] && Horiz[i][j]) T[i][j] = 0; //左も上もマタタビがある
      else if(Vert[i][j]) T[i][j] = T[i][j-1]; //上にマタタビ
      else if(Horiz[i][j]) T[i][j] = T[i-1][j]; //左にマタタビ
      else T[i][j] = T[i][j-1] + T[i-1][j];
    }
  }

  // //テーブルの表示
  // cout << "Ttable:" << endl;
  // for(int row=0; row <= gy; ++row){
  //   for(int col = 0; col <= gx; ++col){
  //     cout << T[row][col];
  //   }
  //   cout << endl;
  // }

  return T[gy][gx];
}

int main(){
  int N,gx,gy,p;
  cin >> N;

  for(int i = 0; i < N; ++i){
    cin >> gx >> gy >> p;
    //printf("(gx,gy,p)=(%d,%d,%d)\n",gx, gy, p);

    int ans = solve(gx, gy, p);

    if(ans == 0)  cout << "Miserable Hokusai!" << endl;
    else cout << ans << endl;
  }
}



Measured memory_bytes: 3096