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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;

    void init(){
        rep(i,par.size())par[i]=i,sz[i]=1;
    }
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M;

int A[111111],B[111111];
vint G[111111];
bool mark[111111];
bool dfs(int v,int p){
    int cnt=0;
    for(auto u:G[v]){
        if(u==p)continue;
        cnt+=dfs(u,v);
    }

    if(cnt>=2)mark[v]=true;
    return mark[v]||cnt;
}

int n,m;
int id[111111];
int par[111111];
int parEdgeId[111111];
int aa[111111],bb[111111];
int dfs2(int v,int p,int a){
    if(mark[v]){
        id[v]=n++;
        par[id[v]]=a;
        if(a!=-1){
            aa[m]=a;
            bb[m]=id[v];
            parEdgeId[id[v]]=m++;
        }
        a=id[v];
    }

    for(auto u:G[v]){
        if(u==p)continue;
        dfs2(u,v,a);
    }
}

typedef bitset<100>mask;

signed main(){
    cin>>N>>M;
    UnionFindTree uf(N);
    vpint es;
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;

        A[i]=a;B[i]=b;
        if(uf.areSame(a,b)){
            es.pb({a,b});
            mark[A[i]]=true;
            mark[B[i]]=true;
        }
        else{
            uf.unite(a,b);
            G[a].pb(b);G[b].pb(a);
        }
    }

    dfs(0,-1);
    dfs2(0,-1,-1);

    rep(i,es.size()){
        es[i].fi=id[es[i].fi];
        es[i].se=id[es[i].se];

        aa[m]=es[i].fi;
        bb[m]=es[i].se;
        m++;
    }


    mask st[20];
    rep(i,es.size()){
        int a=es[i].fi;
        int b=es[i].se;
        st[i][m-(int)es.size()+i]=1;

        rep(latte,2){
            int v=a;
            while(par[v]!=-1){
                st[i][parEdgeId[v]]=1-st[i][parEdgeId[v]];
                v=par[v];
            }
            swap(a,b);
        }
    }

    rep(i,m)if(!(0<=aa[i]&&aa[i]<n)||!(0<=bb[i]&&bb[i]<n)){
    for(;;);}

    int ans=0;
    for(int i=1;i<1<<es.size();i++){
        UnionFindTree uf(n);

        mask x;
        rep(j,es.size())if(i>>j&1)x^=st[j];
        int latte;
        rep(j,m)if(x[j])uf.unite(aa[j],bb[j]),latte=aa[j];
        if(uf.size(latte)==x.count())ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16460
#include <iostream>
#include <string.h>
using namespace std;
int a[30];
char s[30];
int main(){
	while (cin>>s){
		memset(a,0,sizeof(a));
		for (int i=0;s[i];i++){
			a[s[i]-'a']++;
		}
		int flag=0;
		for (int i=0;i<26;i++){
			if (a[i]>1)
				flag=1;
		}
		if (flag)
			cout<<"no"<<endl;
		else
			cout<<"yes"<<endl;
	}
	return 0;
}

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

using namespace std;

bool valid(int y, int x)
{
    return (y >= 0 && x >= 0);
}

int main()
{
    int w, h;
    int dy[4] = {0, 1, 0, -1};
    int dx[4] = {1, 0, -1, 0};
    
    while (scanf("%d %d", &w, &h) && w){
        bool wall[128][128] = {0};
        int step[128][128];
        
        for (int i = 0; i < 128; i++){
            fill(step[i], step[i] + 128, 999);
        }
        
        fill(wall[0], wall[0] + 128, 1);
        wall[0][1] = 0;
        fill(wall[h * 2], wall[h * 2] + 128, 1);
        wall[h * 2][2 * w - 1] = 0;
        for (int i = 1; i <= h * 2 - 1; i++){
            if (i % 2 == 0){
                for (int j = 0; j < w; j++){
                    int x;
                    wall[i][2 * j] = 1;
                    scanf("%d", &x);
                    wall[i][2 * j + 1] = x;
                }
                wall[i][2 * w] = 1;
            }
            else {
                wall[i][0] = wall[i][2 * w] = true;
                for (int j = 2; j <= 2 * (w - 1); j += 2){
                    int x;
                    scanf("%d", &x);
                    wall[i][j] = x;
                }
            }
        }
        
        queue<pair<int, int> > q;
        step[0][1] = 0;
        for (q.push(make_pair(0, 1)); q.size(); q.pop()){
            pair<int, int> pos = q.front();
            
            for (int i = 0; i < 4; i++){
                pair<int, int> npos = make_pair(pos.first + dy[i], pos.second + dx[i]);
                
                if (valid(npos.first, npos.second) && step[npos.first][npos.second] == 999 && !wall[npos.first][npos.second]){
                    step[npos.first][npos.second] = step[pos.first][pos.second] + ((pos.first & 1) & (pos.second & 1));
                    q.push(npos);
                }
            }
        }
        
        printf("%d\n", step[h * 2][w * 2 - 1] == 999 ? 0 : step[h * 2][w * 2 - 1]);
    }
    
    return (0);
}

Measured memory_bytes: 1296
#include <iostream>
#define MAX 200001
using namespace std;

// Rank: height
// p   : parent
int Rank[MAX], p[MAX];
void DisjointSet(int size);
void makeSet(int x);
bool same(int x, int y);
void unite(int x, int y);
void link(int x, int y);
int findSet(int x);



int main() {
    int n, q;
    int t, a, b;
    cin >> n >> q;

    DisjointSet(n);

    for (int i = 0; i < q; i++) {
        cin >> t >> a >> b;
        if (t == 0) {
            unite(a, b);
        }
        else if (t == 1) {
            if (same(a, b)) cout << 1 << '\n';
            else cout << 0 << '\n';
        }
    }
}

void DisjointSet(int size) {
    for (int i = 0; i < size; i++) 
        makeSet(i);
}

void makeSet(int x) {
    p[x] = x;
    Rank[x] = 0;
}

bool same(int x, int y) {
    return findSet(x) == findSet(y);
}

void unite(int x, int y) {
    link(findSet(x), findSet(y));
}

void link(int x, int y) {
    if ( Rank[x] > Rank[y] ) {
        p[y] = x;
    }
    else {
        p[x] = y;
        if ( Rank[x] == Rank[y] ) {
            Rank[y]++;
        }
    }
}

int findSet(int x) {
    if ( x != p[x] ) {
        p[x] = findSet(p[x]);
    }
    return p[x];
}



Measured memory_bytes: 3176
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int cur[9][9],W,H,sx,sy;
int dx[] = {-1,0,0,1} , dy[] = {0,-1,1,0};

bool done[9][9];
int dfs(int x,int y){
	if(done[y][x]) return 0 ;
	else done[y][x] = true;
	if(y == sy && x == sx) return 1;
	if(cur[y][x] != 0) return 0;
	int ans = 1;
	rep(i,4) ans += dfs(x+dx[i],y+dy[i]);
	return ans;
}
void output(){
	rep(i,H+2){
		rep(j,W+2)cout << cur[i][j];
		cout << endl;
	}
}	
bool isTaboo(int c,int x,int y){
	int ans = 0;
	rep(i,9) rep(j,9) done[i][j] = 0;
	rep(i,4) ans+=dfs(x+dx[i],y+dy[i]);
	return c != ans;
}

bool badFlag;
int nest[50] = {0};
int bt(int c,int x,int y){
	if(nest[c]++ > 19000) { badFlag = true;return true;}
	if(c == 0) return (x == sx && y == sy);
	if(cur[y][x] != 0)return false;
	cur[y][x] = 2;
	if(isTaboo(c,x,y)){cur[y][x] = 0;return false;}
	rep(i,4) if( bt(c-1,x+dx[i],y+dy[i]) ) return true;
	cur[y][x] = 0;
	return false;
}
int main(){
	while(cin >> W >> H && W){
		int eCount = 0;
		rep(i,9)rep(j,9) cur[i][j] = 1;
		rep(i,H)rep(j,W) cin >> cur[i+1][j+1] , eCount += !cur[i+1][j+1];
		rep(i,H+2)rep(j,W+2) if(cur[i][j] == 0) sx = j , sy = i;
		rep(i,50)nest[i] = 0;
		badFlag = 0;
		cout << (eCount > 3 && bt(eCount,sx,sy) && !badFlag ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 852
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())
    #define mod ll(1e9+7)
    typedef long long ll;


    bool compare_first(pair<ll,ll >a,pair<ll,ll >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }

int alph[26];
    int main() {
      ios::sync_with_stdio(false);

      string s;
      cin>>s;

      for(int index=0;index<s.size();index++)
        alph[s[index]-'a']++;

      bool yes=true;
      for(int index=0;index<26;index++)
        if(alph[index]%2)
        yes=false;

      if(yes)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;



return 0;
    }


/*

 }
 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	int A[N];
	F0R(a, N)
		cin >> A[a];
	sort(A, A + N);
	ll total = A[N - 1];
	multiset<pair<int, int>> temp;
	temp.insert({A[N - 2], A[N - 1]});
	temp.insert({A[N - 2], A[N - 1]});
	R0F(a, N - 2){
		auto t = temp.end();
		t--;
		temp.erase(t);
		total += (*t).f;
		temp.insert({A[a], (*t).f});
		temp.insert({A[a], (*t).s});
	}
	cout << total << endl;
}

Measured memory_bytes: 13804
import jdk.nashorn.internal.ir.LabelNode;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();

		double rate = 0.0;
		int[] ws = new int[]{1, 0};

		for (int i = 0; i <= 3000; i++) {
			for (int j = 0; j <= 3000; j++) {
				int water = ((a * i) + (b * j)) * 100;
				if (water == 0 || water > f) break;
				int cap = Math.min(f - water, (water / 100) * e);
				for (int k = 0; k <= 3000; k++) {
					for (int l = 0; l <= 3000; l++) {
						int sugar = k * c + l * d;
						if (sugar > cap || water + sugar > f) break;
						if (rate <= 100.0 * sugar / (water + sugar)) {
							rate = 100.0 * sugar / (water + sugar);
							ws[0] = water;
							ws[1] = sugar;
						}
					}
				}
			}
		}

		System.out.println(ws[0] + ws[1] + " " + ws[1]);
	}
}


Measured memory_bytes: 22608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int cowin(int k, int n){
    int ret = 0;
    while(k>n){
        n*=2; ret++;
    }
    return ret;
}

int main(){
    int n,k; std::cin >> n >> k;

    if(n>=k){
        double ans = (n-k+1)/static_cast<double>(n);
        for(int i=1; i<=k-1; i++){
            int tn = cowin(k, i);
            ans += pow(0.5, tn)/static_cast<double>(n);
        }
        std::cout << std::fixed << std::setprecision(10) << ans << "\n";
    }else{
        double ans = 0;
        for(int i=1; i<=n; i++){
            int tn = cowin(k, i);
            ans += pow(0.5, tn)/static_cast<double>(n);
        }
        std::cout << std::fixed << std::setprecision(10) << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 4148
p1 = gets.to_i
p2 = gets.to_i
p3 = gets.to_i
j1 = gets.to_i
j2 = gets.to_i

min = 10**4
[p1, p2, p3].each do |pasta|
    [j1,j2].each do |ju|
        price = pasta + ju - 50
        min = price if price < min
    end
end
puts min


Measured memory_bytes: 6856
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0062
public class Main {
	static Scanner sc = new Scanner(System.in);
	static final double EPS = 1e-8;
	public static void main(String[] args) {
		while(sc.hasNext()) {
			int[][] is = new int[10][10];
			char[] cs = sc.next().toCharArray();
			for (int i = 0; i < 10; i++) is[0][i] = cs[i] - '0';
			for (int i = 1; i < 10; i++) 
				for (int j = 0; j < 10 - i; j++) 
					is[i][j] = (is[i - 1][j] + is[i - 1][j + 1]) % 10;
			
			System.out.println(is[9][0]);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	string S;
	cin >> N >> S;
	char past = '0';
	int sum = N;
	for(int i = 0; i < N; i++){
		char p = S[i];
		if(p == past)
			sum--;
		past = p;
	}
	cout << sum << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

long int combination(long int n, long int r);

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int combination(long int n, long int r)
{
	if(r>n-r) r = n-r;
	if(r == 0) return 1;
	else if(r == 1) return n;
	return (combination(n-1, r) + combination(n-1, r-1));
	//大きくなるとき
	/*
	long int tmp1, tmp2, tmp3;
	tmp1 = combination(n-1, r);
	if(tmp1>=MOD) tmp1 = tmp1%MOD;
	tmp2 = combination(n-1, r-1);
	if(tmp2>=MOD) tmp2 = tmp2%MOD;
	tmp3 = tmp1+tmp2;
	if(tmp3>=MOD) tmp3 = tmp3%MOD;
	return (tmp3);
	*/
}


int main(){
	int n;
	scanf("%d", &n);
	int array[100001];
	for(int i=0; i<n; i++){
		scanf("%d", &array[i]);
	}
	qsort(array, n, sizeof(int), compare_int);
	int cou1=1, cou2=0;
	for(int i=0; i<n-1; i++){
		if(array[i] == array[i+1]){
			cou1++;
		}
		else{
			if(cou1%2 == 1) cou2++;
			cou1 = 1;
		}
	}
	if(cou1%2 == 1) cou2++;
	printf("%d\n", cou2);
		
	return 0;
}

Measured memory_bytes: 892
s = gets.chomp
x, y = gets.split.map(&:to_i)
split = s.split("T")

first_step = !split.empty? && split.first.size > 0 ? true : false
horizontal = split.select.with_index { |c, i| i.even? && c.size > 0 }
horizontal_count = horizontal.size
horizontal_max = horizontal.join.size
horizontal_length = horizontal_max * 2 + 1
horizontal_dp = Array.new(horizontal_count + 1) { Array.new(horizontal_length) }
horizontal_dp[0][0] = true
horizontal_count.times do |from|
  dp_next = horizontal_dp[from + 1]
  step = horizontal[from].size
  horizontal_dp[from].each_with_index do |bool, index|
    next unless bool
    dp_next[(index + step) % horizontal_length] = true
    next if from == 0 && first_step
    dp_next[(index - step) % horizontal_length] = true
  end
end

vertical = split.select.with_index { |c, i| i.odd? && c.size > 0 }
vertical_count = vertical.size
vertical_max = vertical.join.size
vertical_length = vertical_max * 2 + 1
vertical_dp = Array.new(vertical_count + 1) { Array.new (vertical_length) }
vertical_dp[0][0] = true
vertical_count.times do |from|
  dp_next = vertical_dp[from + 1]
  step = vertical[from].size
  vertical_dp[from].each_with_index do |bool, index|
    next unless bool
    dp_next[(index + step) %  vertical_length] = true
    dp_next[(index - step) %  vertical_length] = true
  end
end

if x.abs <= horizontal_max && y.abs <= vertical_max && horizontal_dp.last[x] && vertical_dp.last[y]
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 127356
// https://atcoder.jp/contests/abc132/tasks/abc132_a

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 1; i < n - 1; i++) {
        if (v[i - 1] < v[i] && v[i] < v[i + 1] ||
            v[i - 1] > v[i] && v[i] > v[i + 1]) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

  if (N >= 2 and M >= 2) {
    cout << (N-2)*(M-2) << endl;
  } else if (N == 1 and M == 1) {
    cout << 1 << endl;
  } else if (N == 1 or M == 1) {
    cout << max(N, M) - 2 << endl;
  }
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }
    let mut diff = (60.0 * h + m) * 11.0 / 360.0;
    if diff < 0.0 {
        while diff < 0.0 {
            diff += 2.0;
        }
    } else {
        while diff >= 2.0 {
            diff -= 2.0;
        }
    }
    if diff > 1.0 {
        diff = 2.0 - diff;
    }
    let ans = (a * a + b * b - 2.0 * a * b * (diff * std::f64::consts::PI).cos()).sqrt();
    println!("{:.10}", ans);
}


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int expression();
int term();
int factor();
int number();

