akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: "List[int]", Y: "List[int]", Z: "List[int]"):
    X = map(lambda x: x-1, X)
    Y = map(lambda x: x-1, Y)
    uf = UnionFind(N)
    for x, y in zip(X, Y):
        uf.union(x, y)
    return len(uf.roots())

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

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

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

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


Measured memory_bytes: 16556
n, k, q =  map(int,input().split())
points = [0 for _ in range(n)]
b = q - k

for _ in range(q):
    a = int(input())
    a -=1
    points[a] +=1

for point in points:
    if point >b:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void p(T x){cout << x << endl;}
template<class T>void pvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }

template<class T>void parr(vector<vector<T>>& a){
rep(i, a.size()){
rep(j, a[i].size()){
cout << a[i][j]; printf(" ");}
printf("\n");} printf("\n");}
 
int main()
{
    int h, w; cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    rep(i, h){
        rep(j, w) cin >> a[i][j];
    }

    vector<vector<ll>> dp(h, vector<ll>(w));
    rep(i, h) rep(j, w) dp[i][j]=0;
    if(a[0][1]=='.') dp[0][1]=1;
    if(a[1][0]=='.') dp[1][0]=1;
    // parr(dp);
    rep(i, h){
        rep(j, w){
            if(a[i][j]=='#') continue;
            if(i>0 && a[i-1][j]=='.') dp[i][j] += dp[i-1][j]%MOD;
            if(j>0 && a[i][j-1]=='.') dp[i][j] += dp[i][j-1]%MOD;
            dp[i][j] %= MOD; 
        }
    }

    p(dp[h-1][w-1]);
    return 0;
}

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

#define FASTIO1 ios_base::sync_with_stdio(false)
#define FASTIO2 cin.tie(NULL),cout.tie(NULL)
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll power(ll x,ll y,ll p);
const ll inf=999999999;
const ll mod=1e9+7;
bool tc=false;

void solve()
{
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')
        cout<<s<<"es";
    else
        cout<<s<<"s";
}

int main() 
{
    FASTIO1;
    FASTIO2;
    clock_t start=clock();
    ll t=1; 
    if(tc) cin>>t;
    while(t--)
        solve();
    cerr<<fixed<<setprecision(6);
    cerr<<(double)(clock()-start)/CLOCKS_PER_SEC<<endl;
    return 0;
}

ll power(ll x,ll y,ll p)  
{  
    ll res=1; x=x%p;
    if(x==0) return 0;
    while(y>0)  
    {
        if(y&1) res=(res*x)%p;
        y=y>>1; x=(x*x)%p;  
    }
    return res;  
}  


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

