akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 100;

int n, l, t, dex, x[N], w[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> l >> t;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> w[i];
		if (w[i] == 1)
			dex = (dex + (t + x[i]) / l);
		else
			dex = (dex - (t - x[i] + l - 1) / l);
		dex = (dex % n + n) % n;
		x[i] = ((x[i] + (w[i] == 1? : -1) * t) % l + l) % l;
	}
	sort(x, x + n);
	for (int i = 0; i < n; i++)
		cout << x[(dex + i) % n] << '\n';
}


Measured memory_bytes: 2048
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    bool flag = false;
    s = to_string(n);
    rep(i,0,1){
        if(s[i]==s[i+1]&&s[i]==s[i+2]) flag = true;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 888
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"


bool check(string s){

  return true;
}
bool solve(){ 
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  vector<ll>count(n,0);
  rep(i,n){
    count[a[i]]++;
  }
  ll ans=0;
  rep(i,n)ans+=count[i]*(count[i]-1)/2;
  rep(i,n){
    ll num=a[i];
    ans-=count[num]*(count[num]-1)/2;
    count[num]--;
    ans+=count[num]*(count[num]-1)/2;
    cout<<ans<<endl;
    ans-=count[num]*(count[num]-1)/2;
    count[num]++;
    ans+=count[num]*(count[num]-1)/2;
  }
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int p[100000];
int y[100000];
int z[100000];
int ans[100000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int gcd(int a, int b) {
	if (b == 0)return a;
	int tmp = a%b;
	a = b;
	b = tmp;
	return gcd(a, b);
}

int main() {
	int n;
	scanf("%d%d", &n);
	if (n == 3 || n == 5 || n == 7) {
		puts("YES");
	}
	else {
		puts("NO");
	}
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int n,x,a[200],vis[300];
int main()
{
	cin>>x>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		vis[a[i]]=1;
	}
	for(int i=0;i<=200;i++)
	{
		if(vis[x+i]&&vis[x-i])continue;
		else
		{
			if(!vis[x-i])cout<<x-i;
			else cout<<x+i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3644
n,p,i,a[51];
main(){
	for(;~scanf("%d",&n),n;) {
		for(a[n]=p=i=0;i<n;i++)scanf("%d",a+i);
		for(i=1;i<=n;i++){
			if(a[i-1]-a[i]+1) {
				if(i-p-1)printf(n-i?"%d-%d ":"%d-%d\n",a[p],a[i-1]);
				else printf(n-i?"%d ":"%d\n",a[p]);
				p=i;
			}
		}
	}
	exit(0);
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int h,a;
    cin >> h >> a;
    cout << (h+a-1) / a << endl;
}

Measured memory_bytes: 888
x = int(input())


for a in range(-1, 20000):
    # ubとlbは余裕を持って大きく（小さく）取っておく
    ub = 1000**5
    lb = -1000**5
    while lb + 1 < ub:
        target = (ub+lb)//2
        if a**5 - x == target**5:
            print(a, target)
            exit()
        elif (a**5 - x >= target**5):
            lb = target
        else:
            ub = target
    if a**5 - target**5-x == 0:
        print(a, target)


Measured memory_bytes: 67656
import Control.Applicative
import Control.Monad
main = do
  s <- getLine
  if s == "-" then return ()
              else do
                n <- (read::(String->Int)) <$> getLine
                v <- replicateM n getLine
                let vv = map read v :: [Int]
                putStrLn $ shuf s vv
                main

shuf :: String -> [Int] -> String
shuf s [] = s
shuf s (x:xs) = shuf (aux s x) xs 
    where
      aux :: String -> Int -> String
      aux s n = (drop n s) ++ (take n s)

Measured memory_bytes: 4144
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		boolean[] numH= new boolean[13];
		boolean[] numS= new boolean[13];
		boolean[] numC= new boolean[13];
		boolean[] numD= new boolean[13];
		for(int i=0;i<13;i++){
			numH[i]=true;
			numS[i]=true;
			numC[i]=true;
			numD[i]=true;
		}
		Scanner sc = new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());

		for(int j=0;j<n;j++){
			String[] input = sc.nextLine().split(" ");
			int i=Integer.parseInt(input[1])-1;
			if(input[0].equals("H")){
				numH[i]=false;
			}else if(input[0].equals("S")){
				numS[i]=false;
			}else if(input[0].equals("C")){
				numC[i]=false;
			}else if(input[0].equals("D")){
				numD[i]=false;
			}
		}
		for(int i=0;i<13;i++){
			if(numS[i]){
				System.out.println("S "+(i+1));
			}
		}
		for(int i=0;i<13;i++){
			if(numH[i]){
				System.out.println("H "+(i+1));
			}
		}
		for(int i=0;i<13;i++){
			if(numC[i]){
				System.out.println("C "+(i+1));
			}
		}
		for(int i=0;i<13;i++){
			if(numD[i]){
				System.out.println("D "+(i+1));
			}
		}
	}
}

Measured memory_bytes: 26360
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    lines.shift();
    const set = new Set();
    lines.forEach(e => set.add(e));
    console.log(set.size);
});

Measured memory_bytes: 58056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String word;
        try {
            word = reader.readLine();
            int num = Integer.parseInt(word);
            int ans = num * num * num;
            System.out.println(ans);
        } catch (IOException e) {
            // TODO ????????????????????? catch ????????????
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // TODO ????????????????????? catch ????????????
                e.printStackTrace();
            }
        }
         
         
    }
}

