akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;
const int MAX = 200005;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

long long inverse[MAX+1];
long long factorial[MAX+1];
long long factorial_inverse[MAX+1];

void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}

struct edge
{
	int to;
};

struct Rerooting
{
	struct T {
		long long val, size, size_fact_inv;
		T(long long val, long long size, long long size_fact_inv) : val(val), size(size), size_fact_inv(size_fact_inv) {}
	};
	friend ostream &operator<<(ostream &os, const T &x) {
		return os << x.val;
	}
	T operate(T x, T y) const {
		return T(mod(x.val*y.val), x.size+y.size, mod(x.size_fact_inv*y.size_fact_inv));
	}
	const T ID = T(1, 0, 1);
	T operate_node(T x) const {
		return T(factorial[x.size] * x.val % MOD * x.size_fact_inv % MOD, x.size+1, factorial_inverse[x.size+1]);
	}

	const vector<vector<edge>> &g;
	int V;
	vector<int> parent_loc;
	vector<vector<T>> dp;
	vector<T> dp_tree;

	Rerooting(const vector<vector<edge>> &g) : g(g), V(g.size()) {}

	void calc() {
		parent_loc.assign(V, -1);
		dp.assign(V, vector<T>());
		for (int i = 0; i < V; i++) dp[i].assign(g[i].size(), ID);
		dp_tree.assign(V, ID);
		dfs1(0, -1);
		dfs2(0, -1, ID);
	}

	T dfs1(int v, int parent) {
		int deg = g[v].size();
		T res = ID;
		for (int i = 0; i < deg; i++) {
			int nv = g[v][i].to;
			if (nv == parent) {
				parent_loc[v] = i;
				continue;
			}
			dp[v][i] = dfs1(nv, v);
			res = operate(res, dp[v][i]);
		}
		return operate_node(res);
	}

	void dfs2(int v, int parent, T dp_parent) {
		if (parent != -1) dp[v][parent_loc[v]] = dp_parent;
		int deg = g[v].size();
		vector<T> acc_L(deg, ID), acc_R(deg, ID);
		for (int i = 0; i < deg-1; i++) {
			acc_L[i+1] = operate(acc_L[i], dp[v][i]);
		}
		for (int i = deg-1; i > 0; i--) {
			acc_R[i-1] = operate(acc_R[i], dp[v][i]);
		}
		dp_tree[v] = operate_node(operate(acc_R[0], dp[v][0]));
		for (int i = 0; i < deg; i++) {
			int nv = g[v][i].to;
			if (nv == parent) continue;
			dfs2(nv, v, operate_node(operate(acc_L[i], acc_R[i])));
		}
	}
};

int main() {
	int n;
	cin >> n;
	calc(n+3);
	vector<vector<edge>> g(n);
	for (int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back({b});
		g[b].push_back({a});
	}
	Rerooting R(g);
	R.calc();
	for (auto e : R.dp_tree) {
		cout << e << endl;
	}
	return 0;
}