int main() {
    int x;
    cin>>x;
    auto is_prime = [](int n){
        for (size_t i = 2; i*i <=n ; i++)
        {
            if (n%i==0){
                return false;
            }
            /* code */
        }
        return true;
    };
    for (size_t i = x;; i++)
    {
        if(is_prime(i)){
            cout<<i<<endl;
            break;
        }
        /* code */
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e5, I = 1e9 * 1e9;
const ld EPS = 1e-9 * 1e-2;

ll dp[3000][100];

int main()
{
	fastInp;

	ll n, a;
	cin >> n >> a;
	vector<ll> vec(n);
	for (int i = 0; i < n; i++) cin >> vec[i];

	dp[0][0] = 1;

	for (auto val : vec) {
		for (int j = 99; j >= 0; j--) {
			for (int s = 2999; s >= 0; s--) {
				if (s >= val) dp[s][j] += dp[s - val][j - 1];
			}
		}
	}

	ll ans = 0;
	for (int j = 0; j < 100; j++) {
		for (int k = 0; k < 3000; k++) {
			if (a * j == k) {
				ans += dp[k][j];
			}
		}
	}

	cout << ans - 1;

	return 0;
}

Measured memory_bytes: 5940
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vector<pii> v(n);
    rep(i,n)cin >> v[i].first;
    rep(i,n)cin >> v[i].second, v[i].second *= -1;
    sort(all(v));
    reverse(all(v));
    rep(i,n)v[i].second *= -1;
    int cnt = 0;
    priority_queue< pii, vector<pii>, greater<pii> > q;
    //v[i].first < v[k].second となるすべてのkについて
    //pii(v[k].first, k) を push していく
    map<pii,int> ma;
    rep(i,n)ma[pii(v[i].second,i)]++;
    auto itr = ma.end();
    itr--;
    rep(i,n)if(v[i].first > v[i].second){
        //cout << "!" << i << " " << v[i].first << endl;
        while(itr->first.first >= v[i].first){
            int sec = itr->first.first;
            int id = itr->first.second;
            //cout << sec << " " << id << endl;
            q.push(pii(v[id].first,id));
            itr--;
        }
        if(q.empty()){
            cout << "No" << endl;
            return 0;
        }
        pii p = q.top();
        int index = p.second;
        q.pop();
        // v[i].second　と v[index].second を swap する
        //このとき、v[index].firstのペアはv[i].secondになるのでその変更をする
        ma.erase(pii(v[i].second,i));
        ma[pii(v[i].second,index)]++;
        v[index].second = v[i].second;
        cnt++;
    }
    if(cnt <= n-2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    double x[n];
    string u[n];
    for(int i = 0; i < n; i ++){
        cin >> x[i] >> u[i];
    }
    double sum = 0.0;
    for(int i = 0; i < n; i ++){
        if(u[i] == "JPY"){
            sum += x[i];

        }else{
            sum += 380000.0 * x[i];

        }

    }
    cout << sum << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

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

  rep(i,n){
    rep(j,n-i){
      if(n==4*i+7*j){cout<<"Yes";return 0;}
    }
  }

  cout<<"No";

  return 0;
}

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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    // sort(a.begin(), a.end(), greater<int>());
    // vector<vector<int>> dp(n);
    // for (int i = 0; i < n; ++i) dp[i].resize(a[i], -1);

    // function<int(int, int)> Dfs = [&](int r, int c) {
        // if (dp[r][c] >= 0) return dp[r][c];
        // dp[r][c] = 0;
        // if (r + 1 < n && c < dp[r + 1].size() && !Dfs(r + 1, c)) dp[r][c] = 1;
        // if (c + 1 < dp[r].size() && !Dfs(r, c + 1)) dp[r][c] = 1;
        // return dp[r][c];
    // };

    // for (int i = 0; i < n; ++i) {
        // for (int j = 0; j < a[i]; ++j) printf("%d ", Dfs(i, j));
        // puts("");
    // }

    set<int> s;
    sort(a.begin(), a.end());
    int shift = 0;
    vector<bool> invert(n);
    for (int i = 1; i < n; ++i) {
        shift++;
        if (a[i] == a[i - 1]) {
            invert[i] = !invert[i - 1];
        } else {
            if (invert[i - 1] && (a[i] - a[i - 1]) % 2 == 1) {
                s.insert(a[i - 1] - (n - 1 - i));
            }
            if (!invert[i - 1] && (a[i] - a[i - 1]) % 2 == 0) {
                s.insert(a[i - 1] + 1 - (n - 1 - i));
            }
        }
    }

    // printf("s : ");
    // for (auto it : s) printf("%d ", it); puts("");
    int cnt = 0;
    for (auto it : s) cnt += it >= 3;
    if (s.count(1) || s.count(2)) puts("First");
    else if (!invert[n - 1] && a[n - 1] % 2 == cnt % 2) puts("First");
    else if (!invert[n - 1] && a[n - 1] % 2 != cnt % 2) puts("Second");
    else if (invert[n - 1] && a[n - 1] % 2 != cnt % 2) puts("First");
    else puts("Second");
}


Measured memory_bytes: 2432
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var s = next();
  var max = 0;
  var count = 0;
  for(var i = 0; i < s.length; i++){
  	if(s[i] == "R"){
  		count++;
  	}else{
  		max = Math.max(max, count);
  		count = 0;
  	}
  }
  max = Math.max(max, count);
  myout(max);
}

