akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        a: [i64; 3],
    }
    puts!("{}\n", if a.iter().filter(|&&x| x % 2 == 0).count() >= 2 { "Tem" } else { "Hom" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



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

string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	if(s == "Sunny")
		cout << "Cloudy";
	else if(s == "Cloudy")
		cout << "Rainy";
	else
		cout << "Sunny";
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  string N;
  cin>>N;
  string ans="No";
  if(N.at(0)=='9')ans="Yes";
  else if(N.at(1)=='9')ans="Yes";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#!/usr/bin/env python3
x, y, *p = map(int, open(0).read().split())
if y == 0:
    print(x)
    quit()
a = []
for i in range(min(p)-1, max(p)+2):
    if i not in p:
        a += [(abs(x-i), i)]
a.sort(key=lambda x: (x[0], x[1]))
print(a[0][1])


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

int main() {
    int r, c;
    cin >> r >> c;
    int A[r+1][c+1];
    int sumi[c+1], sumj;
    for (int i = 0; i < r+1; i++){
        for (int j = 0; j < c+1; j++){
            sumi[j] = 0;
            A[i][j] = 0;
        }

    }

    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < r + 1; i++){
        if (i < r){
            sumj = 0;
            for (int j = 0; j < c + 1; j++){
                if (j < c) sumj += A[i][j];
                else A[i][j] = sumj;
                sumi[j] += A[i][j];
            }
        }
        else{
            for (int j = 0; j < c + 1; j++){
                A[i][j] = sumi[j];
            }
        }

    }

    for (int i = 0; i < r+1; i++){
        for (int j = 0; j < c+1; j++){
            if (j < c) cout << A[i][j] << " ";
            else cout << A[i][j];

        }
        cout << "\n";
    }

    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long n,m,v,p;
    cin>>n>>m>>v>>p;

    vector<long long> a(n);
    rep(i,n)cin>>a[i];

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    long long sum[n+1];
    sum[0]=0;
    rep(i,n)sum[i+1]=sum[i]+a[i];

    long long border=a[p-1];
    long long ans=0;
    for(long long i=0;i<n;i++){
        if(a[i]>=border){
            ans++;
        }
        else{
            long long  L=n-(i+1);
            long long voter=v-(L+1);
            long long res=m*voter;
            if(voter<=0 && a[i]+m>=border){
                ans++;
            }
            else if(voter<p && a[i]+m>=border){
                ans++;
            }
            else if(voter>=p){
                voter-=(p-1);
                res=voter*m;
                //残りのresを分配する
                long long new_border=a[i]+m;
                if(a[p-1]>new_border){
                    continue;
                }
                else{
                long long mergin=new_border*(i-(p-1))-(sum[i]-sum[p-1]);
                res-=mergin;
                }
                /*
                for(int k=p-1;k<i;k++){
                    if(new_border<a[k])break;
                    res-=new_border-a[k];
                }*/
                if(res<=0)ans++;
            }
        }
    }

    cout<<ans<<endl;
    return 0;

}
/*


*/


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string ans;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){ans+='0';}
        else if(s[i]=='1'){ans+='1';}
        else if(s[i]=='B'){
            if(ans.size()==0){continue;}
            else ans.erase(ans.size()-1,1);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define LOOP(i,first,end) for(int i=(first);i<(end);i++)
#define ULL unsigned long long
#define LL long long
#define VULL vector<ULL>
#define VLL vector<LL>
#define VINT vector<int>

int main(void){
	int n;
	VINT p;

	cin >> n;
	p.resize(n);
	LOOP(i, 0, n)cin >> p[i];

	int count = 0;
	LOOP(i, 1, n - 1)if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1]))count++;
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	cout<<t<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;

ll _abs(ll a)
{
	return a>0?a:-a;
}

ll gcd(ll a,ll b)
{
	return !b?a:gcd(b,a%b);
}

ll mul(ll a,ll b,ll c)
{
	ll res=a*b-((ll)((long double)a*b/c+0.5)*c);
	return res<0?res+c:res;
}

ll fexp(ll a,ll b,ll c)
{
	ll x=1,o=a;
	for(;b;b>>=1,o=mul(o,o,c))
		if(b&1)x=mul(x,o,c);
	return x;
}

