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

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut v = n;
    let mut sum = 0;
    while v > 0 {
        sum += v % 10;
        v /= 10;
    }
    println!("{}", if n % sum == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,k,t,temp,cnt =0;
    cin >> n >> k;
    int pp[n];
    fo(i,n){
        pp[i] = 0;
    }
    fo(i,k){
        cin >> t;
        fo(i,t){
            cin >> temp;
            pp[temp-1] = k;
        } 
    }
    fo(i,n){
        if(pp[i] == 0){
            ++cnt;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[5];
    int t= -1;
    int min= 9;
    REP(i,5){
        cin >> A[i];
        if(min>=A[i]%10 && A[i]%10!=0){
            t= i;
            min= A[i]%10;
        } 
    }
    int sum= 0;
    REP(i,5){
        if(i==t) continue;
        sum+= A[i]+((A[i]%10)?(10-A[i]%10):0);
    }
    if(t!=-1) sum+= A[t];
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int my_money, a_money, book_price;
  std::cin >> my_money >> a_money >> book_price;

  if (my_money + a_money < book_price) {
    std::cout << "NA" << std::endl;
    return 0;
  }
  if (my_money >= book_price) {
    std::cout << 0 << std::endl;
    return 0;
  }
  std::cout << book_price - my_money << std::endl;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,i;
	cin>>a>>b;
	if(a<b)
	{
        for(i=1;i<=b;i++)
            cout<<a;
	}
	else
	{
        for(i=1;i<=a;i++)
            cout<<b;
	}
	cout<<endl;

}

Measured memory_bytes: 256
from collections import deque
import sys
N, M = map(int, input().split())
K = [[] for _ in range(N)]
for i in range(M):
    L, R, D = map(int, input().split())
    K[L-1].append([R-1, D])
    K[R-1].append([L-1, -D])
used = [0]*(N+1)
Num = [10**12]*(N+1)
for i in range(N):
    large = 0
    small = 0
    if used[i] == 0:
        used[i] = 1
        Num[i] = 0
        P = deque([i])
        while(True):
            if len(P) == 0:
                break
            a = P.popleft()
            for s, m in K[a]:
                if Num[s] == 10**12:
                    Num[s] = Num[a] + m
                else:
                    if Num[s] != Num[a]+m:
                        print("No")
                        sys.exit()
                large = max(large, Num[s])
                small = min(small, Num[s])
                if used[s] == 0:
                    used[s] = 1
                    P.append(s)
        if large - small > 10**9:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 130956
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

template<typename T> T In() { T v; cin >> v; return v; }

#define P(s) cout<<s<<endl
#define P2(b,y,f) P(((b)?y:f))
#define REP(i,b,e) for(int i=b;i<e;++i)
#define ALL(con) con.begin(), con.end()

inline void Solve(int a, int b, int c) {
    P2(a + b == c || b + c == a || c + a == b, "Yes", "No");
}

int main() {
#if TEST
    Solve(10, 30, 20);  // Yes
    Solve(30, 30, 100);  // No
    Solve(56, 25, 31); // Yes
#else
    Solve(In<int>(), In<int>(), In<int>());
#endif
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  bool dupli;
  int index = 0, k;
  string s, tmp;
  vector<string> a(1);
  cin >> s;
  cin >> k;
  a[0] = s[0];
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < s.size() - i; j++) {
      dupli = false;
      for (int k = 0; k <= index; k++) {
        if (a[k] == s.substr(j, i + 1)) {
          dupli = true;
          break;
        }
      }
      tmp = s.substr(j, i + 1);
      if (!dupli) {
        a.push_back(tmp);
        index++;
      }
    }
  }
  sort(a.begin(), a.end());

  cout << a[k - 1] << endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    if (s.size() == 2) cout << s << endl;
    else {
        for (int i = 2; i >= 0; i--) {
            cout << s[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    ll A, V, B, W, T;
    cin>>A>>V>>B>>W>>T;
    ll Dist=abs(A-B);
    if(W>=V){
        cout<<"NO"<<endl;
        return 0;
    }
    ll Time=Dist/(V-W);
    if(Dist%(V-W))Time++;
    YES(Time<=T);
    return 0;
}
     

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!
 
// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long
 
//////////////////////
const int N = 100005;


int32_t main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int tt = 1;
	// cin >> tt;

	while(tt--) {
		int n;
		cin >> n;
		vector<vector<int>> v(n+1,vector<int>(60,0));
		vector<int> num(n+1);

		rep(i,n) cin >> num[i+1];
		rep(i,n) {
			rep(j,60) {
				v[i+1][j] = v[i][j];
				if((1ll<<j)&num[i+1])
					v[i+1][j]++;
			}
		}

		int ans = 0;
		repA(i,1,n) {
			rep(j,60) {
				if((1ll<<j)&num[i])
					ans = (ans + ((1ll<<j)%MOD*(i-v[i][j]))%MOD)%MOD;
				else
					ans = (ans + ((1ll<<j)%MOD*(v[i][j]))%MOD)%MOD;
			}
			// db(ans);
		}
		cout << ans << '\n';
	}
}

Measured memory_bytes: 155008
def main():
    yen_per_btc = 380000.0
    result = 0
    N = int(input())
    for _ in range(N):
        x, u = input().split(" ")
        if u == "JPY":
            result += float(x)
        else:
            result += (float(x) * yen_per_btc)
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] a = new int[14];
		for(int i = 0; i < 14; i++){
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < 13; i += 2)
		System.out.println(a[i] - a[i+1]);
	}
}