Measured memory_bytes: 30164
#include <cstdio>
int main() {
	int A, B, C, K, ans = 0;
	scanf("%d %d %d %d", &A, &B, &C, &K);
	if (K <= A) {//数字1卡片够取
		ans = K;
	} else { //数字1卡片不够取
		K -= A;
		ans = A;
		if (K > B) { //先取数字0卡片,看看0卡片够不够,如果不够，则就需要取-1卡片
			K -= B;
			ans -= K;
		}
	}
	printf("%d", ans);
	return 0;
}

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

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

    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        int res = 0;
        for (int j = 1; j * j <= i; j += 2) {
            if (i % j == 0) {
                res += j * j == i ? 1 : 2;
            }
        }
        if (res == 8) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b&&b<=c){
        printf("%d %d %d\n",a,b,c);
    }
    else if(a<=c&&c<=b){
        printf("%d %d %d\n",a,c,b);
    }
    else if(b<=a&&a<=c){
        printf("%d %d %d\n",b,a,c);
    }
    else if(b<=c&&c<=a){
        printf("%d %d %d\n",b,c,a);
    }
    else if(c<=a&&a<=b){
        printf("%d %d %d\n",c,a,b);
    }
    else if(c<=b&&b<=a){
        printf("%d %d %d\n",c,b,a);
    }
    return 0;
}

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

int main()
{
  using namespace std;
  float n, s1=0.0, s2=0.0;
  int p, ans;
  cin >> n;
  int x[(int)n];
  for(int i=0; i<n; i++){
    cin >> x[i];
    s1+=x[i];
    s2+=x[i]*x[i];
  }
  p=round(s1/n);
  //cout << "s1=" << s1 << ", p=" << p << ", s2=" << s2 << endl;
  ans = s2+n*p*p-2*p*s1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
using System.Linq;
using System;

public class Team
{
    public string n { get; set; }
    public int w { get; set; }
    public int L { get; set; }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var teams = new Team[n];
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Trim().Split(' ');
                var wc = 0; var Lc = 0;
                for (int j = 0; j < n - 1; j++)
                    if (s[j + 1] == "0") wc++;
                    else if (s[j + 1] == "1") Lc++;
                teams[i] = new Team { n = s[0], w = wc, L = Lc };
            }
            foreach (var x in teams.OrderByDescending(y => y.w).ThenBy(y => y.L))
                Console.WriteLine(x.n);
        }
    }
}

Measured memory_bytes: 9844
#include <bits/stdc++.h>
using namespace std;
int ans;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s>>s;
    for(int i=0;i<s.size();i++){
        int a=0,b=0;
        for(int j=0;j<i;j++){
            a|= 1<<(s[j]-'a');
        }
        for(int j=i;j<s.size();j++){
            b|= 1<<(s[j]-'a');
        }
        ans=max(ans,__builtin_popcount(a&b));
    }
    cout<<ans<<'\n';
    return 0;
}



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

void    Print(vector<int> &A) {
    for (int i=0; i<A.size()-1; i++)
        cout <<A.at(i) <<' ';
    cout <<A.back() <<endl;
    return;
}

void    Insert(vector<int> &A, int s, int t) {
    int L=lower_bound(A.begin()+s, A.begin()+t, A.at(t))-A.begin();
    for (int i=t-1; i>=L; i--)
        swap(A.at(i), A.at(i+1));
    return;
}

int main() {
    int N;
    cin >>N;
    vector<int> A(N, 0);
    for (int i=0; i<N; i++)
        cin >>A.at(i);
    Print(A);
    for (int i=1; i<N; i++) {
        Insert(A, 0, i);
        Print(A);
    }
    return 0;
}


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

maxh=max(A)
ans=0
for i in range(1,maxh+1):
  # i 以上の高さのブロック数をカウントする
  block=0
  cur=False
  if A[0]>=i:
    block+=1
    cur=True
  for j in range(1,len(A)):
    if A[j]>=i:
      if not cur:
        block+=1
        cur=True
    else:
      cur=False
  ans+=block

print(ans)


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    
    rep(i, n){
        cin >> a.at(i);
    }
    int ans = 1;
    rep(i, n){
        if(a.at(i)%2==0){
            if(a.at(i)%3!=0&&a.at(i)%5!=0){
                ans = 0;
            }
        }
    }
    if(ans==1){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int S,h,m,s;
	scanf("%d", &S);
	h = S/3600;
	m = (S%3600)/60;
	s = (S%3600)%60;
	printf("%d:%d:%d\n", h,m,s);
	return 0;
}