int judge(ll n)
{
	if(n<2)
		return 0;
	static int pr[]={2,3,5,7,11,13,17,19,23,29};
	for(int p:pr)
		if(n%p==0)
			return n==p;
	ll m=n-1;
	int k=0;
	while(~m&1)
	{
		++k;
		m>>=1;
	}
	for(int p:pr)
	{
		ll x=fexp(p,m,n),y;
		for(int j=0;j<k;++j)
		{
			y=mul(x,x,n);
			if(y==1&&x!=1&&x!=n-1)
				return 0;
			x=y;
		}
		if(x!=1)
			return 0;
	}
	return 1;
}

ll find(ll n)
{
	if(~n&1)
		return 2;
	ll c=rand()%(n-1)+1,x,y,z,k=1;
	x=y=0;
	for(int d=2;;d<<=1)
	{
		for(int i=1;i<=d;++i)
		{
			x=(mul(x,x,n)+c)%n;
			k=mul(k,_abs(x-y),n);
			if(!(i&127) && (z=gcd(k,n))>1)
				return z;
		}
		if((z=gcd(k,n))>1)
			return z;
		y=x;
	}
}

void divide(ll n,map<ll,int>& m)
{
	if(n==1)
		return;
	if(judge(n))
	{
		m[n]++;
		return;
	}
	ll d=find(n);
	divide(d,m);
	divide(n/d,m);
}

int n,ans;
ll x;

map<ll,int> cnt;
map<ll,ll> rev;
set<ll> s;

//考虑把质数幂次模3，那么每个集合唯一对应一个集合，不同集合对之间独立，可以贪心。 

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		scanf("%lld",&x);
		map<ll,int> fact;
		divide(x,fact);
		ll y=1,z=1;
		for(auto &u:fact)
		{
			int k=u.second%3;
			if(k==1)
				y*=u.first,z*=u.first*u.first;
			if(k==2)
				y*=u.first*u.first,z*=u.first;
		}
		s.insert(y);
		rev[y]=z;
		cnt[y]++;
	}
	while(!s.empty())
	{
		ll x=*s.begin(),y=rev[x];
		ans+=(x==1?1:max(cnt[x],cnt[y]));
		s.erase(x);s.erase(y);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 23168
import math
num=int(input())
n=[]
for i in range(num):
    b=int(input())
    if b==2 or b%2!=0:
        n.append(b)
count=0
for i in n:
    a=0
    for j in range(1,int(math.sqrt(i))+1):
        if i%j==0:
            a+=1
            if a>1:
                break
    if a==1:
        count+=1
print(count)


Measured memory_bytes: 5776
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){

	int sum = 0;
	char ch;


	while (1){
		while ((ch = getchar()) != '\n'){
			sum += ch - '0';
		}
		if (sum == 0){
			break;
		}
		else{
			cout << sum << endl;
			sum = 0;
		}
	}

}


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

#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];
    int ans = 0;
    while(true) {
        int f = 0;
        for(int i=0; i<n; ++i) {
            if(v[i]%2!=0) {
                f++;
                break;
            }
        }
        if(f) break;
        for(int i=0; i<n; ++i) v[i] /= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	ll n,k,ans=0;
	cin>>n>>k;
	while(n)
	{
		ans++;
		n/=k;
	}
	cout<<ans;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
	
int main(){
	vector <long long> A, B;
	long long K;
	long long N, M;
	cin>>N>>M>>K;
	vector<long long> Sum_A(N + 1, 0), Sum_B(M + 1, 0);
	int tmp;
	Sum_A.push_back(0);
	for(int i = 1; i<=N; i++){
			cin>>tmp;
			A.push_back(tmp);
			Sum_A[i] = Sum_A[ i - 1] + tmp;
		}
	Sum_B.push_back(0);
	for(int i = 1; i<=M; i++){
		cin>>tmp;
		B.push_back(tmp);
		Sum_B[i] = Sum_B[ i - 1 ] + tmp;
		}
	int ans = 0;
	long long p = M;
	for(int i = 0; i<=N; i++){
		for(int j = p; j>=0; j--){
			if( Sum_A[i] + Sum_B[j] <= K){
				if( ans < i + j){
				ans = i + j;
				}
				p = j;
				break;
			}
		}
	}
	cout<<ans<<endl;
		
	
	return 0;	
}

Measured memory_bytes: 11556
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;

int n, a[100005];
int dp[MAX];

int main()
{
	   cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i-1] + abs (a[i] - a[i-1]);
        if(i > 2){
            dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n]<<endl;
    return 0;
} 


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