int now;
string s;

int expression(){
	int res=term();
		while(true){
		if(s[now]=='+')now++,res+=term();
		else if(s[now]=='-')now++,res-=term();
		else break;
	}
	return res;
}

int term(){
	int res=factor();
	while(true){
		if(s[now]=='(')res+=factor();
		else if(s[now]=='*')now++,res*=factor();
		else if(s[now]=='/')now++,res/=factor();
		else break;
	}
	return res;
}

int factor(){
	int res=0;
	if(s[now]=='(')now++,res=expression(),now++;
	else return number();
	return res;
}

int number(){
	int res=0;
	while('0'<=s[now] && s[now]<='9')res*=10,res+=s[now++]-'0';
	return res;
}


int main(void){
	int n;
	cin >> n;
	
	while(n--){
		cin >> s;
		now=0;
		cout << expression() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>

int main(){
  int x,n,i = 1;
  scanf("%d",&n);
  for( i ; i <= n ;i++){
    x = i;
    if( x % 3 == 0 ){
      printf(" %d",i);
    }else{
      while(1){
        if( x % 10 == 3){
          printf(" %d",i);
          break;
        }
        x /= 10;
        if(!x)break;
      }
    }
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2044
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = a*b;
		if (c%2==0) {
			System.out.println("Even");
		}else if (c%2==1) {
			System.out.println("Odd");
		}

	}
}

Measured memory_bytes: 21588
#include<stdio.h>
int main()
{
    int A,B,S;
    char C;
    scanf("%d ",&A);
    scanf("%c",&C);
    scanf("%d",&B);
    if(C=='+')
    {
        S=A+B;
        printf("%d\n",S);
    }
    else if(C=='-')
    {
        S=A-B;
        printf("%d\n",S);
    }
    return 0;
}


Measured memory_bytes: 128
import sys
import math

def isExponential(i : int) -> bool:
    for j in range(2,math.ceil(math.sqrt(i))+1):       
        devidend = i
        devisor = j
        #print(devidend,devisor,"inFor") 
        while 1:
            #print(devidend,devisor,"inWhile")
            if devidend % devisor != 0:
                break
            else:
                if devidend == devisor:
                    return True
                else:
                    devidend //= devisor
    return False

x = int(input())
if x == 1:
    print(1)
for i in range(x,0,-1):
    if isExponential(i) == True:
        print(i)
        #print("wtf")
        break

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1001001001001001001ll

using namespace std;

typedef pair<int, int> P;

class CClosedRooms {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }


    int dx[4] = {-1, 0, 0, 1};
    int dy[4] = {0, -1, 1, 0};

    int H, W, K;
    vector<vector<char>> A;
    vector<vector<int>> dist;

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> H >> W >> K;

        A = vector<vector<char>>(H, vector<char>(W));
        dist = vector<vector<int>>(H, vector<int>(W));
        int sx, sy;
        REP(i, H) {
            REP(j, W) {
                cin >> A[i][j];
                if (A[i][j] == 'S') {
                    sx = i, sy = j;
                }
                dist[i][j] = -1;
            }
        }

        queue<P> q;
        q.push({sx, sy});
        dist[sx][sy] = 0;
        while (!q.empty()) {
            int x, y;
            tie(x, y) = q.front();
            q.pop();
            REP(i, 4) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx < 0 || nx > H - 1 || ny < 0 || ny > W - 1) continue;
                if (A[nx][ny] == '#') continue;
                if (dist[nx][ny] >= 0) continue;
                dist[nx][ny] = dist[x][y] + 1;
                q.push({nx, ny});
            }
        }

        int res = INF;
        REP(i, H) {
            REP(j, W) {
                if (dist[i][j] != -1 && dist[i][j] <= K) {
                    int tmp = min({i, H - 1 - i, j, W - 1 - j});
                    res = min(res, (tmp + K - 1) / K);
                }
            }
        }
        cout << res + 1 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CClosedRooms solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6016