Measured memory_bytes: 2108
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int N = 0;
		int Q = 0;
		String s;
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.next());
		Q = Integer.parseInt(sc.next());
		s = sc.next();
		int n;
		String Golem[] = new String[N];
		for (n = 0; n < N; n++) {
			Golem[n] = s.substring(n, n + 1);
		}
		int l = 0;
		int L = 0;
		int r = N-1;
		int R = 0;
		int m = 0;
		String t[] = new String[Q];
		String d[] = new String[Q];
		for (n = 0; n < Q; n++) {
			t[n] = sc.next();
			d[n] = sc.next();
		}
		while (r >=l) {
			// 左側
			m = (l + r) / 2;
			if (simulate(Golem, t, d, Q, m, N) == -1)
				l = m + 1;
			else
				r = m - 1;
		}
		L = r;
		l = 0;
		r = N-1;
		while (r >=l) {
			// 右側
			m = (l + r) / 2;
			if (simulate(Golem, t, d, Q, m, N) == 1)
				r = m - 1;
			else
				l = m + 1;
		}
		R = r;
		sc.close();
		System.out.println(R - L);
	}
 
	static int simulate(String Golem[], String t[], String d[], int Q, int m, int N) {
		int temp = 0;
		temp = m;
 
		for (int i = 0; i < Q; i++) {
			if (Golem[temp].equals(t[i])) {
				if (d[i].equals("R"))
					temp++;
				else
					temp--;
				if (temp < 0)
					return -1;// 左に落下
				if (temp >= N)
					return 1;// 右に落下
			}
		}
		return 0;
	}
}

Measured memory_bytes: 98764
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int N,K;
  long ans;
  vector<long> p;
  vector<long> m;
  cin >> N >> K;
  long x[N];
  for(int i = 0; i < N;i++){
    scanf("%ld",&x[i]);
    if(x[i] > 0){
      p.push_back(x[i]);
    }else if(x[i] < 0){
      m.push_back(-x[i]);
    }else{
      K--;
    }
  }
  sort(m.begin(),m.end());
  if(K == 0){
    cout << 0 << endl;
    return 0;
  }
  // cout << "p" << endl;
  // for(int i = 0; i < p.size(); i++) cout << p[i] << endl;
  // cout << "m" << endl;
  // for(int i = 0; i < m.size(); i++) cout << m[i] << endl;
  ans = 1e15;
  for(int i = 0; i < p.size(); i++){
    if(i == K-1) {
      ans = min(ans,p[i]);
      break;
    }
    else if(i+1 < K){
      if( i + 1 + m.size() >= K) {
        //printf("i: = %d,ans = %ld + %ld\n",i,2*p[i] , m[K-i-2]);
        ans = min(ans,(2*p[i] + m[K-i-2]));
      }
    }

  }
  //printf("ans = %ld \n",ans);
  for(int i = 0; i < m.size(); i++){
    if(i == K-1) {
      ans = min(ans,m[i]);
      break;
    }
    else if(i < K-1){
      if( i + 1 + p.size() >= K) {
        //printf("i = %d,ans = %ld + %ld\n",i,2*m[i] , p[K-i-2]);
        ans = min(ans,(2*m[i] + p[K- i-2]));
      }
    }
  }

  cout << ans << endl;


  return 0;
}


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

#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i)++)
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)
#define abs(a) (a)>0?(a):-(a)
#define ll long long

char* lunlun(char*,int);

int main(){
	int K; scanf("%d",&K);
	char s[100];
	rep(i,0,100) s[i]=0;
	s[0]='0';
	lunlun(s,K);
	int n = strlen(s);
	rep(i,0,n){
		printf("%c",s[n-1-i]);
	}
	return 0;
}

char* lunlun(char *s,int k){
	if( k==0 ) return s;
	int n = strlen(s);
	int i;
	for(i=0;i<n;i++){
		if( i==n-1 ){
			if( s[i]=='9' ){
				s[i+1]='1';
				i+=1;
			}else{
				s[i]++;
			}
			break;
		}
		if( s[i]<=s[i+1] && s[i]!='9' ){
			s[i]++;
			break;
		}
	}
	rep(j,0,i){
		if( s[i-j]!='0' ) s[i-j-1] = s[i-j]-1;
		else s[i-j-1]='0';
	}
	return lunlun(s,k-1);
}


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

