akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    
    while(true){
        int N;
        cin>>N;
        if(N==0)break;
        map<double,vector<string>> Effi;
        
        REP(i,N){
            string L;
            ll P,A,B,C,D,E,F,S,M;
            cin>>L>>P>>A>>B>>C>>D>>E>>F>>S>>M;
        
            double income=F*M*S-P;
            double time=(A+B+C)+(D+E)*M;
            Effi[income/time].push_back(L);
        }
        
        vector<string> ans;
        for(auto i=Effi.begin();i!=Effi.end();i++){
            vector<string> t=i->second;
            sort(t.begin(),t.end());
            for(int j=(int)t.size()-1;j>=0;j--)ans.push_back(t[j]);
        }
        
        reverse(ans.begin(),ans.end());
        REP(i,ans.size())cout<<ans[i]<<endl;
        cout<<"#"<<endl;
    }
  
    return 0;
}

Measured memory_bytes: 3208
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
S = input()

is_ok = [0] * N
for i in range(N):
    if S[i] == 'L':
        if i != 0 and S[i-1] == 'L':
            is_ok[i] = 1
    else:
        if i != N-1 and S[i+1] == 'R':
            is_ok[i] = 1

cur = S[0]
A = []
st = 0
tmp = is_ok[0]
for i in range(1, N):
    if S[i] == cur:
        tmp += is_ok[i]
    else:
        A.append((tmp, st, i, cur))
        st = i
        tmp = is_ok[i]
        cur = S[i]
A.append((tmp, st, N, cur))

LR = {'L': [], 'R': []}
for cnt, st, end, d in A:
    if st == 0 and end == N:
        pass
    elif st == 0 or end == N:
        LR[d].append(1)
    else:
        LR[d].append(2)

LR['L'].sort(reverse=True)
LR['R'].sort(reverse=True)
ans = sum(is_ok)

# if ans == N-1:
#     print(ans)
#     exit()

ans += max(sum(LR['L'][:K]), sum(LR['R'][:K]))
print(ans)


Measured memory_bytes: 17352
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template <typename T>
using V = vector<T>;

int main() {
	for (int n, m; n = in, m = in;) {
		V<V<int>> v(m + 2, V<int>(n + 2));
		function<int(int, int, int)> f = [&](int i, int j, int n) {
			static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
			v[i][j] = 0;
			int r {++n};
			for (int k: range(4))
				if (v[i + dy[k]][j + dx[k]])
					r = max(r, f(i + dy[k], j + dx[k], n));
			v[i][j] = 1;
			return r;
		};
		for (int i: range(1, m + 1))
			for (int j: range(1, n + 1))
				v[i][j] = in;
		int r {};
		for (int i: range(1, m + 1))
			for (int j: range(1, n + 1))
				if (v[i][j])
					r = max(r, f(i, j, 0));
		outl(r);
	}
}


Measured memory_bytes: 2656
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <unordered_map>
#include <iomanip>
#include <math.h>
#include <cmath>

#define PI 3.14159265359

using namespace std;
#define ASCII 97


int main() {
	std::string S;
	cin >> S;

	const char* s = S.c_str();
	bool flag = false;
	for (int i = 0; i < S.size(); i++) {
		if (!flag && s[i] == 'L'
			|| flag && s[i] == 'R'
			) {
			cout << "No" << endl;
			return 0;
		}

		flag = !flag;
	}
	cout << "Yes" << endl;
	return 0;
}



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