s = input()
a = s[:2]
b = s[2:]
b1 = 0
a1 = 0

if b[0] == '0': b1 = int(b[1])
else: b1 = int(b)
if a[0] == '0': a1 = int(a[1])
else: a1 = int(a)

if (b1>=1 and b1<=12) and (a1>=1 and a1<=12): print("AMBIGUOUS")
elif b1>=1 and b1<=12: print("YYMM")
elif a1>=1 and a1<=12: print("MMYY")
else: print("NA") 

Measured memory_bytes: 9080
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

struct SCC{//O(V+E)
    static const int MAX_V = 1e5+10;
    int V;
    vector<int> G[MAX_V], rG[MAX_V];
    vector<int> vs;
    bool used[MAX_V];
    int cmp[MAX_V];
    vector<vector<int> > res;


    SCC(int v) : V(v){assert(v < MAX_V);};
    void add_edge(int from, int to){
        G[from].push_back(to);
        rG[to].push_back(from);
    }

    void dfs(int v){
        used[v] = true;
        for(int i = 0; i < G[v].size(); i++){
            if(!used[G[v][i]]) dfs(G[v][i]);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k){
        used[v] = true;
        cmp[v] = k;
        for(int i = 0; i < rG[v].size(); i++){
            if(!used[rG[v][i]]) rdfs(rG[v][i], k);
        }
    }

    int scc(){
        memset(used, 0, sizeof(used));
        vs.clear();
        for(int v = 0; v < V; v++){
            if(!used[v]) dfs(v);
        }
        memset(used, 0, sizeof(used));
        int k = 0;
        for(int i = vs.size() - 1; i >= 0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++);
        }

        res.clear();
        res.resize(k);
        for(int i = 0; i < V; i++){
            res[cmp[i]].push_back(i);
        }
        return k;
    }
};