Measured memory_bytes: 17336
from heapq import *
n,m = map(int,input().split())
a = [[int(i) for i in input().split()] for _ in range(n)]
a.sort(key=lambda x:x[0])
ans = 0
PQ = []
idx = 0
for i in range(1,m+1):
    while idx < n and a[idx][0] <= i:
        heappush(PQ,-a[idx][1])
        idx += 1
    if PQ: ans -= heappop(PQ)
print(ans)

Measured memory_bytes: 25736
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  	int N;
  	cin >> N;
  	int ans = 1, n = sqrt(N);
  	for(int i = 1; i <= n; i++){
      	if(i*i <= N){
          	ans = i*i;
        }
    }
  	cout << ans;
 	return 0;
}

Measured memory_bytes: 256
N = int(input())
MAXN = 1005
MAXV = MAXN*(MAXN-1)//2
to = [[]for _ in range(MAXV)]
id = [[0]*MAXN for _ in range(MAXN)]


def toId(i, j):
    return id[min(i, j)][max(i, j)]


visited = [False] * MAXV
calculated = [False] * MAXV
dp = [0] * MAXV


def dfs(v):
    if visited[v]:
        if not calculated[v]:
            return -1
        return dp[v]
    visited[v] = True
    dp[v] = 1
    for nv in to[v]:
        res = dfs(nv)
        if res == -1:
            return -1
        dp[v] = max(dp[v], res + 1)
    calculated[v] = True
    return dp[v]


a = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
    for j in range(N-1):
        a[i][j] -= 1
vid = 0
for i in range(N):
    for j in range(N):
        if i < j:
            id[i][j] = vid
            vid += 1

# プレイヤーiの試合の依存関係の情報をグラフ化
for i in range(N):
    for j in range(N-1):
        a[i][j] = toId(i, a[i][j])
    for j in range(N-2):
        to[a[i][j+1]].append(a[i][j])
ans = 0

for i in range(vid):
    res = dfs(i)
    if res == -1:
        print(-1)
        exit()
    ans = max(ans, res)
print(ans)


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a < c && c < b) || (b < c && c < a)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N;cin>>N;
    vector<int>A(N);
  	vector<int>C(N);
    REP(i,N)cin>>A[i];
  	C=A;
  	sort(C.begin(),C.end());
    int lm=C[N/2-1];
    int rm=C[N/2];
    REP(i,N){
        if(A[i]<=lm)cout<<rm<<endl;
        else cout<<lm<<endl;
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll h,w;
  cin >> h >> w;
  vector<vll> a(h, vll(w));
  REP(i, h){
    REP(j, w)
      cin >> a[i][j];
  }

  ll cur = 0;
  vector<pair<pll, pll>> ans(h*w);
  REP(i, h){
    REP(j, w-1){
      ll in = i%2==0 ? j : w-1-j;
      ll out = i%2==0 ? j+1 : w-2-j;

      if(a[i][in]%2 ==0)
        continue;
      ans[cur].FI = make_pair(i+1, in+1);
      ans[cur].SE = make_pair(i+1, out+1);
      a[i][out]++;
      cur++;
    }
    ll out = i%2==0 ? w-1 : 0;
    if(i != h-1 && a[i][out]%2 != 0){ 
      ans[cur].FI = make_pair(i+1, out+1);
      ans[cur].SE = make_pair(i+2, out+1);
      a[i+1][out]++;
      cur++;
    }
  }

  cout << cur << endl;
  REP(i, cur){
    cout << ans[i].FI.FI << " " << ans[i].FI.SE << " ";
    cout << ans[i].SE.FI << " " << ans[i].SE.SE << endl;
  }



}


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