using Bits = bitset<4 * 80 * 80 + 1>;
int h, w;
int a[80][80];
Bits dp[80][80];

int solve() {
  const int kmax = 2 * 80 * 80;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int diff = a[i][j];
      if (i == 0 && j == 0) {
        dp[i][j][kmax + diff] = true;
        dp[i][j][kmax - diff] = true;
      } else {
        Bits sum;
        if (i > 0) {
          sum |= dp[i - 1][j] << diff;
          sum |= dp[i - 1][j] >> diff;
        }
        if (j > 0) {
          sum |= dp[i][j - 1] << diff;
          sum |= dp[i][j - 1] >> diff;
        }
        dp[i][j] = sum;
      }
    }
  }
  
  for (int k = 0; k <= kmax; ++k) {
    if (dp[h - 1][w - 1][kmax + k]) return k;
    if (dp[h - 1][w - 1][kmax - k]) return k;
  }
  return 1e9;
}

void input() {
  cin >> h >> w;
  int tmp[80][80];
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> tmp[i][j];
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int buf;
      cin >> buf;
      a[i][j] = abs(buf - tmp[i][j]);
    }
  }
}

int main() {
  input();
  cout << solve() << endl;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	int ans;
	ans = max(a+b,a-b);
	ans = max(ans, a*b);
	cout << ans << endl;
	return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  string s;
  cin >> n >> s;
  vector<vector<int>> pos(10);
  for (int i = 0; i < n; i++) {
    int index = s[i] - '0';
    pos[index].push_back(i);
  }
  int ret = 0;
  for (int i = 0; i <= 999; i++) {
    int tmp = i;
    int x1 = tmp / 100;
    tmp %= 100;
    int x2 = tmp / 10;
    int x3 = tmp % 10;
    int p = -1;
    auto itr1 = upper_bound(pos[x1].begin(), pos[x1].end(), p);
    if (itr1 == pos[x1].end()) continue;
    p = *itr1;

    auto itr2 = upper_bound(pos[x2].begin(), pos[x2].end(), p);
    if (itr2 == pos[x2].end()) continue;
    p = *itr2;

    auto itr3 = upper_bound(pos[x3].begin(), pos[x3].end(), p);
    if (itr3 == pos[x3].end()) continue;

    ret++;
  }
  cout << ret << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
    int v;
    color[u]=GRAY;
    d[u]=++tt;
    for(v=0;v<n;v++){
	if(M[u][v]==0) continue;
	if(color[v]==WHITE){
	    dfs_visit(v);
	}
    }
    color[u]=BLACK;
    f[u]=++tt;
}

void dfs(){
    int u;
    
    for(u=0;u<n;u++) color[u]=WHITE;
    tt=0;

    for(u=0;u<n;u++){
	if(color[u]==WHITE) dfs_visit(u);
    }
    for(u=0;u<n;u++){
	printf("%d %d %d\n",u+1,d[u],f[u]);
    }
}

int main(){
    int u,k,v,i,j;

    scanf("%d",&n);
    for(i=0;i<n;i++){
	scanf("%d%d",&u,&k);
	u--;
	for(j=0;j<k;j++){
	    scanf("%d",&v);
	    v--;
	    M[u][v]=1;
	}
    }

    dfs();

    return 0;
}

Measured memory_bytes: 636
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n; cin >> n;
    cout << n * n * n << endl;

    return 0;
}

Measured memory_bytes: 256
A = [0]*100201
A[0] = 1

for i in range(100000):
    if A[i]:
        A[i+100] = 1
        A[i+101] = 1
        A[i+102] = 1
        A[i+103] = 1
        A[i+104] = 1
        A[i+105] = 1