const int MAX_N = 1e5+10;
struct Edge{ int to, cost; };
vector<Edge> es[MAX_N];

int main(){
    int n, m;
    cin >> n >> m;
    SCC scc(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        scc.add_edge(a, b);
        es[a].pb({b, c});
    }
    scc.scc();
    map<int, ll> mp;
    auto v = scc.res;
    bool f = true;
    for(auto& x : v) {
        for(auto& y : x) {
            for(auto& e : es[y]) {
                int z = e.to;
                if(mp.count(y) && mp.count(z)) {
                    if(mp[z] - mp[y] != e.cost) f = false;
                }
                else if(mp.count(y)) {
                    mp[z] = mp[y] + e.cost;
                }
                else if(mp.count(z)) {
                    mp[y] = mp[z] - e.cost;
                }
                else {
                    mp[y] = 0LL;
                    mp[z] = e.cost;
                }
            }
        }
    }
    string yes = "Yes", no = "No";
    cout << (f ? yes : no) << endl;
    return 0;
}

Measured memory_bytes: 36220
#include <iostream>
#include <vector>
#include <map>

#define MOD 998244353

typedef long long ll;

using namespace std;

vector<ll> memoFact, memoInvFact;
map< ll, map<ll, ll> > memoComb;

ll addMod(ll a, ll b) {
    return (a + b) % MOD;
}