typedef long long ll;

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

    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> p(m);
    for(int i=0;i<m;i++){
        int s,c;
        cin >> s >> c;
        p[i] = make_pair(s,c);
    }
    sort(p.begin(),p.end());
    vector<int> ans(n,-1);
    vector<bool> ok(n,false);
    for(int i=0;i<m;i++){
        if(p[i].first==1){
            if(p[i].second==0 && n!=1){
                cout << -1 << endl;
                return 0;
            }else{
                if(ok[0]==false) ans[0] = p[i].second;
                else{
                    if(ans[0]==p[i].second) continue;
                    else{
                        cout << -1 << endl;
                        return 0;
                    }
                }
                ok[0] = true;
            }
        }else if(p[i].first==2){
            if(ok[1]==false) ans[1] = p[i].second;
            else{
                if(ans[1]==p[i].second) continue;
                else{
                    cout << -1 << endl;
                    return 0;
                }
            }
            ok[1] = true;
        }else if(p[i].first==3){
            if(ok[2]==false) ans[2] = p[i].second;
            else{
                if(ans[2]==p[i].second) continue;
                else{
                    cout << -1 << endl;
                    return 0;
                }
            }
            ok[2] = true;
        }
    }
    for(int i=0;i<n;i++){
        if(ans[i]==-1){
            if(i==0 && n==1) ans[i] = 0;
            else if(i==0) ans[i] = 1;
            else ans[i] = 0;
        }
    }
    for(int i=0;i<n;i++) cout << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cassert>
#include<functional>
#include<set>
using namespace std ;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;

int main(){
    string s ;
    cin >> s ;
    int a = 0 ;
    int b = 0 ;
    int c = 0 ;
    rep(i,3){
        if(s[i] == 'a' ) a++ ;
        if(s[i] == 'b' ) b++ ;
        if(s[i] == 'c' ) c++ ;
    }  
    if(a&&b&&c)cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;
vector<int> ans;

signed main() {
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	rep(i, n) {
		for (int j = (int)a.size() - 1; j >= 0; j--) {
			if (a[j] == j + 1) {
				ans.push_back(a[j]);
				a.erase(a.begin() + j);
				break;
			}
		}
	}
	reverse(all(ans));
	if ((int)ans.size() != n)cout << -1 << endl;
	else rep(i, (int)ans.size())cout << ans[i] << endl;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main () {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) {
        cnt++;
      }
    }
    if (cnt == 8) {
      ans++;
    }
  }
  cout << ans << endl;

}


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