print(A[int(input())])


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb,lc,lx;
  double da,db,dc;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  rep(i,0,a){
    cin >> c;
    if(c >= b) ans++;
    
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
// Hack it and have it ;) //
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows!* * * * * * */
#include      <bits/stdc++.h>
using namespace std;
#define IOS       ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC      cout.precision (10); cout << fixed
#ifdef CONVICTION
#include "/home/convict/Dropbox/myfiles/sport_coding/cplib/snippets/debug.h"
#else
#define debug(x...)
#endif
//Don’t practice until you get it right. Practice until you can’t get it wrong

void preproc() {
}

void solve() {
   int N;
   cin >> N;
   vector <int> ar(N);
   map <int, int> mp;
   long long sm = 0;
   for (int i = 0; i < N; ++i) {
      cin >> ar[i];
      ++mp[ar[i]];
      sm += ar[i];
   }

   int Q;
   cin >> Q;
   while (Q--) {
      int B, C;
      cin >> B >> C;
      int occ = mp[B];
      sm += 1ll*occ*(C - B);
      mp[B] = 0;
      mp[C] += occ;
      cout << sm << '\n';
   }
   return;
}

signed main() {
  IOS; PREC;
  preproc();

  int tc = 1;
  // cin >> tc;
  for (int Tt = 1; Tt <= tc; ++Tt) {
    // cout << "Case #" << Tt << ": ";
    solve();
  }
  return EXIT_SUCCESS;
}


Measured memory_bytes: 8268
def solve():
    N, M = map(int, input().split())
    lst = [-1] * N
    for i in range(M):
        s, c = map(int, input().split())
        if s == 1 and c == 0 and N > 1:
            return -1
        elif lst[s-1] == -1:
            lst[s-1] = c
        elif lst[s-1] == c:
            continue
        else:
            return -1
    ans = ''
    for i in range(N):
        if lst[i] == -1:
            if i or N == 1:
                ans += '0'
            else:
                ans += '1'
        else:
            ans += str(lst[i])
    return ans

print(solve())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

struct mint {
    long long x;
    mint(long long _x=0):x((_x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    ll sum = accumulate(all(A), 0LL);
    mint ans = 0;
    rep(i,N){
        ans += mint(A[i]) * mint(sum - A[i]);
    }
    cout << ans * mint(2).inv() << endl;
}


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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

string s;
ll dp[3000][3000];//dp[i][j] := i番目(0-idx)の数字を決定して, jこの未使用の数字が決定された数字よりも大きいときの場合の数
ll ruisekiwa[2][3001];

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

	auto sum_f = ruisekiwa[0], sum_s = ruisekiwa[1];

	sum_f[0] = 0;
	for (int i = 0; i < N; i++) {
		dp[0][i] = 1;
		sum_f[i + 1] = (sum_f[i] + dp[0][i]) % MOD;
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < N; j++)sum_s[j] = 0;
		for (int j = 0; j < N; j++) {
			if (s[i - 1] == '<') {
				//前の数字より大きくないといけないとき、dp[i][j] = sigma(dp[i - 1][(j + 1) ~ (N - i)])
				//今の時点で今の数字より多いのがj個あるとき、一つ前としてありうるのは(j + 1) ~ (N - i)個の全部
				if(N - i >= j + 1)dp[i][j] = (sum_f[N - i + 1] - sum_f[j + 1] + MOD) % MOD;
				sum_s[j + 1] = (sum_s[j] + dp[i][j]) % MOD;
			}
			else {
				//前の数字より小さくないといけないとき、dp[i][j] = sigma(dp[i - 1])
				//今の時点で今の数字より少ないのが(N - 1 - i - j)個あるとき、
				//一つ前としてありうるのは(N - i - j) ~ (N - i)個の全部(今の場所より小さい数字の個数)
				//つまり今より大きい個数に直すと、0 ~ j 個の全部
				if(j >= 0)dp[i][j] = (sum_f[j + 1] - sum_f[0] + MOD) % MOD;
				sum_s[j + 1] = (sum_s[j] + dp[i][j]) % MOD;
					
			}
		}
		swap(sum_f, sum_s);
	}
	
	cout << dp[N - 1][0] << endl;

	return 0;
}


Measured memory_bytes: 70656
var str=readLine()!

for num in 0...3{
  let a=str.index(str.startIndex,offsetBy:num)
  let b=str.index(str.startIndex,offsetBy:num+1)

  if str[a]==str[b] {
    print("Bad")
    break;
  }
  else if num==3 {
    print("Good")
  }
}

Measured memory_bytes: 7708
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <string.h>
using namespace std;
using ll = long long;
typedef pair <int, int> pii;

//void kansuu(int n, string t)
//{
//	if (n == len)
//	{
//		//cout << t << endl;
//
//		int z = 0;
//		string u,v;
//		//cout << stoll(t) << endl;
//		while (1)
//		{
//			if (z==t.length()-1)
//			{
//				u += t[z];
//				//cout << "last sum+=" << stoll(u) << endl;
//
//				sum += stoll(u);
//				return;
//			}
//			else if (t[z] == 'a')
//			{
//				//cout <<"sum+="<< stoll(u) << endl;
//
//				sum += stoll(u);
//				z++;
//				u = v;
//				/*u = t[z];
//				z++;*/
//			}
//			else
//			{
//				u += t[z];
//			z++;
//			}
//		}
//
//		return;
//	}
//	/*sum += stoll(t);
//	cout << stoll(t) << endl;
//*/
//	t += s[n];
//	//t = "aaaaaaa";
//	/*sum += stoll(t);
//	cout << stoll(t) << endl;
//
//	t = s[n];*/
//	kansuu(n + 1, t);
//	//t += "a";
//	if (n!=s.length()-1)
//	{
//
//	t += "a";
//	kansuu(n + 1, t);
//	}
//	return;
//}
ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	ll P[11];
	ll C[11];
void kansuu(ll score, ll num, ll (&solved)[11], ll solveNum)
{
	for (d = 1; d <= a; d++)
	{
		//cout << "solved[d]=" << solved[d] << endl;
	}
	while (score<b&&P[solveNum]>solved[solveNum])
	{
		score += solveNum * 100;
		solved[solveNum]++;
		num++;
		//cout << "ccccccccccccc" << endl;
		//cout << "score=" << score << endl;
	}
	if (P[solveNum]==solved[solveNum])
	{
		score += C[solveNum];
		/*cout << "aaaaaaaaaaaaa" << endl;
		cout << "solveNum=" << solveNum << endl;
		cout << "score=" << score << endl;
		cout << "num=" << num << endl;
		cout << "solved[solveNum]=" << solved[solveNum] << endl;
*/
	}
	if (score>=b)
	{
		//cout << "num=" << num << endl;
		//cout << "l=" << l << endl;
		//cout << "score=" << score << endl;
		//cout <<"solveNum="<< solveNum << endl;

		l = min(l,num);
		return;
	}
	ll copy[11] = { 0 };
	memcpy(copy, solved, sizeof(ll) * 11);
	for (int i = 1; i <= a; i++)
	{
		if (solved[i]==0)
		{
			kansuu(score, num, solved, i);
			memcpy( solved, copy, sizeof(ll) * 11);

		}
	}




	return;
}
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long long n, A[1000000000];
	ll n, m, q;
	//int   y[100001], z[100001], x[10001] = {};
	//pii y[100001];
	//pair<int, float> pii[100001];
	string s;
	//cin >> s;
	//x = s[0];
	//x = '0';
	cin >> a;
	cin >> b;
	ll sol[11] = { 0 };
	for (c = 1; c <= a; c++)
	{
		cin >> P[c];
		cin >> C[c];
	}
	l = 100000000;
	for (c = 1; c <= a; c++)
	{
		//cout << "bbbbbbbbbbbbbbbbbbbbb" << endl;
		for ( d = 1; d <= a; d++)
		{
			//cout << "P[c]=" << P[d] << endl;
			//cout << "C[c]=" << C[d] << endl;
			//cout << "sol[c]=" << sol[d] << endl;

		}
		//kansuu(0, 0, (&sol)[11], c);
		for ( d = 1; d <= a; d++)
		{
			sol[d] = 0;
		}
		kansuu(0, 0, sol, c);
	}
	

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;
	cout << l << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MN 200001
using namespace std;

const int MOD=1e9+7;
int qa[MN],qb[MN],n,x,y,X,Y;
char a[MN],b[MN];
int main(){
	scanf("%s%s",a+1,b+1);
	for (int i=1;a[i];i++) qa[i]=qa[i-1]+a[i]-'A'+1;
	for (int i=1;b[i];i++) qb[i]=qb[i-1]+b[i]-'A'+1;
	scanf("%d",&n);
	while(n--){
		scanf("%d%d%d%d",&x,&y,&X,&Y);
		puts((qa[y]-qa[x-1])%3==(qb[Y]-qb[X-1])%3?"YES":"NO");
	}
}

Measured memory_bytes: 1536
function prime(max){
   var arr=[];
   for(var i=0;i<=max;i++)arr[i]=i;
   arr[0]=false;
   arr[1]=false;
   var sqrt=Math.floor(Math.sqrt(max));
   for(var i=2;i<=sqrt;i++){
      if(arr[i]==false)continue;
         for(var j=i+i;j<=max;j+=i){
            arr[j]=false;
         }
   }
   var result={};
   for(var i=0;i<=max;i++){
      if(arr[i]!==false)result[arr[i]]=true;
   }
   return result;
}
var p=prime(1000000);

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var I=0;I<Arr.length;I++){
   var v=Arr[I];
   if(v==0)break;
   var cnt=0;
   var obj={};
   for(var k in p){
      if(k>=v)break;
      if(obj.hasOwnProperty(k))continue;
      obj[v-k]=true;
      if(p.hasOwnProperty(v-k))cnt++;
   }
   console.log(cnt);
}

