akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
using P = pair<i64, i64>;
vector<P> ps;
int main() {
  cin >> n;
  init_n(ps, n + 1);
  for (i64 i = 0; i < n; ++i) cin >> ps[i].first >> ps[i].second;
  sort(begin(ps), end(ps), [](auto p, auto q) {
    return p.first + p.second < q.first + q.second;    
  });

  vector<vector<i64>> dp(n + 1, vector<i64>(n + 1, 1ll << 32));
  dp[0][0] = 0;
  for (i64 i = 1; i <= n; ++i) {
    for (i64 k = 0; k <= i; ++k) {
      dp[i][k] = dp[i - 1][k];
      if (k > 0 && dp[i - 1][k - 1] <= ps[i].first) {
        dp[i][k] = min(dp[i][k], dp[i - 1][k - 1] + ps[i].second);
      }
    }
  }
  i64 ans = 0;
  for (i64 k = 0; k <= n && dp[n][k] < (1ll << 32); ++k) {
    ans = k;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 195968
#include <iostream>
using namespace std;
int main()
{
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  for (int a = 0; a <= A; a++)
  {
    for (int b = 0; b <= B; b++)
    {
      for (int c = 0; c <= C; c++)
      {
        if (500 * a + 100 * b + 50 * c == X)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
using namespace std;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define iT(_t,_x) _t _x;std::cin >> _x;  
#define iInt(_x) int _x;in(_x); 
#define ill(_x) ll _x;in(_x); 
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }


set<int> s;
int main() {
	iInt(n);
	int sum = 0;
	while (n--)
	{
		iInt(a);
		if(s.insert(a).second==0)
		{
			s.erase(a);
		}
		else { s.insert(a); }
	}
	std::cout << s.size();
}


Measured memory_bytes: 4864
#include<iostream>
#include<iomanip>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
#include <functional>
#include <cassert>
typedef long long int ll;
using namespace std;

int main(){
	int A,B;
	string s;
	cin>>A>>B;
	vector<string> S;
	for(int i=0;i<A;i++){
		cin>>s;
		S.push_back(s);
	}
	sort(S.begin(),S.end());
	for(int i=0;i<A;i++){
		cout<<S[i];
	}
	cout<<endl;
	return 0;

}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li x,n;
    cin>>x>>n;

    li a[n];

    map<li,li> m;

    f(i,0,n-1)
    {
        cin>>a[i];
        m[a[i]]++;
    }   

    vi v;

    f(i,-100,200)
    {
        if(!m.count(i))
        {
            v.PB(i);
        }
    }

    li mn=1e18;

    li ans=1e18;

    fr(i,301-n-1,0)
    {
        if(abs(v[i]-x)<=mn)
        {
            ans=v[i];

            mn=abs(v[i]-x); 
        }
    }

    cout<<ans;
}

int main()
{    
    

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

using V = vector<int>;
using Q = queue<int>;
using Graph = vector<vector<int>>;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
	inn(n, m);
	Graph g(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}

	V dist(n, -1);
	V ans(n, -1);
	Q que;

	dist[0] = 0;
	que.push(0);

	while(!que.empty()) {
		int v = que.front();
		que.pop();

		for(int nv : g[v]) {
			if (dist[nv] != -1) continue;

			dist[nv] = dist[v] + 1;
			ans[nv] = v;
			que.push(nv);
		}
	}

	if (find(ans.begin(), ans.end(), -1) == ans.end()) {
		out("No");
		return 0;
	}

	out("Yes");
	for(int i = 1; i < n; ++i)
		out(ans[i] + 1);

	return 0;
}


Measured memory_bytes: 10728
package main

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

func main() {
	n := readI()
	P, Q := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		P[i] = readI()
	}
	for i := 0; i < n; i++ {
		Q[i] = readI()
	}

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = i + 1
	}
	b := make([][]int, 1)
	b[0] = a
	for nextPermutation(a) {
		b = append(b, make([]int, n))
		copy(b[len(b)-1], a)
	}

	fmt.Println(abs(nop(P, b) - nop(Q, b)))

}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func nop(a []int, b [][]int) int {
	for i := 0; i < len(b); i++ {
		if isSame(a, b[i]) {
			return i
		}
	}
	return -1
}

func isSame(a, b []int) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func nextPermutation(p []int) bool {
	reverse := func(s []int) {
		for i := 0; i < len(s)/2; i++ {
			s[i], s[len(s)-1-i] = s[len(s)-1-i], s[i]
		}
	}
	l, r := len(p)-2, len(p)-1

	for p[l] > p[l+1] {
		if l == 0 {
			reverse(p)
			return false
		}
		l--
	}

	for p[l] > p[r] {
		r--
	}

	p[l], p[r] = p[r], p[l]

	reverse(p[l+1:])
	return true
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 8348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
ll flg,a[N],vis[N],n,m;
vector<ll> adj[N];
void dfs(ll node,ll clr){
    vis[node]=1;
    a[node]=clr;
    for(auto &v:adj[node]){
       if(vis[v]){
            if(a[v]==a[node]){
                cout<< (n*(n-1))/2 - m;
                exit(0);
            }
       }
       else{
            dfs(v,clr^1);
       }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(ll i=1;i<=m;i++){
        ll u,v;cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,2);
    ll b=0;for(ll i=1;i<=n;i++)b+=(a[i]==2);
    cout<< b*(n-b) - m;
}



Measured memory_bytes: 8320
// B - Sumo
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int x = 0;
	for (int i = 0; i < s.size(); i++)
		if (s[i] == 'x') x++;

	cout << (x <= 7 ? "YES" : "NO") << endl;

	return 0;
}


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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var S = Console.ReadLine();
        var E = 0;
        var W = S.Skip(1).Count(x=>x=='E');
        var ans = E+W;
        for (int i=1;i<N;++i)
        {
            if (S[i - 1] == 'W') E++;
            if (S[i] == 'E') W--;
            ans = Math.Min(ans,E+W);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13212
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    c = collections.Counter([S() for _ in range(n)])
    mv = max(c.values())

    return JA(sorted([k for k,v in c.items() if v == mv]), "\n")


print(main())





Measured memory_bytes: 37712
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;

#define prec(i) cout << fixed << setprecision(i)

void outPut_YN(bool isYes) {
	if (isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}

long long ncr(long long n, long long r) {
	long long sum = 1;
	for (long long i = r + 1; i <= n; i++)
		sum *= i;

	return sum;
}

int main()
{
	long long la, lb, lm, min = 99999999, min_a = 99999999, min_b = 99999999;

	cin >> la >> lb >> lm;

	vector<long long> a(la), b(lb);
		
	for (int i = 0; i < la; i++) {
		cin >> a[i];
		if (a[i] < min_a)
			min_a = a[i];
	}
		
	for (int i = 0; i < lb; i++) {
		cin >> b[i];
		if (b[i] < min_b)
			min_b = b[i];
	}

	min = min_a + min_b;

	for (int i = 0; i < lm; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		
		if (a[x - 1] + b[y - 1] - c < min)
			min = a[x - 1] + b[y - 1] - c;
	}
	
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>

#define ll long long
using namespace std;
ll dp[100009]{};
ll MAX = 1000000;
int main()
{

    ll N; cin>>N;
    ll K; cin>>K;
    ll height[N+1]{};
    for(ll i = 1; i<= N ; i++)cin>>height[i];
    memset(dp ,MAX, sizeof(dp[0])*100009);
    dp[0]=0;
    dp[1] = 0;

    for(int i = 2 ;i<=N ;i++)
    {
    for(int k=1 ; k<=K ; k++)
    if(i-k>=1)
    {
        dp[i] = min(dp[i],dp[i-k]+abs(height[i]-height[i-k]));
    }

    }

    cout<<dp[N]<<endl;
    return 0;
}


Measured memory_bytes: 1792
from queue import deque

def main():
    n, q = tuple(map(int, input().split(' ')))

    task_q = deque()
    for idx in range(n):
        l = input().split(' ')
        task_q.append((l[0], int(l[1])))

    tot_time = 0
    while len(task_q) != 0:

        task = task_q.popleft()
        if task[1] > q:
            task_q.append((task[0], task[1] - q))
            tot_time += q

        else:
            tot_time += task[1]
            print(task[0], tot_time)


main()


Measured memory_bytes: 13636
#!/usr/bin/env python3
from collections import deque
d = deque(range(1, 10))
Dequeue = lambda: d.popleft()
Enqueue = lambda x: d.append(x)

for _ in range(int(input())):
    x = Dequeue()
    m = x%10
    if m != 0: Enqueue(10*x + m-1)
    if True  : Enqueue(10*x + m)
    if m != 9: Enqueue(10*x + m+1)
print(x)

Measured memory_bytes: 11960
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;

typedef long long LL;
const int MAXN = 1e5;
int a, b;

int main(){
	cin >> a >> b;
	if(b >= a)cout << a <<endl;
	else cout << a - 1 <<endl;
}

Measured memory_bytes: 256
while True:
    x = input().split()
    if x[1] == '+':
        y = int(x[0])+int(x[2])
        print(y)
    elif x[1] == '-':
        y = int(x[0])-int(x[2])
        print(y)
    elif x[1] == '*':
        y = int(x[0])*int(x[2])
        print(y)
    elif x[1] == '/':
        y = int(x[0])//int(x[2])
        print(y)
    elif x[1] == '?':
        break

Measured memory_bytes: 7584
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include<iomanip>
#define sqr(x) (x)*(x)
#define ll long long
using namespace std;
ll n,num[300005],ans=-1152921504606846976,i,j,l[300005],r[300005];
priority_queue<ll> ri;
priority_queue<ll,vector<ll>,greater<ll>/**/> le;
int main()
{
	cin>>n;
	for (i=1;i<=n*3;i++)
	{
		cin>>num[i];
		if (i<=n) 
		{
			le.push(num[i]);
			l[n]+=num[i];
		}
		if (i>n*2) 
		{
			ri.push(num[i]);
			r[n+n+1]+=num[i];
		}
	}
	for (i=n+1;i<=n+n;i++)
	{
		l[i]=l[i-1];
		if (le.top()<num[i])
		{
			l[i]=l[i]-le.top()+num[i];
			le.pop();
			le.push(num[i]);
		}
	}
	for (i=n+n;i>n;i--)
	{
		r[i]=r[i+1];
		if (ri.top()>num[i])
		{
			r[i]=r[i]-ri.top()+num[i];
			ri.pop();
			ri.push(num[i]);
		}
	}
	for (i=n;i<=n+n;i++)
	{
		ans=max(ans,l[i]-r[i+1]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7668
n,m = map(int,input().split())
lst0, lst1, lst2, lst3, lst4, lst5, lst6, lst7 =[],[],[],[],[],[],[],[]
for i in range(n):
    x,y,z = map(int,input().split())
    lst0.append(x+y+z)
    lst1.append(x+y-z)
    lst2.append(x-y+z)
    lst3.append(x-y-z)
    lst4.append(-x+y+z)
    lst5.append(-x+y-z)
    lst6.append(-x-y+z)
    lst7.append(-x-y-z)
lst0.sort(reverse=True)
lst1.sort(reverse=True)
lst2.sort(reverse=True)
lst3.sort(reverse=True)
lst4.sort(reverse=True)
lst5.sort(reverse=True)
lst6.sort(reverse=True)
lst7.sort(reverse=True)

res = []
res.append(sum(lst0[:m]))
res.append(sum(lst1[:m]))
res.append(sum(lst2[:m]))
res.append(sum(lst3[:m]))
res.append(sum(lst4[:m]))
res.append(sum(lst5[:m]))
res.append(sum(lst6[:m]))
res.append(sum(lst7[:m]))
print(max(res))

Measured memory_bytes: 40304
import java.util.Scanner;

public class Main {

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

		try {

			int first = sc.nextInt();
			int second = sc.nextInt();
			int third = sc.nextInt();

			int values[] = { first, second, third };

			int count5 = 0;
			int count7 = 0;

			for (int value : values) {
				count5 += value == 5 ? 1 : 0;
				count7 += value == 7 ? 1 : 0;
			}

			if (count5 == 2 && count7 == 1) {
				System.out.println("YES");
			} else {
				throw new Exception();
			}
		} catch (Throwable t) {
			System.out.println("NO");
		} finally {
			sc.close();
		}
	}
}


Measured memory_bytes: 9428
#include <stdio.h>

int main()
{
	int n, x, t;
	int cnt;
	scanf("%d%d%d", &n, &x, &t);
	if (n % x != 0)
	{
		cnt = n / x;
		cnt += 1;
		printf("%d", cnt * t);
	}
	else
	{
		cnt = n / x;
		printf("%d", cnt * t);
	}
}

Measured memory_bytes: 1672
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string a,b;
    cin >> a >> b;
    if(a.length() > b.length()){
        cout << "GREATER"<<endl;
        return 0;
    }

    if(a.length() < b.length()){
        cout << "LESS"<<endl;
        return 0;
    }

    rp(i,a.length()){
        if(a[i] > b[i]){
            cout << "GREATER"<<endl;
            return 0;
        }
        if(b[i] > a[i]){
            cout << "LESS"<<endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <cstdio>
const int Mod=1000000007;
int n,a,b;
int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1){
			ans=1ll*ans*a%Mod;
		}
		a=1ll*a*a%Mod;
		b>>=1;
	}
	return ans;
}
int C(int n,int m){
	int ans=1;
	for(int i=1;i<=m;i++){
		ans=1ll*ans*(n-m+i)%Mod;
		ans=1ll*ans*ksm(i,Mod-2)%Mod;
	}
	return ans;
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	printf("%d\n",((ksm(2,n)-C(n,a)+Mod)%Mod-C(n,b)+Mod-1)%Mod);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int sum,n,m,a[55];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=n-m+1;i--)
	{
		sum+=a[i];
	}
    cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int flag=1,tmp,n,i=0,j,cnt=0;
  scanf("%d",&n);
  int A[n];
  for(j=0;j<n;j++){
    scanf("%d",&A[j]);
  }
  while(flag){
    flag=0;
    for(j=n-1;j>i;j--){
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	cnt++;
      }
    }
    i++;
  }
  for(j=0;j<n;j++){
    printf("%d",A[j]);
    if(j<n-1){
      printf(" ");
    }else{
      printf("\n");
    }
  }
  printf("%d\n",cnt);
  return 0;
}



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

using namespace std;

int S(int number)
{
	int _s = 0;

	while (number > 0)
	{
		_s += number % 10;

		number /= 10;
	}

	return _s;
}

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

	if (N % S(N) == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a, b, c = gets.chomp.split(" ").map(&:to_i)

total = a * b * c
r1 = (a / 2) * b * c
b1 = total - r1

r2 = a * (b / 2) * c
b2 = total - r2

r3 = a * b * (c / 2)
b3 = total - r3

puts [(r1 - b1).abs, (r2 - b2).abs, (r3 - b3).abs].min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }

ll dp[55][2600][55];

ll go(int ind, int sum, int cnt, int A, int n, int a[]) {

    if(ind==n) {
        if(sum==cnt*A) {
            return 1;
        }
        else {
            return 0;
        }
    }

    if(dp[ind][sum][cnt]!=-1) {
        return dp[ind][sum][cnt];
    }

    ll pick=go(ind+1, sum+a[ind], cnt+1, A, n, a);
    ll dpick=go(ind+1, sum, cnt, A, n, a);

    return dp[ind][sum][cnt]=pick+dpick;
}



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

    memset(dp,-1,sizeof(dp));
    
    int n,A;
    cin>>n>>A;
    
    int a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }

    ll ans=go(0, 0, 0, A, n, a);

    cout<<ans-1;
    return 0;
}


Measured memory_bytes: 61696
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n+1;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
#define stringc(s) string s; cin >> s;
using namespace std;
int main() {
  stringc(s);
  string t="ABC";
  if(s=="ABC") t="ARC";
  cout << t << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;
const int FIVE = 101010;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>S;
}
//=============================
void func(){}
//=============================
void solve()
{
    int cnt = 0;
    rep(i,S.size()){
        if (S[i]=='o')cnt++;
    }
    cout<<700+100*cnt<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, M; cin >> N >> M;
  string S, T; cin >> S >> T;
  
  int g = gcd(N, M);
  int l = N/g*M;

  rep(i, M) {
    if((i*(l/M)*N)%l == 0 && T[i] != S[(i*(l/M)*N)/l]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << endl;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

ll a,b,k;
int main(){
	cin >> a >> b >> k;
	if (a > k){
		cout << a-k << " " << b;
	}else{
		cout << 0 << " " << max(b+a-k, (ll)0) << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int flag1=0;
string c;
int main()
{
	cin>>c;
	int l=c.size();
	for(int i=0;i<l;i++)
	  if(c[i]=='C') flag1=1;
	  else if(c[i]=='F'&&flag1==1)
	    {
	    	cout<<"Yes";
	    	return 0;
	    }
	cout<<"No";
	return 0;
}

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

 
int main() {
    string s;
    cin>>s;

    //substrの使い方

    auto check=[](string s){
        int n=s.size();
        string pre=s.substr(0,n/2);
        string back=s.substr(n/2); 
        if(pre==back)return 1;
        return 0;
    };

    for(int i=2;i<=s.length();i+=2){
        string tmp=s.substr(0,s.length()-i);
        if(check(tmp)){
            cout<<s.length()-i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

int N, T;
int A[MAX_N];
int ma[MAX_N];
int maI, cnt;

int main()
{
  scanf( "%d%d", &N, &T );
  rep( i, N )
    scanf( "%d", A+i );

  for( int i = N-1; i >= 1; --i )
    ma[i-1] = std::max( A[i], ma[i] );

  rep( i, N )
  {
    if( maI < ma[i]-A[i] )
    {
      maI = ma[i]-A[i];
      cnt = 1;
    }
    else if( maI == ma[i]-A[i] )
      ++cnt;
  }

  printf( "%d\n", cnt );

  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <queue>

using namespace std;

char S = 'S';
char W = 'W';
char N = 'N';
char E = 'E';

class dice{
  private:
    int up;
    int down;
    int east;
    int west;
    int north;
    int south;
  public:
    dice(int up, int south, int east, int west, int north, int down);
    void move(char to);
    int get_up();
    int get_east();
    bool is_up_south(int _up, int _south);
    dice* clone();
};

dice::dice(int _up, int _south, int _east, int _west, int _north, int _down) {
  up = _up;
  south = _south;
  east = _east;
  west = _west;
  north = _north;
  down = _down;
}

dice* dice::clone() {
  return new dice(up, south, east, west, north, down);
}

void dice::move(char to) {
  if(to == S) {
    int tmp = down;

    down = south;
    south = up;
    up = north;
    north = tmp;
  } else if (to == N) {
    int tmp = down;

    down = north;
    north = up;
    up = south;
    south = tmp;
  } else if (to == W) {
    int tmp = down;

    down = west;
    west = up;
    up = east;
    east = tmp;
  } else if (to == E) {
    int tmp = down;

    down = east;
    east = up;
    up = west;
    west = tmp;
  }
}

bool dice::is_up_south(int _up, int _south){
  return up == _up && south == _south;
}

int dice::get_east() {
   return east;
}

int dice::get_up(){
  return up;
}

int main() {
  int up, south, east, west, north, down;
  string move;

  cin >> up;
  cin >> south;
  cin >> east;
  cin >> west;
  cin >> north;
  cin >> down;

  int n, to_up, to_south;
  cin >> n;

  for(int i = 0; i < n; i++) {
    cin >> to_up;
    cin >> to_south;

    queue<dice*> steps;
    steps.push(new dice(up, south, east, west, north, down));

    while(1) {
      dice* d = steps.front(); steps.pop();

      if (d->is_up_south(to_up, to_south)) {
          cout << d->get_east() << endl;
          break;
      }

      dice* cloned_d;

      cloned_d = d->clone();
      cloned_d->move(S);
      steps.push(cloned_d);

      cloned_d = d->clone();
      cloned_d->move(N);
      steps.push(cloned_d);

      cloned_d = d->clone();
      cloned_d->move(W);
      steps.push(cloned_d);

      cloned_d = d->clone();
      cloned_d->move(E);
      steps.push(cloned_d);
    }
  }

  return 0;
}



Measured memory_bytes: 3124
from collections import deque
S = [ord(a)-97 for a in raw_input()]
N = len(S)
for c in xrange(26):
	L = deque()
	for i in xrange(N-1):
		if S[i] == c:
			l = i
			break
	else:
		continue
	cnt = 1
	lenL = 0
	for r in xrange(l+1,N):
		if S[r] == c:
			cnt += 1
			L.append(r)
			lenL += 1
			if cnt * 2 > r - l + 1:
				print l+1,r+1
				quit()
		while cnt * 2 < r - l + 1 and lenL > 0:
			l = L.popleft()
			lenL -= 1
			cnt -= 1
print -1,-1

Measured memory_bytes: 13680
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	long long ret=0;
	int la=0;
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		if(p-la>b){
			ret+=b;
		}else ret+=p-la;
		la=p;
	}
	ret+=b;
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	string s;
	int k;
	cin>>s>>k;

	int n=min((int)s.size(),k);
	set<string> ss;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=s.size()-i;++j){
            string foo = "";
            for(int k = j ; k <= j + i - 1 ; ++k) foo =  foo + s[k] ;
			ss.insert(foo);
		}
	}

	auto itr=ss.begin();
	REP(i,k-1){
		itr=ss.erase(ss.begin());
	}

	cout<<*itr<<endl;
}


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

struct Edge {int from, to, weight;};
using Graph = vector<vector<Edge>>;

int D, N;
string TEXT;
vector<string> PIECE;

set<string> OK;

string text;

int DP[45][45];

bool Levenshtein(auto p) {
  for(auto i = p; i <= text.size(); ++i) {
    auto d = D + 1;
    for(auto j = 1; j <= TEXT.size(); ++j) {
      if(text[i-1] == TEXT[j-1]) DP[i][j] = DP[i-1][j-1];
      else                       DP[i][j] = 1 + min({DP[i-1][j], DP[i][j-1], DP[i-1][j-1]});
      d = min(d, DP[i][j]);
    }
    if(D < d) return false;
  }
  return true;
}

void dfs(const auto& G, auto& used, auto cur) {
  if(TEXT.size() + D < text.size()) return;

  if(!Levenshtein(text.size() - PIECE[cur].size() + 1)) return;

  if(used.count(text)) return;
  used.emplace(text);

  if(DP[text.size()][TEXT.size()] <= D) OK.emplace(text);

  auto dup = text;
  for(auto e: G[cur]) {
    text = dup + PIECE[e.to].substr(e.weight);
    dfs(G, used, e.to);
  }
  text = dup;
}

void solve() {
  Graph G(N);
  for(auto i = 0; i < N; ++i) for(auto j = 0; j < N; ++j) {
    auto lhs = PIECE[i];
    auto rhs = PIECE[j];
    for(auto k = 0; k < lhs.size(); ++k) if(lhs.substr(lhs.size() - k) == rhs.substr(0, k)) G[i].push_back({i, j, k});
  }
 
  unordered_set<string> used;
  for(auto i = 0; i < N; ++i) {
    text = PIECE[i];
    dfs(G, used, i);
  }
}

int main() {
  for(auto i = 0; i < 45; ++i) DP[i][0] = DP[0][i] = i;

  while(cin >> D >> N, D | N) {
    cin >> TEXT;
    PIECE = vector<string>(N);
    for(auto& i: PIECE) cin >> i;
 
    sort(begin(PIECE), end(PIECE));
    PIECE.erase(unique(begin(PIECE), end(PIECE)), end(PIECE));
    N = PIECE.size();
 
    OK.clear();
    solve();
    cout << OK.size() << endl;
    if(OK.size() <= 5) for(auto i: OK) cout << i << endl;
  }
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
int solve(int n) {
  int counter = 0;
  queue<int> que;
  for(int i = 1; i < 10; ++i) {
    que.push(i);
  }
  int front_value;
  while(counter < n) {
    ++counter;
    front_value = que.front(); que.pop();
    int front_value_last_digit = front_value % 10;
    if(front_value_last_digit != 0) que.push(front_value*10 + front_value_last_digit-1);
    que.push(front_value*10 + front_value_last_digit);
    if(front_value_last_digit != 9) que.push(front_value*10 + front_value_last_digit+1);
  }
  return front_value;
}
/***** MAIN *****/
signed main() {
  int n = in();
  cout << solve(n) << endl;
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1792
def main():
  x = int(input())

  #-118<=A<=119, -119<=B<=118
  for a in range(-188, 200):
      for b in range(-199, 118):
          if pow(a, 5) - pow(b, 5) == x:
              print(a, b)
              break
      else:
          continue
      break


if __name__ == '__main__':
  main()


Measured memory_bytes: 9172
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(void) {
	int a,b,count=0,temp;
	cin >> a >> b;
	for(int i=a; i<=b; i++){
		temp=i%100;
		if(i/1000==temp/10+temp%10*10)count++;
	}
	cout << count << endl;
	return 0;
}


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

int main() { /* ここに書く */
  
  long long H , N , i , A , total ;
  cin >> H >> N ;
  i = 0 ;
  while( N > i ){
    cin >> A ;
    total = total + A ;
    i++ ;
  }
  if ( H <= total ){
    cout << "Yes" << endl ;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  
  if((a * b) % 2 == 1){
    System.out.println("Yes");
  }else{
    System.out.println("No");
  }
}
}

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

ll dp[2000100];

int main(void){
  ll n;
  cin >> n;
  fill(dp,dp+2000100,1);
  dp[n] = n;
  ll sum = n-1;
  for(int i = n-1;i > 0;--i){
    dp[i] = dp[i+1];
    dp[i] += (n-1)*(n-1);
    dp[i] %= mod;
    dp[i] += sum;
    dp[i] %= mod;
    sum -= dp[i+1+n];
    sum = (sum+mod) % mod;
    sum += dp[i+2];
    sum %= mod;
  }
  cout << dp[1] << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
int main() {
    ll f[5];
    memset(f, 0, sizeof(f));
    ll N;
    cin >> N;
    while(N--){
        string buf;
        cin >> buf;
        switch(buf[0]){
        case 'M':
            f[0]++;
            break;
        case 'A':
            f[1]++;
            break;
        case 'R':
            f[2]++;
            break;
        case 'C':
            f[3]++;
            break;
        case 'H':
            f[4]++;
            break;
        }
    }
    cout << (f[0] * f[1] * f[2] +
             f[0] * f[1] * f[3] +
             f[0] * f[1] * f[4] +
             f[0] * f[2] * f[3] +
             f[0] * f[2] * f[4] +
             f[0] * f[3] * f[4] +
             f[1] * f[2] * f[3] +
             f[1] * f[2] * f[4] +
             f[1] * f[3] * f[4] +
             f[2] * f[3] * f[4]) << endl;
    return 0;
}


Measured memory_bytes: 256
// B.cpp
// Date: 24:01:17 19 05 2020
// Author: bonelord
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) cerr<<"[("<<__LINE__<<") "<<#x<<" ]: "<<x<<"\n"
#define dbg_arr(x,sz) cerr<<"[("<<__LINE__<<") |"<<sz<<"| "<<#x<<" ]:\n";for(size_t i=0; i<sz; ++i) { cerr<<"["<<i<<"] "<<x[i]<<" "; }cerr<<endl

void solve(){
	int N, K;
	cin>>N>>K;
	vector<int> h(N+1);
	h[0] = 0;
	for (int i = 1; i <= N; ++i){
		cin>>h[i];
	}
	vector<int> dp(N+1,1e9+7);

	dp[0] = dp[1] = 0;
	for (int i = 2; i <= N; ++i){
		for (int j = 1; j <= K && j < i; ++j){
			dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]), dp[i]);
		}
	}
	cout<<dp[N]<<"\n";
}

main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.setf(ios::fixed);

//	int t; cin>>t; while (t--)
	solve();
}


Measured memory_bytes: 1024
if __name__ == "__main__":
    N = int(input())
    MAX_COORDINATE = 1000
    table = [[0] * (MAX_COORDINATE + 1) for idx in range(MAX_COORDINATE + 1)]

    for _ in range(N):
        x1, y1, x2, y2 = map(lambda x: int(x), input().split())
        table[y1][x1] += 1
        table[y1][x2] -= 1
        table[y2][x1] -= 1
        table[y2][x2] += 1
    for i in range(MAX_COORDINATE):
        for j in range(MAX_COORDINATE):
            table[i][j + 1] += table[i][j]
    for j in range(MAX_COORDINATE):
        for i in range(MAX_COORDINATE):
            table[i + 1][j] += table[i][j]

    print(max(max(val) for val in table))



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

using namespace std;


int main(void)
{
    int n, count = 0;
    int A[100];

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

    for (int i = 0; i < n; i++) {
        int min_index = i;
        for (int j = i; j < n; j++) {
            if (A[min_index] > A[j])
                min_index = j;
        }
        if (min_index != i) {
            int tmp = A[min_index];
            A[min_index] = A[i];
            A[i] = tmp;
            count++;
        }
    }

    for (int i = 0; i < n - 1; i++)
        cout << A[i] << " ";
    cout << A[n - 1] << endl;
    cout << count << endl;
}



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

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> c(n+1);
  c[0] = 3;
  mint ans = 1;
  rep(i,n) {
    if (!c[a[i]]) {
      puts("0");
      return 0;
    }
    ans *= c[a[i]];
    c[a[i]]--;
    c[a[i]+1]++;
  }
  cout<<ans.x<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
// vint divisor(ll n){ // nの約数
//   vint ret;
//   for(ll i=1;i*i<=n;i++){
//     if(n%i == 0){
//       ret.pb(i);
//       if(i*i!=n) ret.pb(n/i);
//     }
//   }
//   vsort(ret);
//   return ret;
// }
//
// ll get_digits_num(ll n){
//   ll ret=0;
//   while(n){
//     n/=10;
//     ret++;
//   }
//   return ret;
// }



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

  ll H,W;cin>>H>>W;
  vvchar A(H+2, vchar(W+2, '.'));
  ll cnt=0;
  rep(i,H){
    rep(j,W){
      char tmp;
      cin>>tmp;
      cnt+=(tmp=='#');
    }
  }




  if(cnt==H+W-1) cout<<"Possible" << endl;
  else cout << "Impossible" << endl;


}

















//


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    final int modder=1000000007;
    int n=sc.nextInt();
    int m=sc.nextInt();
    Deque<Integer> h=new ArrayDeque<>(m);
    for(int i=0;i<m;i++){
      h.addLast(sc.nextInt());
    }
    int dp[]=new int[n+1+2];
    Arrays.fill(dp,0);
    dp[0]=1;
    for(int i=0;i<=n;i++){
      if(h.peekFirst()!=null&&h.peekFirst()==i){
        h.pollFirst();
        dp[i]=0;
      }else{
        dp[i+1]=(dp[i+1]+dp[i])%modder;
        dp[i+2]=(dp[i+2]+dp[i])%modder;
      }
    }
    System.out.println(dp[n]);
  }
}

Measured memory_bytes: 60512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除

ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
string RLE(string s){
  ll n=s.size();
  char now='.';
  ll count=1;
  string press;
  loop(i,n){
    if(s[i]!=now){
      if(i){
        press+=now;
        press+=to_string(count);
      }
      now=s[i];
      count=1;
      continue;
    }
    else count++;
  }
  press+=now;
  press+=to_string(count);
  return press;
}
int main() {
  cout << fixed << setprecision(30);
  string s;
  cin>>s;
  string x=RLE(s);
  ll n=x.size();
  ll rcount=0;
  loop(i,n)if(x[i]=='R')rcount++;
  ll area=0;
  loop(i,rcount){
    string a,b;
    ll p1=0,p2=0;
    Loop(j,area,n){
      if(x[j]=='L'){
      p1=j-1;
      break;
    }
    }
    Loop(j,p1,n)if(x[j]=='R'){
      p2=j-1;
      break;
    }
    if(i==rcount-1)p2=n-1;
    Loop(j,area+1,p1+1)a+=x[j];
    Loop(j,p1+2,p2+1)b+=x[j];
    ll r=stoll(a);
    ll l=stoll(b);
    loop(j,r-1)putout(0);
    ll k=(r+1)/2+l/2;
    putout(k);
    putout(r+l-k);
    loop(j,l-1)putout(0);
    Loop(j,area+1,n){
      if(x[j]=='R'){
        area=j;
        break;
      }
    }
  }
}

Measured memory_bytes: 1040