Measured memory_bytes: 24136
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, t) for(ll i = 0; i < t; i++)

using namespace std;
using ll = long long;
using P = std::pair<ll, ll>;

int main() {
    ll n;
    cin >> n;
    vector<ll> map(3001, 0);
    
    ll sum = 0;
    while (n--) {
        ll a;
        cin >> a;
        sum += a - 1;
    }
    cout << sum << endl;
    
}



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

int main(){
    int a,b,c;
    cin >>a >> b>>c;
    
    if(a > b){
        int i = b;
        b = a;
        a = i;
    }
    if (b > c){
        int j = c;
        c = b;
        b = j;
    }
    if(a > b){
        int k = b;
        b = a;
        a = k;
    }
    cout << a <<" "<< b<<" "<< c <<endl;
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

const int MAX_A = 300001;

void solve() {
    int n, k;
    cin >> n >> k;
    segtree<int, op, e> dp(MAX_A);
    int a;
    REP(i, n) {
        cin >> a;
        int l = max(a - k, 0);
        int r = min(a + k + 1, MAX_A);
        dp.set(a, dp.prod(l, r) + 1);
    }
    int ans = dp.prod(0, MAX_A);
    cout << ans << endl;
}


Measured memory_bytes: 8488
S = input()
a = ""
stock = ""
data = []

for i in S:
    a = a + i
    if a != stock:
        stock = a
        data.append(a)
        a = ""
count = len(data)


if a == stock:
    i = 1
    data.append(a)
    check = 1
    c = 0
    while True:
        word = ""
        a = ""
        c = 0
        stock2 = ""
        data2 = []
        for j in range(i+1):
            word = data[-(j+1)] + word
        
        for j in reversed(word):
            c += 1
            a = j + a
            if check > c:
                continue
            if a != stock2:
                stock2 = a
                data2.insert(0,a)
                a = ""
        if len(data2)>=2:
            if (len(S)<=i+2) and (data2[0]!=data2[1]) and (a == ""):
                count = len(data2)
                break
            elif len(S)<=i+2:
                check += 1
                if check == len(S):
                    count = 1
                    break
                continue
        elif (len(data2)==1) and (a==""):
            if S==data2[0]:
                count = 1
                break
            else:
                i += 1
                continue
        elif len(data2)==1:
            check += 1
            continue
        if (data2[0] != data[-(i+2)]) and (a == ""):
            count = len(data) - (i+1) + len(data2)
            break
        i += 1
        

print(count)

Measured memory_bytes: 8296
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
    ll N;
    cin>>N;
    ll num = N*(N-1)/2;
    cout<<num<<endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  vector<int> v;
  cin >> N;
  for(int i=0; i<2*N; i++) {
    int a; cin >> a;
    v.push_back( a );
  }

  sort( v.begin(), v.end() );
  int sum = 0;
  for(int i=0; i<2*N; i+=2) {
    sum += v[i];
  }

  cout << sum << endl;
}


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

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    string S;
    cin >> S;
    int N = S.size();
    string k = "";
    int cnt = 0;
    ll ans = 0,acnt = 0;
    while(cnt < N - 1){
        if(S[cnt] == 'A'){
            acnt++;
            cnt++;
        }else if(S[cnt] == 'B' && S[cnt+1] == 'C'){
            ans += acnt;
            cnt += 2;
        }else{
            acnt = 0;
            cnt++;
        }
    }
    
    cout << ans << endl;
}

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