int main(){
  int n;
  cin >> n;
  int target=0;
  int cnt = 0;
  rep(i,n){
    int tmp;
    cin >> tmp;
    tmp--;
    if (tmp==target){
      target++;
    }else{
      cnt++;
    }
  }
  if (target==0) cnt=-1;
  cout << cnt << endl;
      
}

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


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll m = 1000;
    for(int i = 0 ; i+1 < n; ++i) {
        if(a[i]>=a[i+1]) continue;
        else {
            ll d = a[i+1] - a[i];
            ll kabu = m/a[i];
            m+=kabu*d;
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3604
import collections
n=int(input())
c=list(map(int,input().split()))
c = collections.Counter(c)
count=0
for x in c:
    if x==c[x]:
        continue
    elif x>c[x]:
        count+=c[x]
    else:
        count=count+(c[x]-x)
print(count)

Measured memory_bytes: 18676
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> P;

static const int N = 1e5 + 5;
vi a(N);
int n;

int main() {
	cin >> n;
	Loop1(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	Loop(i, n) {
		if (a[a[i]] == i) ans++;
	}
	ans /= 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n;
    ll a[1000000];
    cin>>n;
    REP(i,1000000){
        a[i]=10000000000;
    }
    REP(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    bool ok=false;
    for (int i = 0; i < n-1; i++)
    {
        /* code */
        if (a[i+1]==a[i])
        {
            /* code */
            ok=true;
 
        }
        
    }
    if (ok)
    {
        /* code */
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
    
    
    
}



Measured memory_bytes: 8064
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    long long ans=0,a;
    cin>>s;
    for(int i=0;i<(1<<s.size()-1);i++){
        a = s[0] - '0';
        for(int j=0;j<s.size()-1;j++){
                if(i&(1<<j)){
                    ans+=a;
                    a=0;
                }
                a = a*10+s[j+1]-'0';
        }
        ans += a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    char b;
    cin >> b;
    if (b == 'A'){
      printf("%s","T");
    }
    else if (b == 'T'){
      printf("%s","A");
    }
    else if (b == 'G'){
      printf("%s","C");
    }
    else {
      printf("%s","G");
    }
}

Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>

using namespace std;

long long result, n,m,k;

long long total[2] = {};

long long a[100000] = {};

int main() {

	cin >> n >> k;
	
	result =0;

	for (int i = k+1; i <= n; i++) {
		result += (n / i)*(i - k);
		if (n%i >= k) {
			if (k != 0) {
				result += (n%i) - k + 1;
			}
			if (k == 0) {
				result += (n%i) - k;
			}

		}

	}


	cout << result << endl;

return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;


int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(m);
  vector<int> dif(m-1);
  rep(i,m){
    cin>>x.at(i);
  }
  sort(x.begin(),x.end());
  rep(i,m-1){
    dif.at(i)=x.at(i+1)-x.at(i);
  }
  sort(dif.begin(),dif.end());
  if(m-n<=0)cout<<0<<endl;
  else{
    ll res = 0;
    rep(i,m-n)res+=dif.at(i);
    cout<<res<<endl;
  }
  return 0;
}


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

namespace C
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] tmp = Console.ReadLine().Split(' ');
			int K = int.Parse(tmp[0]);
			int N = int.Parse(tmp[1]);

			tmp = Console.ReadLine().Split(' ');
			List<int> A = new List<int>();
			for (int i = 0; i < tmp.Length; i++)
			{
				A.Add(int.Parse(tmp[i]));
			}

			int max_num = A.First() + (K - A.Last());
			for (int i = 0; i < A.Count() - 1; i++)
			{
				max_num = Math.Max(max_num, A[i+1] - A[i]);
			}

			Console.WriteLine(K - max_num);
		}
	}
}


Measured memory_bytes: 34652
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
    int n;
    double m, v, std_dev;
    while(cin >> n){
        if(n == 0){
            break;
        }
        // init
        vector<int> s;
        s.resize(n);
        m = 0.0;
        v = 0.0;
        std_dev = 0.0;
        for (int i=0; i<n; ++i){
            cin >> s[i];
        }
        // find m
        for (int i=0; i<n; ++i){
            m += (double) s[i];
            if (i == n-1){
                m = m / (double) n;
            }
        }
        // find s
        for (int i=0; i<n; ++i){
            v += pow(s[i] - m, 2);
            if (i == n-1){
                v = v / (double) n;
            }
        }
        std_dev = sqrt(v);
        printf("%.8f\n", std_dev);
    }
    return 0;
}



Measured memory_bytes: 3192
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
    ll n, k, ans;
    cin >> n >> k;
    
    ans = n % k;

    ans = min(ans, k-ans);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#include<bitset>
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
   int n;
   cin>>n;
   for(int i=1;i<=9;++i)
   {
       if(n%i==0 and n/i<=9)
       {
          cout<<"Yes";
           return;
       }
   }
   cout<<"No";
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

int main() {
  string orig;
  int n;
  cin >> orig >> n;
  for (int i = 0; i < n; ++i) {
    string cmd;
    int a, b;
    cin >> cmd >> a >> b;
    if (cmd == "print") {
      cout << orig.substr(a, b - a + 1) << endl;
    } else if (cmd == "reverse") {
      reverse(orig.begin() + a, orig.begin() + b + 1);
    } else {
      string p;
      cin >> p;
      copy(p.begin(), p.end(), orig.begin() + a);
    }
  }
}

Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, K;
	cin >> N >> K;
	int x[100100];
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
	}
	int ans = INF;
	for (int i = 0; i < N - K + 1; ++i) {
		int A = min(x[i + K - 1] - x[i] + abs(x[i + K - 1]), x[i + K - 1] - x[i] + abs(x[i]));
		ans = min(ans, A);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
from functools import lru_cache

@lru_cache(maxsize=1000000)
def fx(n):
  if n == 0:
    return 0
  if n == 1:
    return 1
  arr = []
  cnt = 0
  
  if n < 6:
    b = fx(n-1)+1
    arr.append(b)
  while n-6**cnt >= 0:
    cnt += 1
  if cnt > 1:
    
    x = n-(6**(cnt-1))
    b = fx(x)+1
    arr.append(b)

  cnt = 0
  while n-9**cnt >= 0:
    cnt += 1
  if cnt > 1:
    x = n-(9**(cnt-1))
    b = fx(x)+1
    arr.append(b)
  
  return min(arr)
  
N = int(input())
print(fx(N))



Measured memory_bytes: 3572
#include<bits/stdc++.h>   
using namespace std;    
int main(){ 
  int a,b;
  cin>>a>>b;
  int ans = 0;
  if(b%a ==0){
    ans=a+b;
  }

  else{
    ans=b-a;
  }

  cout<<ans<<endl;
}


  
  

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        long ans = b + Math.min(c,a+ b + 1);
        System.out.println(ans);
    } 
}

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