int main(){
  int n;
  cin >> n;
  int a[100000];

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

  sort(a,a+n);

  int num = 0;
  int cnt = 0;

  int ans = 0;
  for(int i = 0;i < n;i++){
    if(a[i] != num){
      if(cnt < num) ans += cnt;
      num = a[i];
      cnt = 1;
    }else{
      cnt++;
      if(cnt > num) ans++;
    }
  }
  if(cnt < num) ans += cnt;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
def c_forbidden_list(RANGE=101):
    X, N = [int(i) for i in input().split()]
    P = set([int(i) for i in input().split()]) if N != 0 else set()

    for t in range(RANGE + 1):
        if X - t not in P:
            return X - t
        elif X + t not in P:
            return X + t
    return None  # 入力の制約上ここには来ない

print(c_forbidden_list())

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

int main()
{
    int N;
    vector<int> d;
    cin >> N;
    rep(i,N){
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }
    int ans = 0;
    for(int i = 0;i < N; i++){
        for(int j = i+1;j < N;j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<cmath>
#define POINT_A 1
#define POINT_B 2
#define POINT_C 3
#define EPS 1.0e-6
using namespace std;
typedef long double elem;
typedef complex<elem> point, vec;
bool eq(elem a, elem b){return abs(a - b)<EPS; } 
vec normv(const vec &v){return v/abs(v);}
elem dist(const point &a, const point &b){return abs(a-b); }
elem dot(const vec &a, const vec &b){return a.real()*b.real()+a.imag()*b.imag();}
elem AreaOfTriangle(elem a, elem b, elem c){ elem s = (a+b+c)/2; return sqrt(s)*sqrt(s-a)*sqrt(s-b)*sqrt(s-c); }
elem InradiusOfTriangle(elem a, elem b, elem c){ return AreaOfTriangle(a,b,c) / (a+b+c); }
elem InradiusOfTriangleByMalfatti(elem r1, elem r2, elem r3){ return ( 2 * sqrt(r1*r2*r3) ) / ( sqrt(r1)+sqrt(r2)+sqrt(r3) - sqrt(r1+r2+r3) ); }
elem QueryR(point A, point B, point C, elem ka, elem Ra, int query){
	vec v1,v2,px,X,e;
	point p;
	
	X = ka * ( normv( normv(B-A) + normv(C-A) ) ) + A;
	if( query == POINT_B ){ v1 = A-B; v2 = C-B; p = B;
	}else if(  query == POINT_C ){ v1 = A-C; v2 = B-C; p = C; }
	px = X - p;
	e = normv( normv(v1) + normv(v2) );

	//cout << "E: " << e << " X: " << X << endl;

	elem sinH = sin( acos( dot(v1,v2) / (abs(v1)*abs(v2)) ) / 2 );
	elem a = 1 - ( 1 / pow(sinH,2) );
	elem b = Ra + dot(px,e)/sinH;
	elem c = pow(Ra,2)-pow(abs(px),2);

	elem candR1 = ( -b + sqrt( pow(b,2) - a*c ) ) / a;
	elem candR2 = ( -b - sqrt( pow(b,2) - a*c ) ) / a;

	//cout << "POINT " << p << "CAND R1: " << candR1 << " CAND R2: " << candR2 << endl;

	if( candR1 * candR2 < 0 )
		return max( candR1, candR2 );
	else
		return min( candR1, candR2 );
}
int main(){
	while(true){
		point A,B,C;				// ¸_
		elem a,b,c;					// ÎÓÌå«³
		elem sinAh, sinBh, sinCh;	// sin(A/2)ÈÇ
		elem ka,kb,kc;
		elem Ra, Rb, Rc;

		elem xa,ya,xb,yb,xc,yc;
		scanf("%Lf%Lf%Lf%Lf%Lf%Lf",&xa,&ya,&xb,&yb,&xc,&yc);
		if(xa==0.0&&ya==0.0&&xb==0.0&&yb==0.0&&xc==0.0&&yc==0.0)break;

		A=complex<elem>(xa,ya);B=complex<elem>(xb,yb);C=complex<elem>(xc,yc);
		a = abs( B-C ); b = abs( C-A ); c = abs( B-A );
		vec v1,v2;
		v1 = B - A; v2 = C - A; sinAh=sin( acos( dot(v1,v2) / (abs(v1)*abs(v2)) ) / 2 );
		v1 = A - B; v2 = C - B; sinBh=sin( acos( dot(v1,v2) / (abs(v1)*abs(v2)) ) / 2 );
		v1 = A - C; v2 = B - C; sinCh=sin( acos( dot(v1,v2) / (abs(v1)*abs(v2)) ) / 2 );

		/* binary serach */
		Ra = Rb = Rc = 0.0;
		elem l = 0;
		elem r = 2 * abs( ((c/(b+c))*(C-B) + B) - A );
		while( r > l + EPS )
		{
			elem m = (l+r)/2;
			//printf("L=%Lf M=%Lf R=%Lf Ra=%Lf Rb=%Lf Rc=%Lf\n", l,m,r,Ra,Rb,Rc);
			ka = m;
			Ra = sinAh * ka;
			Rb = QueryR(A,B,C,ka,Ra,POINT_B);
			Rc = QueryR(A,B,C,ka,Ra,POINT_C);
			kb = Rb / sinBh;
			kc = Rc / sinCh;
			vec BY = kb * normv( normv(A-B) + normv(C-B) );
			vec CZ = kc * normv( normv(A-C) + normv(B-C) );
			elem d = dist( B + BY, C + CZ );
			if( eq(d-(Rb+Rc),0.0) )
				break;
			else if( d > Rb + Rc ){
				r = m;
			}else{
				l = m;
			}
		}
		printf("%.5Lf %.5Lf %.5Lf\n", Ra, Rb, Rc);
	}
	return 0;
}

Measured memory_bytes: 956
#include <stdio.h>

#define ARR_LIMIT 10000
#define ERROR -9999

void InputNumber(int* number, int limitLow, int limitHigh);
void InputOperator(char* oper);
int Add(int x, int y);
int Sub(int x, int y);
int Mul(int x, int y);
int Div(int x, int y);
int Calculation(int x, int y, char oper);

int main(void) {

    int x;
    char oper;
    int y;
    int i;
    int idx = 0;
    int result[ARR_LIMIT];

    do {
    	InputNumber(&x, 0, 20000);
		InputOperator(&oper);
		InputNumber(&y, 0, 20000);

		int res = Calculation(x, y, oper);
		if (res == ERROR) {
			continue;
		}
		result[idx++] = res;
    } while (oper != '?');

    for (i = 0; i < idx; i++) {
        printf("%d\n", result[i]);
    }

    return 0;
}

void InputNumber(int* number, int limitLow, int limitHigh) {
    int x;
    do {
        scanf("%d", &x);
    } while (x < limitLow || x > limitHigh);
    *number = x;
}

void InputOperator(char* oper) {
    char op;
    do {
        scanf("%c", &op);
    } while (op != '+' && op != '-' && op != '*' && op != '/' && op != '?');
    *oper = op;
}

int Add(int x, int y) {
    return x + y;
}

int Sub(int x, int y) {
    return x - y;
}

int Mul(int x, int y) {
    return x * y;
}

int Div(int x, int y) {
    return x / y;
}

int Calculation(int x, int y, char oper) {
    switch (oper) {
        case '+':
            return Add(x, y);

        case '-':
            return Sub(x, y);

        case '*':
            return Mul(x, y);

        case '/':
            return Div(x, y);
    }
    return ERROR;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})


int main(){

 int n; cin>>n;
 ll ans=0;

 for(int i=0;i<n;i++){
      int x;
      cin>>x;

      while(x%2 == 0){
            x = x/2;
            ans++;
      }
 }

 cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 3628
n = int(input())
arr = list(map(int, input().split()))
sum = 0
for x in arr:
	sum = sum+x
q = int(input())
newarr = [0]*10**6
for x in arr:
	newarr[x]=newarr[x]+1
for t in range(q):
	b, c = map(int, input().split())
	sum = sum - b*newarr[b]
	sum = sum + c*newarr[b]
	newarr[c] = newarr[c] + newarr[b]
	newarr[b] = 0
	print(sum)

Measured memory_bytes: 23860
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 50;
int N, A;
int x[MAX_N+1];
ll dp[MAX_N+1][MAX_N+1][MAX_N*MAX_N+1];

int main() {
  cin >> N >> A;
  for (int i = 1; i <= N; ++i) cin >> x[i];

  ll sum = 0;
  for (int i = 1; i <= N; ++i) sum += x[i];
  for (int i = 0; i <= N; ++i) dp[i][0][0] = 1;

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= i; ++j) {
      for (int k = 0; k <= sum; ++k) {
        dp[i][j][k] = dp[i-1][j][k];
        if (k >= x[i]) dp[i][j][k] += dp[i-1][j-1][k-x[i]];
      }
    }
  }

  ll ans = 0;
  for (int j = 1; j <= N; ++j) {
    ans += dp[N][j][j*A];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 49024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    int x_max = -100;
    int y_min = 100;
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
        x_max = max(x_max, x[i]);
    }
    for (int i = 0; i < M; i++)
    {
        cin >> y[i];
        y_min = min(y_min, y[i]);
    }

    bool war = true;
    for (int z = X + 1; z <= Y; z++) {
        if (z > x_max && z <= y_min) {
            war = false;
            break;
        }
    }
    if (war) {
        cout << "War" << endl;
    } else {
        cout << "No War" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<vector<int>> A(N, vector<int>(M + 1));

    rep(i, N) {
        rep(j, M + 1) cin >> A[i][j];
    }

    ll ans = INF;
    rep(bit, 1 << N) {
        vector<int> res(M);
        ll cost = 0;
        rep(i, N) {
            if ((bit >> i) & 1) {
                cost += A[i][0];
                repd(j, 1, M + 1) {
                    res[j - 1] += A[i][j];
                }
            }
        }

        bool flag = true;
        rep(i, M) {
            if (res[i] < X) flag = false;
        }
        if (flag) chmin(ans, cost);
    }

    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<deque>
#include<set>
#include<vector>
#include<map>
#define ll long long
using namespace std;
int a[200005];
int main()
{
   int n;
   ll sum=0;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
   	scanf("%d",&a[i]);
   	a[i]=a[i]-i;
	} 
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		sum+=abs(a[i]-a[(n+1)/2]);
	}
	printf("%lld\n",sum);
	return 0;
 } 


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int arr[10];
    arr[0]=2;
    for(int i=1;i<=10;i++)
        arr[i]=2*arr[i-1];
    scanf("%d",&n);
    if(n<=2)
    {printf("%d\n",n);return 0;}
    for(int i=0;i<10;i++)
    {
        if(n<arr[i])
        {
            printf("%d\n",arr[i-1]);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define A[302][602]
H,W,d A,a,i,j,v,L A;char C A;main(){for(scanf("%d%d ",&H,&W);W--;a+=v)for(i=0;i++<H;)for(j=0;j++<H;v=d[i][j]=fmin(d[i][j-1],d[i-1][j])+(L[W][i-j+H]+=C[i][W]==C[j][W+1]))i-1||gets(C+j);printf("%d",a);}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

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

	vector<int32_t> X(N), sorted_X(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> X[i];
		sorted_X[i] = X[i];
	}
	sort(sorted_X.begin(), sorted_X.end());
	int32_t first_center = sorted_X[(N - 2) / 2];
	int32_t second_center = sorted_X[N / 2];

	for (int32_t i = 0; i < N; i++) {
		int32_t res;

		if (X[i] <= first_center)
			res = second_center;
		else
			res = first_center;
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 3712
alphabet='abcdefghijklmnopqrstuvwxyz'
N=int(input())
r=[]
while N>26:    
  x=N%26
  N=N//26
  if x==0:
    N-=1
    x=26
  r.append(x)
r.append(N)
name=[alphabet[i-1] for i in r]
name.reverse()
name=''.join(name)
print(name)

Measured memory_bytes: 9104
#include<iostream>

using namespace std;

long A[500'000];

long h = 0;
long par(long i) { return i / 2; }
long left(long i) { return 2 * i; }
long right(long i) { return 2 * i + 1; }


void maxHeapify(long A[], long i) {

	long l, r, largest, sw;
	l = left(i);
	r = right(i);
	// 左の子、自分、右の子で値が最大のノードを選ぶ
	if (l <= h and A[l] > A[i]) {
		largest = l;
	}
	else {
		largest = i;
	}

	if (r <= h and A[r] > A[largest])
		largest = r;

	if (largest != i) { // i の子の方が値が大きい場合、
		// A[i] と A[largest] を交換
		sw = A[i];
		A[i] = A[largest];
		A[largest] = sw;

		maxHeapify(A, largest); // 再帰的に呼び出し
	}

}

void buildMaxHeap(long A[]) {

	for (int i = h / 2;i >= 1;i--) {
		maxHeapify(A, i);
	}
}

int main() {


	cin >> h;


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

	buildMaxHeap(A);

	for (int i = 1;i <= h;i++) {
		cout << " " << A[i];
	}

	cout << endl;

	return 0;
}



Measured memory_bytes: 6988
#!/usr/bin/env python
# coding: utf-8

# In[34]:


N,P = map(int, input().split())


# In[35]:


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


# In[37]:


mylist = factorization(P)
mylist = sorted(mylist, key=lambda x:x[1], reverse=True)
ans = 1
for i,item in enumerate(mylist):
    if item[1] >= N:
        ans *= item[0]**(item[1]//N)
    else:
        break
print(ans)


# In[ ]:






Measured memory_bytes: 9340
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#define ll longlong
using namespace std;
int a[100005];
int main()
{
    int t,s=0;
  while(~scanf("%d",&t))
{
    for(int i=0;i<t;i++)
       {
        scanf("%d",&a[i]);
       }
       sort(a,a+t);
    for(int k=0;k<t; )
      {
        if(a[k]==a[k+1])
          k=k+2;
        else
         {
          s++;
          k++;
         }
      }
    printf("%d\n",s);
}
    return 0;
}




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

main(){
  int n,i,size,i2;
  cin >> n;
  string w[n];
  for (i=0;i<n;i++) cin >> w[i];
  for (i=1;i<n;i++){
    size=w[i-1].size();
    for(int j=0;j<i;j++)if(w[j]==w[i]) {
      cout << "No" << endl;
      return 0;
    }
    if (w[i-1][size-1] != w[i][0]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
n = int(input())
w = []
count = 0

for i in range(n):
    w.append(input())

for i in range(n):
    if i >= 1:
        if w[i-1][-1] != w[i][0]:
            print('No')
            exit()

        for j in range(i-1):
            if w[i] == w[j]:
                print('No')
                exit()

print('Yes')

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

int main() {
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> A(N);
  for (int &e : A) cin >> e;
  sort(A.begin(), A.end());
  
  int bus = 1;
  int cap = 1;
  int TL = A[0]+K;
  for (int i = 1; i < N; i++) {
    if (A[i] <= TL && cap < C) {
      cap += 1;
    }
    else {
      bus += 1;
      cap = 1;
      TL = A[i] + K;
    }
  }
  cout << bus << endl;
}

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

int main(){
  int h, w; cin >> h >> w;
  int cnt[h][w];
  char s[h][w];
  P mv[] = {make_pair(0, 1), make_pair(1, 0)};
  rep(i, h) rep(j, w) cin >> s[i][j];
  int INF = 1e9;
  rep(i, h) rep(j, w) cnt[i][j] = INF;

  queue<P> q;
  q.push(make_pair(0, 0));
  if(s[0][0] == '.') cnt[0][0] = 0;
  else cnt[0][0] = 1;

  while(!q.empty()){
    P now = q.front(); q.pop();
    rep(i, 2){
      int nx = now.first + mv[i].first, ny = now.second + mv[i].second;
      if(nx >= h || ny >= w) continue;
      if(cnt[nx][ny] == INF) q.push(make_pair(nx, ny));

      int c = cnt[now.first][now.second];
      if(s[nx][ny] == '#' && s[now.first][now.second] == '.') c++;


      cnt[nx][ny] = min(cnt[nx][ny], c);

    }
  }

  /*rep(i, h){
    rep(j, w) cout << cnt[i][j] << " "; cout << endl;
  }*/
  cout << cnt[h - 1][w - 1] << endl;
  return 0;
}


Measured memory_bytes: 3620
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
var obj={};
for(var i=0;i<=100001;i++){
   obj[i]=1;
}
for(var i=0;i<n;i++){
   var ab=(Arr.shift()).split(" ").map(Number);
   for(var j=ab[0];j<=ab[1];j++)obj[j]++;
}
var max=1;
for(var i=0;i<=100001;i++){
   if(obj[i]<i)continue;
   if(obj[i]>=i)obj[i]=i;
   max=Math.max(max,obj[i]);
}
   
console.log(max-1);

Measured memory_bytes: 36920
s = input()
k = int(input())

cand = []

ilis = sorted(range(len(s)), key=lambda k: s[k])

visited = set()

for i in range(len(s)):
    for j in range(5):
        cand.append(s[ilis[i]:ilis[i]+j+1])

cand.sort()

ret = sorted(list(set(cand)))

print(ret[k-1])


Measured memory_bytes: 11180
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


int a[4];

int main(){
	for(int i = 0; i < 4; i++){
		cin >> a[i];
	}
	
	if(a[0]+a[1] == a[2]+a[3]){
		cout << "Balanced" << endl;
	}
	else if(a[0]+a[1] > a[2] + a[3]){
		cout << "Left" << endl;
	}
	else cout << "Right" << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither long longo the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const long long inf=0x3f3f3f3f;
const double eps=1e-6;
const long long mod=1000000007;
typedef long long ll;
inline string getstr(string &s,long long l,long long r){string ret="";for(long long i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
long long modpow(long long x,long long y,long long md=mod){long long ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline long long Rand(){return rand()*32768+rand();}
long long n,k,s,t;
long long a[55];
long long c[55][55];
vector<long long>g1[20],g0[20];
long long num[55],ban[55];
long long calc(long long x,long long y){
	if(y>x)return 1ll<<x;
	else{
		long long ret=0;
		for(long long i=0;i<=y;i++)ret+=c[x][i];
		return ret;
	}
}
long long func(long long mask){
	map<long long,long long>mp;
	long long sum=0;
	for(long long i=1;i<=n;i++)if(!ban[i]){
		mp[a[i]&mask]++;sum++;
	}
	long long ans=0;
	for(auto p:mp){
		ans+=calc(p.second,k)-1;
	}
	ans++;
//	cerr<<"return: "<<mask<<" "<<ans<<endl;
	return ans;
}
signed main(){
	for(long long i=0;i<=50;i++){
		c[i][0]=c[i][i]=1;
		for(long long j=1;j<i;j++){
			c[i][j]=c[i-1][j]+c[i-1][j-1];
		}
	}
	cin>>n>>k>>s>>t;
	for(long long i=1;i<=n;i++){
		cin>>a[i];
		for(long long j=0;j<18;j++){
			if(a[i]&(1<<j))g1[j].push_back(i);
			else g0[j].push_back(i);
		}
	}
	if((t&s)!=s){
		puts("0");
		return 0;
	}
	vector<long long>one,zero;
	memset(num,-1,sizeof num);
	for(long long i=0;i<18;i++){
		if(s&(1<<i))one.push_back(i),num[i]=1;
		if((t&(1<<i))==0)zero.push_back(i),num[i]=0;
	}
	long long ans=0;
	for(long long i=0;i<18;i++){
		if(num[i]==0){
			for(long long j=1;j<=n;j++)if(a[j]&(1<<i))ban[j]=1;
		}
		if(num[i]==1){
			for(long long j=1;j<=n;j++)if(!(a[j]&(1<<i)))ban[j]=1;
		}
	}
	for(long long i=0;i<(1<<18);i++){
		long long bt=__builtin_popcount(i);
		bool valid=1;
		for(long long j=0;j<18;j++)if(i&(1<<j))if(num[j]!=-1)valid=0;
		if(!valid)continue;
		if(bt&1)ans-=func(i);
		else ans+=func(i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;
     
    public class Main {
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
			int[] a= new int[3];
			for(int i=0;i<3;i++)
			{
				a[i]=scan.nextInt();
			}
			int m = a[0];
			int n = a[1];
			int o = a[2];
			if(m+n+o>=22)
				System.out.println("bust");
			else
				System.out.println("win");
    	}
    }

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

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

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const  long long  INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, m, a, b, c;
string s[101];
map<string, bool>mp;

int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> s[i];
		if (mp[s[i]]) {
			cout << "No" << endl;
			return 0;
		}
		mp[s[i]] = 1;
	}
	for (int i = 0;i < n - 1;i++) {
		if (s[i][s[i].size() - 1] != s[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=1<<17;
const ll INF=(1ll<<31)-1;
//update value Query min
class Lz_segtree{
public:
    int n;
    ll e=INF;
    ll init=-1;
    vector<ll> dat,lz;
    Lz_segtree(int n_):n(n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(n*2,e);
        lz.resize(n*2,init);
    }
    void update_f(ll& d,ll x){
        d=x;
    }
    ll dat_propergate(ll l,ll r){
        return min(l,r);
    }
    void lz_propergate(ll& l,ll& r,ll x){
        l=x,r=x;
    }
    void eval(int len,int k){
        if(lz[k]!=init) update_f(dat[k],lz[k]);
        if(len>1){//flag check!
            if(lz[k]!=init)lz_propergate(lz[k*2+1],lz[k*2+2],lz[k]);
        }
        lz[k]=init;
    }
    //range [a,b)
    void update(int a,int b,int k,int l,int r,ll x){
        eval(r-l,k);
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b){
            update_f(lz[k],x);
            eval(r-l,k);
        }
        else{
            update(a,b,k*2+1,l,(l+r)/2,x);
            update(a,b,k*2+2,(l+r)/2,r,x);
            dat[k]=dat_propergate(dat[2*k+1],dat[2*k+2]);
        }
    }
    //range [a,b)
    ll query(int a,int b,int k,int l,int r){
        eval(r-l,k);
        if(r<=a||b<=l) return e;
        if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=query(a,b,k*2+1,l,(l+r)/2);
            ll vr=query(a,b,k*2+2,(l+r)/2,r);
            return dat_propergate(vl,vr);
        }
    }
    void update(int a,int b,ll x){
        return update(a,b,0,0,n,x);
    }
    ll query(int a,int b){
        return query(a,b,0,0,n);
    }
};

int main(){
    int n,q,c,s,t,x;
    cin>>n>>q;
    Lz_segtree seg(n);
    rep(i,q){
        cin>>c;
        if(c==0){
            cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }
        else{
            cin>>s>>t;
            ll ans=seg.query(s,t+1);
            cout<<ans<<endl;
        }
    }
    return 0;
}



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

int main() {
  int N;
  int64_t D, a, b;
  cin >> N >> D;
  int64_t c = 0;
  int count = 0;
  D *= D;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    a *= a;
    b *= b;
    c = a + b;
    if (c <= D) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        main_ITP1_1_D(args);
    }

    public static void main_ITP1_1_D(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int h = n / (60 * 60);
        int m = (n / 60) % 60;
        int s = n % 60;
        System.out.println(String.format("%d:%d:%d", h, m, s));
    }
}



Measured memory_bytes: 26284
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N,K;
ll x[1000],y[10000];
vector<ll> xs,ys;
int main(){
	cin>>N>>K;
	rep(i,N) cin>>x[i]>>y[i];
	rep(i,N){
		xs.pb(x[i]);
		ys.pb(y[i]);
	}
	sort(all(xs));xs.erase(unique(xs.begin(),xs.end()),xs.end());
	sort(all(ys));ys.erase(unique(ys.begin(),ys.end()),ys.end());
	ll ans = 8e18;
	rep(bx,N) rep(ax,bx){
		rep(by,N) rep(ay,by){
			ll S = (ys[by]-ys[ay])*(xs[bx]-xs[ax]);
			int c = 0;
			rep(i,N){
				if(xs[ax]<=x[i]&&x[i]<=xs[bx]&&ys[ay]<=y[i]&&y[i]<=ys[by]) c++;
			}
			if(c>=K) chmin(ans,S);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
  
	int n,s=0;
  
  	cin >> n;
  
  	int tmp = n;
  
  	while(tmp){
    	s+= tmp%10;
      	tmp/=10;
    }
  
  if(n%s)cout <<"No" << endl;
  else cout << "Yes" << endl;
  
  return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
 vector<int> A(N);
  int count=0;
  for(int i=0;i<N;i++){
  cin>>A.at(i);
    if(A.at(i)>=K){
    count++;
    }
    
    
    
  
  }
  cout<<count<<endl;
  
  
}

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

int main() {
  int n, a;
  cin >> n >> a;
  if(n % 500 <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256