using namespace std;



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

    set<int> sunuke;
    for (int i = 1; i <= N; i++) {
        sunuke.insert(i);
    }

    for (int i = 1; i <= K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            sunuke.erase(a);
        }
    }
    cout << sunuke.size() << endl;
}


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);i
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin); i != (end); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10 = 1024, X11 = 2048, X12 = 4096, X13 = 8196, X14 = 16392, X15 = 32786, X16 = 65536, X17 = 131072, X18 = 262144, X19 = 524288, X20 = 1048576;

const int MOD = (int)(1e9+7);
template<typename T>
T read(){T x;cin >>x;return x;}

int A[388];
int B[388];
void _(){
    int n, m, x, y;
    cin >> n >> m >>x >>y;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    for (int j = 0; j < m; ++j) {
        cin >> B[j];
    }
    int a_mx = *max_element(A, A+n);
    int b_mi = *min_element(B, B+m);
    if(a_mx < b_mi && a_mx < y && b_mi > x)cout << "No War";
    else cout << "War";



}

int main() {
#ifdef Debug
    freopen("/home/hiroo/Desktop/competitive-programming/IO/Input.txt", "r", stdin);
    freopen("/home/hiroo/Desktop/competitive-programming/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}




Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())
    w = a * 7 + b
    ans = c // w * 7
    c = c % w
    d = c // a
    if c % a > 0:
        d += 1
    if d > 7:
        d = 7
    ans += d
    print(ans)

if __name__ == '__main__':
  main()



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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

ll N, M, X;
vector<bool> take;
vector<vector<ll> > vec;
ll ans = LLONG_MAX;

void f(int index){
	if(index == N){
		vector<ll> sum(M,0);
		ll cost = 0;
		for(int i = 0; i < N; i++){
			if(take[i]){
				cost += vec[i][0];
				for(int j = 1; j <= M; j++){
					sum[j-1] += vec[i][j];
				}
			}
		}
		bool valid = true;
		for(int i =0; i < M; i++){
			if(sum[i] < X){
				valid = false;
				break;
			}
		}
		if(valid) ans = min(ans,cost);
		return;
	}
	
	take[index] = true;
	f(index+1);
	take[index] = false;
	f(index+1);
}

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

	cin >> N >> M >> X;
	vec.resize(N);
	take.resize(N);
	
	for(int i = 0; i < N; i++){
		take[i] = false;
		for(int j = 0; j <= M; j++){
			ll temp;
			cin >> temp;
			vec[i].pb(temp);
		}
	}
	f(0);
	
	if(ans == LLONG_MAX) cout << -1 << endl;
	else cout << ans << endl; 
	return 0;
}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 



const int D = 365;
vector<int> c(26, 0);
vector<vector<int>> s(D, vector<int>(26, 0));

ll calc_score(vector<int> &t){
  vector<int> last(26, -1);
  ll score = 0;
  for(int d=0; d<D; d++){
    int type = t[d];
    score += s[d][type];
    last[type] = d;
  
    for(int i=0; i<26; i++){
      score = score - c[i] * (d - last[i]);
    }
  }
  return score;
}

