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

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n, m;
    while (cin >> n >> m, n) {
        priority_queue<i_i > pq;
        rep(i, n) {
            int a, b;
            cin >> a >> b;
            pq.push(i_i(b, a));
        }
        int ans = 0;
        while (m && !pq.empty()) {
            i_i tmp = pq.top(); pq.pop();
            if (m >= tmp.second) {
                m -= tmp.second;
            } else {
                ans += tmp.first * (tmp.second - m);
                m = 0;
            }
        }
        while (!pq.empty()) {
            ans += pq.top().first * pq.top().second; pq.pop();
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3244
import collections

N = int(input())
ans = 0
d = collections.defaultdict(int)
for i in range(1, N+1):
    str_i = str(i)
    key = str_i[0] + str_i[-1]
    if "0" in key:
        continue
    d[key] += 1

for k, v in d.items():
    rev_k = k[::-1]
    rev_v = d.get(rev_k)
    if rev_v is None:
        continue
    ans += v * rev_v
print(ans)

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

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	rep(i, a) cin >> p[i];
	rep(i, b) cin >> q[i];
	rep(i, c) cin >> r[i];
	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());
	sort(r.begin(), r.end(), greater<int>());

	rep(i, x) r.push_back(p[i]);
	rep(i, y) r.push_back(q[i]);
	sort(r.begin(), r.end(), greater<int>());

	ll ans = 0;
	rep(i, x + y) ans += r[i];
	cout << ans << endl;
}

Measured memory_bytes: 2552
#include <iostream>
using namespace std;
int main(void){
        long long int N,A,B;
        cin>>N>>A>>B;
        long long int c=N%(A+B);
        if(c>=A){
            cout<<A+N/(A+B)*A<<endl;
        }
        else {
            cout<<c+N/(A+B)*A<<endl;
        }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int a,b,c,d;

    cin >> a >> b >> c >> d;

    //cout <<std::fixed<< setprecision(10) <<  ans << endl;

    int ans = 0;

    if(a!=c && b !=d){
        ans = 1;
    }


    cout <<  ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;

const int INF = 1e6;

int read() {
    int x = 0;
    char k;
    while (1) {
        if (isdigit(k = getchar())) { x = k - '0'; break; }
    }
    while (1) {
        if (!isdigit(k = getchar())) break;
        x = x * 10 + k - '0';
    }
    return x;
}

void write(int x) {
    int sz = 0;
    char buf[10];
    char m = 0;
    if (x < 0) m = 1, x = -x;
    while (x) buf[sz++] = x % 10 + '0', x /= 10;
    if (m) buf[sz++] = '-';
    if (!sz) buf[sz++] = '0';
    while (sz--) putchar(buf[sz]);
    putchar('\n');
}

int n, m;
struct edge { int d, w; };
vector<edge> g[110];
int W[10010];

int l, r, vis[10010];

int dfs(int u) {
    int res = 1;
    vis[u] = true;
    for (int i = 0; i < (int)g[u].size(); ++i) {
        edge &e = g[u][i];
        if (!vis[e.d] && l <= e.w && e.w <= r) {
            res += dfs(e.d);
        }
    }
    return res;
}

bool check(int l, int r) {
    memset(vis, 0, sizeof vis);
    ::l = l;
    ::r = r;
    int cnt = dfs(0);
    return cnt == n;
}

int main() {
    srand(time(0));
    while (n = read()) {
        m = read();
        for (int i = 0; i < n; i++) {
            g[i].clear();
        }
        for (int i = 0; i < m; i++) {
            int a = read() - 1, b = read() - 1, w = read();
            g[a].push_back({ b,w });
            g[b].push_back({ a,w });
            W[i] = w;
        }

        sort(W, W + m);
        const int k = unique(W, W + m) - W;
        random_shuffle(W, W + k);

        if (!check(0, INF)) {
            write(-1);
        } else {
            int ans = INF;
            for (int i = 0; i < k; ++i) {
                if (!check(W[i], W[i] + ans)) continue;
                int lo = W[i] - 1;
                int hi = INF;
                while (lo + 1 < hi) {
                    int mid = (lo + hi) / 2;
                    if (check(W[i], mid)) {
                        hi = mid;
                    } else {
                        lo = mid;
                    }
                }
                ans = min(ans, hi - W[i]);
            }
            write(ans);
        }
    }
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define pb push_back
#define ld long double
typedef pair<ll,ll> P;
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
int main()
{
    ll n,i,a,b,c;
    cin>>n;
    ll DP1[n+1],DP2[n+1],DP3[n+1];
    DP1[0]=0,DP2[0]=0,DP3[0]=0;
    for(i=1;i<=n;i++)
    {
        cin>>a>>b>>c;
        DP1[i]=max(DP2[i-1]+a,DP3[i-1]+a);
        DP2[i]=max(DP1[i-1]+b,DP3[i-1]+b);
        DP3[i]=max(DP1[i-1]+c,DP2[i-1]+c);
    }
    cout<<max(DP1[n],max(DP2[n],DP3[n]))<<endl;
}


Measured memory_bytes: 2560
import java.util.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		B(sc);
	}
	
	public static void A(Scanner sc) {
		out.println(sc.nextInt()/3);
	}
	
	public static void B(Scanner sc) {
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			if(sc.next().charAt(0)=='Y') {
				out.println("Four");
				return;
			}
		}
		out.println("Three");
	}
}


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