ll subMod(ll a, ll b) {
    return (a + MOD - b) % MOD;
}

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

ll mulMod(vector<ll> v) {
    if (v.size() == 0) return 1;
    ll a = v.back();
    v.pop_back();
    return mulMod(a, mulMod(v));
}

ll powMod(ll a, ll b) {
    if (b < 0) return 0;
    if (b == 0) return 1;
    if (b % 2) return mulMod(a, powMod(a, b - 1));
    ll c = powMod(a, b / 2);
    return mulMod(c, c);
}

ll divMod(ll a, ll b) {
    if (b < 0) return divMod(a, b + MOD);
    if (b == 0) throw runtime_error("Zero Division Occured!");
    if (b == 1) return a;
    return mulMod(a, powMod(b, MOD - 2));
}

ll factMod(ll a) {
    if (a < 0) throw runtime_error("Undefined value: factorial for negative number");
    if (memoFact.at(a)) return memoFact.at(a);
    if (a < 2) return memoFact.at(a) = 1;
    return memoFact.at(a) = mulMod(a, factMod(a - 1));
}

ll invFactMod(ll a) {
    if (a < 0) throw runtime_error("Undefined value: factorial for negative number");
    if (memoInvFact.at(a)) return memoInvFact.at(a);
    if (a == memoInvFact.size() - 1) return memoInvFact.at(a) = divMod(1, factMod(a));
    return memoInvFact.at(a) = mulMod(a + 1, invFactMod(a + 1));
}