vector<int> best_oneday(vector<int> &t){
    
    vector<int> last(26, -1);
    for(int d=0; d<D; d++){
        int type = -1;
        ll score = -1e16;// d日目のみで得られるスコア
        for(int j=0; j<26; j++){
            vector<int>  saigo = last;
            ll get = s[d][j];
            saigo[j] = d;
            for(int k=0; k<26; k++){
              get -= c[k] * (d-saigo[k]);
            }
            if(get > score){
              type = j;
              score = get;
            }      
        }
    last[type] = d; 
    t[d] = type;  
    //cout << " (d, type): (" << d << ", " << type << ")  s[d][type]: " << s[d][type] << endl;
    //cout << type + 1 << endl;
  }
  return t;
}

int main(){
  // int D;
  // cin >> D;
  int tmp;
  cin >> tmp;
  //vector<int> c(26, 0);
  for(int i=0; i<26; i++) cin >> c[i];
  //vector<vector<int>> s(D, vector<int>(26, 0));
  for(int i=0; i<D; i++){
    for(int j=0; j<26; j++){
      cin >> s[i][j];
    }
  }


  
  vector<int> t(D);
  t = best_oneday(t);  
  ll score = calc_score(t);
  //cout << "  score: " << score << endl;
  const int LOOP = 100;
  for(int i=0; i<LOOP; i++){
    
    
  }
  for(int i=0; i<D; i++){
    cout << t[i] + 1 << endl;
  }
 
    
}


Measured memory_bytes: 3664
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

odd_n = len([a for a in a_list if a < 0])

# 負の数の個数が偶数の場合は、全部正にできる
if odd_n % 2 == 0:
    s = 0
    for a in a_list:
        s += abs(a)
else:
    # 負の数の個数が奇数の場合は、0があったら全部正にできる
    # 0がない場合は、どれか1個が負のままで残るので、絶対値が一番小さいものを残す
    s = 0
    if 0 in a_list:
        for a in a_list:
            s += abs(a)
    else:
        min_abs = float('inf')
        for a in a_list:
            s += abs(a)
            min_abs = min(min_abs, abs(a))
        s -= min_abs * 2

ans = s
print(ans)


Measured memory_bytes: 14412
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef vector<int> vi;
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define G \
	struct node { int v; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v) { e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v) { adde(u, v); adde(v, u); }
#define W \
	struct node { int v, w; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v, int w) { e[++z].v = v; e[z].w = w; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v, int w) { adde(u, v, w); adde(v, u, w); }
inline int _() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
inline void _(int x) // x >= 0
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
}
/* Default Code Ends Here. */

#define maxn 200100
int n;
int a[maxn];
multiset<int> st;

int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us();
	
	cin >> n;
	enum(i, 1, n)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	int Ans = 0;
	enum(i, 1, n)
	{
		bool flag = false;
		for(LL j = 1; j < 2e9; j <<= 1)
		{
			if(st.count(j - a[i]))
			{
				Ans ++;
				auto it = st.find(j - a[i]);
				st.erase(it);
				flag = true;
				break;
			}
		}
		if(!flag)
			st.insert(a[i]);
	}
	cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;