int main(){
  int n, d, ans=0, i;
  cin >> n >> d;
  for(i=0; ; ){
    ans++;
    i=i+2*d+1;
    if(i>=n){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int N_MAX = 100;
double V[N_MAX+2];
double S_T[N_MAX+2];
double E_T[N_MAX+2];

double solve(int n) {
  double ans = 0;
  double prev_v = 0;
  for (int t = 0; t <= E_T[n+1]*2; t++) { // t is 0.5 unit
    double v = 100;
    double time = t;
    time /= 2;
    for (int j = 0; j < n+2; j++) {
      if (S_T[j] > time) {
	v = min(v, V[j] + S_T[j] - time);
      }
      else if (S_T[j] <= time && time < E_T[j]) {
	v = min(v, V[j]);
      }
      else if (E_T[j] <= time) {
	v = min(v, V[j] + time - E_T[j]);
      }
    }

    ans += 0.25*(v + prev_v);
    prev_v = v;

  }
  return ans;
}

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

  S_T[0] = 0;
  E_T[0] = 0;
  for (int i = 1; i < N+1; i++) {
    int t;
    cin >> t;
    S_T[i] = E_T[i-1];
    E_T[i] = t + S_T[i];
  }
  S_T[N+1] = E_T[N];
  E_T[N+1] = S_T[N+1];

  V[0] = 0;
  for (int i = 1; i < N+1; i++) {
    cin >> V[i];
  }
  V[N+1] = 0;

  printf("%.9lf\n", solve(N));
}

Measured memory_bytes: 632
#include <cstdio>
#include <algorithm>
#define LL long long
#define MX (2000 + 233)
#define chkmx(a ,b) (a = __max(a ,b))

LL __max(LL a ,LL b){return a > b ? a : b;}
LL __abs(LL a){return a > 0 ? a : -a;}
LL dp[MX][MX];

struct P{
	LL id ,A;
	bool operator <(const P &B)const{
		return A > B.A;
	}
}P[MX];

int main(){
	int n; scanf("%d" ,&n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%lld" ,&P[i].A);
		P[i].id = i;
	}std::sort(P + 1 ,P + 1 + n);
	LL Ans = 0;
	for(int i = 0 ; i <= n ; ++i){
		for(int j = 0 ; i + j < n ; ++j){
			int x = i + j + 1;
			chkmx(dp[i + 1][j] ,dp[i][j] + __abs(P[x].id - (i + 1)) * P[x].A);
			chkmx(dp[i][j + 1] ,dp[i][j] + __abs(P[x].id - (n - j)) * P[x].A);
		}
	}
	for(int i = 0 ; i <= n ; ++i)
		chkmx(Ans ,dp[i][n - i]);
	printf("%lld\n" ,Ans);
	return 0;
}

Measured memory_bytes: 26620
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll N; cin >> N;
    N--;
    string ans;
    while(true) {

        ans += (N % 26 + 'a');
        if (N / 26 == 0) {
            reverse(ALL(ans));
            cout << ans << '\n';
            break;
        }
        N = N / 26 -1;
    }

    return 0;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int K;
string S;


signed main()
{
	cin >> K >> S;
	if (S.length() <= K)
	{
		cout << S << endl;
	}
	else
	{
		S = S.substr(0, K);
		cout << S << "..." << endl;
	}
}




Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main() 
{
    fastio
    int n; cin>>n; vector<vector<int>>v(n,vector<int>(3)),dp(v);
    for(int i=0;i<n;i++)
    {
      	cin>>v[i][0]>>v[i][1]>>v[i][2];
      	if(i>0)
      	{
    		dp[i][0]=max(dp[i-1][1]+v[i][0],dp[i-1][2]+v[i][0]);
    		dp[i][1]=max(dp[i-1][2]+v[i][1],dp[i-1][0]+v[i][1]);
    		dp[i][2]=max(dp[i-1][1]+v[i][2],dp[i-1][0]+v[i][2]); 		
    	}  	
    	else
    	dp[i][0]=v[i][0], dp[i][1]=v[i][1], dp[i][2]=v[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0; 
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int dp[111];

signed main(){
    int N;
    while(cin>>N,N){
        dp[0]=1;
        for(int i=1;i<=N;i++){
            dp[i]=0;
            for(int j=1;j<=3;j++)if(i-j>=0)dp[i]+=dp[i-j];
        }
        cout<<((dp[N]+9)/10+364)/365<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <set>
#define FOR(i,n) for(int i=0;i<n;++i)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;

using ti = tuple < int, int, int >;
using lint = long long;
using ii = pair < int, int >;
using ll = pair < lint, lint >;

const int N = 2 * 1e5 + 9;
const int M = 35;
 
vector < ii > a[M];
vector < ii > b[M];

int main() {
	int n, c;
	scanf("%d%d", &n, &c);
	
	for (int i = 0; i < n; i++) {
		int s, t, c;
		scanf("%d%d%d", &s, &t, &c);
		--c;
		a[c].push_back(ii(s, t));
	}

	for (int i = 0; i < c; i++) {
		sort(a[i].begin(), a[i].end());
	}

	for (int i = 0; i < c; i++) {
		int j = 0;
		while (j != a[i].size()) {
			int s = a[i][j].first;
			int e = a[i][j].second;
			++j;
			while (j != a[i].size() && e == a[i][j].first) {
				e = a[i][j].second;
				++j;
			}
			b[i].push_back(ii(s,e));
		}
	}

	vector < ii > v;

	for (int i = 0; i < c; i++) {
		for (int j = 0; j < b[i].size(); j++) {
			b[i][j].first = b[i][j].first * 2 - 1;
			b[i][j].second = b[i][j].second * 2;
			v.push_back(b[i][j]);
		}
	}

	vector < int > t;
	
	sort(v.begin(), v.end());

	for (int i = 0; i < v.size(); i++) {
		int s = v[i].first;
		int e = v[i].second;
		bool ok = false;
		sort(t.rbegin(), t.rend());
		for (int j = 0; j < t.size(); j++) {
			if (t[j] <= s) {
				ok = true;
				t[j] = e;
				break;
			}
		}
		if (!ok)
			t.push_back(e);
	}
	printf("%d", t.size());

	return 0;
}

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

#define ll long long
#define ar array

int main() {

    ios::sync_with_stdio(false);
	
	int a, b, soma, menos, vzs;
	
	cin >> a >> b;
	
	soma = a+b;
	menos = a-b;
	vzs = a*b;
	
	cout << max(max(soma, menos), vzs) << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

template<typename T = ll>
struct FordFulkerson {
    struct Edge { int to, rev; T cap; Edge(int t, int r, T c) : to(t), rev(r), cap(c) {} };
    vector<vector<Edge>> graph;
    vector<int> used;
    int updateIndex;

    void add_edge(int from, int to, T cap) {
        graph[from].emplace_back(to, graph[to].size(), cap);
        graph[to].emplace_back(from, graph[from].size() - 1, 0);
    }

    T dfs(int v, int t, T f) {
        if (v == t) return f;
        used[v] = updateIndex;
        for (auto& e : graph[v]) {
            if (used[e.to] != updateIndex && e.cap > 0) {
                T ret = dfs(e.to, t, min(f, e.cap));
                if (ret > 0) {
                    e.cap -= ret;
                    graph[e.to][e.rev].cap += ret;
                    return ret;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t) {
        used.resize(graph.size(), -1);
        T flow = 0;
        updateIndex = 0;
        for (;;) {
            T f = dfs(s, t, numeric_limits<T>::max());
            if (f == 0) return flow;
            flow += f;
            updateIndex++;
        }
    }
};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    rep(i, H) cin >> A[i];

    int s = -1, t = -1;
    rep(i, H) rep(j, W) {
        if (A[i][j] == 'S') s = W * i + j;
        if (A[i][j] == 'T') t = W * i + j;
    }
    if (s / W == t / W || s % W == t % W) {
        write(-1);
        return 0;
    }

    int N = H * W;
    FordFulkerson<int> ff;
    ff.graph.resize(2 * N);
    rep(i, H) rep(j, W) {
        int v = W * i + j;
        ff.add_edge(v, N + v, 1);
    }
    rep(h, H) {
        rep(i, W - 1) rep(j, i + 1, W) {
            if (A[h][i] != '.' && A[h][j] != '.') {
                int v = W * h + i, u = W * h + j;
                ff.add_edge(N + v, u, H + W);
                ff.add_edge(N + u, v, H + W);
            }
        }
    }
    rep(w, W) {
        rep(i, H - 1) rep(j, i + 1, H) {
            if (A[i][w] != '.' && A[j][w] != '.') {
                int v = W * i + w, u = W * j + w;
                ff.add_edge(N + v, u, H + W);
                ff.add_edge(N + u, v, H + W);
            }
        }
    }

    write(ff.max_flow(N + s, t));
}

Measured memory_bytes: 62080
while true
  (m, f, r) = gets.split().map(&:to_i)
  break if m == -1 && f == -1 && r == -1
  if m == -1 || f == -1
    puts "F"
  elsif m+f >= 80
    puts "A"
  elsif m+f >= 65 && m+f < 80
    puts "B"
  elsif m+f >= 50 && m+f < 65
    puts "C"
  elsif m+f >= 30 && m+f < 50
    if r >= 50
      puts "C"
    else
      puts "D"
    end
  else
    puts "F"
  end
end

Measured memory_bytes: 8604
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
    if a[i] < a[i + 1] < a[i + 2]:
        ans += 1
    if a[i] > a[i + 1] > a[i + 2]:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
long long N;
 
int main() {
	cin >> N;
	if (N == 0) { cout << "0" << endl; return 0; }
	for (int i = 1; i < 36; i += 2) N += (1LL << i);
	string S = "";
	while (N >= 1) {
		if (N % 2 == 1) S += "1";
		else S += "0"; N /= 2;
	}
	reverse(S.begin(), S.end());
	for (int i = (int)S.size() - 2; i >= 0; i -= 2) {
		if (S[i] == '0') S[i] = '1';
		else S[i] = '0';
	}
	while (S[0] == '0') S = S.substr(1, S.size() - 1);
	cout << S << endl;
	return 0;
}

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

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

	vector<int> arr;
	for(int i = 0;i < n;i++)
	{
		int inp;
		cin >> inp;

		arr.push_back(inp);
	}

	vector<int> dp(n,INT_MAX);
	dp[0] = 0;

	for(int i = 0;i < arr.size();i++)
	{
		for(int j : {i+1,i+2})
		{
			if(j < n)
				dp[j] = min(dp[j],dp[i] + abs(arr[i]-arr[j]));
		}
	}

	cout << dp[n-1];

	return 0;

}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(a, b) for(a = 0; a < b; a++)

int main(){  
  int i, N;
  cin >> N;
  int64_t Sum = 0;
  
  rep(i, N){
    
    if (((i + 1) % 3 != 0) && ((i + 1) % 5 != 0)){
      
      //cout << i + 1 << endl;
      Sum += (i + 1);
    }
  }
  cout << Sum << endl;
}



Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if (x + r <= W) {
			if (y + r <= H) {
				if (x - r >= 0) {
					if (y - r >= 0) {
						System.out.println("Yes");
					} else
						System.out.println("No");
				} else {
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26316
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
//const int mod = 1000000007;
const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
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];
  }
} c(10000000);
 
// M * (M-1)^(N-1-K) * N-1 C K
int main(int argc, const char * argv[]) {
    ll N,M,K; cin >> N >> M >> K;
    
    mint ans = 0;
    mint col = M;
    
    
    
    for(ll x=N-1; x>=0 ; x--){
        if(x<=K){
            ans += col * c(N-1,x);
        }
        col *= (M-1);
    }
    
    cout << ans << endl;
    
    
}



Measured memory_bytes: 159352
import java.util.Scanner;
class Main {

	public void ci() {

		Scanner sc = new Scanner(System.in);

		int x0 = 0,y0 = 0;

		int W = sc.nextInt();

		int H = sc.nextInt();

		int x = sc.nextInt();

		int y = sc.nextInt();

		int r = sc.nextInt();

		if(x - r >= 0) {

			if(y - r >= 0) {

				if(x + r - W <= 0) {

					if(y + r - H <= 0) {

						System.out.println("Yes");

					} else {

						System.out.println("No");

					}

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

				}

			} else {

				System.out.println("No");

			}

		} else {

			System.out.println("No");

		}

	}

	public static void main(String[] args) {

		new Main().ci();

	}

}

Measured memory_bytes: 26380
#include <stdio.h>

int add_digits(int n) {
    int sum = 0;

    for (sum = 0; n > 0; n /= 10) {
        sum += n % 10;
    }

    return sum;
}

int main(int argc, char *argv[]) {
    int n;
    int a, b;
    int sum = 0;

    scanf("%d%d%d", &n, &a, &b);

    for (int i = 1; i <= n; i++) {
        int sum_of_digits = add_digits(i);
        if (sum_of_digits >= a && sum_of_digits <= b) sum += i;
    }

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

    return 0;
}


Measured memory_bytes: 128
import heapq

n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)

for _ in range(m):
    p = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-p//2))

print(-sum(a))


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

r = []
for i in range(n):
	s, p = input().split()
	r.append([i, s, int(p)])

r = sorted(r, key= lambda x: x[2], reverse=True)
r = sorted(r, key=lambda x: x[1])

for item in r:
	print(item[0]+1)

Measured memory_bytes: 3060
// ARC092
// D - Two Sequences

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int K = 28;

int N;
vector<int> a, b;

int main() {
    cin >> N;
    a.resize(N);
    b.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }

    int ans = 0;
    for (int k = 0; k <= K; k++) {
        vector<int> q(N);
        for (int i = 0; i < N; i++) {
            q[i] = b[i] & ((1 << (k + 1)) - 1);
        }
        sort(q.begin(), q.end());

        ll cnt = 0;
        for (int i = 0; i < N; i++) {
            int p = a[i] & ((1 << (k + 1)) - 1);
            cnt += lower_bound(q.begin(), q.end(), (4 << k) - p) -
                   lower_bound(q.begin(), q.end(), (3 << k) - p);
            cnt += lower_bound(q.begin(), q.end(), (2 << k) - p) -
                   lower_bound(q.begin(), q.end(), (1 << k) - p);
        }
        if (cnt % 2 == 1) {
            ans |= (1 << k);
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;
const int MOD = 1e9 + 7;

int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  if (a < 0) a += MOD;
  return a;
}

int mul(int a, int b) {
  return (ll) a * b % MOD;
}

int pot(int a, int b) {
  if (!b) return 1;
  if (b % 2) return mul(a, pot(a, b - 1));
  int k = pot(a, b / 2);
  return mul(k, k);
}


int inv(int x) {
  return pot(x, MOD - 2);
}

int n, a[MAXN], p[MAXN], N, P[MAXN];

int main() {
  scanf("%d",&n);
  FOR(i, 1, n + 1) scanf("%d",&a[i]);
  FOR(i, 1, n + 1) p[i] = add(p[i - 1], a[i]);
  FOR(i, 1, n + 1) P[i] = add(P[i - 1], p[i]);

  N = 1;
  FOR(i, 1, n + 1) N = mul(N, i);

  int sol = mul(N, p[n]);
  FOR(l, 1, n - 1) {
    int x = mul(N, inv(mul(l + 1, l + 2)));
    x = mul(x, 2);
    int suff = add(P[n - 1], -P[l]);
    int pref = P[n - l - 1];
    int s = add(suff, -pref);
    sol = add(sol, mul(x, s));
  }

  FOR(i, 1, n) {
    int x = mul(N, inv(i - 1 + 2));
    sol = add(sol, mul(x, p[i]));
  }

  FOR(j, 2, n + 1) {
    int x = mul(N, inv(n - j + 2));
    sol = add(sol, mul(x, add(p[n], -p[j-1])));
  }

  cout << sol << endl;
  return 0;
}


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

int main() {
  int N; cin >> N;
  set<string> st;
  map<string, int> mp;
  int cnt = 1;
  for(int i = 0; i < N; i++) {
    string s; cin >> s;
    if(st.count(s) == 0) {
      mp.insert(make_pair(s, 1));
      st.insert(s);
    } else {
      mp.at(s) = mp.at(s) + 1;
      cnt = max(cnt, mp.at(s));
    }
  }

  vector<string> S;
  for(auto s: st) {
    S.push_back(s);
  }
  sort(S.begin(), S.end());
  for(auto s : S) {
    if(mp[s] == cnt) {
      cout << s << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 36340
import math
import fractions
from functools import reduce

n, m = map(int, input().split())
a = list(map(lambda x:int(x)//2, input().split()))

t = 0
while all([i%(2**(t+1))==0 for i in a]):t+=1
a = [i//(2**t) for i in a]

if any([i%2==0 for i in a]):
  print(0)
else:
  b = reduce(lambda x,y:x*(y//fractions.gcd(x,y)),a) * (2**t)
  print((m//b+1)//2)

Measured memory_bytes: 120832
#include<stdio.h>
#include<string.h>
int main(void)
{
  int N;
  int K;
  char S[100];
  scanf("%d\n",&N);
  scanf("%s\n",S);
  scanf("%d\n",&K);
  
  for(int i=0;i<N;i++){
	if(S[i]!=S[K-1]){
      S[i]='*';
    }
  }
  printf("%s\n",S);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct Combination {
    vector<int64_t> fact, rfact;
    Combination(int sz) : fact(sz + 1), rfact(sz + 1) {
        fact[0] = 1;
        for(int i = 1; i < fact.size(); i++){
            fact[i] = fact[i - 1] * i % mod;
        }
        rfact[sz] = inv(fact[sz]);
        for(int i = sz - 1; i >= 0; i--){
            rfact[i] = rfact[i + 1] * (i + 1) % mod;
        }
    }
    int64_t inv(int x) const {
        return pow(x, mod - 2);
    }
    int64_t pow(int64_t x, int64_t n) const {
        int64_t ret = 1;
        while(n > 0){
            if(n & 1) (ret *= x) %= mod;
            (x *= x) %= mod;
            n >>= 1;
        }
        return (ret);
    }
    int64_t P(int n, int r) const {
        if(r < 0 || n < r) return (0);
        return (fact[n] * rfact[n - r] % mod);
    }

    int64_t C(int p, int q) const {
        if(q < 0 || p < q) return (0);
        return (fact[p] * rfact[q] % mod * rfact[p - q] % mod);
    }

    int64_t H(int n, int r) const {
        if(n < 0 || r < 0) return (0);
        return (r == 0 ? 1 : C(n + r - 1, r));
    }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    if((x + y) % 3){
        cout << 0 << endl;
        return 0;
    }
    int n = (x + y) / 3;
    x -= n;
    y -= n;
    if(x < 0 || y < 0){
        cout << 0 << endl;
        return 0;
    }
    Combination cb(n);
    cout << cb.C(n, x) << endl;
}

Measured memory_bytes: 10624
import sys

N, K = map(int, sys.stdin.readline().rstrip().split())

counter = [0] * N

for k in range(K):
    d = int(sys.stdin.readline().rstrip())
    A = list(map(int, sys.stdin.readline().rstrip().split()))
    for a in A:
        counter[a - 1] += 1

print(counter.count(0))


Measured memory_bytes: 9120
#include <stdio.h>

int main(void)
{
	int numofint;
	int min, max;
	long int sum;
	int a[100000];
	
	scanf("%d",&numofint);

	for (int i = 0; i < numofint; i++){
		scanf("%d", &a[i]);
	}
	
	min = a[0];
	max = a[0];
	sum = 0;
	for (int i = 0; i < numofint; i++){
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
		sum += a[i];
	}
	printf ("%d %d %ld\n", min, max, sum);
	return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s, t;
  cin >> s;
  //s.resize(n);
  bool two = false;
  for (int i = 1; i < n; i++) if (abs(s[i] - s[i - 1]) == 2) two = true;
  for (int i = 1; i < n; i++) if (abs(s[i] - s[i - 1]) == 1) two = false;
  bool ok = true;

  vector<bool> bs(n);
  if (two) {
    for (int i = 0; i < n; i++)
      if (s[i] == '3') bs[i] = true;
      else bs[i] = false;
  } else {
    for (int i = 0; i < n; i++)
      if (s[i] == '2') bs[i] = true;
      else bs[i] = false;
  }

  while (bs.size() > 1) {
    int k = 1;
    while (k <= bs.size()) {
      k <<= 1;
    }
    k >>= 1;
    bool c = 0;
    for (int i = 0; i < k - 1; i++) {
      c ^= bs[i];
    }
    vector<bool> cs;
    for (int i = k - 1; i < bs.size(); i++) {
      c ^= bs[i];
      if (i - k >= 0)
        c ^= bs[i - k];
      cs.push_back(c);
    }
    swap(bs, cs);
  }
  ok = bs[0];

  if (two) {
    if (ok)
      cout << 2 << endl;
    else cout << 0 << endl;
  } else {
    if (ok)
      cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N, K;  cin >> N >> K;
    vector<ll> h(N);  rep(i, N)  cin >> h[i];

    sort(h.begin(), h.end());
    ll ans = INF;
    rep(i, N-K+1) {
        ans = min(ans, h[i+K-1] - h[i]);
    }

    print(ans);

}


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

int main(){
    int N,K;
    cin >> N >> K;
    int Bar[N];
    for(int i = 0; i < N; i++){
       cin >> Bar[i];
    }
    sort(Bar, Bar + N,greater<int>());
    int sum = 0;
    for(int i =0; i < K; i++){
        sum += Bar[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/*https://atcoder.jp/contests/abc157/tasks/abc157_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n = 3, a[100][100], b[10], m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	}
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			for (int k = 0; k < m; k++)
				if (a[i][j] == b[k] && b[k] != 0) a[i][j] = 0, b[k] = 0;

		}
	}
	for (int i = 0; i < n; i++)
	{
		int count = 0;
		for (int j = 0; j < n; j++)
			if (a[i][j] == 0) count++;
		if (count == n)
		{
			cout << "Yes";
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
	{
		int count = 0;
		for (int j = 0; j < n; j++)
			if (a[j][i] == 0) count++;
		// cout << count << endl;

		if (count == n)
		{
			cout << "Yes";
			return 0;
		}
	}
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			if (i == j && a[i][j] == 0) count++;
		if (count == n)
		{
			cout << "Yes";
			return 0;
		}
	}
	count = 0;
	for (int i = 0; i < n; i++)
	{
		// int count = 0;
		for (int j = 0; j < n; j++)
			if (i + j == n - 1 && a[i][j] == 0) count++;
		if (count == n)
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No" << endl;
	// for (int i = 0; i < n; i++)
	// {
	// 	for (int j = 0; j < n; j++)
	// 		cout << a[i][j] << " ";
	// 	cout << endl;
	// }
	// for (int i = 0; i < m; i++)
	// 	cout << b[i] << " ";

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll x = n / (a + b);
    ll ans = x * a + min(n - x * (a + b), a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		int trainPrice = sc.nextInt();
      	int busPrice = sc.nextInt();
      	
      	System.out.println(trainPrice + (busPrice / 2));
    }
}

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

using namespace std;

#define int long long

inline int start(int a, int i) {
    if (i < a) return i;
    return i + 1;
}

inline int finish(int b, int i, int x) {
    if (x < b) return x - i + 1;
    int lst = x + 1;
    if (lst - i + 1 > b) return lst - i + 1;
    return lst - i;
}

inline int get(int a, int b, int x) {
    int ans = 0;
    for (int i = max((long long)1, x / 2 - 2); i <= min(x, x / 2 + 2); ++i) {
        ans = max(ans, start(a, i) * finish(b, i, x));
    }
    return ans;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int q, a, b;
    cin >> q;
    while (q--) {
        int l = 0, r = 2000 * 1000 * 1000;
        cin >> a >> b;
        while (r - l > 1) {
            int m = (r + l) / 2;
            if (get(a, b, m) < a * b) l = m;
            else r = m;
        }
        cout << l << '\n';
    }
    return 0;
}


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

using namespace std;

long long a[50];

auto f(long long st, long long en) {
    long long w = en - st;
    vector<pair<int, long long>> vt;
    for (long long i = 0; i < (1 << w); ++i) {
        long long sum = 0;
        int cnt = __builtin_popcount(i);
        for (long long j = 0; j < w; ++j) {
            if ((i >> j) & 1) {
                sum += a[st + j];
            }
        }
        vt.emplace_back(make_pair(cnt, sum));
    }
    return vt;
}

int main() {
    int n, k;
    long long l, r;
    cin >> n >> k >> l >> r;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    auto vt1 = f(0, n / 2);
    auto vt2 = f(n / 2, n);
    sort(vt2.begin(), vt2.end());

    long long ans = 0;
    for (auto x:vt1) {
        auto it1 = lower_bound(
                vt2.begin(), vt2.end(),
                pair<int, long long>(k - x.first, l - x.second));
        auto it2 = upper_bound(
                vt2.begin(), vt2.end(),
                pair<int, long long>(k - x.first, r - x.second));
        ans += it2 - it1;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 43772
package main

import (
	"fmt"
	"strconv"
)

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

	strN := strconv.Itoa(n)
	sn := 0
	for i := range strN {
		x, err := strconv.Atoi(string(strN[i]))
		if err != nil {
			panic(err)
		}
		sn += x
	}

	if n%sn == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1e9 + 5

int main(){
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k; j++){
			if(i + j < n)
				dp[i + j] = min(dp[i + j], dp[i] + abs(v[i]-v[i+j]));
		} 			
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100011
struct PEO{
	LL val;int bel;
}p[N<<1];
int n,ba[N],bb[N];
LL a[N],b[N],ans,sum[N<<1];
bool cmp(PEO a,PEO b){
	return a.val<b.val;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i],&b[i]);
	LL tmp=0;
	for(int i=1;i<=n;i++)ans=ans+a[i],tmp=tmp+b[i];
	ans=min(ans,tmp);
	for(int i=1;i<=n;i++)p[i].val=a[i],p[i].bel=i;
	for(int i=1;i<=n;i++)p[n+i].val=b[i],p[n+i].bel=i+n;
	sort(p+1,p+2*n+1,cmp);
	for(int i=1;i<=2*n;i++){
		if(p[i].bel<=n) ba[p[i].bel]=i;
		else bb[p[i].bel-n]=i;
		sum[i]=sum[i-1]+p[i].val;
	}
	for(int i=1;i<=n;i++){
		if(bb[i]<=n&&ba[i]<=n) ans=min(ans,sum[n]);
		else if(ba[i]<=n){
			if(ba[i]==n){
				ans=min(ans,sum[n]-p[n-1].val+b[i]);
			}else
				ans=min(ans,sum[n-1]+b[i]);
		}else
		if(bb[i]<=n){
			if(bb[i]==n){
				ans=min(ans,sum[n]-p[n-1].val+a[i]);
			}else{
				ans=min(ans,sum[n-1]+a[i]);
			}
		}
	}
	printf("%lld\n",ans);
} 

Measured memory_bytes: 7296