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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

typedef vector<vi> board;

board decode(string s) {
    board b;
    b.push_back({});
    for (char c : s) {
        if (isdigit(c)) {
            rep(i, 0, c - '0') b.back().push_back(0);
        } else if (c == '/') {
            b.push_back({});
        } else {
            b.back().push_back(1);
        }
    }
    return b;
}

string encode(board b) {
    string res;
    for (int i = 0; i < b.size(); i++) {
        if (i) res.push_back('/');
        int len = 0;
        for (int j = 0; j < b[i].size(); j++) {
            if (b[i][j] == 1) {
                if (len) {
                    res.push_back('0' + len);
                }
                res.push_back('b');
                len = 0;
            } else {
                len++;
            }
        }
        if (len) res.push_back('0' + len);
    }
    return res;
}

int main() {
    for (;;) {
        string s; cin >> s; if (s == "#") break;
        board b = decode(s);
        // for (auto p : b) {
        //     cout << "[" << p.size() << "] ";
        //     for (auto q : p) cout << q << " "; cout << endl;
        // }
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        --x1, --y1, --x2, --y2;
        b[x1][y1] = 0, b[x2][y2] = 1;
        cout << encode(b) << endl;
    }
}


Measured memory_bytes: 3208
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let k = get();
    let a: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let mut mi: i64 = 1 << 60;
    for bits in 0 .. 1u32 << n {
        let mut a = a.clone();
        if bits.count_ones() != k { continue; }
        let mut height = 0;
        let mut cost = 0;
        for i in 0 .. n {
            if (bits & 1 << i) != 0 {
                if a[i] <= height {
                    cost += height - a[i] + 1;
                    a[i] = height + 1;
                }
            }
            height = max(height, a[i]);
        }
        mi = min(mi, cost);
    }
    println!("{}", mi);
}

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: 8572
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];

int check(llong P){
  int i=0;
  int j;

  for(j=0;j<k;j++){
    llong s=0;
    while(s+T[i]<=P){
      s+=T[i];
      i++;
      if(i==n) return n;
    }
  }
  return i;
}

int solve(){
  llong left=0;
  llong right=100000*10000;
  llong mid;

  while(right-left>1){
    mid=(left+right)/2;
    int v;
    v=check(mid);
    if(v>=n) right=mid;
    else left=mid;
  }
  return right;
}

int main(){
  cin>>n>>k;
  int i;

  for(i=0;i<n;i++)
    cin>>T[i];
  llong ans=solve();
  cout<<ans<<endl;
}



Measured memory_bytes: 3892
// problem: "https://atcoder.jp/contests/abc159/tasks/abc159_b"

#include<bits/stdc++.h>

using namespace std;