void solve(){
    int n; cin >> n;
    vi v(n);
    int maxi = 0;
    vi seg;
    for(int i = 0; i < n; i++){
       cin >> v[i];
    }
    
    int ans = 0;
    for(int i = 0; i < n; i ++){
        int tmp = v[i];
        ans += tmp;
        for(int j = i; j < n; j++){
            tmp = min(tmp,v[j]);
            v[j] -= tmp;
        }
    }
    cout << ans << endl;
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


Measured memory_bytes: 256
import numpy as np
# 座標を入力
sx, sy, tx, ty = map(int, input().split())
S = np.array([sx, sy])
T = np.array([tx, ty])

# 2点の最短経路を返す関数を定義（左右移動優先かつ方向転換1回のみ） 
def shortest_path(start, end):
    if start[0] <= end[0]:
        lr_path = "R" * (end[0] - start[0])
    else:
        lr_path = "L" * (start[0] - end[0])
    if start[1] <= end[1]:
        ud_path = "U" * (end[1] - start[1])
    else:
        ud_path = "D" * (start[1] - end[1])
    return lr_path + ud_path

# 点Sから点Tまでの経路（1回目）
path_1 = shortest_path(S, T)
# 点Tから点Sまでの経路（1回目）
path_2 = shortest_path(T, S)
# 点Sから点Tまでの経路（2回目）
path_3 = "D" + shortest_path(S + np.array([0, -1]), T + np.array([1, 0])) + "L"
# 点Tから点Sまでの経路（2回目）
path_4 = "U" + shortest_path(T + np.array([0, 1]), S + np.array([-1, 0])) + "R"
# 全経路を出力
print(path_1 + path_2 + path_3 + path_4)

Measured memory_bytes: 14460
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var num int

	if sc.Scan() {
		num, _ = strconv.Atoi(sc.Text())
	}

	logs := make([]string, num)

	for i := 0; i < num; i++ {
		var text string
		if sc.Scan() {
			text = sc.Text()
		}

		logs[i] = text
	}

	result := true

	for i, log := range logs {
		logCopy := logs
		for j, otherLog := range logCopy {

			// Ignore same word

			if i == j {
				continue
			}

			// Check for same words
			if log == otherLog {
				result = false
				break
			}
		}

		if i == 0 {
			continue
		}

		// 今回の単語の最初
		firstWord := string(log[0])

		// 前の単語の最後
		lastWord := logCopy[i-1][len(logCopy[i-1])-1:]

		if firstWord != lastWord {
			result = false
			break
		}
	}

	if result {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}

Measured memory_bytes: 640
K,N=io.read("*n","*n")
A={}
for i=1,N do
A[i]={i,io.read"*n"}
end
table.sort(A,function(a,b)return a[2]<b[2]end)
B={}
for i=1,N-1 do
B[i]=A[i+1][2]-A[i][2]
end
B[N]=K+A[1][2]-A[N][2]
local maxi=1
local maxv=B[1]
for i=2,N do
	if(B[i]>maxv)then maxi=i maxv=B[i] end
end
print(K-maxv)

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}

template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}