ll combMod(ll a, ll b) {
    if (b * 2 > a) return combMod(a, a - b);
    if (a < b || b < 0) return 0;
    if (b == 0) return 1;
    if (memoComb[a][b]) return memoComb.at(a).at(b);
    return memoComb[a][b] = mulMod({factMod(a), invFactMod(b), invFactMod(a - b)});
}

int main() {
    ll n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    memoFact.resize(n + 1);
    memoInvFact.resize(n + 1);
    for (ll i = 0; a * i <= k; ++i) {
        ll j = k - a * i;
        if (j < 0 || j % b) continue;
        j /= b;
        ans = addMod(ans, mulMod(combMod(n, i), combMod(n, j)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23808
object Main extends App {
  val input = io.StdIn.readLine().split(" ").map(_.toInt)
  val N = input(0)
  val L = input(1)

  val apples = (1 to N).toArray
  val tastes = apples.map { a => L + a - 1 }
  val totalTaste = tastes.sum
  // 全てが正の時→最小の整数
  // 正と負の時→最小の整数
  // 全てが負の時→最大の整数

  val result = if (tastes.head >= 0) tastes.tail.sum
  else if (tastes.last <= 0) tastes.init.sum
  else {
    var isFound = false
    tastes.foldLeft(scala.collection.mutable.ArrayBuffer.empty[Int]) { (acc, v) =>
      if (isFound) {
        acc += v
      } else {
        if (v >= 0) {
          isFound = true
          acc
        } else {
          acc += v
        }
      }
    }.sum
  }

  println(result)
}


Measured memory_bytes: 25536
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

string s, t;
int dp[3010][3010] = {0};

int main() {
    cin >> s >> t;
    int n = s.size(), m = t.size();

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            }
        }
    }

    /* DPテーブルの確認
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            cout << dp[i][j];
        }
        cout << endl;
    }
    */

    // 復元
    string ans = "";
    int i = n, j = m;
    while (i > 0 && j > 0) {
        if (s[i-1] == t[j-1]) {
            // cout << i << " " << j << endl;
            ans += s[i-1];
            i--; j--;
        } else {
            if (dp[i-1][j] > dp[i][j-1]) i--;
            else j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 35584
import itertools

h, w, k = list(map(int, input().split()))
s = []
a = []
h_index = []
w_index = []
for i in range(h):
    h_index.append(i)
for i in range(w):
    w_index.append(i)
for i in range(h):
    s.append(input())
    a.append([])
    for j in s[i]:
        if(j == '.'):
            a[i].append(0)
        else:
            a[i].append(1)

ans = 0
h_list = []
for i in range(h+1):
    h_list.extend(list(itertools.combinations(h_index, i)))

w_list = []
for i in range(w+1):
    w_list.extend(list(itertools.combinations(w_index, i)))

for selected_hs in h_list:
    for selected_ws in w_list:
        for i in selected_hs:
            a[i] = [0] * w
        for j in selected_ws:
            for i in range(h):
                a[i][j] = 0
        kuro = 0
        for a_sub in a:
            kuro += sum(a_sub)
        if(kuro == k):
            ans += 1
        for i in range(h):
            for j in range(w):
                if(s[i][j] == '.'):
                    a[i][j] = 0
                else:
                    a[i][j] = 1

print(ans)


Measured memory_bytes: 9120
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  int n;
  vector<ll> c,s,f;
  cin>>n;
  ll x,y,z;
  c.pb(0);s.pb(0);f.pb(0);
  for(int i=1;i<n;i++){
    cin>>x>>y>>z;
    c.pb(x);
    s.pb(y);
    f.pb(z);
  }
  for(int i=1;i<=n-1;i++){
    ll ima=0;
    
    for(int j=i;j<=n-1;j++){
      if(ima<=s[j]){
	ima=s[j];
      }
      else if(ima%f[j]==0){
      }
      else{
	ima+=f[j]-(ima%f[j]);
      }
      ima+=c[j];
    }
    cout<<ima<<endl;
  }
  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ LL to, cost; edge(int t, LL c) :to(t), cost(c){} };

int dxk[] = { 1, 1, 1, 0, -1, 0 };
int dxg[] = { 0, 1, 0, -1, -1, -1 };
int dy[] = { -1, 0, 1, 1, 0, -1 };

int bitcount(int a)
{
	int ret = 0;
	while (a != 0) { ret++; a = (a - 1) & a; }
	return ret;
}

int main()
{
	int n, k;
	while (cin >> n && n)
	{
		cin >> k;
		vector<int> input;
		bool hasZero = false;
		rep(i, k)
		{
			int x; cin >> x;
			if (x == 0)
			{
				hasZero = true;
				continue;
			}
			input.push_back(x);
		}
		sort(all(input));

		vector<P> arr;
		arr.emplace_back(0, 1);
		for (int i = 1; i < input.size(); i++)
		{
			if (input[i] == input[i - 1] + 1)
				(--arr.end())->second++;
			else
				arr.emplace_back(i, 1);
		}

		int ans = 0;
		rep(i, arr.size()) ans = max(ans, arr[i].second);
		if(hasZero) rep(i, arr.size() - 1)
		{
			if (input[arr[i].first + arr[i].second - 1] + 2 == input[arr[i + 1].first])
			{
				ans = max(ans, arr[i].second + arr[i + 1].second + 1);
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    int i;
    int cnt=0;
    for(i=0; i<n; i++) {
        if(str[i]=='g') {
            if(i%2) cnt++;
        }
        else {
            if(i%2==0) cnt--;
        }
    }
    printf("%d\n", cnt);

    return 0;
}


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

const int MOD = 1000000007;

// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

//最小公倍数
int lcm(int number1,int number2){
	return number1 * number2 / gcd(number1,number2);	
}
  
int main(){
int N;
cin >> N;

vector<int>a(N);
REP(i,N){
    cin >> a[i];
}

int sum = 0;
REP(i,N){
    sum += a[i] - 1;
}

cout << sum << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;


vector<int> IntegerToVector(int bit, int N)
{
	vector<int> S;
	for(int i = 0; i < N; ++i)
	{
			S.push_back((bit >> i)&1);
	}
	return S;
}

int main()
{
	int n;cin >> n;
	vector<vector<int>> M(n,vector<int>());
	rep(i,n)
	rep(j,n)
	M[i].push_back(-1);
	rep(i,n)
	{
		int A;
		cin >> A;
		rep(j,A)
		{
			int foo,fooo;
			cin >> foo >> fooo;
			foo--;
			M[i][foo] = fooo;
		}
	}
	//rep(i,n){rep(j,n)cout<<M[i][j]<<' ';cout<<endl;}
	int ans = 0;
	for(int bit = 0; bit < (1 << n); ++bit)
	{
		vector<int> subbit = IntegerToVector(bit,n);
		//rep(i,n)cout<<subbit[i]<<' ';cout<<endl;
		bool mujun = false;
		int c=0;
		for(int i = 0;i<n;i++)
		{
			if(subbit[i]==1)
			{
				c++;
				for(int j=0;j<n;j++)
				{
					if(M[i][j]==1&&subbit[j]==0)mujun=true;
					if(M[i][j]==0&&subbit[j]==1)mujun=true;
				}
			}
		}
		if(mujun==false)ans = max(c,ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
dic = {}
for i in range(2, n+1):
    num = i
    for j in range(2, num+1):
        c = 0
        while num%j==0:
            c += 1
            num //= j
        if c > 0:
            if j in dic:
                dic[j] += c
            else:
                dic[j] = c
t, f, ft, tw = 0,0,0,0
end = 0
for _i, j in dic.items():
    if j >= 2:
        t += 1
        if j >= 4:
            f += 1
            if j >= 14:
                ft += 1
                if j >= 24:
                    tw += 1
                    if j >= 74:
                        end += 1

result = 0

result += end

result += tw*(t-1)

result += ft*(f-1)

result += f*(f-1)*(t-2)//2

print(result)

Measured memory_bytes: 38512
// while( !(succeed == try()) );

#include "bits/stdc++.h"
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	int x;
	cin>>x;

	int p = 100;
	loop(i,1,3761)
	{
		int t = p * 1.01;
		p = t;

		if(p>=x)
		{
			cout<<i<<endl;
			return;
		}

	}
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	int ans;
	bool v = true;
	ans = 1;
	scanf("%d", &n);
	scanf("%d %d", &x,&y);
	f(i, n){
		scanf("%d", &z);
		a[z]++;
	}

	k = 0;
	f(i, x+1)k+=a[i];
	ans = k;
	k = 0;
	for (int i = x + 1; i <= y; i++)k+=a[i];
	ans =min(ans,k);
	k = 0;
	for (int i = y + 1; i <= 30; i++)k+=a[i];
	ans = min(ans, k);

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


	return 0;
}

Measured memory_bytes: 896
=begin
  1, ２次元配列でH*Wのマスを作る
  2, (0,0)から順に文字を受け取る
    2.1, '#'を受け取ったらスキップ
    2.2, '.'だった場合は、以下の操作を行う
      2.2.1, 受け取った地点の周囲を探索し、'#'があればcountを増やす
      2,2,2, '.' をカウントに置き換える
  3, 探索が終了した配列を出力する
=end

dx = [-1, -1, -1, 0, 1, 1, 1, 0]
dy = [-1, 0, 1, 1, 1, 0, -1, -1]

board = []
H, W = gets.split.map(&:to_i)
H.times do board << gets.chomp.chars end

0.upto(H-1){|i|
  0.upto(W-1){|j|
    next if board[i][j] == '#'
    cnt = 0
    8.times do |k|
      x = i + dx[k]
      y = j + dy[k]
      next if x < 0 || x >= H || y < 0 || y >= W
      cnt += 1 if board[x][y] == '#'
    end
    board[i][j] = cnt
  }
}

board.each{|v|
  puts v.join('')
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string s, t;
  cin >> s >> t;

  if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) cout << "YES";
  else cout << "NO";
  return 0;
}


Measured memory_bytes: 256
const Main = (input) => {
  const tmp = input.trim().split('\n')
  const employees = parseInt(tmp[0])
  const subordinateArray = tmp[1].split(' ').map((n) => parseInt(n))
  const resultArray = []

  for (let i = 0; i < employees; i++) {
    resultArray.push(0)
  }

  for (let j = 0; j < subordinateArray.length; j++) {
    resultArray[subordinateArray[j] - 1] += 1
  }
  result = resultArray.join('\n')

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 57248
import numpy

n, d = map(int, input().split())

l = []
for v in range(n):
    l.append(list(map(int, input().split())))

ans = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        a = numpy.array(l[i])
        b = numpy.array(l[j])
        c = numpy.linalg.norm(b - a)
        if (c.is_integer()):
            ans += 1

print(ans)


Measured memory_bytes: 12504
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; }
typedef pair<ll,ll> pll;
const ll mn=2e4+4;
ll a[mn],b[mn],p[mn];
int main() {
	ll n; scanf("%lld",&n);
	for (ll x=0;x<n;x++) {
		ll y; scanf("%lld",&y);
		p[x]=y-1;
	}
	ll k=n+1;
	for (ll x=0;x<n;x++) {
		a[x]=(x*k)+1;
		b[x]=(k-x-1)*k+1;
	}
	for (ll i=0;i<n;i++) {
		ll x=p[i];
		a[x]+=i;
	}
	for (ll i=1;i<n;i++) {
		assert(a[i-1]<a[i]);
		assert(b[i-1]>b[i]);
		ll x=p[i],l=p[i-1];
		assert(a[l]+b[l]<a[x]+b[x]);
	}
	for (ll x=0;x<n;x++) printf("%lld ",a[x]);
	printf("\n");
	for (ll x=0;x<n;x++) printf("%lld ",b[x]);
	printf("\n");
}

Measured memory_bytes: 1024
a,b = map(int, input().split())

N=100
ans = [["#" for _ in range(N)] for _ in range(N)]

for i in range(N):
    for j in range(N//2,N):
        ans[j][i]="."

for i in range(0,N,2):
    if a==1:
        break
    for j in range(0,N,2):
        ans[i][j]="."
        a-=1
        if a==1:
            break

for i in range(1+N//2,N,2):
    if b==1:
        break
    for j in range(0,N,2):
        ans[i][j]="#"
        b-=1
        if b==1:
            break

print(100,100)
for i in range(N):
    print(*ans[i],sep="")

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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0){
            if(a[i] % 3 == 0) continue;
            else if(a[i] % 5 == 0) continue;
            else{
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

int firstA(string S) {
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A') {
            return i;
        }
    }
}

int lastZ(string S) {
    for (int i = S.size() - 1; i >= 0; i--) {
        if (S[i] == 'Z') {
            return i;
        }
    }
}


int main(){
string S; cin >> S;
cout << lastZ(S) - firstA(S) + 1 << endl;

}

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

const int N = (int) 1e5 + 5;

int n;
vector <int> g[N];
vector <pair <int, int> > edge;
map <pair <int, int>, int> colorEdge;
bool used[N];
int c[N];

int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		edge.push_back({u, v});
		g[u].push_back(v);
		g[v].push_back(u);
	}
	queue <int> q;
	q.push(1); used[1] = true;
	int nColor = 0;
	while (!q.empty()) {
		int u = q.front(); q.pop();
		nColor = max(nColor, (int) g[u].size());
		int cur = 1;
		for (auto v: g[u]) {
			if (used[v]) continue;
			if (cur == c[u]) cur++;
			c[v] = colorEdge[{u, v}] = colorEdge[{v, u}] = cur++;
			used[v] = true;
			q.push(v);
		}
	}
	cout << nColor << "\n";
	for (auto e: edge) cout << colorEdge[e] << "\n";
	return 0;
}


Measured memory_bytes: 19832
const N,K=map(x->parse(Int,x),split(readline()))
const A=sort(map(x->parse(Int,x),split(readline())))
function main()
	L=2*-10^18
	R=2*10^18
	while R-L>1
		M=div(L+R,2)
		now=0
		for a in A
			if a*a<=M
				now-=1
			end
			if a==0
				if M>=0
					now+=N
				end
			elseif a>0
				l=0
				r=N+1
				while r-l>1
					m=div(l+r,2)
					if A[m]*a<=M
						l=m
					else
						r=m
					end
				end
				now+=l
			else
				l=0
				r=N+1
				while r-l>1
					m=div(l+r,2)
					if A[m]*a<=M
						r=m
					else
						l=m
					end
				end
				now+=N-l
			end
		end
		if now>=K*2
			R=M
		else
			L=M
		end
	end
	println(R)
end
main()

Measured memory_bytes: 126376