akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    map<ll, ll> mp;
    ll dp[n+1]; mem(dp, 0);
    ll l = -1, ans = 1;
    rep(i, n)
    {
        ll x; cin >> x;
        if(x == 1)
        {
            l = 1; dp[1] = 1;
        }
        else{
            if(dp[x-1])dp[x] = dp[x-1]+1;
            ans = max(ans, dp[x]);
        }
        mp[x] = 1;
    }
    if(l == -1) ANS(-1);
    cout << n - ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 14336
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include  <cassert>
#include <fstream>
#include <codecvt>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

static const int MAX = 1400;
int dp[MAX][MAX], G[MAX][MAX];

int getLargestSquare(int h, int w) {
	int maxWidth = 0;
	rep(i, h) {
		rep(j, w) {
			dp[i][j] = (G[i][j] + 1) %2;
			maxWidth |= dp[i][j];
		}
	}
	FOR(i, 1, h) {
		FOR(j, 1, w) {
			if (G[i][j]) {
				dp[i][j] = 0;
			}
			else {
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				maxWidth = max(maxWidth, dp[i][j]);
			}
		}
	}
	return maxWidth * maxWidth;
}

signed main() {
	ios::sync_with_stdio(true);
	int h, w;
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> G[i][j];
		}
	}
	cout << getLargestSquare(h, w) << endl;;
	return 0;
}


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

int edge[705][705],memo[705],cnt1,cnt2,f=1,n;

void dfs(int now,int t)
{
	for (int i = 0; i < n; ++i)
	{
		if (edge[now][i]==1||i==now)
		{
			continue;
		}
		if (memo[i]==0)
		{
			if (t==1)
			{
				memo[i]=2;
				++cnt2;
				dfs(i,2);
			}
			else
			{
				memo[i]=1;
				++cnt1;
				dfs(i,1);
			}
		}
		else if (memo[now]==memo[i])
		{
			f=0;
		}
	}
}

int main(int argc, char const *argv[])
{
	int m;
	cin>>n>>m;
	int a,b;
	for (int i = 0; i < m; ++i)
	{
		cin>>a>>b;--a;--b;
		edge[a][b]=1;
		edge[b][a]=1;
	}
	vector<pair<int,int>> cnt;
	for (int i = 0; i < n; ++i)
	{
		if (memo[i]==0)
		{
			cnt1=1;cnt2=0;
			memo[i]=1;
			dfs(i,1);
			cnt.push_back({cnt1,cnt2});
		}
	}
	if (f==0)
	{
		cout<<"-1\n";
		return 0;
	}
	int dp[cnt.size()+5][n+5]={};
	dp[0][0]=1;
	for (int i = 0; i < cnt.size(); ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (dp[i][j]==1)
			{
				dp[i+1][j+cnt.at(i).first]=1;
				dp[i+1][j+cnt.at(i).second]=1;
			}
		}
	}
	int ans=100000000;
	for (int i = 0; i <= n; ++i)
	{
		if (dp[cnt.size()][i]==1)
		{
			ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4096
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n = arr.shift() - 0;
var a = arr.map(v => {
    return v.split(" ").map(Number);
});
a.sort(function(a, b) {
    return a[0] - b[0];
});
var min = Infinity;
for (var i = 0; i < a.length - 1; i++) {
    min = Math.min(min, Math.pow(a[i + 1][0] - a[i][0], 2) + Math.pow(a[i + 1][1] - a[i][1], 2));
}
for (var i = 0; i < a.length - 1; i++) {
    for (var j = i + 1; j < a.length; j++) {
        if (Math.pow(a[j][0] - a[i][0], 2) >= min) break;
        min = Math.min(min, Math.pow(a[j][0] - a[i][0], 2) + Math.pow(a[j][1] - a[i][1], 2));
    }
}
console.log(min);


Measured memory_bytes: 113244
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll 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;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N, K; cin >> N>> K;
    const double p = 0.5;
    double ans = 0.0;
    
    if (N>=K)
    {
        REP(i, N)
        {
            int point  = (K+i)/(i+1);
            int m = ceil(log2(point));
            ans += pow(p, m);
        }
        ans /= N;
    }

    else
    {
        REP(i, N)
        {
            int point  = (K+i)/(i+1);
            int m = ceil(log2(point));
            ans += pow(p, m);
        }
        ans /= N;
    }
    printf("%.16f\n", ans);
    return 0;
}



Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> List = new ArrayList<>();
        ArrayList<Integer> OPT = new ArrayList<>();
        int sum =0;
        int S = 0;
        for(int i=1;i<=N;i++){
            int num = sc.nextInt();
            List.add(num);
            if(i%2==0) sum+=num;
            S+=num;
        }
        OPT.add(S-2*sum);
        for(int i=0;i<N-1;i++) OPT.add(2*List.get(i)-OPT.get(i));
        for(int i=0;i<OPT.size();i++){
            System.out.print(OPT.get(i));
            if(i!=OPT.size()-1) System.out.print(" ");
        }
    }
}