int main(){
    long long n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    for(int i=0;i<n;i++){
        long long m=i,p=n-1-i;
        long long l,r;
        
        l = a - m*d + p*c;
        r = a - m*c + p*d;
        if(l<=b && b<=r){
            cerr<<m<<" "<<l<<" "<<r<<endl;
            cout<<"YES"<<endl;
            return 0;
        }

        
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
a = input()

n = len(a)
ans = 0
for i in range(2**(n-1)):
    f = a[0]
    for j in range(n-1):
        if ((i >> j) & 1):
            f += '+'
        f += a[j+1]

    ans += sum(map(int, f.split('+')))

print(ans)

Measured memory_bytes: 8980
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a;
	cin>>a;
	if(a<=999)
		cout<<"ABC"<<endl;
	else
		cout<<"ABD"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif

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

	ll n;
	cin >> n;
	ll a[n], b[n];
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	if (n % 2)
	{
		ll y = a[n / 2];
		ll z = b[n / 2];
		cout << z - y + 1;
		return 0;
	}
	else
	{
		ll y = (a[n / 2 - 1] + a[n / 2]);
		ll z = (b[n / 2 - 1] + b[n / 2]);
		cout << z - y + 1;
		return 0;
	}
}



Measured memory_bytes: 6732
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int n=0,pm[10011],pe[10011],pj[10011],ans[10011],A[10011],i=0;
while(1){
cin >> n;
if(n==0){
break;
}
for(int i=0;i<n;i++){
cin >> pm[i] >> pe[i] >> pj[i];
ans[i]=pm[i]+pe[i]+pj[i];
ans[i]=ans[i]/3;
if(pm[i]==100||pe[i]==100||pj[i]==100||90<=(pm[i]+pe[i])/2||80<=ans[i]){
A[i]=1;
}else if(70<=ans[i]){
A[i]=2;
}else if(50<=ans[i]&&80<=pm[i]||50<=ans[i]&&80<=pe[i]){
A[i]=2;
}else{
A[i]=3;
}
}
for(int i=0;i<n;i++){
if(A[i]==1){
cout << "A" << endl;
}else if(A[i]==2){
cout << "B" << endl;
}else if(A[i]==3){
cout << "C" << endl;
}
}
}
return(0);
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
using namespace std;
int n,m;
int cnt[200005];
int empty;
int a[200005],b[200005];
int main(){
	cin>>n>>m;
	empty=n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		cnt[a[i]]++;
		int pl=a[i]-cnt[a[i]]+1;
	//	cout<<pl<<endl;
		if (pl>=1){
			if (b[pl]==0){
				b[pl]++;
				empty--;
			}
			else{
				b[pl]++;
			}
		}
	}
	//cout<<empty<<endl;
	while (m--){
		int x,y;
		cin>>x>>y;
		int pl=a[x]-cnt[a[x]]+1;
	//	cout<<"pl="<<pl<<endl;
	//	for (int i=1;i<=n;i++){
	//		cout<<b[i]<<" ";
	//	}
	//	cout<<endl;
		if (pl>=1){
			if (b[pl]==1){
				b[pl]--;
				empty++;
			}
			else{
				b[pl]--;
			}
		}
	//	cout<<" "<<empty<<endl;
		cnt[a[x]]--;
		a[x]=y;
		cnt[y]++;
		pl=a[x]-cnt[a[x]]+1;
		if (pl>=1){
			if (b[pl]==0){
				b[pl]++;
				empty--;
			}
			else{
				b[pl]++;
			}
		}
		cout<<empty<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

vector<int> ans, v;

int main(void) {
  int n;
  cin >> n;
  rep(i, 0, n) {
    int a;
    cin >> a;
    v.pb(a);
  }
  
  while(sz(v)>0) {
    int idx = -1;
    for (int i=sz(v)-1; i>=0; i--) {
      if (v[i]==i+1) {idx = i; break;}
    }
    if(idx==-1){puts("-1"); return 0;}
    ans.pb(v[idx]);
    v.erase(v.bg + idx);
  }
  
  for(int i=sz(ans)-1; i>=0; i--) printf("%d\n", ans[i]);
  
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		int h=s.nextInt(),a=s.nextInt();
		System.out.println((h+a-1)/a);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}

Measured memory_bytes: 23636
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	count := 0
	for i:=1; i<=n; i++{
		if (i % 3) != 0 && (i % 5) != 0{
			count += i
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 1752
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++ ) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while ( head != tail ) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else printf("%s %d\n", u.name, elaps);
  }

  return 0;
}


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


int main(void) {
    int const N=3;
    int a[N];
    int i,j;
    
    
    
    //initialization
    cin >> a[0] >> a[1] >> a[2];
    

    
    
    //sort
    for(i=0; i<N; i++){
        for(j=i+1; j<N; j++){
            if(a[i]>a[j]){
                int tmp;
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
    
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;



int main() {
int A, B;
cin >> A >> B;
int count = 0;
for(int i = A; i <= B; i++){
string S = to_string(i);

if(S[0] == S[4] && S[1] == S[3]) count++;

}
cout << count << endl;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

vector<string> split(const string &str, char sep) {
  vector<string> v;
  auto beg = str.begin();
  while(beg != str.end()) {
    auto end = beg;
    while(end != str.end() && *end != sep) ++end;
    if (string(beg, end) != ""){
      v.push_back(string(beg, end));
    }
    if(end != str.end()) ++end;
    beg = end;
  }
  return v;
}

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

  int n, k; cin >> n >> k;
  string str; cin >> str;

  vector<int> v;

  int beg = 0;
  while (beg < n){
    int end = beg;
    while (end + 1 < n && str[end + 1] == str[beg]) ++end;
    int len = end - beg + 1;
    v.push_back(len);
    beg = end + 1;
  }
  
  //for (int i = 0; i < (int) v.size(); ++i) debug(v[i]);

  if (str[0] == '0') v.insert(v.begin(), 1);
  if (str.back() == '0') v.push_back(1);

  vector<string> spl = split(str, '1');

  if ((int) spl.size() <= k){
    print(n); return 0;
  }

  vector<int> s(n + 5, 0);

  s[0] = v[0];
  for (int i = 1; i < (int) v.size(); ++i) s[i] = s[i - 1] + v[i];


  int SIZE = v.size();

  int ans = s[2 * k];
  if (str[0] == '0') --ans;
  for (int i = 2; i + 2 * k <= SIZE - 1; i += 2){
    if (i + 2 * k == SIZE - 1 && str.back() == '0') ans = max(ans, s[i + 2 * k] - s[i - 1] - 1);
    else ans = max(ans, s[i + 2 * k] - s[i - 1]);
  }

  print(ans);

  return 0;
}

Measured memory_bytes: 3912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152A
{
	class Program
	{
		static void Main(string[] args)
		{
			int n, m;
			var word = Console.ReadLine().Split(' ');
			n = int.Parse(word[0]);
			m = int.Parse(word[1]);

			if (m == n)
				Console.WriteLine("Yes");
			else
				Console.WriteLine("No");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int mod=1000000007;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
struct bian
{
	int x,y,w;
	friend bool operator < (bian a,bian b){return a.w<b.w;}
}bi[2020];
int n,m,ans;
long long s;
int f[2020];
int find(int x)
{
	if(x!=f[x])return f[x]=find(f[x]);
	return x;
}
vector<pair<int,int> >E[2020];
int up[2020][11],mx[2020][11],dep[2020];
void dfs(int v,int fa)
{
	dep[v]=dep[fa]+1;
	for(auto u:E[v])
		if(u.first!=fa)
		{
			up[u.first][0]=v;
			mx[u.first][0]=u.second;
			for(int i=1;i<=10;++i)up[u.first][i]=up[up[u.first][i-1]][i-1],mx[u.first][i]=max(mx[u.first][i-1],mx[up[u.first][i-1]][i-1]);
			dfs(u.first,v);
		}
}
int query(int x,int y)
{
	int res=0;
	if(dep[x]<dep[y])swap(x,y);
	for(int i=10;~i;--i)if(dep[up[x][i]]>=dep[y])res=max(res,mx[x][i]),x=up[x][i];
	if(x==y)return res;
	for(int i=10;~i;--i)if(up[x][i]!=up[y][i])res=max(res,mx[x][i]),res=max(res,mx[y][i]),x=up[x][i],y=up[y][i];
	res=max(res,mx[x][0]);
	res=max(res,mx[y][0]);
	return res;
}
int main()
{
	scanf("%d %d",&n,&m);
	scanf("%lld",&s);
	int x,y,w;
	for(int i=1;i<=m;++i)scanf("%d %d %d",&x,&y,&w),bi[i]=bian{x,y,w};
	sort(bi+1,bi+1+m);
	for(int i=1;i<=n;++i)f[i]=i;
	long long sum=0;
	for(int i=1;i<=m;++i)
	{
		x=find(bi[i].x),y=find(bi[i].y);
		if(x!=y)
		{
			sum+=bi[i].w;
			f[x]=y;
			E[bi[i].x].emplace_back(make_pair(bi[i].y,bi[i].w));
			E[bi[i].y].emplace_back(make_pair(bi[i].x,bi[i].w));
		}		
	}
	dfs(1,0);
	int cnt1=0,cnt2=0;
	for(int i=1;i<=m;++i)
	{
		w=bi[i].w-query(bi[i].x,bi[i].y);
		if(w==s-sum)++cnt1;
		if(w>s-sum)++cnt2;
	}
	if(s==sum)
	{
		ans=1;
		for(int i=1;i<=cnt1;++i)add(ans,ans);
		add(ans,mod-2);
		for(int i=1;i<=cnt2;++i)add(ans,ans);
	}
	else
	{
		ans=2;
		for(int i=1;i<=cnt1;++i)add(ans,ans);
		add(ans,mod-2);
		for(int i=1;i<=cnt2;++i)add(ans,ans);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf\n",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int,int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;
ll fastaxp(ll x , ll y ){

    ll temp =1 ;
    while ( y > 0 ){
        if(y &1 ){
            temp = temp * x % MOD;
            if(y == 1) break;
        }
        x = (x  * x) % MOD ;
        y /= 2 ;
    }
    return temp % MOD;
}



signed main ( ) {
    IOS
    ll n, a , b ;
    cin >> n>> a >> b ;


    ll t1 = 1 ;
    for (int i = n; i > ( n-a) ; --i) {
        t1 = t1 * i %MOD;
    }
    ll t2 = 1;
    for (int j = n ; j > n- b  ; --j) {
        t2 = t2 * j % MOD;
    }
   // cout << t1 << " " << t2 << endl;
    ll f1 =1 , f2 =1 ;
    for (int k = 1; k <=a ; ++k) {
        f1 = f1 * k % MOD;
    }
    for (int l = 1; l <=b ; ++l) {
        f2 = f2 * l  % MOD;
    }

    ll res = (fastaxp( 2 , n)
    - t1 *fastaxp(f1 , MOD-2 ) %MOD
    - t2 * fastaxp(f2 , MOD -2 ) %MOD
     - 1  + MOD * 3LL) % MOD;
    cout << res;
    return 0;
}



















Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,n) for(int i=0;i<n;i++)
    ll a,b,c,d,e,f,g,n,m,k,t,p,x,y;
 
    ll mod = 998244353;
    
    void solve(){
       
        cin >> x >> y >> a>> b >> c;
        vector<ll> red(a);
        vector<ll> green(b);
        vector<ll> color(c);
        FOR(i,a) cin >> red[i];
        FOR(i,b) cin >> green[i];
        FOR(i,c) cin >> color[i];
        sortV(red);
        sortV(green);
        sortV(color);
        revV(red);
        revV(green);
        revV(color);

        ll cnt = 0;
        int L1 = 0, L2 = 0, L3 = 0;
        int used = 0;
        for(int i=0;i<x;i++){
            if(red[L1] < color[L3] && L3 < c){
                cnt += color[L3];
                L3++;
            }else{
                cnt += red[L1];
                L1++;
            }
        }
        for(int i=0;i<y;i++){
            if(x == L1 && L3 == c){
                cnt += green[L2];
                L2++;
            }else if(x == L1){
                ll g = green[L2];
                ll clr = color[L3];
                if(g >= clr){
                    cnt += g;
                    L2++;
                }else{
                    cnt += clr;
                    L3++;
                }
            }else if(L3 == c){
                ll r = red[L1];
                ll g = green[L2];
                if(r > g){
                    L1++;
                    cnt += r;
                }else{
                    cnt += g;
                    L2++;
                }
            }else{
                ll r = red[L1];
                ll g = green[L2];
                ll clr = color[L3];
                if(r > g && r > clr){
                    cnt += red[L1];
                    L1++;
                }else if(g >= clr && g >= r){
                    cnt += g;
                    L2++;
                }else{
                    cnt += clr;
                    L3++;
                }
            }
        }
        cout << cnt;

        

    }
 
    int main(){
        ios_base::sync_with_stdio(false);
       
        int cases = 1; 
        //cin >> cases;
       
        while(cases--){
            solve();
        }
        return 0;
 
    }

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define int long long

using namespace std;

const int N = 2e5 + 5;

int n, a[N], b[N], ans, sum = 1e9 + 7;

bool fl = 0;

vector <int> vec;

main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%lld%lld", &a[i], &b[i]), fl |= (a[i] != b[i]), ans += a[i];

    if (!fl)
    {
        puts("0");
        return 0;
    }
    for (int i = 1; i <= n; i++)
    {
        if (a[i] > b[i])
            sum = min(sum, b[i]);
    }
    cout << ans - sum << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a,s,d,i,j;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
			for(i=0;i<a;i++){
				for(j=0;j<s;j++)
					printf("#");
				printf("\n");
			}
			printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2596
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

const int maxn = 1e5 + 10;

int p[maxn];

int boss(int v) {
    if (p[v] == v) return v;
    return p[v] = boss(p[v]);
}

void merge(int a, int b) {
    a = boss(a), b = boss(b);
    if (a == b) return;
    p[a] = b;
}

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

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) p[i] = i;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        merge(u, v);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += boss(i) == i;
    cout << ans - 1 << '\n';

    return 0;
}


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

using namespace std;
using T = long long;
struct BinaryIndexedTree{
private:
    vector<T> vect;
    const int n;
public:
    BinaryIndexedTree(int _n) : vect(_n + 1, 0), n(_n) {}

    T sum(int i) {
        i++;
        T s = 0;
        while( i > 0){
            s += vect[i];
            i -= i & (-i);
        }
        return s;
    }
    //[i,j) 外からは0index
    T sum(int i, int j) {
        i--;j--;
        T ret_i = sum(i);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }
    void add(int i, T x) {
        i++;
        while(i <= n) {
            vect[i] += x;
            i += i & (-i);
        }
    }
};

int main () {
    int n,q;
    cin >> n >> q;
    BinaryIndexedTree bit(n);
    int c,x,y;

    for(int i=0; i<q ; i++){
        cin >> c;
        if( c==0 ){
            cin >> x >> y;
            x--;
            bit.add(x,y);
        }else{
            cin >> x >> y;
            x--;
            cout << bit.sum(x,y) << endl;
        }
    } 

    return 0;
}



Measured memory_bytes: 3604
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if( (a+b) % 2 == 0){
			System.out.println( (a+b) / 2 );
		}else{
			System.out.println( (a+b) / 2 + 1);
		}
		scan.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------
ll n, k;
ll a[200010], f[200010];

bool can(ll Max_score) {
    ll cnt = 0;

    rep(i, n) {
        if (a[i] * f[i] <= Max_score) continue;
        cnt += a[i] - (Max_score/ f[i]);
    }

    return cnt <= k;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    cin >> n >> k;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a, a + n);
    sort(f, f + n);
    reverse(f, f + n);
    ll lo = -1, hi = (ll) (1e12);
    while (hi - lo > 1) {
        ll mi = (lo + hi) / 2;
        if (can(mi)) hi = mi;
        else lo = mi;
    }

    cout << hi << endl;
    return 0;
}


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 100005;

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	int a[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int dp[n];
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (i = 0; i < n; i++) {
		if (i + 1 < n) {
			dp[i + 1] = min(dp[i + 1] , dp[i] + abs(a[i] - a[i + 1]));
		}
		if (i + 2 < n) {
			dp[i + 2] = min(dp[i + 2] , dp[i] + abs(a[i] - a[i + 2]));
		}
	}
	cout << dp[n - 1];
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 1792