Measured memory_bytes: 51320
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define pob pop_back();
#define for_t int t;cin>>t;while(t--)
#define MOD 1000000007
#define fi first
#define se second
#define le length
#define debug(n1) cout << n1 << endl
#define set_bits(n) __builtin_popcount(n);
#define rep(i , j , n) for(ll i = j ; i <= n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef map<int, int>mapp;
 
int stoif(string num){
    stringstream geek(num);
    int x = 0; 
    geek >> x; 
    return x;
}   
 
int main() {
    SPEED;
    int n;
    cin>>n;
    vi vec(n);
    rep(i,0,n-1){
        cin>>vec[i];
        vec[i]--;
    }
    vi sat(n);
    rep(i,0,n-1){
        cin>>sat[i];
    }
    vi adsat(n-1);
    rep(i,0,n-2){
        cin>>adsat[i];
    }
    ll ans = 0;
    ans = ans+sat[vec[0]];
    rep(i,1,n-1){
        if(vec[i]==vec[i-1]+1){
            ans = ans + adsat[vec[i-1]];
        }
        ans=ans+sat[vec[i]];
    }
    cout<<ans;
}

Measured memory_bytes: 256
//P2E
#include <bits/stdc++.h>
//#define double long double
using namespace std;
typedef long long ll;
const double PI = 3.1415926535;
const int maxn = 2e5+10;
const double eps = 1e-10;
bool flag = 0;
double a,h,x,maxdeg,delta;
bool judge(double deg){
	double tmp;
	if(flag)tmp = (h - a*tan(deg*PI/180)/2)*a*a;
	else tmp = a*h*h/2/tan(deg*PI/180);
//	cout << tmp << endl;
//	if(tmp < 0)tmp = (a*tan((90.0-deg)*PI/180)/2)*a*a;
//	cout << tmp<< endl;
	return (tmp - x) >= eps;

////	cout <<  << "yay" << endl;
//	return (h - a*tan(deg*PI/180)/2)*a*a >= x;
}
int main(){
	cin >> a >> h >> x;
//	x = a*a*h - x;
	if(x > a*a*h/2)flag = 1;
	if(x == a*a*h/2){
		printf("45.00000000");
		return 0;
	}
	double L = 0,R = 90,M;
	while(L <= R){
		M = (R+L)/2;
		delta = M;
		if(judge(M))L = M+eps;
		else R = M-eps;
		delta -= (R+L)/2;
//		cout << delta << endl;
	}
	printf("%.12lf",M);
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
indices = []
for _ in range(m):
  s_map = map(int, input().split())
  next(s_map)
  indices.append([s-1 for s in s_map])
p = list(map(int, input().split()))
count = 0
for i in range(1 << n):
  list_i = [int(bit) for bit in format(i, '0{}b'.format(n))]
  flag = True
  for j in range(m):
    on = 0
    for idx in indices[j]:
      on ^= list_i[idx]
    if on != p[j]:
      flag = False
      break
  if flag:
    count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int a, b;
	int cnt = 0;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		for (int j = 0; j <= s.size() / 2; j++) {
			if (s[j] != s[s.size() - 1 - j]) {
				break;
			}
			if (j == s.size() / 2) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

ll g(ll n, ll x){
    ll len = pow(2,n+1)-3;
    ll p = pow(2,n)-1;
    if(n == 0) return 1;
    
    if(x == 1) return 0;
    else if(x <= len+1) return g(n-1,x-1);
    else if(x == len+2) return p+1;
    else if(x<=(len*2)+2) return p+1+g(n-1,x-len-2);
    else return p*2+1;
}

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

    ll n,x;
    cin>>n>>x;
    cout<<g(n,x)<<endl;

}

Measured memory_bytes: 4076
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string a, s, c;
    cin >> a  >> s >> c;
    cout << 'A' << s[0] << 'C';
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
INF = 1e12


def dijkstra(graph, source):
    lg = len(graph)
    unused = list(range(lg))
    d = [INF] * (lg)
    d[source] = 0

    while unused:
        v = min(unused, key=lambda u: d[u])
        unused.remove(v)
        for u in range(n + 1):
            d[u] = min(d[u], d[v] + graph[v][u])

    return d

n = int(input())
m = int(input())

cost = [[INF] * (n + 1) for i in range(n + 1)]
for i in range(m):
    ai, bi, ci, di = map(int, input().split(','))
    cost[ai][bi] = ci
    cost[bi][ai] = di

x1, x2, y1, y2 = map(int, input().split(','))

d_go = dijkstra(cost, x1)[x2]
d_back = dijkstra(cost, x2)[x1]

print(y1 - y2 - d_go - d_back)

Measured memory_bytes: 6776
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int N, M, R;
int r[8];
int dp[200][1<<8];
int d[200][200];

int main() {
	cin >> N >> M >> R;
	REP(i, R) scanf("%d", r + i), r[i]--;
	
	fill(d[0], d[N], INF);
	REP(i, M) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		chmin(d[a][b], c);
		chmin(d[b][a], c);
	}
	REP(i, N) d[i][i] = 0;
	
	REP(k, N) REP(i, N) REP(j, N) chmin(d[i][j], d[i][k] + d[k][j]);
	
	fill(dp[0], dp[N], INF);
	REP(i, N) dp[i][0] = 0;
	REP(i, R) dp[r[i]][1<<i] = 0;
	
	REP(i, 1<<8) {
		REP(j, N) {
			if (dp[j][i] == INF) continue;
			
			REP(k, N) chmin(dp[k][i], dp[j][i] + d[j][k]);
			REP(k, R) chmin(dp[r[k]][i | (1<<k)], dp[j][i] + d[j][r[k]]);
		}
	}
	
	int ans = INF;
	REP(i, N) chmin(ans, dp[i][(1<<R)-1]);
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define N 100000
using namespace std;
void fast()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}
ll f(ll n)
{
    ll cnt=0;
    for(ll i=10;n/i>=1;i*=5)
        cnt+=n/i;
    return cnt;
}
int main()
{
    fast();
    ll n;cin>>n;
    cout<<(n%2?0:f(n));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    priority_queue<int> que;
    que.push(a);
    que.push(b);
    que.push(c);

    rep(i, k) {
        int t = que.top();
        que.pop();
        t *= 2;
        que.push(t);
    }

    int res = 0;
    while (!que.empty()) {
        res += que.top();
        que.pop();
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

int n,a,b;cin>>n>>a>>b;
  vector<ll>p(n);rep(i,n){cin>>p.at(i);}
  sort(all(p));
  
  int am=0,bm=0,cm=0;
  rep(i,n){if(p.at(i)<=a)am++;else{break;}}
  rep(i,n){if(p.at(i)<=b&&p.at(i)>a)bm++; if(p.at(i)>b){break;}}
  rep(i,n){if(p.at(i)>b)cm++;}
  int ans=min(am,bm);
  int answer=min(ans,cm);
  cout<<answer<<endl;
  
  
  
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int i, j, n;
	long k,q;
	int a;

	cin >> n >> k >> q;

	vector<long> data(n,0);

	for (i = 0; i < q; i++) {
		cin >> a;
		data[a - 1] += 1;
	}

	for (i = 0; i < n; i++) {
		if ( k - (q - data[i]) > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;

}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    
    while (cin >> n)
    {
        int count = 0;
        for (int i = 0; i <= 9; i++)
        {
            for (int j = 0; j <= 9; j++)
            {
                for (int k = 0; k <= 9; k++)
                {
                    for (int l = 0; l <= 9; l++)
                    {
                        if (i + j + k + l == n)
                        {
                            count++;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
    
    
    
    
    return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    if(n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

const int N = 1005;
int n, k, dp[N][N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> k;
    for(int i = 1; i <= k; i++){
        dp[1][i] = 1;
    } 

    for(int i = 2; i <= n; i++){
        int tot = 0;
        for(int j = 1; j <= k; j++){
            tot += dp[i - 1][j];
        }
        for(int j = 1; j <= k; j++){
            dp[i][j] = tot - dp[i - 1][j];
        }
    }

    int tot2 = 0;
    for(int j = 1; j <= k; j++){
        tot2 += dp[n][j];
    }
    cout << tot2 << '\n';
    return 0;
}

Measured memory_bytes: 4224
sum = 0
stack = [] # \を受け取ったindexのstack
res = [] # /に対応する\のindexとその時に計算した面積のtupleのstack. 最後に各断面の面積として表示する
gets.split("").each_with_index { |v, i|
  if v == "\\"
    stack << i
  elsif v == "/"
    j = stack.pop
    if !j.nil? # \より先に/が来たときのため
      a = i - j # indexの引き算で横向きに計算する
      sum += a

      loop do
        k, b = res.pop
        if !k.nil?
          if j < k
            a += b
          else
            res << [k, b] # 一旦popしてるので特に何もなければ再度pushして戻す
            break
          end
        else
          break
        end
      end
      res << [j, a]
    end
  end
}
puts sum
if res.size() == 0
  puts "0"
else
  puts "#{res.size()} #{res.map{|n| n[1]}.join(" ")}" # size == 0の時にmapがうまくいかない??
end


Measured memory_bytes: 8156
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {
        string s;
        cin>>s;
        vector <char> v;
        v.pb(s[0]);
        ll cnt=0;
        for(auto ch: s)
        {
            if(v[0]!=ch)
            {
                cnt++;
                v[0]=ch;
            }
        }
        cout<<cnt<<endl;

//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int x,y;
	while(1){
		cin>>x>>y;
		if(x==0&&y==0)	break;
		if(x>y){
			swap(x,y);
		}
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}


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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> vbiton(N, 0);
    vector<int> vcondon(M, 0);
    for (int i = 0; i < M; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int s;
            cin >> s;
            s--;
            vbiton[i] |= (1 << s);
        }
    }

    for (int i = 0; i < M; i++)
    {
        int p;
        cin >> p;
        vcondon[i] = p;
    }

    int ans = 0;
    for (int i = 0; i < (1 << N); i++)
    {
        if ([&]() {
                for (int j = 0; j < M; j++)
                {
                    int on = i & vbiton[j];
                    int non = 0;
                    while (on > 0)
                    {
                        if (on & 1)
                            non++;
                        on >>= 1;
                    }
                    if ((non % 2) != vcondon[j])
                        return false;
                }
                return true;
            }())
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    // ll mm[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    ll m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if(m1!=m2)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		scanner.hasNext();

		int a = scanner.nextInt();
		int b = scanner.nextInt();

		double c = (double)a/(double)b;

		System.out.print(a/b + " ");
		System.out.print(a%b + " ");

		String after = String.format("%.16f", c);
		System.out.println(after);
	}
}

Measured memory_bytes: 17176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,k,a,b,c,n,s=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&n);
	for(i=0;i<=a;i++)
	{
		for(j=0;j<=b;j++)
		{
			for(k=0;k<=c;k++)
			{
				if(i*500+j*100+k*50==n)
				{
					s++;
				}
			}
		}
	}
	printf("%d",s);
	return 0;
}

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


int main() {
  int N,a,b;
  cin >> N;
  a = N%100;
  b  = N%10;
  if (N<800 && N > 699){
    cout << "Yes" <<endl;
  }
  
  else if (a<80 && a >69) {
    cout << "Yes" <<endl;
  }
  
  else if (b == 7) {
    cout << "Yes" <<endl;
  }
  
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3624