Measured memory_bytes: 68204
# Problem C - Repsept
# input
K = int(input())

# initialization
seven = 7
ans = 1

# count
if K%2==0 or K%5==0:
    ans = -1
elif K==1:
    ans = 1
else:
    tmp_list = [0]*(10**6+1)
    while not seven%K==0: # 割り切れない限り
        seven = seven*10 + 7
        seven = seven % K
        ans += 1


# output
print(ans)


Measured memory_bytes: 16780
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;


const int MAX_V = 205;
const int MAX_R = 1005;

void init(int m[MAX_V][MAX_V]){
	rep(i,MAX_V) rep(j,MAX_V) m[i][j] = INF;
	rep(i,MAX_V) m[i][i] = 0;
}

void warshallFloyd(int m[MAX_V][MAX_V], int n){
	rep(k,n){
		rep(i,n){
			rep(j,n){
				m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
			}
		}
	}
}

int main(){
	int N, M;
	while(cin >> N >> M, N||M){
		int gl[MAX_V][MAX_V], gs[MAX_V][MAX_V];
		init(gl);
		init(gs);
		rep(i,M){
			int x, y, t;
			char sl;
			cin >> x >> y >> t >> sl;
			x--; y--;
			if(sl == 'L'){
				gl[x][y] = min(t, gl[x][y]);
				gl[y][x] = gl[x][y];
			}else{
				gs[x][y] = min(t, gs[x][y]);
				gs[y][x] = gs[x][y];
			}
		}
		warshallFloyd(gl,N);
		warshallFloyd(gs,N);

		int R;
		cin >> R;
		vector<int> z(R);
		rep(i,R){
			cin >> z[i];
			z[i]--;
		}

		int dp[MAX_R][MAX_V];
		rep(i,MAX_R) rep(j,MAX_V) dp[i][j] = INF;
		dp[0][z[0]] = 0;

		rep(i,R - 1){

			int cur = z[i];
			int next = z[i + 1];
			rep(j,N) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + gl[cur][next]);
			rep(j,N){
				if(dp[i][j] == INF) continue;
				rep(k,N){
					dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + gl[cur][j] + gs[j][k] + gl[k][next]);
					//cout << i << ' ' << j << ' ' << k << endl;
							//show(dp[i][j] + gl[cur][j] + gs[j][k] + gl[k][next]);
				}

			}
		}

		//rep(i,R){
		//	rep(j,N){
		//		if(dp[i][j] >= INF) cout << "_";
		//		else cout << dp[i][j] << ' ';
		//	}
		//	cout << endl;
		//}

		int mini = INT_MAX;
		rep(i,N){
			mini = min(mini, dp[R - 1][i]);
		}
		cout << mini << endl;
	}
}

Measured memory_bytes: 4184
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int xdif=0;
		int ydif=0;
		int time=0;

		int nyuryoku=sc.nextInt();
		int tmp1t,tmp2t,tmp1x,tmp2x,tmp1y,tmp2y;
		boolean tadori=true;
		tmp2t=0;
		tmp2x=0;
		tmp2y=0;
		for(int i=0; i<nyuryoku; i++) {
			tmp1t=sc.nextInt();
			tmp1x=sc.nextInt();
			tmp1y=sc.nextInt();

			if(i==0) {
				if(tmp1t-tmp1x-tmp1y<0 || (tmp1t-tmp1x-tmp1y)%2==1) {
					tadori=false;
				}
			}
			else if(tadori==true){
				if((tmp1t-tmp2t)-Math.abs(tmp1x-tmp2x)-Math.abs(tmp1y-tmp2y)<0 || ((tmp1t-tmp2t)-Math.abs(tmp1x-tmp2x)-Math.abs(tmp1y-tmp2y))%2==1) {
					tadori=false;
				}
			}
			tmp2t=tmp1t;
			tmp2x=tmp1x;
			tmp2y=tmp1y;
		}

		if(tadori) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

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