#define pp pair < int, int >
#define x first
#define y second

using namespace std;

int n, u, v, le, l[200000], r[200000];
pp t[200000];

void Input()
{
    ios_base::sync_with_stdio(0);       cin.tie(0);

    cin >> n;       r[0] = 1e9+1;
    for (int i=1; i<=n; i++)
    {
        cin >> l[i] >> r[i];
        if (l[u] < l[i]) u = i;
        if (r[v] > r[i]) v = i;
    }
}

bool cmp(const pp &l, const pp &r)
{
    return l.x < r.x;
}

void Process()
{
    int ans = 0;
    for (int i=1; i<=n; i++)
    {
        t[i].x = max(r[i] - l[u] + 1, 0);
        t[i].y = max(r[v] - l[i] + 1, 0);
        if (i != u && i != v)
            le = max(le, r[i] - l[i] + 1);

    }

    sort(t + 1, t + n + 1, cmp);

    int k = 0;
    for (int i=2; i<=n; i++)
        k = max(k, t[i].y);
    ans = k + t[1].x;

    k =1e9+1;
    for (int i=2; i<=n; i++)
    {
        k = min(k, t[i-1].y);
        ans = max(ans, t[i].x + k);
    }

    cout << max(le + max(r[v] - l[u] + 1, 0), ans);
}

int main()
{
    Input();
    Process();
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int H,W,h,w,i=1,j;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  if(H%h||W%w){
    puts("Yes");
    for(;i<=H;++i,puts("")) for(j=0;j<W;++j,printf("%d ",(i%h||j%w)?1000:-1000*(h*w-1)-1));
  }else puts("No");
  return 0;
}

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

int s[200006];

int main()
{
	int n,f;
	scanf("%d",&n);
	for(int i=2;i<=n;++i) {scanf("%d",&f);s[f]++;}
	for(int i=1;i<=n;++i) printf("%d\n",s[i]);
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

int n;
int d[105];
int ft[105];
int get(int u){return u ? max(ft[u], get(u - (u & -u))) : 0;}
void upd(int u, int v){
	for (; u <= 100; u += (u & -u)) ft[u] = max(ft[u], v);
}
int main(){
	n = re<int>();
	for (int i = 1; i <= n; i++) d[i] = re<int>();
	sort(d+1, d+n+1);
	int mx = 0;
	for (int i = 1; i <= n; i++){
		int tmp = get(d[i] - 1);
		upd(d[i], tmp + 1);
		mx = max(mx, tmp+1);
	}
	printf("%d\n", mx);
	return 0;
}


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

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

using namespace std;

int64_t p10(int64_t n) {
  return n?(p10(n-1)*10):1;
}

int main() {
  while(1){
    int64_t n,k;
    cin>>n>>k;
    if(!n)break;
    int64_t sum = 0;
    int i = 0;
    for(;;++i) {
      if (sum + p10(i) * 9 * (i+1) >= n) {
        break;
      }
      sum += p10(i) * 9 * (i+1);
      //cout<<p10(i)<<' ';
    }
    int64_t rem = n - (sum + 1);
    int64_t ofs = rem / (i + 1);
    rem = rem % (i+1);
    //cout << rem << ' ' << ofs << endl;
    int64_t start = p10(i) + ofs;
    string s;
    REP(i,100) {
      s += to_string(start + i);
    }
    cout << s.substr(rem, k) << endl;
  }
  return 0;
}

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

using namespace std;

int N,M;
vector<vector<int>> neighbor;
int res = 0;

void dfs(int now, int reached){
    if(reached == (1<<N)-1)res++;
    else{
        for(int neigh : neighbor.at(now)){
            if((1<<(neigh-1)) & reached)continue;
            else dfs(neigh, reached + (1<<(neigh-1)));
        }
    }
}

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

    neighbor = vector<vector<int>>(N+1, vector<int>(0));
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        neighbor.at(a).push_back(b);
        neighbor.at(b).push_back(a);
    }

    dfs(1, 1);

    cout << res << endl;
}

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