Measured memory_bytes: 49616
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
  ll n,m;
  cin>>n>>m;
  cout<<(n*(n-1)+m*(m-1))/2<<endl;
}/*『你强归你强，Siyuan比你强』*/





Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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 <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 <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n;
  cin >> n;

  int cnt = 1;
  rep(i,n) {
    int a;
    cin >> a;
    if(a % 2 == 0) cnt *= 2;
    if(a % 2 == 1) cnt *= 1;
  }

  cout << pow(3, n) - cnt << endl;
  return 0;
}

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

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  vector<i64> sum(n);
  sum[0] = a[0];
  for (i64 i = 1; i < n; i++)
    sum[i] = sum[i - 1] + a[i];
  for (i64 i = n - 2; 0 <= i; i--)
  {
    if (sum[i] * 2 < a[i + 1])
    {
      cout << n - i - 1 << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 1920
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int r; scan(r);
    writeln(3*r^^2);
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h+2) {
        rep(j, w+2) {
            if ( i == 0 || i == h + 1)      cout << "#";
            else if ( j == 0 || j == w + 1) cout << "#";
            else                            cout << a[i-1][j-1];
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, m;
int cnt[N];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        int k;
        cin >> k;
        while(k--)
        {
            int x;
            cin >> x;
            cnt[x]++;
        }
    }

    int res = 0;
    for(int i = 1; i <= m; i++)
        if(cnt[i] == n)
            res++;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
count = {}

for s in S:
  ls = str(sorted(list(s)))
  if ls in count:
    count[ls] +=1
  else:
    count[ls] = 1

for s in count:
  count[s] = count[s]*(count[s]-1)//2 
print(sum(count.values()))


Measured memory_bytes: 29204
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
typedef long long ll;
const int mod=1e9+7;
int main()
{
    fastio;
    int n;
    cin>>n;
    int table[n][3];
    cin>>table[0][0]>>table[0][1]>>table[0][2];
    int a,b,c;
    fore(i,1,n)
    {
        cin>>a>>b>>c;
        table[i][0]=max(table[i-1][1]+a,table[i-1][2]+a);
        table[i][1]=max(table[i-1][0]+b,table[i-1][2]+b);
        table[i][2]=max(table[i-1][1]+c,table[i-1][0]+c);
    }
    print(maxe(table[n-1][0],table[n-1][1],table[n-1][2]));
}

Measured memory_bytes: 1408
"use strict";

function Main(input) {
  var S = [...input.split("\n")[0]].map(function (v) {
    return parseInt(v, 10);
  });
  var A = S.reduce(function (a, c, i) {
    a += c % 2 == i % 2 ? 1 : 0;
    return a;
  }, 0);
  var B = S.reduce(function (a, c, i) {
    a += c % 2 != i % 2 ? 1 : 0;
    return a;
  }, 0);
  console.log(Math.min(A, B));
} 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15100
//Let's join Kaede Takagaki Fun Club !!
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int k,n;
vector<int>vec;
int main(){
	ios::sync_with_stdio(false);
	g(k); g(n);
	rep(i,n){ int a; g(a); vec.pb(a); }
	int ans = 0;
	rep(i,n){
		int x = vec[(i+1)%n] - vec[i];
		if(x < 0) x += k;
		chmax(ans, x);
	}
	o(k-ans);
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> to[200010];
  rep(i,m){
    int a,b; cin>>a>>b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  bool ans=0;
  for(auto x : to[1]){
    q.push(x);    
  }
  while(!q.empty()){
    int l=q.front(); q.pop();
    for(auto x : to[l]){
      if(x==n)ans=1;
    }
  }
  if(ans) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 15188
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> p(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        p.at(i)=make_pair(a,b);
    }
    sort(all(p));
    
    ll ans=0;
    rep(i,n){
        if(m<=0) break;
        int a=p.at(i).first, b=p.at(i).second;
        rep(i,b){
            if(m<=0) break;
            m-=1;
            ans+=(ll)a;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
n=int(input())
s=input()
count = 0
i = 0
j = 1
while (i) < n:
    j = 1
    while (i+2*j) < n:
        if s[i] != s[i+j] and s[i+2*j] not in [s[i],s[i+j]]:
            count += 1
        j += 1
    i += 1
r,g,b = 0,0,0
for p in s:
    if p == 'R':
        r += 1
    elif p == 'G':
        g += 1
    else:
        b += 1
print(r*g*b-count)

Measured memory_bytes: 9072
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var sub = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(sub);
        const int MOD = 1000000007;
        var dic = new Dictionary<int, int>();
        for(var i = 0; i < num; i++)
        {
            if (num % 2 ==sub[i] % 2) { WriteLine(0);return; }
            if (num % 2 == 1 && sub[i] == 0) continue;
            if (dic.ContainsKey(sub[i])) dic[sub[i]]++;
            else dic[sub[i]] = 1;
            if (num % 2 == 0 && i % 2 == 1 && dic[sub[i]] != 2) { WriteLine(0);return; }
            if (num % 2 == 1 && i % 2 == 0 && dic[sub[i]] != 2) { WriteLine(0);return; }
            if (dic[sub[i]] > 2) { WriteLine(0); return; }
        }
        var result = 1;
        for(var i = 0; i < dic.Keys.Count; i++)
        {
            result = (2 * result % MOD)%MOD;
        }
        WriteLine(result);
    }
}

Measured memory_bytes: 19680
import math
N = int(input())
Hs = [int(x) for x in input().split()]
current = Hs[0]-1
for H in Hs:
  if H < current:
    print('No')
    exit()    
  if H - current >= 1:
    current = H-1
  elif H == current:
    pass
print('Yes')
    
    
   


Measured memory_bytes: 14404
N = int(input())
DX = input().split(' ')
D,X = int(DX[0]),int(DX[1])

A = [int(input()) for i in range(N)]

lis = []
for i in range(len(A)):
    x = 1
    while x <= D:
        lis.append(x)
        x += A[i]

print(len(lis)+X)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <map>
#include <cmath>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

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

    int count = 0; int rec = 0;
    rep(i, s.size()) {
        if (s[i] == 'A' ||
            s[i] == 'C' ||
            s[i] == 'G' ||
            s[i] == 'T')
        {
            /* code */
            count++;
            rec = max(count, rec);
        }
        else
        {
            /* code */
            count = 0;
        }
        
    }
    cout << rec << endl;
}

Measured memory_bytes: 256
let () =
  let m = 999999 in
  let a = Array.make (m + 1) true in
  a.(0) <- false; a.(1) <- false;
  let dp = Array.make (m + 1) 0 in
  for i = 2 to m do
    if a.(i) then begin
      let n = m / i in
      for j = 2 to n do
        a.(i*j) <- false
      done
    end;
    dp.(i) <- dp.(i-1) + if a.(i) then 1 else 0;
  done;
  try
    while true do
      Printf.printf "%d\n" dp.(read_int ())
    done
  with _ -> ()

Measured memory_bytes: 18252
def main2():
    n = int(input())
    d = 0
    keta = 0
    tmp = n
    ans = ""
    while n > 0:
        n -= 1
        ans += chr(ord('a') + (n%26))
        n //= 26
    print(ans[::-1])

if __name__ == '__main__':
    main2()

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


int main(){
  string s;
  cin >> s;
  int cnt=0;
  int n=s.size();
  for(int i=0;i<n;++i){
    if(cnt==0 && s[i]=='C') cnt++;
    if(cnt==1 && s[i]=='F') cnt++;
  }
  if(cnt==2)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3564
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
v = inl()
v.sort()
s = (v[0]+v[1])/2
for i in range(2,n):
    s = (s+v[i])/2
print(s)


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
struct human
{
	vector<int> inout;
	vector<int> date;
};
struct god
{
	int in, out, date;
};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	while(cin >> N, N)
	{
		human info_h[N + 1];
		god info_g[N + 1];
		int last;
		string day, time, inout, num;
		int pos1 = 0, pos2 = 0;
		vector<int> programer(1000, 0);
		for(int i = 0; i < N; i++)
		{
			cin >> day >> time >> inout >> num;
			string tmp_s = day.substr(0, 2);
			tmp_s += day.substr(3);
			int tmp_time = stoi(time.substr(0, 2)) * 60 + stoi(time.substr(3));
			int tmp_num = stoi(num);
			int tmp_day = stoi(tmp_s);
			if(tmp_num == 0)
			{
				if(inout == "I")
				{
					info_g[pos1].in = tmp_time;
					info_g[pos1].date = tmp_day;
				}
				else
				{
					info_g[pos1].out = tmp_time;
					info_g[pos1].date = tmp_day;
					pos1++;
				}
			}
			else
			{
				if(inout == "I")
				{
					info_h[tmp_num].inout.push_back(tmp_time);
					info_h[tmp_num].date.push_back(tmp_day);
				}
				else
				{
					info_h[tmp_num].inout.push_back(tmp_time);
					info_h[tmp_num].date.push_back(tmp_day);
				}
			}
		}
		/*
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < info_h[i].date.size(); j++)
			{
				//if(j % 2)
				//	cout << info_h[i].inout[j] << endl;
				//else
				//	cout << info_h[i].inout[j] << " ";
				//cout << info_h[i].date[j] << endl;
			}
		}*/
		for(int i = 0; i < pos1; i++)
		{
			for(int j = 0; j < N; j++)
			{
				for(int k = 0; k < info_h[j].inout.size(); k += 2)
				{
					//cout << info_h[j].inout[k + 1] << " " << info_g[i].out << " # " << info_h[j].inout[k] << " " << info_g[i].in << endl;
					//cout << info_g[i].date << " " << info_h[j].date[k] << " " <<  endl;
					if(info_h[j].inout[k] > info_g[i].out || info_h[j].inout[k + 1] < info_g[i].in)
						continue;
					if(info_g[i].date != info_h[j].date[k])
						continue;
					programer[j] += min(info_h[j].inout[k + 1], info_g[i].out) - max(info_h[j].inout[k], info_g[i].in);
					//cout << programer[j] << " " << j << endl;
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < N; i++)
		{
			if(programer[i] > ans)
				ans = programer[i];
		}
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  int ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    --a;
    ans += a;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define true 1
#define false 0


int judge(int , int);
int A[25],Q[205];
 int n,q,sum=0,flag=0;

int main(){

  int i,j;
  
  
  scanf("%d",&n); 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&Q[i]);
  }


  for(j=0;j<q;j++){
    if(judge(0,Q[j]) == true)printf("yes\n");
    else printf("no\n");
  }
 


  return 0;
}

int judge(int i, int m){
  //printf("%d %d\n",i,m);
  int res = false;
  
  if(m == 0) return true;

  if(i >= n) return false;

 
  if (judge(i+1, m -A[i]) == true )res = true;
  if (judge(i+1, m) == true) res = true;

  return res;
}



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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int main(){
	int n=read();
	int sum=0;
	for(int i=1;i<=n;i++){
		int d=read();
		sum+=d;
		sum-=1;
	}
	cout<<sum;


	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		long a=ir.nextLong();
		long b=ir.nextLong();
		long x=ir.nextLong();
		if(a==0){
			out.println(b/x+1);
			return;
		}
		out.println(b/x-(a-1)/x);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q;
  cin>>n>>q;
  string st;
  cin>>st;
  vector<int>a(n,0);
  for(int i=0;i<n-1;i++){
    if(st.at(i)=='A'&&st.at(i+1)=='C')a[i+1]=1;
  }
  vector<int>s(n+1,0);
  for(int i=0;i<n;i++)s[i+1]=s[i]+a[i];
  //for(int i=0;i<n+1;i++)cout<<s[i]<<" ";
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    cout<<s[b]-s[a]<<endl;
  }
}

Measured memory_bytes: 4256
namei = []
ai = []
bi = []
n = 1
while n <= 9:
    line = input()
    t = line.split(" ")
    namei.append(t[0])
    ai.append(int(t[1]))
    bi.append(int(t[2]))
    n += 1

namei.append("fin")
i = 0
while namei[i] != "fin":
    sosu = ai[i]+bi[i]
    ryokin = ai[i]*200+bi[i]*300
    print(namei[i],sosu,ryokin)
    i += 1


Measured memory_bytes: 5596
N, K = map(int, input().split())

sunuke_dict = {}
for i in range(K):
    input()
    okashi_sunukes = map(int, input().split())
    for okashi_sunuke in okashi_sunukes:
        sunuke_dict[okashi_sunuke] = ''

print(N - len(sunuke_dict))

Measured memory_bytes: 9148
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  string s; cin >> s;
  if (s=="RRR") cout << 3 << endl;
  else if (s=="RRS" || s=="SRR") cout << 2 << endl;
  else if (s=="SSS") cout << 0 << endl;
  else cout << 1 << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 3644
#pragma target("avx2")
#pragma optimize("O3")
#include<stdio.h>

int main(void){
        unsigned a, b, k, i;
        scanf("%u %u %u", &a, &b, &k);
        if(b-a>=2*k){
                for(i=a; i<a+k; i++) printf("%u\n", i);
                for(i=b-k+1; i<=b; i++) printf("%u\n", i);
        }else{
                for(i=a; i<=b; i++) printf("%u\n", i);
        }
        return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    int n;
    cin >> n;

    // 処理
    // 出力
    if (n == 25) {
        cout << "Christmas" << endl;
    }
    if (n == 24) {
        cout << "Christmas Eve" << endl;
    }
    if (n == 23) {
        cout << "Christmas Eve Eve" << endl;
    }
    if (n == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main() {
	int H, W;
	scanf("%d %d", &H, &W)+1;

	char** grid = new char*[H + 2];
	grid[0] = new char[W + 2];
	memset(grid[0], '.', W + 2);
	for (int i = 1; i <= H; i++) {
		grid[i] = new char[W + 2];
		grid[i][0] = '.';
		scanf("%s", &grid[i][1])+1;
		grid[i][W + 1] = '.';
	}
	grid[H + 1] = new char[W + 2];
	memset(grid[H + 1], '.', W + 2);

	int ans = 1;

	for (int x = 1; x <= W; x++) {
		for (int y = 1; y <= H; y++) {
			if (grid[y][x] == '#' && grid[y - 1][x] == '.' && grid[y + 1][x] == '.' && grid[y][x - 1] == '.' && grid[y][x + 1] == '.') {
				ans = 0;
				break;
			}
		}
	}

	if (ans) printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        String s = br.readLine().trim();
        int cnt=0;
        for (int i=0; i<s.length(); i++){
            if (s.charAt(i) == 'o'){
                cnt++;
            }
        }
        System.out.println(700+cnt*100);


    }

}



Measured memory_bytes: 32420
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = INT_MAX / 2;

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

    vector<int> as;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        as.push_back(a);
    }

    for (int i = 0; i < N; i++) {
        as.push_back(as[i] + K);
    }

    // for (auto a : as) {
    //     cout << a << " ";
    // }
    // cout << endl;

    int ans = INF;
    for (int i = 0; i + N - 1 < 2 * N; i++) {
        chmin(ans, as[i + N - 1] - as[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5352
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	while(1){
		int ans=0,p=0,n,k,x,a[100001]={},flag=0,sflag=0;
		vector<int> V;
		cin>>n>>k;
		if(n==0 && k==0)
			break;
		for(int i=0;i<k;i++){
			cin>>x;
			if(x==0)
			flag=1;
			a[x]=1;
		}
		for(int i=1;i<=n;i++){
			if(sflag==0 && a[i])
				sflag=1;
			if(sflag){
				if(a[i])
					p++;
				else{
					sflag=0;
					V.push_back(p);
					p=0;
				}
			}
		}
		V.push_back(p);
		if(flag){
			for(int i=0;i<V.size()-1;i++)
				ans=max(V[i]+V[i+1]+1,ans);
		}else{
			for(int i=0;i<V.size();i++)
				ans=max(V[i],ans);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1740
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
string s;
int main()
{
	int a[3];
	while(cin>>s){
		int len=s.length();
		a[0]=a[1]=a[2]=0;
		for(int i=0;i<len;i++){
			if(s[i]=='a')
				a[0]++;
			else if(s[i]=='b')
				a[1]++;
			else 
				a[2]++;
		}
		sort(a,a+3);
		//cout<<a[0]<<a[1]<<a[2];
		if(a[2]-a[1]<=1&&a[1]-a[0]<=1&&a[2]-a[0]<=1)
			puts("YES");
		else
			puts("NO");
	}
}


Measured memory_bytes: 512
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath> 
using namespace std; 
int main()
{
	string a, b, c; 
	cin >> a >> b >> c; 
	char t = 'a'; 
	int aa = 0;
	int bb = 0;
		int cc = 0; 
	for (;;)
	{
		if (t=='a')
		{ 
			if (aa==a.size())
			{
				cout << "A" << endl; 
				break;
			} 
			t = a.at(aa);
			aa++; 
		}  
		else if (t == 'b')
		{
			if (bb == b.size())
			{
				cout << "B" << endl;
				break;
			}
			t = b.at(bb);
			bb++;
		} 
		else 
		{
			if (cc == c.size())
			{
				cout << "C" << endl;
				break;
			}
			t = c.at(cc);
			cc++;
		}
		

	}
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI 3.141592653589793
#define vi vector<int>
#define p pair<int,int>
const int MOD = 1000000007;
inline double degcos(double ang) {return cos(ang*PI/180);}
inline double degsin(double ang) {return sin(ang*PI/180);}
#define rep(i,j,k,in) for (int i = j; i < k; i += in)


/*---END OF TEMPLATE---*/
int n;
ll freq[2000005];
ll arr[2000005];

unordered_map<ll,ll>mp;
ll nC2(ll n) {
    if (n == 0) {
        mp[0] = 0;
        return 0;
    }
    if (mp.find(n) != mp.end()) return mp[n];
    mp[n] = (n*(n-1))/2;
    return mp[n];
}

int main() {
    //cin.sync_with_stdio(0);
    //cin.tie(0);
    //ifstream fin("data.in");
    //ofstream fout("data.out");
    cin >> n;
    rep(i,0,2000005,1) freq[i] = 0;
    rep(i,0,n,1) {
        cin >> arr[i];
        arr[i]--;
        freq[arr[i]]++;
    }
    ll tot = 0;
    rep(i,0,n,1) {
        tot += nC2(freq[i]);
    }
    rep(i,0,n,1) {
        ll x = tot;
        x -= freq[arr[i]]-1;
        cout << fixed << x << "\n";
    }
    

}

Measured memory_bytes: 21120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int c = 0;
    cin >> c;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < c; ++i)
    {
        set<char> r, l;
        int cnt = 0;
        for (int j = 0; j < c; ++j)
        {
            if (j < i) l.insert(s[j]);
            else r.insert(s[j]);
        }
        map<char, int> m;
        for (auto x: r) ++m[x];
        for (auto x: l) ++m[x];
        for (auto x: m) if(x.second == 2) ++cnt;
        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define PI 3.14159265358979

int main(){
    double a, b, x;
    cin >> a >> b >> x;

    double ans;
    if(a*a*b/2<=x){
        double tan_theta = 2*(a*a*b-x)/(a*a*a);
        double theta = atan(tan_theta);
        ans = theta*180.0/PI;
    }else{
        double tan_theta = 2*x/(a*b*b);
        double theta = atan(tan_theta);
        ans = 90.0 - theta*180.0/PI;
    }
    printf("%.10f\n",ans);

    return 0;

}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char[] memo  = s.toCharArray();
		int sum = 700;
		for(int i=0; i<memo.length; i++) {
			char c = memo[i];
			if(c == 'o') {
				sum = sum + 100;
			}
		}
		
		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
using namespace std;
int main(){
	int a[2];
	cin >> a[0] >> a[1];
	sort(a, a + 2);
	if (a[0] == 1 && a[1] == 2) {
		cout << "3" << endl;
	}
	else if (a[0] == 1 && a[1] == 3) {
		cout << "2" << endl;
	}
	else {
		cout << "1" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    println(
        if (rotateCheck(s, t)) {
            "Yes"
        } else {
            "No"
        }
    )
}

fun rotateCheck(a: String, b: String): Boolean {
    repeat(a.length) {
        if (a.rotate(it) == b) {
            return true
        }
    }
    return false
}

fun String.rotate(n: Int): String {
    val a = this.substring(0..(this.lastIndex- n))
    val b = this.substring((this.lastIndex - n + 1)..this.lastIndex)
    return b + a
}


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

int main() {
    int H=0, W=0;
    cin >> H >> W;
    vector<vector<char>> pic(H, vector<char>(W, 'e'));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> pic.at(i).at(j);
        }
    }

    //compress hight
    if(W == 1){
        for(int i=0; i<H; i++){
            if(pic.at(i).at(0) == '#'){
                cout << '#';
            }
        }
        cout << endl;
        return 0;
    }
    for(int i=0; i<pic.size(); i++){
        int check = 0;
        for(int j=1; j<W; j++){
            if(pic.at(i).at(0) == '.' && pic.at(i).at(0) == pic.at(i).at(j))
                check++;
        }
        if(check == W-1){
            for(int k=i; k<pic.size()-1; k++){
                swap(pic.at(k), pic.at(k+1));
            }
            pic.pop_back();
            i--;
        }
    }

/*    //output
    cout << endl;
    for(int i=0; i<pic.size(); i++){
        for(int j=0; j<pic.at(0).size(); j++){
            cout << pic.at(i).at(j);
        }
        cout << endl;
    }*/

    //compress width
    if(pic.size() == 1){
        for(int j=0; j<W; j++){
            if(pic.at(0).at(j) == '#')
                cout << '#';
        }
        cout << endl;
    }else{
        for(int j=0; j<pic.at(0).size(); j++){
            int check = 0;
            for(int i=1; i<pic.size(); i++){
                if(pic.at(0).at(j) == '.' && pic.at(0).at(j) == pic.at(i).at(j))
                    check++;
            }
            if(check == pic.size()-1){
                int wi = pic.at(0).size();
                for(int i=0; i<pic.size(); i++){
                    for(int k=j; k<wi-1; k++){
                        swap(pic.at(i).at(k), pic.at(i).at(k+1));
                    }
                    pic.at(i).pop_back();
                }
                j--;
            }
        }

    //output
    cout << endl;
    for(int i=0; i<pic.size(); i++){
        for(int j=0; j<pic.at(0).size(); j++){
            cout << pic.at(i).at(j);
        }
        cout << endl;
    }
    }
}

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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            
            var nk = Reads();
            var n = nk[0];
            var k = nk[1];
            var data = new Dictionary<long, long>();
            for (int i = 0; i < n; i++)
            {
                var ab = Reads();
                if (data.ContainsKey(ab[0]))
                    data[ab[0]]+=ab[1];
                else
                    data.Add(ab[0], ab[1]);                 
            }
            var sort = data.OrderBy(x => x.Key);
            long count = 0;
            long ans = 0;
            foreach(KeyValuePair<long,long> x in sort)
            {
                count += x.Value;
                if (count >= k)
                {
                    ans = x.Key;
                    break;
                }
            }
            Console.WriteLine(ans);


            Console.Out.Flush();
        }
    }
}




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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1
#define j0 gray_cat_j0

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 55, MAXB = 18;

vi v;

ll c[MAXN][MAXN];

int bit_cnt[1 << MAXB];

void solve(){
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	if ((s & t) != s) {
		printf("0\n");
		return;
	}
	REP(i, 0, n) {
		int a;
		cin >> a;
		if ((t | a) == t && (s & a) == s) {
			v.pb(a);
		}
	}
	n = SZ(v);
	
	REPN(i, 0, n) {
		c[i][0] = c[i][i] = 1;
		REP(j, 1, i) {
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
		}
	}
	REP(i, 1, 1 << MAXB) {
		bit_cnt[i] = bit_cnt[i >> 1] + (i & 1);
	}
	
	ll ans = 0ll;
	REP(i, 0, n) {
		int mask_all = (s ^ t);
		for(int k = mask_all; ; k = (k - 1) & mask_all) {
			int cnt_allowed = n - 1 - i;
			REP(l, i + 1, n) {
				if ((v[i] ^ v[l]) & k) {
					cnt_allowed--;
				}
			}
			ll sgn = (bit_cnt[k] & 1) ? -1 : 1;
			REP(l, 0, m) {
				ans += sgn * c[cnt_allowed][l];
			}
			if (!k) {
				break;
			}
		}
	}
	cout << ans << endl;
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 4656
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>

using namespace std;

map<int,int> m;
map<int,int>::iterator it;
int n,v[2001],po,cnt,x,a[2001][11],la,fa[30001],siz[30001],tot,las[2001],c[20001],mx;
bool b[2001],bo[2001],bb[30001];

int gcd(int a,int b) {return (!b)?a:gcd(b,a%b);}
int ask(int x) {return fa[x]==x?x:fa[x]=ask(fa[x]);}
int getmax(int a,int b) {return a>b?a:b;}

void unite(int x,int y)
{
	int p=ask(x),q=ask(y);
	if (p==q) return;
	fa[p]=q; siz[q]+=siz[p];
}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d",&v[i]);
	sort(v+1,v+1+n);
	m.clear(); cnt=0;
	for (int i=1; i<=n; i++)
	{
		x=v[i];
		for (int j=2; j*j<=v[i]; j++)
			if (x%j==0)
			{
				a[i][++a[i][0]]=j;
				while (x%j==0) x/=j;
			}
		if (x!=1) a[i][++a[i][0]]=x;
		for (int j=1; j<=a[i][0]; j++)
		{
			it=m.find(a[i][j]);
			if (it==m.end()) m[a[i][j]]=++cnt,a[i][j]=cnt;
			else a[i][j]=m[a[i][j]];
		}
	}
	memset(c,0,sizeof(c));
	memset(las,0,sizeof(las));
	la=(1e9);
	memset(b,1,sizeof(b));
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=cnt+1; j++) fa[j]=j,siz[j]=1;
		memset(bb,0,sizeof(bb));
		for (int j=1; j<=n; j++)
			if (b[j])
			{
				for (int k=1; k<=a[j][0]; k++) bb[a[j][k]]=1;
				for (int k=2; k<=a[j][0]; k++) unite(a[j][1],a[j][k]);
			}
		tot=1;
		for (int j=1; j<=cnt; j++) if (bb[j]) tot++;
		for (int j=1; j<=n; j++) 
			if (b[j]) 
			{
				mx=0;
				for (int k=1; k<=a[j][0]; k++) mx=getmax(mx,c[a[j][k]]);
				if (las[j]>mx) continue;
				if (a[j][0]) unite(a[j][1],cnt+1);
				if (siz[ask(cnt+1)]==tot) {po=j; break;}
			}
		printf("%d ",v[po]); b[po]=0; la=v[po];
		for (int j=po+1; j<=n; j++) las[j]=i;
		for (int j=1; j<=a[po][0]; j++) c[a[po][j]]=i;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  n %= 10;
  if (n == 3) {
    cout << "bon" << endl;
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3640
#include<stdio.h>

int n,p[21],cnt;

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&p[i]);
  for(int i=1;i<n-1;i++)if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1]))cnt++;
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int H, W, K, ans = 1e8;
    cin >> H >> W >> K;
    vector<vector<int>> s(H, vector<int>(W));
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            s[i][j] = c - '0';
        }

    for (int bit = 0; bit < (1 << H - 1); ++bit) {
        int cnt = 0;
        vector<int> v(1, 0);
        for (int i = 0; i < H - 1; i++)
            if (bit & (1 << i)) v.push_back(i + 1), cnt++;
        v.push_back(H);
        int n = v.size() - 1;
        vector<vector<int>> press(n, vector<int>(W, 0));
        for (int j = 0; j < W; j++) {
            for (int k = 0; k < n; k++) {
                int i0 = v[k], i1 = v[k + 1];
                while (i0 != i1) press[k][j] += s[i0][j], i0++;
                if (press[k][j] > K) {
                    cnt = -1;
                    break;
                }
            }
            if (cnt == -1) break;
        }
        if (cnt == -1) continue;
        vector<int> sw(n, 0);
        for (int j = 0; j < W; j++) {
            for (int k = 0; k < n; k++) {
                if (sw[k] + press[k][j] > K) {
                    cnt++;
                    for (int k = 0; k < n; k++) sw[k] = press[k][j];
                    break;
                }
                sw[k] += press[k][j];
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=1e4;
int main()
{
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<s[0]<<s.length()-2<<s[s.length()-1];
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
void dbg(int Astrt,int Aend,int Bstrt,int Bend,char A[],char B[]);

int main(){
	char str[4000];
	char A[12000];
	char B[12000];
	int Astrt,Aend,Bstrt,Bend;
	int len_max,len;
	int i,i_strt,i_end;
	int ii;
	int lenA,lenB;
	
	
	while(1){
		for(i=0;i<12000;i++)A[i]=B[i]='\0';

		if(scanf("%[^\n]\n",str)==EOF)break;
		lenA=strlen(str);
		strcpy(A,str);
		if(scanf("%[^\n]\n",str)==EOF)break;
		lenB=strlen(str);
		strcpy(&B[strlen(A)-1],str);
		strcpy(str,A);


		Astrt=0,Aend=lenA-1,Bstrt=strlen(A)-1,Bend=Bstrt+lenB-1;

		len_max=0;
		for(;Astrt<=Bend;){


//dbg(Astrt,Aend,Bstrt,Bend,A,B);
			i_strt=Astrt<Bstrt?Bstrt:Astrt;
			i_end=Aend<Bend?Aend:Bend;
			len=0;
			for(i=i_strt;i<=i_end;i++){
				if(A[i]==B[i]){
					len++;
					if(len>len_max)len_max=len;
				}
				if(A[i]!=B[i])len=0;
			}
			
			Astrt++;
			Aend++;
			strcpy(&A[Astrt],str);
			A[Astrt-1]='\0';
		}
		printf("%d\n",len_max);
	}

	return 0;
}



void dbg(int Astrt,int Aend,int Bstrt,int Bend,char A[],char B[]){
	int ii;
printf("Astrt=%d,Aend=%d,Bstrt=%d,Bend=%d\n",Astrt,Aend,Bstrt,Bend);

	for(ii=(Astrt<Bstrt?Astrt:Bstrt);ii<=(Aend<Bend?Bend:Aend);ii++){
		if(A[ii]==0)printf("0");
		if(A[ii]>='A'&&A[ii]<='Z')printf("%c",A[ii]);
	}
	printf("\n");
	for(ii=(Astrt<Bstrt?Astrt:Bstrt);ii<=(Aend<Bend?Bend:Aend);ii++){
		if(B[ii]==0)printf("0");
		if(B[ii]>='A'&&B[ii]<='Z')printf("%c",B[ii]);
	}
	printf("\n");

	for(ii=(Astrt<Bstrt?Astrt:Bstrt);ii<=(Aend<Bend?Bend:Aend);ii++){
		if(A[ii]>='A'&&A[ii]<='Z' && B[ii]>='A'&&B[ii]<='Z' &&A[ii]==B[ii]){
			printf("^");
		}else{
			printf(" ");
		}
	}
	printf("\n");




	return;
}
	

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

int main() {
  string s;
  cin >> s;
  if((s.at(2)==s.at(3))&&(s.at(4)==s.at(5))){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256