string S;

int main()
{
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }else if(S == "ARC"){
        cout << "ABC" << endl;
    }
  
    return 0;
}

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

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

using namespace std;

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

    ll N,sum=0;
    cin>>N;

    for(ll i = 1; i<=N; ++i)
    {
        if(i%3==0 or i%5==0)
            continue;
        else
        {
            sum+=i;
        }
        
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 3636
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Grouping 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", n / 3);
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
OKcount=NOcount=0
for i in range (0,M):
    if A[i]>=sum(A)/(4*M):
        OKcount+=1
    else:
        NOcount+=1
if OKcount>0 and NOcount==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class APlacingMarbles {
public:
	void solve(istream& in, ostream& out) {
        string s; in >> s;
        int ans = 0;
        rep(i,3) if(s[i] == '1') ans++;
        out << ans << endl;
	}
};

int main() {
	APlacingMarbles solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int a, b;
int sum1,sum2,sum3,sum4,sum5;
int max=0;
int main(){
     scanf("%d %d",&a,&b);
      sum1= a+(a-1);
       sum2=b+(b-1);
  sum3=a+b; 
  if(max<sum1) max=sum1;
  if(max<sum2) max=sum2;
  if(max<sum3) max=sum3;
  printf("%d\n",max);
  }

Measured memory_bytes: 128
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""


def make_primes(n): #nまでの素数列挙
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass  


def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

def make_divisors(n): #約数列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return len(divisors)


n = onem()
po = [1 for i in range(10**7+1)]

for i in range(n+1):
	if i == 0 or i == 1:
		continue
	for j in range(i,n+1,i):
		po[j] += 1
an = 0

for i in range(n+1):
	an += po[i]*i
print(an)

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

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> x(m);
	rep(i,m) cin >> x[i];
	sort(x.begin(), x.end());
	
	if (m==1) {
		cout << 0 << endl;
	}
	else {
		vector<int> d(m-1);
		rep(i,m-1) d[i] = x[i+1] - x[i];
		sort(d.begin(), d.end(), greater<int>());
		int ans = x[m-1] - x[0];
		int max_idx = min(n-1,m-1);
		rep(i,max_idx) ans -= d[i];
		cout << ans << endl;
	}
	

	return 0;
}


Measured memory_bytes: 1024
class Integer
  def combination(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*) / k.factorial
  end

  def factorial
    return 1 if self.zero?

    (1..self).inject(:*)
  end
end
n,k = gets.split.map(&:to_i)
r = n-k
mod = 10**9 + 7
flag = false
(1..k).each do |i|
	if flag
		puts 0
	else
		ans = (r+1).combination(i) * (k-1).combination(i-1) % mod
		flag = 0 if ans==0
		puts ans
	end
end



Measured memory_bytes: 3004
use proconio::{fastout, input, marker::Usize1};

fn dfs(graph: &Vec<Vec<usize>>, seen: &mut Vec<bool>, v: usize) {
    seen[v] = true;
    for next in graph[v].iter() {
        if !seen[*next] {
            dfs(graph, seen, *next);
        }
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        graph_base: [(Usize1, Usize1, i64); m]
    }

    let mut graph: Vec<Vec<usize>> = Vec::new();
    for _ in 0..n {
        graph.push(Vec::new());
    }
    for edge in graph_base.iter() {
        graph[edge.0].push(edge.1);
        graph[edge.1].push(edge.0);
    }

    let mut seen = vec![false; n];
    let mut count = 0;
    for v in 0..n {
        if !seen[v] {
            dfs(&graph, &mut seen, v);
            count += 1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 16176
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            int A = Integer.parseInt(sl[0]);
            char op = sl[1].charAt(0);
            int B = Integer.parseInt(sl[2]);

            if (op == '+') System.out.println(A + B);
            else System.out.println(A - B);
        }
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int mod_pow(ll a, int n, int m) {
    ll b, t;
    if (n == 0) {
        return 1;
    }
    a %= m;
    b = a * a;
    b %= m;
    t = mod_pow(b, n / 2, m);
    if (n % 2 != 0) {
        t *= a;
        t %= m;
    }
    return t;
}

ll com[200005], inv[200005];

int main() {

    ll N, A, B;
    cin >> N >> A >> B;

    com[1] = N;
    inv[1] = 1;
    for (ll i = 2; i <= 200000; i++) {
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
        com[i] = com[i - 1] * (N - i + 1) % MOD * inv[i];
        com[i] %= MOD;
    }

    ll ans = mod_pow(2, N, MOD) - 1;
    ans -= com[A];
    ans -= com[B];

    if (ans < 0)
        ans += 2 * MOD;

    cout << ans % MOD << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N;
  cin>>N;
  map<int,int> mp;
  rep(i,N){
    int a; cin>>a;
    mp[a]++;
  }
  int ct=0;
  for(auto x: mp){
    ct+=( x.second - x.first >= 0 ? x.second - x.first : x.second );
  }
  cout<< ct<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define eb emplace_back
int main()
{
    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    lli t,q,n,m,i,j,a,b,h,k;
    cin>>n;
    lli input[3],dp[3]={};
    for(k=0;k<n;k++)
    {
        cin>>input[0]>>input[1]>>input[2];
        lli newDp[3]={};
        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
                if(j!=i)
                    newDp[j]=max(newDp[j],input[j]+dp[i]);
            }
        }
        dp[0]=newDp[0];dp[1]=newDp[1];dp[2]=newDp[2];
    }
    cout<<max({dp[0],dp[1],dp[2]});
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
struct sides{
    int t;
    int v;
};
struct ts{
    int f;
    int t;
    int v;
    void cpy(sides s){
        t=s.t;
        v=s.v;
    };
};
int main(){
    int n,m,p,q,s,e,ans,value[21];
    sides temp[2];
    vector<sides> a[21];
    ts t,b;
    queue<ts> unsolved;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d,%d,%d,%d",&temp[0].t,&temp[1].t,&temp[1].v,&temp[0].v);
        temp[0].t--;
        temp[1].t--;
        a[temp[0].t].push_back(temp[1]);
        a[temp[1].t].push_back(temp[0]);
    }
    scanf("%d,%d,%d,%d",&s,&e,&p,&q);
    s--;
    e--;
    ans=p-q;
    for(int i=0;i<a[s].size();i++){
        t.cpy(a[s][i]);
        t.f=s;
        unsolved.push(t);
    }
    for(int i=0;i<n;i++)value[i]=-1;
    value[s]=0;
    while(!unsolved.empty()){
        t=unsolved.front();
        unsolved.pop();
        if(value[t.t]!=-1&&value[t.t]<value[t.f]+t.v)continue;
        value[t.t]=value[t.f]+t.v;
        b=t;
        for(int i=0;i<a[b.t].size();i++){
            t.cpy(a[b.t][i]);
            t.f=b.t;
            unsolved.push(t);
        }
    }
    ans-=value[e];
    for(int i=0;i<a[e].size();i++){
        t.cpy(a[e][i]);
        t.f=e;
        unsolved.push(t);
    }
    for(int i=0;i<n;i++)value[i]=-1;
    value[e]=0;
    while(!unsolved.empty()){
        t=unsolved.front();
        unsolved.pop();
        if(value[t.t]!=-1&&value[t.t]<value[t.f]+t.v)continue;
        value[t.t]=value[t.f]+t.v;
        b=t;
        for(int i=0;i<a[b.t].size();i++){
            t.cpy(a[b.t][i]);
            t.f=b.t;
            unsolved.push(t);
        }
    }
    ans-=value[s];
    printf("%d\n",ans);
}

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

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i = 0; i < N; i++) cin >> p[i];
  int ans = 0;
  for(int i = 0; i < N - 1; i++){
    if(p[i] == i + 1){
      swap(p[i], p[i + 1]);
      ans++;
    }
  }
  if(p[N - 1] == N) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
s = gets.split("")
min = 753
(s.length-2).times do |i|
  x = s[i].to_s + s[i+1].to_s + s[i+2].to_s
  x = x.to_i
  b = (753-x).abs
  if b < min
    min = b
  end
end
puts min

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

struct Era{
	string name;
	int start; //0
	int end;
};

int main(){
	while(1){
		int n,q;
		cin >> n >> q;
		if(n==0) break;
		
		vector<Era> data(n);
		for(int i=0; i<n; i++){
			int eby;
			cin >> data[i].name >> eby >> data[i].end;
			data[i].start = data[i].end-eby;
		}
		
		for(int i=0; i<q; i++){
			bool found = false;
			int year;
			cin >> year;
			for(int j=0; j<n; j++){
				if(data[j].start<year && year<=data[j].end){
					cout << data[j].name << " " << year-data[j].start << endl;
					found = true;
					break;
				}
			}
			if(!found){
				cout << "Unknown" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3104
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


ll N, K;
vll x, y;

ll cnt(ll xl, ll xr, ll yl, ll yr) {
	ll ret = 0;
	rep(i, N) {
		if (xl <= x[i] && x[i] <= xr && yl <= y[i] && y[i] <= yr) {
			++ret;
		}
	}
	return ret;
}

int main() {
	fastio;
	
	cin >> N >> K;
	x.resize(N), y.resize(N);
	rep(i, N) cin >> x[i] >> y[i];

	ll ans = 9 * INF;
	rep(p, N) fori(q, p + 1, N) {
		rep(r, N) fori(s, r + 1, N) {
			ll xl = min(x[p], x[q]), xr = max(x[p], x[q]);
			ll yl = min(y[r], y[s]), yr = max(y[r], y[s]);
			if (K <= cnt(xl, xr, yl, yr)) {
				ans = min((xr - xl) * (yr - yl), ans);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }
int e() { return -1; }
int target;
bool f(int v) { return v < target; }
void Main()
{
    int n, Q;
    cin >> n >> Q;

    vector<int> A(n);
    rep(i, n) cin >> A[i];
    
    segtree<int, op, e> seg(A);

    rep(i, Q) {
        int t;
        cin >> t;
        if (t == 1) {
            int x, v;
            cin >> x >> v;
            x--;
            seg.set(x, v);
        }
        else if (t == 2) {
            int l, r;
            cin >> l >> r;
            l--;
            put(seg.prod(l, r));
        }
        else {
            int p;
            cin >> p >> target;
            p--;
            // p以上でfがfalseになる最小のインデックスを返す
            put(seg.max_right<f>(p) + 1);
        }
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 6216
#include<iostream>

using namespace std;

char a[100][101];
char b[102][102];

int main(){
	int H,W; cin >> H >> W;

	for(int i=0; i<H; i++)
			scanf("%s",a[i]);

//あらかじめ#で埋もれた配列を用意
	for(int i=0; i<H+2; i++)
			for(int j=0; j<W+2; j++)
					b[i][j] = '#';

	for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
					b[i+1][j+1] = a[i][j];

	for(int i=0; i<H+2; i++)	{
			for(int j=0; j<W+2; j++)
				cout << b[i][j];
			cout << endl;
	}

}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC172E
#include <iostream>
#include<vector>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { 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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// c(i,j) Combination
// c.p(i,j) Permutation
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);
mint factrial(int k){
    int f=1;
    for (int i=2; i<=k; i++) {
        f=(f*i)%mod;
    }
    return f%mod;
}
int main(int argc, const char * argv[]) {
    int n,m;
    cin>>n>>m;
    mint c_sum;
    mint p_sum;
    mint ans=0;
    mint a_all=c.p(m,n);
    rep(k,n+1){
        c_sum=c(n,k);
        p_sum=c.p(m-k, n-k);
        if(k%2==0){
            ans+=(c_sum*p_sum);
        } else {
            ans-=(c_sum*p_sum);
        }
    }
    cout<<a_all*ans<<endl;
    return 0;
}


Measured memory_bytes: 18204
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ll a,b,c,d;cin >>a>>b>>c>>d;
    ll g=__gcd(c,d);
    ll lcm=c*d/g;
    a--;
    ll ctc=b/c-a/c;
    ll ctd=b/d-a/d;
    ll ctl=b/lcm-a/lcm;
    ll U=b-a;
    ll ans=U-(ctc+ctd-ctl);
    cout <<ans <<endl;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  cout << a + b + c + max({a, b, c}) * (pow(2, k) - 1);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4192
a = int(input())

def factorization(n):
    arr = []
    tmp = n

    for i in range(2, int(n**0.5//1)+1):
        if tmp%i==0:
            cnt = 0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    if tmp!=1:
        arr.append([tmp,1])
    if arr==[]:
        arr.append([n,1])
    return arr

while True:
  arr = factorization(a)
  if (len(arr)==1) & (arr[0][1]==1):
    print(a)
    break
  a+=1


Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
#define int 	long long int

int32_t main(){
	
	int d,k;
	cin>>d>>k;

	int val=(int)pow(100,d);
	if(k!=100)
		cout<<val*k<<endl;
	else
		cout<<val*(k+1)<<endl;

	return 0;
}




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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define OO 1e9
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const  int MOD=1e10;
const int N=1e5+9;
const int inf = 1LL<<32;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
int sum[N];
int32_t main() {
    IOS;
int n;
cin>>n;
int ans=0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin>>a;
        ans=gcd(ans,a);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=INF;
	cin >>n;
	Vi x(n);
	int cnt = 0;
	input(x);
	sort(all(x));
	for (int i = x[0]; i <= x.back(); i++) {
		cnt = 0;
		rep(j, n) { cnt += (i - x[j]) * ( i - x[j]); }
		chmin(ans, cnt);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const double PI = 3.1415926535;

int main()
{
  i64 R;
  cin >> R;
  cout << fixed << setprecision(3) << (double)R * 2.0 * PI << endl;
  return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>

int abs(int a) {
  return a > 0 ? a : -a;
}

int main(void) {
  int i, j, n, m;
  scanf("%d%d", &n, &m);
  int a[n], b[n], c[m], d[m];
  for(i = 0; i < n; ++i) scanf("%d%d", &a[i], &b[i]);
  for(i = 0; i < m; ++i) scanf("%d%d", &c[i], &d[i]);
  for(i = 0; i < n; ++i) {
    int min = 1e9, minn;
    for(j = 0; j < m; ++j) if(abs(a[i] - c[j])+ abs(b[i] - d[j]) < min) min = abs(a[i] - c[j])+ abs(b[i] - d[j]), minn = j + 1;
    printf("%d\n", minn);
  }
  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

    int N, K;
    cin >> N >> K;
    
    vector<int> V(N);

    REP(i, N){
        cin >> V[i];
    }

    ll ans = 0;
    for(int a=0; a<=min(N,K); a++){
        for(int b =0; a+b<=min(N,K); b++){
            vector<int> H;
            ll s = 0;
            // 左端から順に手に取る
            for(int i=0; i<a; i++){
                H.push_back(V[i]);
                s += V[i];
            }
            // 右端から順に手に取る
             for(int i=0; i<b; i++){
                H.push_back(V[N-i-1]);
                s += V[N-i-1];
            }

            // 手にとった宝石をソート
            sort(H.begin(), H.end());
            
            // 残っている操作回数分手から捨てていく(捨てなくても良い)
            for(int i=0; i< min(K-a-b, (int)H.size()); ++i) {
                if (H[i] < 0) s -= H[i];
            }
            ans = max(ans, s);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s=s+j; c=c+1
        j += 1
    x[c][s] += 1

while 1:
    n,s = map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]

Measured memory_bytes: 4252
#include<cstdio>
#include<iostream>
using namespace std;
int k;
 
int gcd(int a,int b)
{
    return b>0?gcd(b,a%b):a;
}
 
int main()
{
	int k;
	int ans = 0;
	cin >> k;
	for(int i = 1; i <= k;i++){
		for(int j = 1; j <= k; j++){
			for(int l = 1; l <= k; l++){
			ans += gcd(gcd(i,j),l);
			}
		}
	}
	cout << ans << endl;


}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>

using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int h[n];
    for(int i(0);i<n;i++) cin >> h[i];
    
    int cnt(0);
    for(int i(0);i<n;i++){
        if(h[i] >= k) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


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

using namespace std;
#define ll long long
const int N = 2e5 + 5, mod = 1e9 + 7;
int fac[N];

int fp(int a, int p) {
    if (!p) return 1;
    int t = fp(a, p >> 1);
    t = (t * 1LL * t) % mod;
    if (p & 1) t = (t * 1LL * a) % mod;
    return t;
}

int ncr(int n, int r) {
    return ((fac[n] * 1LL * fp(fac[r], mod - 2)) % mod * 1LL * fp(fac[n - r], mod - 2)) % mod;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    fac[0] = 1;

//    for (int i = 1; i < N; i++)fac[i] = (fac[i - 1] * 1LL * i) % mod;

//    for (int n = 4; n <= 15; n++) {
//        set<int> st;
//        for (int i = 1; i <= n; i++) {
//            for (int j = i + 1; j <= n; j++)
//                for (int k = j + 1; k <= n; k++)
//                    for (int w = k + 1; w <= n; w++)
//                        st.insert(i + k + w + j);
//        }
////        cout << n << " " << st.size() << " " << (n - 4) * 4 + 1 << endl;
//    }
//    return 0;
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    ++n;
    for (int i = k; i <= n; i++) {
        ans = (ans + (n - i) * 1LL * i + 1) % mod;

    }
    cout << ans << endl;

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

int common(string s1, string s2){
	int cnt = 0;
  	rep(i,26){
      	char temp = 'a' + i;
      	// cout << temp << endl;
    	if(s1.find(temp) != string::npos && s2.find(temp) != string::npos) cnt++;
    }
  	return cnt;
}

void Main()
{
	int n; string s;
  	cin >> n >> s;
  	
  	
    /*
    string test1 = "aab", test2 = "bca";
  	cout << common(test1, test2) << endl;
  	*/
  	
  	int mx = 0;
 	//*
    rep(i,n){
      	// cout << i << ": " << s.substr(0,i) << ", " << s.substr(i) <<  ", " << common(s.substr(0,i), s.substr(i)) << endl;
		mx = max(mx, common(s.substr(0,i), s.substr(i)));    	
    }
    //*/
	cout << mx << endl;
	return;
}

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

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

using namespace std;
#define LL long long 
char d[105][105];

int main(){
    string a,b,c;
    LL H, W;
    LL ans = 1e18;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

ll GCD(ll a, ll b){
	if(b==0) return a;
	
	return GCD(b, a%b);
}

int main(){
	int n;
	cin >> n;
	vector<ll> t(n);
	REP(i,n) cin >> t[i];
	
	ll ans = 0;
	ans = t[0];
	FOR(i,1,n){
		ans = (ans/GCD(ans,t[i])) * t[i];
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
	long long int n;
	while (cin >> n) {
		int m = 0;
		long long int prime[2000000];
		bool is_prime[2000000];
		for (int i = 0; i <= n; i++) {
			is_prime[i] = true;
		}
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i <= n; i++) {
			if (is_prime[i]) {
				m++;
				for (int j = i * 2; j <= n; j += i) {
					is_prime[j] = false;
				}
			}
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 4064
#include <stdio.h>
#include <string.h>
#include <math.h>



int main() {

    int k, x;
    scanf("%d %d", &k, &x);


    int mindata = x - k + 1;
    int maxdata = x + k - 1;

    if (mindata < -1000000) {
        mindata = -1000000;
    }

    if (1000000 < maxdata) {
        maxdata = 100000;
    }

    for (int i = mindata; i <= maxdata; i++) {
        printf("%d ", i);
    }




    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define   FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define   vi vector<long long>
#define   vvi vector<vector<long long>>
#define   all(a) (a).begin(), (a).end()
#define   rep(i,a,b)  for(int  i=a;i<b;i++)
#define   tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define   pb push_back
#define   endl "\n"
#define   dbg(x,y) cout<<(x)<<" -->  "<<(y)<<endl
#define   dbg2(k)   cout<<(k)<<" * "<<endl;
#define   F first
#define   S second
#define   int long long
#define   ll long long

const int  inf=1e6+2;
const int  ninf=-1e9 ;
const int  mod=1e9+7;

vvi mat(55,vi(55,0));
vvi ans(55,vi(55,0));
//vvi m1(55,vi(55,0));
//vvi m2(55,vi(55,0));
//vvi res(55,vi(55,0));

vvi matmul(vvi m1,vvi m2,int n)
{
	    int i,j,k;
       vvi res(n,vi(n));
	   for(i=0;i<n;i++)
	   {
	      for(j=0;j<n;j++)
		  {
		  	  int s=0;
		     for(k=0;k<n;k++)
			 {
			   	s=(s%mod+(m1[i][k]%mod*m2[k][j]%mod)%mod)%mod;
			 }
			 res[i][j]=s%mod;	
		  }	
	   }
	   return res; 
}


vvi expo(int n,int k)
{
    if(k==1)
	return mat;
	
	if(k%2==1)
	{
	    vvi m1=expo(n,k-1);  
	   return matmul(mat,m1,n);      	
	}
	else
	{
	   vvi m2=expo(n,k/2);
	  return matmul(m2,m2,n);     	
	}
}  
  
void solve()
{
  	 int m,i,j,k,p,l,q,n,x,c1,c2;
  	 cin>>n>>k;
  	
  	 for(i=0;i<n;i++)
	 {
	 	for(j=0;j<n;j++)
	 	{
	 	 cin>>mat[i][j];
		}
	 }
	 
	 vvi ans=expo(n,k);
	 
	  int f=0;
	  
	  for(i=0;i<n;i++)
	 {
	 	for(j=0;j<n;j++)
	 	{
	       f=(ans[i][j]%mod+f%mod)%mod;
	    }
     }
     
	
	 cout<<f<<endl;	 
}
signed main()
{
   FASTIO;
   int T;
   T=1;
//   cin>>T;
   while(T--)
   {
    solve();
   }
   return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <queue>
using namespace std;
int main() {
    long long int N,M,A,r=0;
    cin >> N >> M;
    priority_queue<int> que;
    for(int i=0; i<N; ++i) {
        cin >> A;
        que.push(A);
    }
    for(int i=0; i<M; ++i) {
        que.push(que.top()/2);
        que.pop();
    }
    while(!que.empty()) {
        r += que.top();
        que.pop();
    }
    cout << r;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 1e5 + 5;

#define pii pair<int, int>
#define ll long long

int n, q;
ll m;
int uf[N];
vector<pii> E0, E1;

int find(int x) {
	return uf[x] == x ? x : uf[x] = find(uf[x]);
}
boolean unit(int x, int y) {
	x = find(x), y = find(y);
	if (x ^ y) {
		uf[x] = y;
		return true;
	}
	return false;
}

void quitf(boolean expression) {
	if (expression) {
		puts("No");
		exit(0);
	}
}

int main() {
	scanf("%d%lld%d", &n, &m, &q);
	for (int i = 1; i <= n; i++)
		uf[i] = i;
	for (int i = 1, u, v, opt; i <= q; i++) {
		scanf("%d%d%d", &u, &v, &opt);
		++u, ++v;
		if (opt == 0) {
			E0.emplace_back(u, v);
		} else {
			E1.emplace_back(v, u);
		}
	}
	for (auto e : E0)
		unit(e.first, e.second);
	for (auto e : E1)
		quitf(find(e.first) == find(e.second));
	int comp = 0;
	for (int i = 1; i <= n; i++)
		comp += find(i) == i;
	quitf(E1.size() && comp == 2);
	ll mi = ((E1.size()) ? (n) : (n - 1));
	ll mx = (n - comp) + (comp * 1ll * (comp - 1) >> 1);
	quitf(m < mi || m > mx);
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

struct UnionFind {  
  vector<int> par,sizes;                     // par[i]:iの親の番号(ex)par[3]=2 : 3の親が2
  UnionFind(int n) : par(n),sizes(n,1)  {    //最初は全てが根であるとして初期化
    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の根が同じ(=同じ木にある)時はそのまま
    if(sizes[rx]<sizes[ry]){ swap(rx, ry); } //xの木をおおきくする
    par[ry] = rx; 
    sizes[rx] += sizes[ry];                  //sizes[ry]はもう使わない
  }
 
  bool check(int x, int y) {                 // x,yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
  
  int size(int x){                           //xが含まれる木の大きさを返す
    return sizes[root(x)];
  }
};

int main(){
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind road(n);
  UnionFind train(n);
  
  rep(i,k){
    int p,q; cin>>p>>q; p--; q--;
    if(road.check(p,q)){continue;}
    road.unite(p,q);
  }
  rep(i,l){
    int p,q; cin>>p>>q; p--; q--;
    if(train.check(p,q)){continue;}
    train.unite(p,q);
  }
  
  map<P,int> ans;
  rep(i,n){
    ans[{road.root(i),train.root(i)}]++;
  }
  rep(i,n){
    cout << ans[{road.root(i),train.root(i)}] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <math.h>
typedef long long ll;
using namespace std;
#define prt(var) cout << (var) << endl;
#define rep(i,n) for(int i=0; i<int(n); i++)

int main() {
  int n;
  cin>>n;
  int a[n+1];
  a[0]=-1;
  rep(i,n){
    int k;
    cin>>k;
    a[k]=i+1;
  }
  
  int mx=0;
  int tmp=0;
  rep(i,n){
    if(a[i]<a[i+1]){
      tmp++;
    } else {
      tmp=1;
    }
    
    mx = max(mx, tmp);
  }
  
  prt(n-mx);
}

Measured memory_bytes: 4424