#define LL long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define vecprint(vec) for (int i=0;i<vec.size();i++)printf("%d ",vec[i]);
#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define MEM(v,x) memset(v,x,sizeof v)

const double eps=1e-7,PI=3.1415926;
const int N=2e5+10;

using namespace std;

int n,q,m,k,x,y,a[N],mx=-1,mn=1e9,sum,t;
char c[N];
string s,s1,s2;
map < int , int > mp;
vector < int > vec;

int main(){
    cin>>s1>>s2;
    s=s2+s1;
    cout<<s<<endl;
    return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  vll ans;

  if (n == 3) {
    ans.push_back(2);
    ans.push_back(5);
    ans.push_back(63);
  } else if (n == 4) {
    ans.push_back(2);
    ans.push_back(5);
    ans.push_back(20);
    ans.push_back(63);
  } else {
    ll v = 0;
    while (n >= 8) {
      ans.push_back(v + 2);
      ans.push_back(v + 3);
      ans.push_back(v + 4);
      ans.push_back(v + 6);
      ans.push_back(v + 8);
      ans.push_back(v + 9);
      ans.push_back(v + 10);
      ans.push_back(v + 12);
      v += 12;
      n -= 8;
    }

    switch (n) {
    case 1:
      ans.push_back(v + 12);
      break;
    case 2:
      ans.push_back(v + 6);
      ans.push_back(v + 12);
      break;
    case 3:
      ans.push_back(v + 3);
      ans.push_back(v + 9);
      ans.push_back(v + 12);
      break;
    case 4:
      ans.push_back(v + 2);
      ans.push_back(v + 4);
      ans.push_back(v + 6);
      ans.push_back(v + 12);
      break;

    case 5:
      ans.push_back(v + 2);
      ans.push_back(v + 4);
      ans.push_back(v + 6);
      ans.push_back(v + 3);
      ans.push_back(v + 9);
      break;

    case 6:
      ans.push_back(v + 2);
      ans.push_back(v + 4);
      ans.push_back(v + 6);
      ans.push_back(v + 3);
      ans.push_back(v + 9);
      ans.push_back(v + 12);
      break;

    case 7:
      ans.push_back(v + 2);
      ans.push_back(v + 3);
      ans.push_back(v + 4);
      ans.push_back(v + 6);
      ans.push_back(v + 8);
      ans.push_back(v + 9);
      ans.push_back(v + 10);
      break;

    default:
      break;
    }
  }

  for (auto it : ans) {
    cout << it << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3760
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    int N=S.size();
    int g=0,p=0,win=0,lose=0;
    for(int i=0;i<N;i++){
        if(p==g){
            g++;
            if(S[i]=='p')lose++;
        }
        else{
            p++;
            if(S[i]=='g')win++;
        }
    }
    cout<<win-lose<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

	ll x,a;
  cin>>x>>a;
  if(x>=a) cout << 10 << endl;
  else cout << 0 << endl;

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e18)

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

signed main(){
	int N, M, i, d, dsum = 0, ans = inf;
	scanf("%lld%lld", &N, &M);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
	}
	int *x = (int *)malloc(sizeof(int) * (3 * M + 1));
	for(i = 0; i <= 3 * M; i++){
		x[i] = 0;
	}
	for(i = 1; i < N; i++){
		if(a[i - 1] > a[i]){
			a[i - 1] -= M;
		}
		d = a[i] - a[i - 1];
		dsum += d;
		x[M + a[i - 1] + 2] += -1;
		x[M + a[i] + 1] += d;
		x[M + a[i] + 2] += -d + 1;
		x[2 * M + a[i - 1] + 2] += -1;
		x[2 * M + a[i] + 1] += d;
		x[2 * M + a[i] + 2] += -d + 1;
	}
	for(i = 1; i <= 3 * M; i++){
		x[i] += x[i - 1];
	}
	x[0] = dsum;
	for(i = 1; i <= 3 * M; i++){
		x[i] += x[i - 1];
	}
	for(i = M + 1; i <= 2 * M; i++){
//		printf("x[%lld] = %lld\n", i, x[i]);
		ans = min(ans, x[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] h = new long[n];
		for(int i = 0 ; i < n ; i++) {
			h[i] = sc.nextLong();
		}
		Arrays.sort(h);
		long sum = 0;
		for(int i = n ; i >= 0 ; i-- , k--) {
			if(k >= 0)
				continue;
			sum += h[i];
		}
		System.out.println(sum);

	}


}



Measured memory_bytes: 61976
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

ll pw[64], cnt[64];
void pre() {
    pw[0] = 1;
    for(ll i = 1; i < 50; i++) pw[i] = pw[i - 1] * 2ll;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    ll n, k;
    cin>>n>>k;
    ll a[n];
    f(i, n) cin>>a[i];
    pre();
    f(i, n){
        f(j, 50) {
            if(a[i] & pw[j]) cnt[j]++;
        }
    }
    ll num = 0, ans = 0;
    for(int i = 49; i >= 0; i--) {
        ll ff = cnt[i], ss = n - cnt[i];
        //cout<<i<<' '<<ff<<' '<<ss<<endl;
        if(ff > ss) {
            ans += ff * pw[i];
        }
        else{
            if(num + pw[i] <= k){
                ans += ss * pw[i];
                num += pw[i];
            }
            else {
                ans += ff * pw[i];
            }
        }
    }
    cout<<ans;
    return 0;
}

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

#define MAX 22

using namespace std;

int main(void)
{
	int w,d;
	int h;
	int i1,i2;
	int sum;
	int minn;

	while(1){
		cin>>w>>d;
		if(w+d==0) break;

		vector<int> hw(MAX,0);
		vector<int> hd(MAX,0);

		for(i1=0;i1<w;i1++){
			cin>>h;
			hw[h]++;
		}
		for(i1=0;i1<d;i1++){
			cin>>h;
			hd[h]++;
		}
		sum=0;
		for(i1=0;i1<MAX;i1++){
			if(hw[i1]>0 && hd[i1]>0) {
				minn=min(hw[i1],hd[i1]);
				sum+=(minn*i1);
				hw[i1]-=minn;
				hd[i1]-=minn;
			}
			if(hw[i1]>0) {
				sum+=(hw[i1]*i1);
			}
			if(hd[i1]>0) {
				sum+=(hd[i1]*i1);
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;

long long int n,w,i,j;
long long int waga[103];
long long int koszt[103];
long long int dp[103][100003];

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> w;
    for(i=1;i<=n;i++){
        cin >> waga[i] >> koszt[i];
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(waga[i]>j){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=max(dp[i-1][j], dp[i-1][j-waga[i]]+koszt[i]);
            }
        }
    }
    cout << dp[n][w];
    return 0;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int h,w,n,t[20000],x,c[200][200];
int main(){
	cin>>h>>w>>n;
	for(int i=0;i<n;i++)
		cin>>t[i];
	for(int k=0;k<h;k++){
		if ( k % 2 == 0 ) 
		{
		for(int i=0;i<w;i++){
			if ( t[x] )
			       t[x] -- , c[k][i] = x ;
			else
				x++ , c[k][i] = x ,t[x]--;	

		}
		}
		else
		{
			for(int i=w-1;i>=0;i--){
				if ( t[x] )
			       		t[x] -- , c[k][i] = x ;
				else
					x++ , c[k][i] = x ,t[x]--;		
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			cout<<c[i][j]+1<<" ";
		cout<<endl;
	}
}


Measured memory_bytes: 384
using System;
namespace ABC150A
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            int[] inp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.WriteLine(500 * inp[0] >= inp[1] ? "Yes" : "No");
        }
    }
}


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

int main() {
    int n; cin >> n;
    vector<int> v(3 * n);
    for (auto& i : v) cin >> i;
    sort(v.begin(), v.end());

    long long int sum = 0;
    for (int i = n; i < 3 * n; i += 2) sum += v[i];
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAXN=60;
char G[MAXN][MAXN]; char ans[MAXN][MAXN];



int main(){
    int H,W;
    cin>>H>>W;
    for(int i=1;i<=H;++i)
        for(int j=1;j<=W;++j)
            scanf(" %c",&G[i][j]);
    for(int i=1;i<=H;++i)
        for(int j=1;j<=W;++j) {
            int cnt=0;
            if(G[i][j]=='#') {ans[i][j]='#'; continue;}
            if(G[i-1][j-1]=='#') cnt++;
            if(G[i-1][j]=='#') cnt++;
            if(G[i-1][j+1]=='#') cnt++;
            if(G[i+1][j-1]=='#') cnt++;
            if(G[i+1][j+1]=='#') cnt++;
            if(G[i+1][j]=='#') cnt++;
            if(G[i][j-1]=='#') cnt++;
            if(G[i][j+1]=='#') cnt++;
            ans[i][j]=cnt+'0';
        }
    for(int i=1;i<=H;++i){

        for(int j=1;j<=W;++j)
            printf("%c",ans[i][j]);
        cout<<endl;
    }
    return 0;

}






















/*
struct Edge{
    int nx,v,w;
}e[MAXE];
int Fi[MAXN],sz;
void E_add(int u,int v,int w){
    e[sz].v=v,e[sz].w=w,e[sz].nx=Fi[u],Fi[u]=sz++;
}
void SPFA(int st){
    mset(dis,0x3f);
    mset(vis,0); dis[st]=0;
    queue<int> q;
    q.push(st);
    while(!q.empty()){
        int u=q.front(); q.pop();
        vis[u]=0;
        for(int i=Fi[u];i!=-1;i=e[i].nx){
            int v=e[i].v;
            if(dis[v]>dis[u]+e[i].w){
                dis[v]=dis[u]+e[i].w;
                if(!vis[v]){ vis[v]=1; q.push(v); }
            }
        }
    }
}
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define DEBUG

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7, maxn = 52, maxm = (1 << 21);
const double PI = acos(-1);

int main (){
    ll n, a, d, ans = 0;
    cin >> n >> d >> a;
    vector<pii> v(n);

    for (int i=0; i<n; i++){
        cin >> v[i].ff >> v[i].ss;
        v[i].ss = (v[i].ss - 1)/a + 1;
        // cout << v[i].ff << " " << v[i].ss << endl;
    }
    sort(all(v));
    priority_queue<pii> fila;
    ll bombas = 0;

    for (int i=0; i<n; i++){
        while (not fila.empty() and v[i].ff > abs(fila.top().ff)) bombas-=fila.top().ss, fila.pop();
        ll add = v[i].ss - bombas;
        if (add > 0) fila.push({-(v[i].ff + d*2), add}), ans += add, bombas += add;
    }
    cout << ans << endl;
    return 0;
}

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

vector<int> child[100005];
vector<int> adjl[100005];

int ans = 0;

int func(int node){
if (child[node].size()==0) return 1;
vector<int> v;
for (int x : child[node]){
    v.push_back(func(x));
}
int mx = -1;
for (int x = 0; x<23; x++){
    bool c = false;
    for (int y : v){
        if ((y&(1<<x))!=0){
            if (c) mx = x;
            else c = true;
        }
    }
}
for (int x = mx+1; x<23; x++){
    bool can = true;
    int t = 0;
    for (int y : v){
        if ((y&(1<<x))!=0){
            can = false;
            break;
        }
        t = (t|y);
    }
    if (can){
        ans = max(ans,x);
        return (t&(~((1<<(x))-1)))|(1<<x);
    }
}
}

void dfs(int node, int parent){
    for (int x : adjl[node]){
        if (x==parent) continue;
        child[node].push_back(x);
        dfs(x,node);
    }
}

int main(){
int n;
scanf("%d",&n);
for (int x = 0; x<n-1; x++){
    int a,b;
    scanf("%d%d",&a,&b);
    adjl[a].push_back(b);
    adjl[b].push_back(a);
}
dfs(1,-1);
func(1);
printf("%d",ans);
}


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

namespace _20190308_04 {
    class Program {
        static void Main(string[] args) {
            var line = Console.ReadLine().Split(' ').Select(d => int.Parse(d)).ToArray();
            var a = line[0];
            var b = line[1];
            var q = line[2];
            var s = Enumerable.Repeat(long.MaxValue>>3, a + 2).ToArray();
            var t = Enumerable.Repeat(long.MaxValue>>3, b + 2).ToArray();
            var x = Enumerable.Repeat((long)0, q).ToArray();
            s[0] = long.MinValue>>3;
            t[0] = long.MinValue>>3;
            for (int i = 1; i <= a; i++) {
                s[i] = long.Parse(Console.ReadLine());
            }
            for (int i = 1; i <= b; i++) {
                t[i] = long.Parse(Console.ReadLine());
            }
            for (int i = 0; i < q; i++) {
                x[i] = long.Parse(Console.ReadLine());
            }
            foreach (var item in x) {
                var sn = new int[2];
                var tn = new int[2];
                sn[1] = Array.BinarySearch(s, item);
                tn[1] = Array.BinarySearch(t, item);
                if (sn[1] < 0) {
                    sn[1] = ~sn[1];
                }
                if (tn[1] < 0) {
                    tn[1] = ~tn[1];
                }
                sn[0] = sn[1] - 1;
                tn[0] = tn[1] - 1;
                var ans = long.MaxValue;
                for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                        var temp = Math.Min(Math.Abs(item - s[sn[i]]) + Math.Abs(s[sn[i]] - t[tn[j]]), Math.Abs(item - t[tn[j]]) + Math.Abs(s[sn[i]] - t[tn[j]]));
                        ans = Math.Min(ans, temp);
                    }
                }
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 26312
# サイコロクラス
class Dice:
    # 初期化(サイコロの面データを設定)
    def __init__(self, dice_surface_str):
        dice_surface_list = [int(i) for i in dice_surface_str.split()]
        self.dice_surface = dice_surface_list

    # インデックスを指定したサイコロの面を返す(デフォルトは全面)
    def return_surface(self, return_surface_index=""):
        if return_surface_index == "":
            return self.dice_surface
        else:
            return self.dice_surface[return_surface_index]

    # インデックスを指定したサイコロの面を出力(デフォルトは全面)
    def print_surface(self, print_surface_index=""):
        print(self.return_surface(print_surface_index))

    # サイコロを転がした時の面の遷移を返す
    def dice_roll_transition(self, direction):
        roll_dict = {"N": [1, 5, 2, 3, 0, 4], "E": [3, 1, 0, 5, 4, 2], "W": [2, 1, 5, 0, 4, 3], "S": [4, 0, 2, 3, 5, 1]}
        if direction == "N" or direction == "E" or direction == "W" or direction == "S":
            roll_list = roll_dict[direction]
        #if direction == "N":
        #    roll_list = [1, 5, 2, 3, 0, 4]
        #elif direction == "E":
        #    roll_list = [3, 1, 0, 5, 4, 2]
        #elif direction == "W":
        #    roll_list = [2, 1, 5, 0, 4, 3]
        #elif direction == "S":
        #    roll_list = [4, 0, 2, 3, 5, 1]
        else:
            print("命令が不正です")
            print(f"不正な入力データ : {direction}")
        return roll_list

    # サイコロを転がす
    def dice_roll(self, order):
        for o in order:
            surface_tmp = self.return_surface()
            surface_after_roll = []
            surface_after_roll = [surface_tmp[d] for d in self.dice_roll_transition(o)]
            self.dice_surface = surface_after_roll

# 処理実行
## サイコロの面データを受け取る
dc = input()
## インスタンス化
hoge = Dice(dc)
## 命令を受け取る
inp_order = input()
## 命令を実行
hoge.dice_roll(inp_order)
## 上面を出力
hoge.print_surface(0)



Measured memory_bytes: 5624
#include<iostream>
 using namespace std;
 int main() {
    int n,m,sum=0,i;
    cin>>n>>m;
    int a[m];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(n-sum>=0)
    {
        cout<<n-sum;
    }
    else
    {
        cout<<"-1";
    }

 }


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

#define xx first
#define yy second

const int N = 1e5 + 1;
const int mod = 1e9 + 7;

int add(int x, int y) {
    return ((x + y) % mod + mod) % mod;
}
int mul(ll x, ll y) {
    return (x * y) % mod;
}

int n, memo[2][N];
vector<int> adj[N];

int dp(int j, int i, int par = -1) {
    if (memo[j][i] != -1)
        return memo[j][i];
    int ans = 1;
    for (auto& ch : adj[i]) 
        if (ch != par) {
            int f = 0;
            f = add(f, dp(0, ch, i));
            if (!j)
                f = add(f, dp(1, ch, i));
            ans = mul(ans, f);
        }
    return memo[j][i] = ans;
}

void solve() {
    cin >> n;
    for (int i = 1, u, v; i < n; i++) {
        cin >> u >> v;
        --u, --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < 2; i++)
        fill(memo[i], memo[i] + n, -1);
    int ans = add(dp(0, 0), dp(1, 0));
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 16724
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#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 PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int N;  cin >> N;
  vector<pii> s(N);
  REP(i, N){
    int n;  cin >> n;
    s[i] = make_pair(n, i+1);
  }
  sort(ALL(s));
  REP(i, N) cout << s[i].second << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 1664
(function(input) {
    var a = input.split('\n');
    var s = a.shift();
    var n = Number(a.shift());
    var i = 0;
    while (i++ < n) {
        var c = a.shift().split(' ');
        s = command(s, c);
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function command(s, c) {
    var com = c.shift();
    switch (com) {
        case 'print':
            var a = Number(c.shift());
            var b = Number(c.shift());
            console.log(s.slice(a, b + 1));
            break;
        case 'reverse':
            var a = Number(c.shift());
            var b = Number(c.shift());
            s = s.slice(0, a)
            + s.slice(a, b + 1).split('').reverse().join('')
            + s.slice(b + 1, s.length);
            break;
        case 'replace':
            var a = Number(c.shift());
            var b = Number(c.shift());
            var p = c.shift();
            s = s.slice(0, a)
            + p
            + s.slice(b + 1, s.length);
            break;
    }
    return s;
}

Measured memory_bytes: 7648
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)
#define MOD 1000000007

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 10025;
ll dp[MAX_N][105];
int arr[MAX_N],len,D;
char str[MAX_N];

ll dfs(int pos,int now,bool limit)
{
    if(pos==len+1)
        return dp[pos][now] = (now==0);
    if(!limit && dp[pos][now] != -1)
        return dp[pos][now];
    int up = limit?arr[pos]:9;
    ll sum = 0;
    for(int i = 0;i<=up;++i)
    {
        sum+=dfs(pos+1,(now+i)%D,limit&&i==up);
        if(sum>=MOD) sum-=MOD;
    }
    if(!limit)
        dp[pos][now] = sum;
    return sum;
}
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    scanf("%s",str+1);
    scanf("%d",&D);
    len = strlen(str+1);
    for(int i = 1;i<=len;++i) arr[i] = str[i] - '0';
    memset(dp,-1,sizeof(dp));
    printf("%lld\n",(dfs(1,0,true)-1+MOD)%MOD);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 9344
def judgeResult(mid,fin,ret)
        return "F" if mid == -1 || fin==-1
        sum=mid+fin
        if sum>=80
                "A"
        elsif sum>=65
                "B"
        elsif sum>=50
                "C"
        elsif sum>=30
                ret>=50?"C":"D"
        else
                "F"
        end
end
while buf = gets
        buf = buf.chomp.split(' ').map(&:to_i)
        break if buf == [-1,-1,-1]

        mid = buf[0]
        fin = buf[1]
        ret = buf[2]

        res=judgeResult(mid,fin,ret)
        puts res
end

Measured memory_bytes: 8656
#include <bits/stdc++.h>
#define RG register

using namespace std;

inline int gi(){
	RG char ch=getchar();RG int x=0,q=0;
	while(ch<'0' || ch>'9') ch=='-'?(q=1):0,ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return q?(-x):x;
}

int cl,x,y,c[1050][1050];

int main(){
	int w=gi(),h=gi(),col=gi(); x=y=1;
	for (int i=1; i<=col; ++i) {
		cl=gi();
		while(cl--){
			c[x][y]=i;
			++y;
			if (y>h) ++x,y=1;
		}
	}
	for (int i=1; i<=w; ++i){
		if (i&1)
			for (int j=1; j<=h; ++j)
				printf("%d ",c[i][j]);
		else
			for (int j=h; j; --j)
				printf("%d ",c[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 640
O = input()
E = input()
res = ''

if len(O) > len(E):
  for i in range(len(E)):
    res += O[i]
    res += E[i]
  res += O[len(O)-1]
else:
  for i in range(len(O)):
    res += O[i]
    res += E[i]

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    string S; cin >> S;
    int N; N = sz(S);
    int As = 0;
    int idx = 0;
    ll ans = 0;
    while(idx < N) {
        if(S[idx] == 'A') {
            ++As;
            ++idx;
        }
        else if(S[idx] == 'B') {
            if(S[idx + 1] == 'C') {
                ans += As;
                idx += 2;
            } else if(S[idx + 1] == 'B') {
                As = 0;
                idx += 2;
            } else {
                As = 1;
                idx += 2;
            }
        } else {
            As = 0;
            ++idx;
        }
    }
    cout << ans << "\n";
}


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

int main() 
{
    int a,b;
    cin >> a >> b;
    if(a * b % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
    
}


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

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



Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
ll N;
ll d[200];
cin>>N;
for(int i=0; i<N; ++i)cin>>d[i];

int num[200] = {0};
for(int i = 0; i<N; ++i) {
num[d[i]]++;
}
int res = 0;
for(int i=1; i<=100; ++i)
if(num[i]){
  ++res;
    }
cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string s, t;
  cin >> s >> t;
  rep (i, s.size()) {
    string tmp = "";
    for (int j = i; j < s.size(); j++) {
      tmp += s[j];
    }
    rep (j, i) {
      tmp += s[j];
    }
    if (tmp == t) {
      Yes;
      return 0;
    }
  }
  No;

  return 0;
}



Measured memory_bytes: 256
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(N)]
ab.sort()
cd.sort()

g = [[] for _ in range(N)]

for i, pab in enumerate(ab):
    for j, pcd in enumerate(cd):
        if pab[0] < pcd[0] and pab[1] < pcd[1]:
            g[j].append([pab[1],i])
        
ans = 0
s = set()

for gg in g:
    gg.sort(reverse=True)
    for ggg in gg:
        if ggg[1] in s:continue
        else:
            ans += 1
            s.add(ggg[1])
            break
print(ans)


Measured memory_bytes: 9248
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n;
ll a[200005];
ll b[200005];
ll mn = 4e18;

int main()
{
    scanf("%lld", &n);
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        b[i] = b[i - 1] + a[i];
    }
    ll j = 1, k = 3;
    for(ll i = 2; i <= n - 2;)
    {
        if(b[j + 1] * 2 <= b[i]) j++;
        else if(k < n && (b[k + 1] - b[i]) * 2 <= (b[n] - b[i])) k++;
        else
        {
            ll t1 = min(max(b[j], b[i] - b[j]), max(b[j + 1], b[i] - b[j + 1]));
            ll t2 = min(max(b[k] - b[i], b[n] - b[k]), max(b[k + 1] - b[i], b[n] - b[k + 1]));
            ll t3 = b[i] - t1;
            ll t4 = b[n] - b[i] - t2;
            mn = min(mn, max(t1, t2) - min(t3, t4));
            i++;
        }
    }
    cout<<mn<<endl;
    return 0;
}


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

int main() {
    int N,i;
    string S,T,a="";
    cin >> N >> S >> T;

    for(i=0; i<N; i++) {
        a += S.at(i);
        a += T.at(i);
    }

    cout << a << endl;
}

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

using namespace std;

const long long oo = 1000000000000ll;
const int maxN = 200000;

#define foru(i, l, r) for (int i = l; i <= r; ++i)
#define ford(i, r, l) for (int i = r; i >= l; --i)
#define repu(i, r) for (int i = 0; i < r; ++i)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pint pair < ll, int >

int n, a[maxN], A, B;
ll res;

bool check(ll x) {
    ll y = 0;
    foru(i, 1, n) {
        ll t = A - B;
        if (x * B >= a[i]) continue;
        ll p = a[i] - (x * B);
        y += (p - 1) / t + 1;
        if (y > x) return false;
    }
    return true;
}

int main() {
    cin >> n >> A >> B;
    foru(i, 1, n) cin >> a[i];
    int l = 1, r = 1000000000;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) res = mid, r = mid - 1;
        else l = mid + 1;
    }
    cout << res;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//解説AC
int main() {
  int n,p; cin >>n>>p;
  int kisuu=0;
  int guusuu=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if( x%2==1 )kisuu++;
    else guusuu++;
  }
  if(p==1&&kisuu==0){
    cout <<0<<endl;
    return 0;
  }
  long long kotae=0;
  if(p==0&&kisuu==0)kotae=pow(2,n);
  else kotae=pow(2,n-1);
  cout<<kotae<<endl;
  return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll a[100001];

int partition(int p, int r) {
  int x, i, j;
  x = a[r];
  i = p - 1;
  for(int j = p; j < r; j++) {
    if (a[j] <= x) {
      i++;
      swap(a[i], a[j]);
    }
  }
  swap(a[i + 1], a[r]);
  return i + 1;
}

signed main() {
	ll q, n;
  cin >> n;
  rep(i, n) cin >> a[i];

  q = partition(0, n - 1);

  rep(i, n) {
    if (i) cout << " ";
    if (i == q) cout << "[";
    cout << a[i];
    if (i == q) cout << "]";
  }
  cout << endl;
}


Measured memory_bytes: 3840
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int[] x=new int[n];
		int max = 0;
		boolean[] all=new boolean[10000000];
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			if(x[i]>max)
				max = x[i];
		}
		Arrays.sort(x);
		for(int i=0;i<n-1;i++){
			if(!all[x[i]]){
				if(x[i]==x[i+1])
					all[x[i]] = true;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=2;j*x[i]<=max;j++){
				if(!all[j*x[i]]){
					all[j*x[i]] = true;
				}
				if(j*x[i]>max)
					break;
			}
			if(x[i]*2>max)
				break;
			
		}
		int sum = n;
		for(int i=0;i<n;i++){
			if(all[x[i]]){
				sum--;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 60240