bool isPalindrome(string &s,int i,int j)
{
    while(i < j)
    {
        if(s[i] != s[j])
            return false;

        i++;
        j--;
    }

    return true;
}

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

    if(isPalindrome(s,0,s.size()/2-1) && isPalindrome(s,0,s.size()-1) && isPalindrome(s,s.size()/2+1,s.size()-1))       // define
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x;
    cin >> x;
    if( x < 1200 ) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = w * h / 2;
    ll count = 0;
    if(x == w / 2 && y == h / 2) count++;
    printf("%.10f %lli\n", ans, count);




}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n; cin >> n;
    bool ans = false;
    rep(i,100)rep(j,100){
        if(4*i+7*j==n){
            ans = true;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

vector<pair<int, int>> hist_to_vector(const map<int, int> &h)
{
	vector<pair<int, int>> v;
	for (const auto &e : h) {
		v.emplace_back(e.second, e.first);
	}
	sort(v.begin(), v.end());
	return v;
}

int main()
{
	int n;
	cin >> n;
	
	map<int, int> hist_e, hist_o;

	hist_e[-2] = 0;
	hist_o[-1] = 0;
	for (int i = 0; i < n; ++i) {
		int v;
		cin >> v;
		if (i % 2 == 0) {
			++hist_e[v];
		}
		else {
			++hist_o[v];
		}
	}

	const vector<pair<int, int>> v_e = hist_to_vector(hist_e);
	const vector<pair<int, int>> v_o = hist_to_vector(hist_o);
	
	int ans = n;
	for (auto &e : v_e) {
		for (int k = v_o.size() - 1; k >= 0; --k) {
			auto &o = v_o[k];
			if (e.second != o.second) {
				int tmp = (n / 2 - e.first) + (n / 2 - o.first);
				if (tmp >= ans) {
					break;
				}
				ans = tmp;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        sort(all(s));
        m[s]++;
    }
    ll sol = 0;
    for (auto it = m.begin(); it != m.end(); ++it)
    {
        sol += 1ll * it->second * (it->second - 1) / 2;
    }
    cout << sol;
}


Measured memory_bytes: 11264
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int p = scan.nextInt();
        int m = scan.nextInt();
        int c = scan.nextInt();
        
       System.out.println(p+m+c);
       
       
           }
        
    }




Measured memory_bytes: 26344
#include<stdio.h>
  
int main()
{
    while (1)
    {
        char num[1001];
        scanf("%s", num);
        if (num[0] == '0') break;
        int n, sum = 0;
        for (n = 0; num[n] != '\0'; n++)
        {
            sum += num[n] - '0';
        }
        printf("%d\n", sum);
    }
  
    return 0;
}

Measured memory_bytes: 536
import sys
sys.setrecursionlimit(10**9)

H, N = map(int, input().split())
magic = [_ for _ in range(N)]

for k in range(N):
  magic[k] = list(map(int, input().split()))
  magic[k].append(magic[k][0]/magic[k][1])

magic.sort(key = lambda x: x[2], reverse=True)
ans = [0 for _ in range(H+1)]
visited = [0]
anskouho = [float('inf')]

def solve(start, power, point, maryoku):
  if start == H:
    print(min(point, min(anskouho)))
    exit()
  elif start > H:
    anskouho.append(point)
    visited.sort(reverse=True)
    return 0
  elif ans[start] != 0:
    visited.sort(reverse=True)
    return 0
  else:
    visited.append(start)
    ans[start] = point
    solve(start+power, power, point+maryoku, maryoku)

for k in range(N):
  for item in visited:
    solve(item+magic[k][0], magic[k][0], ans[item] + magic[k][1], magic[k][1])

print(min(anskouho))

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

ll a[2000], b[2000];
int main() {
	ll n, x; scanf("%lld%lld", &n, &x);
	rep(i, n) { scanf("%lld", &a[i]); b[i] = a[i]; }
	ll ans = LLONG_MAX;
	rep(i, n) {
		ll cnt = 0;
		rep(j, n) { b[j] = min(b[j], a[(j + n - i) % n]); cnt += b[j]; }
		ans = min(ans, cnt + i*x);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a  
lgcds = [A[0]]
rgcds = [A[N-1]]
for n in range(N-2):
    lgcds.append(gcd(lgcds[-1],A[n+1]))
    rgcds.append(gcd(rgcds[-1],A[-2-n]))
gcds = [lgcds[-1],rgcds[-1]]
for i in range(N-2):
    gcds.append(gcd(lgcds[i],rgcds[-2-i]))
print(max(gcds))

Measured memory_bytes: 14436
#include<bits/stdc++.h>
using namespace std;
#define N 1000001
int is[N];
int main(){
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		is[a[i]]++;
	}
	if(is[1]>0){
		cout<<max(0,2-is[1])<<"\n";
		return 0;
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(is[a[i]]>1) continue;
		bool is_ok=true;
		for(int ii=2;ii*ii<=a[i];ii++){
			if(a[i]%ii==0 and (is[ii] or is[a[i]/ii])){
				is_ok=false;
				break;
			}
		}
		ans+=is_ok;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 8332
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vint p(n);
    int count=0;
    int min=999999;
    rep(i,n){
        cin>>p[i];
        if(min>p[i]){
            count++;
            min=p[i];
        }
        
    }
    cout<<count<<'\n';
    return(0);
}

Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  int n, x, t;
  int a;

  cin >> n >> x >> t;
  a = n/x;
  if (n%x) a++;

  cout << t*a << endl;
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int maxn = 200020;
int a[maxn], n, k;
bool vis[maxn];
vector<int> v;

int main()
{
    scanf("%d%d", &n, &k);
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        a[x] ++;
        if(!vis[x]) {
            vis[x] = true;
            cnt ++;
        }
    }
    if(cnt <= k)
        printf("0");
    else {
        sort(a, a + maxn, greater<int>());
        LL sum = 0;
        for(int i = k; i < cnt; i++)
            sum += a[i];
        printf("%lld\n", sum);
    }
    return 0;
}


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

using namespace std;

struct vec
{
    long double x,y;
    bool operator ==(const vec &a) const{
        return x==a.x&&y==a.y;
    }
    bool operator <(const vec &a) const{
        if(a.x!=x) return x<a.x;
        return y<a.y;
    }
    vec operator +(const vec &a) const{
        return {x+a.x,y+a.y};
    }
    vec operator *(const long double &a) const{
        return {x*a,y*a};
    }
    vec operator -(const vec &a) const{
        return {x-a.x,y-a.y};
    }
    vec operator /(const long double &a) const{
        return {x/a,y/a};
    }
    long double len() const{
        return sqrt(x*x+y*y);
    }
    long double dot(const vec &a) const{
        return x*a.x+y*a.y;
    }
    long double crs(const vec &a) const{
        return x*a.y-y*a.x;
    }
    vec proj(const vec &a) const{
        return (a/a.len())*(*this).dot(a)/a.len();
    }
};

struct P
{
    int x;
    int f;
    int r;
    bool operator <(const P &a)const{
        return x>a.x;
    }
};


bool as(P a,P b)
{
    //if(a.y!=b.y)
    //return a.y<b.y;
    return a.x<b.x;
}

long long x,y,z,mod=1000000007;
vector<int> v[222];
int i,n,m,k,a,d,b,c,dx[10]={1,0,-1,0},dy[10]={0,1,0,-1};
int e;
int o[1111][1111];
int l[1111];
int j[221];
stack<int> s;
//set<int> s;
queue<int> q;
P u[1];
char r[111],r1[111];
//string r,r1;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p,p1;
//v.resize(unique(v.begin(),v.end())-v.begin());

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

int f(int n)
{
    if(j[n]==n) return n;
    return j[n]=f(j[n]);
}

int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
        j[t]=t;
    for(int t=1;t<=a;t++)
        for(int w=1;w<=a;w++)
        {
        scanf("%1d",&o[t][w]);
        if(o[t][w]) j[f(t)]=f(w);
        }
    for(int t=1;t<=a;t++)
        v[f(t)].push_back(t);
    //puts("#");
    for(int i=0;i<=200;i++)
    if(v[i].size())
    {
        k=-1;
        //printf("%d\n",v[i].size());
        for(int p=0;p<v[i].size();p++)
        {
            int t=v[i][p];
            e=0;
            memset(l,0,sizeof(l));
                //if(l[t]==0)
            {
                q.push(t);
                l[t]=1;
                e=1;
                for(;q.size();q.pop())
                {
                    for(int h=1;h<=a;h++)
                        if(o[q.front()][h]&&l[h]==0)
                    {
                        l[h]=l[q.front()]+1;
                        e=max(e,l[h]);
                        q.push(h);
                    }
                }
                //printf("%d %d %d\n",l[1],l[2],l[3]);
                for(int a=0;a<v[i].size();a++)
                    for(int b=0;b<v[i].size();b++)
                    //printf("%d %d %d\n",v[i][a],v[i][b],l[a]-l[b]);
                    if(o[v[i][a]][v[i][b]]&&abs(l[v[i][a]]-l[v[i][b]])!=1)
                    goto qwe;
                    //puts("#");
                k=max(e,k);
                qwe:;
            }
        }
        if(k<0)
        {
            puts("-1");
            return 0;
        }
        b+=k;
    }

    printf("%d",k);
}



//czecycec
//czecxzec


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll n,ue=0,ans=0;
string s;

void init(){
	cin>>s;
	n=s.size();
}

int main(void){
	init();
	irep(i,n){
		int d,e=0;
		d=s[i]-'0'+ue;
		if(i>0)e=s[i-1]-'0';
		if(d<5){
			ans+=d;
			ue=0;
		}else if(d==5 && e<5){
			ans+=d;
			ue=0;
		}else{
			ue=1;
			ans+=10-d;
		}
		// cerr<<ans<<endl;
	}
	if(ue>0)ans+=ue;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1412
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <array>
#include <iostream>
#include <utility>


namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  std::array<u32, 4> a;
  for (auto &e : a) {
    std::cin >> e;
  }
  std::cout << std::max(a[0] * a[1], a[2] * a[3]) << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
import sys
from math import ceil, floor, pow
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    l = int(input())
    print(pow(l/3, 3))
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5304
#include <stdio.h>

int main(void){
	while(1){
		int n, m, i, j;
		long a[20001] = {0};
	
		scanf("%d %d", &n, &m);
		if(n==0 && m==0) break;
		
		for(i=1; i<=m+n; i++)
			scanf(" %ld", &a[i]);
		
		for(i=1; i<=m+n; i++){
			for(j=i; j<=m+n; j++){
				if(a[i] > a[j]){
					long tmp = a[i];
					a[i] = a[j];
					a[j] = tmp;
				}
			}
		}
		
		long max = a[1] - a[0];
		for(i=1; i<=m+n-1; i++){
			if(max < a[i+1] - a[i])
				max = a[i+1] - a[i];
		}
		
		printf("%ld\n", max);
	
	}

	return 0;
}

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

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int main(){
    
    // 各種変数宣言
    
    int n,x,y,i,j,k,c,a,p=0;
    int min,max,answer,carda[100];
    // 配列宣言
    
    
    // メインループ
    
    while(1){
        int card[500]={};
        
        // nとpを読み込む
        scanf("%d", &n);
        if(n==0)break;
        
        for(i=0;i<n;i++){
        scanf("%d", &card[i]);
        }
        
        min=1001;
        for(i=0;i<n;i++){
            if(min>card[i] || min==card[i]){
                min=card[i];
                x=i;
            }
        }
        
        max=0;
        for(i=0;i<n;i++){
            if(max<card[i] || max==card[i]){
                max=card[i];
                y=i;
            }
        }
        
        
        card[x]=0;
        card[y]=0;
        k=0;
        for(i=0;i<n;i++){
            k+=card[i];
        }
        
        answer=k/(n-2);
        carda[p]=answer;
        p++;
    }
    for(i=0;i<p;i++){
        printf("%d\n",carda[i]);
    }
    // 終了
    return 0;
    
}



Measured memory_bytes: 2696
from itertools import combinations

h, w, k = map(int, input().split())
C = [input() for _ in range(h)]

columns = [i for i in range(w)]
rows = [i for i in range(h)]

ans = 0
for c in range(w+1):
    for r in range(h+1):
        for column in combinations(columns, c):
            for row in combinations(rows, r):
                cnt = 0
                for x in range(w):
                    for y in range(h):
                        if not (x in column or y in row):
                            if C[y][x] == '#':
                                cnt += 1
                if cnt == k:
                    ans += 1

print(ans)

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int n,a[100000],c[100000],m=0;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        c[a[i]]++;
    }
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    else if(n==2){
        if(abs(a[0]-a[1])<=2)cout<<2<<endl;
        else cout<<1<<endl;
        return 0;
    }
    else for(int i=1;i<n-1;i++)m=max(m,c[i-1]+c[i]+c[i+1]);
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 1024
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn dfs(
    lv: &Vec<i32>,
    n: usize,
    a: i32,
    b: i32,
    c: i32,
    i: usize,
    ax: i32,
    bx: i32,
    cx: i32,
) -> i32 {
    if i == n {
        return if ax == 0 || bx == 0 || cx == 0 {
            a + b + c
        } else {
            (ax - a).abs() - 10 + (bx - b).abs() - 10 + (cx - c).abs() - 10
        };
    }

    vec![
        dfs(lv, n, a, b, c, i + 1, ax, bx, cx),
        dfs(lv, n, a, b, c, i + 1, ax + lv[i], bx, cx) + 10,
        dfs(lv, n, a, b, c, i + 1, ax, bx + lv[i], cx) + 10,
        dfs(lv, n, a, b, c, i + 1, ax, bx, cx + lv[i]) + 10,
    ]
    .into_iter()
    .min()
    .unwrap()
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let c: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut lv = vec![0i32; n];
    for i in 0..n {
        lv[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let ans = dfs(&lv, n, a, b, c, 0, 0, 0, 0);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll minChange(string str2, string str1) 
{ 
    ll n1 = str1.size(), n2 = str2.size(); 
    ll result = INT_MAX;
    for (ll i = 0; i < n2 - n1 + 1; i++) { 
        ll minRemovedChar = 0; 
  
        for (ll j = 0; j < n1; j++) { 
            if (str1[j] != str2[i + j]) { 
                minRemovedChar++; 
            } 
        } 
        result = min(minRemovedChar, result); 
    } 
    return result; 
} 
int main(){
 string str1,str2;
 cin>>str1>>str2;
 cout<<minChange(str1,str2)<<endl;
  
return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int num_color(int n, vector<int> sizes);

int main()
{
	int n; 
	vector<int> sizes;
	cin >> n;

	for(int i=0; i<n; i++) {
		int tmp;
		cin >> tmp;
		sizes.push_back(tmp);
	}
	cout << num_color(n, sizes) << endl;

	return 0;
}

int num_color(int n, vector<int> sizes)
{
	int num = 0;
	sort(sizes.begin(), sizes.end());

	long long sums = 0;
	for(int i=0; i<n; i++) {
		sums= sums + sizes[i];
	}
	
	for(int i=n-1; i>0; i--) {
		if( ((sums - sizes[i]) << 1) >= sizes[i]) {
			num++;
			sums -= sizes[i];
		}
		else
			break;
	}
	return num+1;
}

Measured memory_bytes: 1144
import sys
input = sys.stdin.readline

def main():
    h,w,m = map(int,input().split())

    h_array = [ 0 for _ in range(h) ]
    w_array = [ 0 for _ in range(w) ]
    ps = set()
    for i in range(m):
        hi,wi = map( lambda x : int(x) - 1 , input().split() )
        h_array[hi] += 1
        w_array[wi] += 1
        ps.add( (hi,wi) )

    h_great = max(h_array)
    w_great = max(w_array)
    h_greats = list()
    w_greats = list()
    for i , hi in enumerate(h_array):
        if hi == h_great:
            h_greats.append(i)
    for i , wi in enumerate(w_array):
        if wi == w_great:
            w_greats.append(i)

    ans = h_great + w_great


    for _h in h_greats:
        for _w in w_greats:
            if (_h,_w) in ps:
                continue
            print(ans)
            exit()

    print(ans-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 83528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = 0;
        int x = 0;

        while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){
                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 24468
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(A: Int, B: Int, K: Int){
    var count = 0
    for (i in 100 downTo 1){
        if (A % i == 0 && B % i ==0){
            count++
        }
        if (count == K){
            println(i)
            return
        }
    }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toInt()
    val B = sc.next().toInt()
    val K = sc.next().toInt()
    solve(A, B, K)
}



Measured memory_bytes: 31264
INF = 1 << 64


def calc_cost(height1, height2):
    return abs(height1 - height2)


def main(n, heights):
    heights.append(INF)
    heights.append(INF)
    costs = [INF for i in range(n + 2)]
    costs[0] = 0
    for i in range(n):
        costs[i + 1] = min(costs[i + 1], calc_cost(heights[i], heights[i + 1]) + costs[i])
        costs[i + 2] = min(costs[i + 2], calc_cost(heights[i], heights[i + 2]) + costs[i])
    return costs[n - 1]


if __name__ == '__main__':
    N = int(input())
    H = list(map(int, input().split()))
    print(main(N, H))


Measured memory_bytes: 13924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

class UnionFind {
private:
  vector<int> par;
public:
  UnionFind(int N) {
    par.resize(N);
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int x) { return (x == par[x])? x: (par[x] = root(par[x])); }
  void unite(int x, int y) { par[root(y)] = root(x); }
  bool same(int x, int y) { return (root(x) == root(y)); }
};

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

  UnionFind UF(N);

  vector<ll> FA(M), FB(M), BA(K), BB(K);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    UF.unite(A, B);
    FA[i] = A, FB[i] = B;
  }
  for (ll i = 0; i < K; i++) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    BA[i] = A, BB[i] = B;
  }
  vector<int> CNT(N, 0);
  for (ll i = 0; i < N; i++) {
    CNT[UF.root(i)]++;
  }

  vector<int> ans(N);
  for (ll i = 0; i < N; i++) {
    ans[i] = CNT[UF.root(i)];
    ans[i]--; // 除く自分
  }
  for (int i = 0; i < M; i++) {
    if (UF.same(FA[i], FB[i])) {
      ans[FA[i]]--;
      ans[FB[i]]--;
    }
  }
  for (ll i = 0; i < K; i++) {
    if (UF.same(BA[i], BB[i])) {
      ans[BA[i]]--;
      ans[BB[i]]--;
    }
  }
  cout << ans[0]; for (int i = 1; i < ans.size(); i++) { cout << ' ' << ans[i]; }

  return 0;
}

Measured memory_bytes: 5632
/*hon when the digit in the one's place of N is 2, 4, 5, 7, or 9
;
pon when the digit in the one's place of N
is 0, 1, 6 or 8
;
bon when the digit in the one's place of N
is 3.*/
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int erm = n%10;
  if(erm ==0||erm==1||erm==6||erm==8)
    cout << "pon";
  else if(erm == 3)
    cout <<"bon";
  else
    cout << "hon";
  return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h=sc.nextInt();
        int n=sc.nextInt();
        int[] a=new int[n];
        int[] b=new int[n];
        int max=0;
        for(int i=0;i<n;i++)
        {
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
            max=Math.max(max,a[i]);
        }
        int[] dp=new int[h+max+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0]=0;
            for(int j=1;j<h+max+1;j++)
                for(int i=0;i<n;i++)
            {
               dp[j]=Math.min(dp[j],dp[Math.max(0,j-a[i])]+b[i]);
            }
        int res=Integer.MAX_VALUE;
            for(int j=h;j<h+max+1;j++)
            {
                res=Math.min(res,dp[j]);
            }
            System.out.println(res);
    }

}


Measured memory_bytes: 28208
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

int gcd(int a,int b){
    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

/*----------------------------------------------------------------*/
signed main(){
	
	int n;
	cin >> n;

	int s = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1; j <= n; j++){
			int x = gcd(i,j);
			for(int k = 1; k <= n; k++){
				s += gcd(x,k);
			}
		}
	}
	cout << s << endl;

	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://atcoder.jp/contests/abc162/tasks/abc162_b


Measured memory_bytes: 3588
n=int(input())
a=list(map(int,input().split()))
ans=0
m=10**10
flg=0
last=0
for i in range(n):
    if a[i]==0:
        flg=1
cnt=len([x for x in a if x<0])

if cnt%2==0 or flg==1:
    for i in range(n):
        ans+=abs(a[i])
else:
    for i in range(n):
        ans+=abs(a[i])
        if m>abs(a[i]):
            m=abs(a[i])
    ans-=2*m
print(ans)

Measured memory_bytes: 14468
#include <iostream>
#include <numeric>

using namespace std;

long int gcd(long int a, long int b){
    
    if(a < b){
        int tmp = a;
        a = b;
        b = tmp;
    }

    while(a % b != 0){
        int tmp = b;
        b = a % b;
        a = tmp;
    }

    return b;

}

long int lcm(long int a, long int b){
    return a * b / gcd(a,b);
}

int main(){

    long int a,b;

    cin >> a >> b;

    cout << lcm(a,b) << endl;

    return 0;
}

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

using namespace std;

int N, A[100004],dp[100004];

int f(int i){
    if(dp[i] != -1){
        return dp[i];
    }
    if(i ==  N-1){
        return 0;
    }
    if(i == N-2){
        return dp[i] = f(i+1) + abs(A[i+1]-A[i]);
    }
    return dp[i] = min(f(i+1)+abs(A[i+1]-A[i]),f(i+2)+abs(A[i+2]-A[i]));
}

int main() {
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        dp[i] = -1;
    }
    printf("%d",f(0));
}

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

int main(void){
    int N;
    cin>>N;
    
    int a[N];
    for(int i=0;i<N;i++) cin>>a[i];
    
    int sum=0;
    for(int i=1;i<=N;i++){
        if(a[i]!=a[i-1])sum++;
        if(a[i]<a[i-1]){
            while(i<N){
                if(a[i]>a[i-1]){
                    break;
                }
                i++;
            }
        }else if(a[i]>a[i-1]){
            while(i<N){
                if(a[i]<a[i-1]){
                    break;
                }
                i++;
            }
        }
    }
    
    cout<<sum<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int v,next;}e[MAX<<1];
int h[MAX],cnt=1;
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;}
int n,m,dep[MAX],s[MAX],k[MAX],ln,U,V,S[MAX],top,tot;
ll ans;
void dfs(int u,int ff)
{
	dep[u]=dep[ff]+1;s[u]=(dep[u]&1)?1:-1;tot+=s[u];
	for(int i=h[u];i;i=e[i].next)
	{
		int v=e[i].v;if(v==ff)continue;
		if(dep[v])ln=abs(dep[u]-dep[v])+1,U=u,V=v;
		else dfs(v,u);
	}
}
void dfs2(int u,int ff)
{
	for(int i=h[u];i;i=e[i].next)
	{
		int v=e[i].v;
		if(v==ff||(U==u&&V==v)||(U==v&&V==u))continue;
		dfs2(v,u),k[u]+=k[v],s[u]+=s[v];
	}
	if(k[u]==0)ans+=abs(s[u]);
	else S[++top]=k[u]*s[u];
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
	{
		int a=read(),b=read();
		Add(a,b);Add(b,a);
	}
	dfs(1,0);
	if(m==n-1){if(tot!=0){puts("-1");return 0;}}
	else if(ln&1)
	{
		if(tot%2==1){puts("-1");return 0;}
		ans+=abs(tot/2);s[U]-=tot/2,s[V]-=tot/2;
	}
	else
	{
		if(tot!=0){puts("-1");return 0;}
		k[U]=1;k[V]=-1;
	}
	dfs2(1,0);
	S[++top]=0;sort(&S[1],&S[top+1]);
	for(int i=1;i<=top;++i)ans+=abs(S[(top+1)/2]-S[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8448
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	int A, B, M;
	cin >> A >> B >> M;
	vi a(A), b(B);
	rep(i,0,A) cin >> a[i];
	rep(i,0,B) cin >> b[i];
	int best = -1;
	rep(i,0,M) {
		int x, y, c;
		cin >> x >> y >> c;
		int pos = a[x -1] + b[y - 1] - c;
		if (best == -1 || best > pos) {
			best = pos;
		}
	}
	sort(all(a));
	sort(all(b));
	best = min(best, a[0] + b[0]);
	cout << best << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#define maxn 105

using namespace std;

int a[maxn],n,m;

int main()
{
	scanf("%d%d",&n,&m); int sum=0;
	for (int i=0;i<n;i++) scanf("%d",&a[i]),sum+=a[i];
	double c=sum*1.0/(4*m);
	int ret=0;
	for (int i=0;i<n;i++) if (a[i]>=c) ret++;
	if (ret>=m) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int a[100000];
int partition(int p, int r) {
	int x, i, j;
	x = a[r];
	i = p - 1;
	for (int j = p; j < r; j++) {
		if (a[j] <= x) {
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}
int main() {
	int n,i,q; cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	q = partition(0, n - 1);
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		if (i == q)cout << "[";
		cout << a[i];
		if (i == q) cout << "]";
	}
	cout << endl;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
using namespace std;

int cnt;

void insert(int *a, int n, int g)
{
    for(int i = g;i < n;i++)
    {
        int v = a[i];
        int j = i - g;
        while(j >= 0 && a[j] > v)
        {
            a[j+g] = a[j];
            j -= g;
            cnt++;
        }
        a[j + g] = v;
    }
}

void shell(int *a, int n)
{
    cnt = 0;
    vector<int> g;
    g.push_back(1);
    for(int h = 1*3 + 1;h < n;h = h*3 + 1)
        g.push_back(h);
    cout<<g.size()<<endl;
    for(int i = g.size() - 1; i >= 0;i--)
    {
        cout<<g[i]<<" ";
        insert(a, n, g[i]);
    }
    cout<<endl;
    cout<<cnt<<endl;
}


int main()
{
    int n;
    cin>>n;

    int *a = new int[n];

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

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

    delete [] a;
}


Measured memory_bytes: 6728
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
const string T[3]={"AB","BC","AC"};


int N,A,B,C,X[100000];
string S;
char res[100000];

bool dfs(int i,int a,int b,int c){
	if(i==N)return true;
	if(X[i]==0){
		if(a==0&&b==0)return false;
		else if(a==1&&b==1){
			res[i]='A';
			if(dfs(i+1,a+1,b-1,c))return true;
			res[i]='B';
			return dfs(i+1,a-1,b+1,c);
		}
		else if(a>b){
			res[i]='B';
			return dfs(i+1,a-1,b+1,c);
		}
		else{
			res[i]='A';
			return dfs(i+1,a+1,b-1,c);
		}
	}
	if(X[i]==1){
		if(b==0&&c==0)return false;
		else if(b==1&&c==1){
			res[i]='B';
			if(dfs(i+1,a,b+1,c-1))return true;
			res[i]='C';
			return dfs(i+1,a,b-1,c+1);
		}
		else if(b>c){
			res[i]='C';
			return dfs(i+1,a,b-1,c+1);
		}
		else{
			res[i]='B';
			return dfs(i+1,a,b+1,c-1);
		}
	}
	if(X[i]==2){
		if(c==0&&a==0)return false;
		else if(c==1&&a==1){
			res[i]='C';
			if(dfs(i+1,a-1,b,c+1))return true;
			res[i]='A';
			return dfs(i+1,a+1,b,c-1);
		}
		else if(c>a){
			res[i]='A';
			return dfs(i+1,a+1,b,c-1);
		}
		else{
			res[i]='C';
			return dfs(i+1,a-1,b,c+1);
		}
	}
	return false;
}

int main(){
	cin>>N>>A>>B>>C;
	for(int i=0;i<N;i++){
		cin>>S;
		for(int j=0;;j++){
			if(T[j]==S){
				X[i]=j;
				break;
			}
		}
	}
	if(dfs(0,A,B,C)){
		puts("Yes");
		for(int i=0;i<N;i++){
			cout<<res[i]<<endl;
		}
	}
	else{
		puts("No");
	}
}


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

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

  int N; cin >> N;
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << (A[N - 1] - A[0]) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[10];
  char t[10];
  char u[10];
  int a, b;

  scanf("%s", s);
  scanf("%s", t);
  scanf("%d%d", &a, &b);
  scanf("%s", u);

  if ((int)strcmp(s, u) == 0)
    a--;
  if ((int)strcmp(t, u) == 0)
    b--;

  printf("%d %d\n", a, b);

  return 0;
}


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

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> L(Q);
    vector<int> R(Q);
    for (int i = 0; i < Q; i++) {
        cin >> L[i] >> R[i];
    }
    
    vector<int> cnt(N + 1);
    cnt[0] = 0;
    for (int i = 0; i < N - 1; i++) {
        if (S[i] == 'A' && S[i + 1] == 'C') cnt[i + 1]++;
    }
    for (int i = 1; i <= N; i++) cnt[i] += cnt[i - 1];
    for (int i = 0; i < Q; i++) {
        cout << cnt[R[i] - 1] - cnt[L[i] - 1] << endl;
    }
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string str;
int w,n,e,s;
bool check()
{
    if(w && e && n && s) return true;
    if(w && e && !n && !s) return true;
    if(!w && !e && n && s) return true;
    if(!w && !e && !n && !s) return true;
    return 0;
}
int main()
{
	getline(cin,str);
	for(int i=0;i<str.length();i++)
	{
		if(str[i]=='W') w++;
		else if(str[i]=='N') n++;
		else if(str[i]=='E') e++;
		else s++;
	}
	if(check()) printf("Yes");
	else printf("No");
	printf("\n");
	return 0;
}

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

struct DJS
{
	int par[200001],sz[200001];
	void init(int n)
	{
		for(int i=1;i<=n;i++)
			par[i]=i, sz[i]=1;
	}
	int Find(int a)
	{
		if(par[a]==a) return a;
		else return par[a]=Find(par[a]);
	}
	void Union(int a,int b)
	{
		a=Find(a), b=Find(b);
		if(a==b) return;
		par[a]=b;
		sz[b]+=sz[a];
	}
} d,w;

struct Elem
{
	int g1,g2,ind;
	Elem(int g1,int g2,int ind)
	{
		this->g1=g1;
		this->g2=g2;
		this->ind=ind;
	}
    bool operator<(const Elem &other)const
    {
        if(g1==other.g1) return g2<other.g2;
        else return g1<other.g1;
	}
};
vector<Elem> v;
int ans[200001];

int main()
{
	int n,k,l;
	scanf("%d %d %d",&n,&k,&l);

	d.init(n);
	for(int i=1,a,b;i<=k;i++)
	{
		scanf("%d %d",&a,&b);
		d.Union(a,b);
	}

	w.init(n);
	for(int i=1,a,b;i<=l;i++)
	{
		scanf("%d %d",&a,&b);
		w.Union(a,b);
	}

	for(int i=1;i<=n;i++)
		v.push_back(Elem(d.Find(i),w.Find(i),i));
	sort(v.begin(),v.end());

	for(int i=0;i<n;i++)
	{
		int j=i;
		while(j+1<n && v[j+1].g1==v[j].g1 && v[j+1].g2==v[j].g2)
			j++;
		for(int k=i;k<=j;k++)
			ans[v[k].ind]=j-i+1;
		i=j;
	}

    for(int i=1;i<=n;i++)
		printf("%d ",ans[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 7024
// Copyright 2017 wu_qing
#include <cstdio>
int a, b;
int main() {
    scanf("%d%d", &a, &b);
    if (a <= 0 && b >= 0)
        printf("Zero\n");
    else if (a > 0)
        printf("Positive\n");
    else if ((b - a) & 1)
        printf("Positive\n");
    else
        printf("Negative\n");
    return 0;
}


Measured memory_bytes: 128
/*
f[S][j]表示当前选择的集合为S，到达了点j，能选的边最大边权和是多少
考虑转移，朴素做法是
找一个点k，和一个子集T(k∈T)，转移到f[S|T][k]，表示增加这个连通块

注意到转移的时候可以独立：
1、增加一个点，直接增加代价
2、增加这个点所在的连通块，即枚举子集。注意到这时候还是满足条件的：除了这个点的连通块不和其它点相邻。 
 
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
const int mod = 998244353;
int n,m,B,ans;
int f[1<<15][15],p[1<<15],w[15][15];
int main(){
	n = rd(),m = rd();
	Rep(i,1,m) {
		int a = rd()-1,b = rd()-1,c = rd();
		w[a][b] = w[b][a] = c;
		ans+=c;
	}
	p[0] = 0;
	rep(i,1,1<<n){
		int now=0;
		rep(j,0,n)if(i>>j&1){now=j;break;}
		p[i]=p[i^(1<<now)];
		rep(j,0,n)if(i>>j&1)p[i]+=w[now][j];
	}
	mem(f,0xc0);
	f[1][0]=0;
	rep(s,0,1<<n){
		rep(i,0,n){
			for(int t=s;t;t=(t-1)&s)
				if(t>>i&1) f[s][i]=max(f[s][i],f[(s-t)|(1<<i)][i]+p[t]);
			rep(j,0,n)
				if(!(s>>j&1) && w[i][j])
					f[s|(1<<j)][j]=max(f[s|(1<<j)][j],f[s][i]+w[i][j]);
		}
	}
	writeln(ans-f[(1<<n)-1][n-1]);
}
/*
f[S][j]表示当前选择的集合为S，到达了点j，能选的边最大边权和是多少
考虑转移，朴素做法是
找一个点k，和一个子集T(k∈T)，转移到f[S|T][k]，表示增加这个连通块

注意到转移的时候可以独立：
1、增加一个点，直接增加代价
2、增加这个点所在的连通块，即枚举子集。注意到这时候还是满足条件的：除了这个点的连通块不和其它点相邻。 
 
*/


Measured memory_bytes: 2304