template <typename T> void print(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void print(const T &value, const Args&... args){std::cout << value << " ";print(args...);}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

/**
 * @title Enumerate divisors
 * @docs enumerate_divisor.md
 */
std::vector<std::int64_t> enumerate_divisor(std::int64_t n){
  std::vector<std::int64_t> temp, ret;

  {
    std::int64_t i;
    for(i = 1LL; i * i < n; ++i){
      if(n%i == 0){
        temp.push_back(n / i);
        ret.push_back(i);
      }
    }
    if(i * i == n) ret.push_back(i);
  }

  std::reverse(temp.begin(), temp.end());
  ret.insert(ret.end(), temp.begin(), temp.end());
  
  return ret;
}



int main(){
  int N;

  while(cin >> N){
    vector<int> A(N); cin >> A;

    vector<int> B(A);
    sort(ALL(B));
    UNIQ(B);

    std::vector<bool> check(2000000, true);

    {
      map<int, int> m;
      REP(i,N){
        m[A[i]] += 1;
      }

      for(auto p : m){
        if(p.snd > 1){
          check[p.fst] = false;
        }
      }
    }

    for(auto x : B){
      for(int i = x * 2; i <= 1000000; i += x){
        check[i] = false;
      }
    }

    int ans = 0;
    REP(i,N) if(check[A[i]]) ++ans;
    print(ans);
  }
  

  return 0;
}


Measured memory_bytes: 14156
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	n := scanInt(sc)
	nums := map[string]int{}
	for _ = range loop0(n) {
		nums[scanString(sc)]++
	}
	toStr := map[int][]string{}
	max := 0
	for k, c := range nums {
		toStr[c] = append(toStr[c], k)
		if max < c {
			max = c
		}
	}
	r := toStr[max]
	sort.Sort(sort.StringSlice(r))
	for _, s := range r {
		fmt.Println(s)
	}
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 32508
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	vector<pair<int, int>> ab(n);
	rep(i, n) {
		ab[i] = make_pair(a[i], b[i]);
	}

	sort(ab.begin(), ab.end());

	long long ans = 0;
	rep(i, n) {
		int buy = min(m, ab[i].second);
		ans += (long long)buy * ab[i].first;

		m -= buy;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int a, b, c, x;
int res = 0;

int main(){
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    for(int c500=0;c500 < a+1;c500++){
        for(int c100=0;c100<b+1;c100++){
            for(int c50=0;c50<c+1;c50++){
                if(500*c500 + 100*c100 + 50*c50 == x) res++;
            }
        }
    }

    cout << res << endl;
}   

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    if len(s)%2:
        print("No")
        exit()
    for i in range(0,len(s),2):
        if s[i:i+2]!="hi":
            print("No")
            exit()
    print("Yes")

main()

Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include<string>
using namespace std;

int main(){
  int n;
  std::cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    char c;
    std::cin >> c;
    s += c;
  }
  set<int> si;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if(j - i > 7)continue;
      string tmp = s.substr(i, j - i + 1).c_str();
      si.insert(atoi(tmp.c_str()));
    }
  }
  for (int i = 0; i < 1e7; i++) {
    if(si.find(i) == si.end()){
      std::cout << i << std::endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3440
from itertools import *
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in [0]*C]
c = [list(map(int, input().split())) for _ in [0]*N]
tri = [[] for _ in [0]*3]
for i in range(1, N+1):
    for j in range(1, N+1):
        tri[(i+j) % 3] += [c[i-1][j-1] - 1]
incom = [[0]*C for _ in [0]*3]
for i in range(3):
    for color in range(C):
        incom[i][color] = sum(D[x][color] for x in tri[i])
ans = 1<<30
for p in permutations(range(C), 3):
    t = sum(incom[x][y]for x,y in enumerate(p))
    if t < ans: ans = t
print(ans)

Measured memory_bytes: 7696
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N = 2e5+5;
int n,cnt[N],x[N];
ll sum=0;
int main()
{
	cin>>n;
	rep(i,n)cin>>x[i],cnt[x[i]]++;
	rep(i,n+1)sum+=1ll*cnt[i]*(cnt[i]-1)/2;
	rep(j,n)
	{
		ll ans=sum;
		int i=x[j];
		if(cnt[i]!=0)
		{
			ans=ans-1ll*cnt[i]*(cnt[i]-1)/2+1ll*(cnt[i]-1)*(cnt[i]-2)/2;
		}
		cout<<ans<<"\n";
	}
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout << x << '\n';

#define INF (1 << 29)

#define FAST cin.tie(0), ios::sync_with_stdio(false)
inline int chmax(int &a, int b){return b>a ? a=b,1 : 0;}
inline int chmin(int &a, int b){return b<a ? a=b,1 : 0;}
//________

main(){
  FAST;
  string s,ans;
  cin >> s;
  for(int i=0; i<s.length(); i+=2)ans += s[i];
  outl(ans);
}


Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

#define mod 998244353
#define inf 0x7f7f7f7f
#define maxn 500005
#define N 300005
typedef long long ll;
typedef struct{
    int u,v, next;
}Edge;
Edge e[2*maxn];

int cnt,head[300005];

inline void add(int u,int v){
    e[cnt].u=u;
    e[cnt].v=v;
    //e[cnt].w=w;
    //e[cnt].f=f;
    e[cnt].next=head[u];
    head[u]=cnt++;
    e[cnt].u=v;
    e[cnt].v=u;
    //e[cnt].w=0;
    //e[cnt].f=-f;
    e[cnt].next=head[v];
    head[v]=cnt++;
}

inline ll quick_pow(int a, int b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = (ans * a) % mod;
        a = (1ll * a * a) % mod;
        b >>= 1;
    }
    return ans;
}
inline int read()
{
    int x = 0;
    int f = 1;
    char c = getchar();
    while (c<'0' || c>'9')
    {    
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0'&&c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x*f;
}

//_scc[u]存u点所在强连通分量的标号,out[x]存标号为x的强连通分量的出度,
//cot[x]存标号为x的连通量的点的数目
int n;
int main() {
    cin >> n;
    double t;
    if (n%2){
        t = 1.0 * (n / 2 + 1) / n;
    }else 
        t = 1.0 * (n / 2) / n;
    printf("%.8lf\n", t);
}   

Measured memory_bytes: 256
// Lets go to the next level
// AIM EXP at CF *__* asap
// Hit A,B,C faster and reach Expert
// Remember you were also a novice when you started,
// hence never be rude to anyone who wants to learn something!Be calm and help everyone.
// Never open the rank list until and unless you are done with solving problems!

//Author: kaiyu
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};

bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 2e5+ 10;

#define int long long
int32_t main() {
//#ifndef ONLINE_JUDGE
    //freopen("inp1.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
//#endif
    fio
    int x,n;
    cin >> x >> n;
    int p[n];
    set<int>cont;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        cont.insert(p[i]);
    }
    vi  av ;
    for (int j = 0; j <= 101 ; ++j) {
        if(cont.find(j)==cont.end()) {
            av.pb(j);
        }
    }
    sort(all(av));
    int z = lower_bound(all(av),x)-av.begin();

    int one = abs(x-av[z]);
    int two = abs(x-av[z-1]);

    if(one > two) {
        cout << av[z-1] << endl;
    }
    else if(one < two){
        cout << av[z] << endl;
    }
    else {
        cout << av[z-1] << endl;
    }


    //cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






Measured memory_bytes: 3664
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n, cnt = 0; cin >> n;
    Rep(i, 1, n+1) {
        if(to_string(i).size() % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int N, K, A, s, r;
map<int, int> m;
vector<int> c;

int main()
{
  s = r = 0;
  cin >> N >> K;
  REP(i, N)
  {
    cin >> A;
    if (m.find(A) != m.end())
      m[A]++;
    else
    {
      m[A] = 1;
      s++;
    }
  }

  for (auto &p : m)
  {
    c.push_back(p.second);
  }

  sort(ALL(c));

  REP(i, max(0, s - K))
  {
    r += c[i];
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(begin(a),end(a),greater<ll>());
    ll ans=0;
    FOR(i,1,n){
        ans+=a[i/2];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4784
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int a, b, c, k; cin >> a >> b >> c >> k;
  long long ans = 0;
  if(k >= a) {
    k -= a;
    ans += a;
  }else {
    ans += k;
    k = 0;
  }
  if(k >= b) {
    k -= b;
  }else {
    k = 0;
  }
  if(k >= c) {
    k -= c;
    ans -= c;
  }else {
    ans -= k;
    k = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
using System;

public class S
{



    public static void Main()
	{
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        solver(input[0],input[1],input[2]);
    }

    public static void solver(int A, int B, int C){

        var able = B/A;
        Console.WriteLine(able >= C ? C : able);

    }

    public static long lower_bound(long[] array, long input){
        var left = 0;
        var right = array.Length-1;
        var mid =0;
        while(right >= left){
            mid = left + (right - left)/2;
            if(array[mid] == input){
                return mid;
            }
            if(array[mid] > input){
                right = mid-1;
            }else{
                left = mid+1;
            }
        }

        return right;
    }

}

Measured memory_bytes: 13140
s = input()
s = s.replace("BC","D")
a,ans = 0,0
#Dより前にあるB,C意外でつながったAの数をカウント
for i in s:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0
print(ans)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n;
  std::vector<long> xs;
  Solver() {
    S002 reader;
    reader >= n >n>= xs;      
  }
  void solve() {
    long count = 0;
    for(long x : xs) {
      if( x % 2 == 1 ) count += 1;
    }
    puts(count % 2 == 0 ? "YES" : "NO");
  }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 1024