akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 201000
typedef long long ll;
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
const int P = 1e9 + 7;
const int inf = 987654321;
inline void MIN(int &a, int b) {
	if (b < a)	a = b;
}
int n, m;
char s[N];
namespace jzp1 {
	ll jie[N], jieni[N];
	inline ll get_c(int n, int m) {
//		printf("get_c(%d, %d)\n", n, m);
		if (n < 0 || m < 0 || n - m < 0)	return 0;
//		printf("get_c(%d, %d)\n", n, m);
		return jie[n] * jieni[m] % P * jieni[n - m] % P;
	}
	inline ll quickpow(ll x, int k) {
		ll res = 1;
		while (k) {
			if (k & 1)	res = res * x % P;
			x = x * x % P;
			k >>= 1;
		}
		return res;
	}
	inline void sol() {
//		while(1);
		if (n == 1) { puts("1"); return ; }
		jie[0] = jieni[0] = 1;
		int up = n + 1;
		for (int i = 1; i <= up; ++i)	jie[i] = jie[i - 1] * i % P;
		jieni[up] = quickpow(jie[up], P - 2);
		for (int i = up - 1; i; --i)	jieni[i] = jieni[i + 1] * (i + 1) % P;
		ll res = 0;
		for (int i = 0; i <= n; ++i) {
			res = (res + get_c(n - i + 1, i) - get_c(n - i - 1, i - 2)) % P;
//			printf("res = %lld\n", res);
		}
		printf("%lld\n", (res % P + P) % P);
	}
}
ll f[N];
ll sum[N];
int main() {
	read(n), read(m);
	scanf("%s", s + 1);
	bool flag = false;
	int tmp = 0;
	for (int i = 1; i <= m; ++i)	if (s[i] != s[1]) { flag = true; tmp = i - 1; break; }
	if (!flag) { jzp1::sol(); return 0; }
	if (n & 1) { puts("0"); return 0; }
	int lst = 1, mn = tmp | 1;
	for (int i = 2; i <= m; ++i) {
//		printf("i = %d, mn = %d\n", i, mn);
		if (s[i] != s[1]) {
			if (lst & 1)	MIN(mn, lst);
			lst = 0;
			continue;
		}
		if (s[i] == s[i - 1])	++lst;
		else {
			if (lst & 1) MIN(mn, lst);
			lst = 1;
		}
	}
	if (mn == inf) {
//		while (1);
		int memo = 1;
		for (int i = 1; s[i] == s[1]; ++i) memo = i;
		mn = memo + 1;
		printf("memo = %d\n", memo);
	}
	n >>= 1;
	int k = (mn + 1) >> 1;
	MIN(k, n);
	f[0] = 1; sum[0] = 1;
//	printf("n = %d, k = %d\n", n, k);
	for (int i = 1; i <= n; ++i) {
		if (i <= k)	f[i] = sum[i - 1];
		else f[i] = (sum[i - 1] - sum[i - k - 1]) % P;
		sum[i] = (sum[i - 1] + f[i]) % P;
	}
	ll ans = 0;
	for (int i = 1; i <= k; ++i) {
		ans = (ans + f[n - i] * i) % P;
	}
	ans = (ans << 1) % P;
	printf("%lld\n", (ans % P + P) % P);
	return 0;
}

/*
3 3
BBB
//4

1 1
B
//1

12 10
RRRRBRRRRB
//78

6 5
RRBBR
//8
*/

Measured memory_bytes: 6400
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 100000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;


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

	int n,m;
	cin >> n;
	vi t(n);
	ll ans = 0;
	rep(i, n) {
		cin >> t[i];
		ans += t[i];
	}
	cin >> m;
	vi p(m), x(m);
	rep(i, m) {
		cin >> p[i] >> x[i];
	}
	rep(i, m) {
		cout << ans - (t[p[i]-1] - x[i]) << endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,i,ans;
  for(i=1;i<=5;i++)
  {
    cin>>x;
    if(x==0)
    {
      ans=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3544
// https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  const ll MAX_POSITION = 2e5;

  struct Point {
    ll x, y;
    char d;
  };

  V<Point> ps(N);
  rep(i, N) cin >> ps[i].x >> ps[i].y >> ps[i].d;

  map<char, char> rotate_map{
      {'U', 'R'},
      {'R', 'D'},
      {'D', 'L'},
      {'L', 'U'},
  };

  auto rotate = [&]() {
    rep(i, N) {
      auto p = ps[i];

      ps[i].x = p.y;
      ps[i].y = MAX_POSITION - p.x;
      ps[i].d = rotate_map[p.d];
    }
  };

  // 反対方向の衝突
  auto solve1 = [&]() {
    map<ll, V<P<ll, char>>> ps_for_y;

    rep(i, N) {
      unless(ps[i].d == 'L' || ps[i].d == 'R') continue;
      ps_for_y[ps[i].y].emplace_back(ps[i].x, ps[i].d);
    }

    ll res = INF;

    for (auto [_, ps] : ps_for_y) {
      sort(all(ps));

      rep(i, ps.size() - 1) {
        unless(ps[i].se == 'R' && ps[i + 1].se == 'L') continue;
        chmin(res, (ps[i + 1].fi - ps[i].fi) * 5);
      }
    }

    return res;
  };

  // 右・上方向の衝突
  auto solve2 = [&]() {
    map<ll, V<P<ll, char>>> ps_for_xy_sum;

    rep(i, N) {
      unless(ps[i].d == 'U' || ps[i].d == 'R') continue;
      ll sum = ps[i].x + ps[i].y;
      ps_for_xy_sum[sum].emplace_back(ps[i].x, ps[i].d);
    }

    ll res = INF;

    for (auto [_, ps] : ps_for_xy_sum) {
      sort(all(ps));

      rep(i, ps.size() - 1) {
        unless(ps[i].se == 'R' && ps[i + 1].se == 'U') continue;
        chmin(res, (ps[i + 1].fi - ps[i].fi) * 10);
      }
    }

    return res;
  };

  ll res = INF;

  rep(i, 4) {
    if (i < 2) chmin(res, solve1());
    chmin(res, solve2());
    rotate();
  }

  if (res == INF) drop("SAFE");

  cout << res << "\n";
}


Measured memory_bytes: 29472
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll i,n,ans;
ii a[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,0,n) cin>>a[i].f>>a[i].se;
    sort(a,a + n,[&](ii a,ii b){
        return a.f + a.se > b.f + b.se;
    });
    rep(i,0,n){
        if(i & 1)
            ans -= a[i].se;
        else
            ans += a[i].f;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
//import java.io.BufferedReader;
import java.io.IOException;
//import java.io.InputStreamReader;
import java.util.Scanner;
//import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException
	{
		//BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer st= new StringTokenizer(br.readLine());
		
		//int a= Integer.parseInt(st.nextToken());
		//int b= Integer.parseInt(st.nextToken());
		//String inputString=br.readLine();
		//int a = Integer.parseInt ( inputString );
		//int b = Integer.parseInt ( inputString );
		
		Scanner sc= new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if((a*b)%2==0)
			System.out.println("Even");
		else System.out.println("Odd");
	
	}

}

Measured memory_bytes: 23892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		long a[] = new long[n];
		long b[] = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			b[i] = Long.parseLong(str[i]);
		}

		long cntA = 0;
		long cntB = 0;

		for (int i = 0; i < n; ++i) {
			if (a[i] > b[i])
				cntA += a[i] - b[i];
			if (b[i] > a[i])
				cntB += (b[i] - a[i]) / 2;
		}

		if (cntB >= cntA) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main()
{
    int a[10000], i = 0;

    while (true) {
        cin >> a[i];
        if (a[i] == 0)
            break;
        i++;
    }

    i = 0;
    while (a[i] != 0) {
        cout << "Case " << i + 1 << ": " << a[i] << endl;
        i++;
    }
}


Measured memory_bytes: 3124
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int idx=Integer.parseInt(buf.readLine()); 
        int ans=0;
        for(int i=0;i<idx;i++){
            int x=Integer.parseInt(buf.readLine());
            int flg=0;
             
            if(x==2){
                flg=0;
            }else if(x%2==0 || x<2){
                flg=1;
            }else{
                double sqrt=Math.sqrt(x);
                for(int j=3;j<=sqrt;j+=2){
                    if(x%j==0){
                        flg=1;break;
                    }
                }
            }
            if(flg==0){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 30784
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll                long long int
#define ld                long double
#define pb                push_back
#define mk                make_pair
#define in(i,a,n)         for(ll i=0;i<n;++i) cin>>a[i];
#define out(i,a,n)        for(ll i=0;i<n;++i) cout<<a[i]<<" ";
#define sz                size()
#define all(c)            c.begin(), c.end()
#define rall(c)           c.rbegin(), c.rend()
#define loop(i,a,b)       for(ll i=a;i<b;i++)
#define rloop(i,a,b)      for(ll i=a;i>b;i--)
#define F                 first
#define S                 second
#define deb(x) cout << #x << " " << x << endl
#define inf INT_MAX
const ll N = 100010;
const ll MOD = 1e9+7;
ll mod(ll n) {
    return (n % MOD + MOD) % MOD;
}


void solve(){
    int x, y;
    cin >> x >> y;
    if(y >= 2*x && y <= 4*x && y % 2 == 0) cout << "Yes\n";
    else cout << "No\n";
}

int main(){
    fast
    int T=1;
    //cin >> T;
    for(int i=0;i<T;i++) solve();
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}

int N, M, Q;
vi a, b, c, d;
lli ans;

void dfs(int idx, vi &arr, int last){
    if(idx == N){
        lli tp = 0;
        rep(i, Q){
            if(arr[b[i]] - arr[a[i]] == c[i]){
                tp += d[i];
            }
        }
        smax(ans, tp);
        return;
    }
    repA(j, last, M){
        arr[idx] = j;
        dfs(idx+1, arr, j);
    }
}

int main(){
    
    fastio;
    
    cin >> N  >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    ans = 0;

    vi arr(N);
    dfs(0, arr, 1);

    cout << ans << endl;


}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
typedef pair<long long, long long> P;

int main(){
    long long x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<x2-(y2-y1)<<" "<<y2+x2-x1<<" "<<x1+y1-y2<<" "<<y1-(x1-x2)<<endl;

    return 0;
}

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

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

    int N, S;
    cin >> N >> S;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    int t = 0, ans = N + 1;
    ll total = 0;
    for (int s = 0; s < N; s++) {
        for (; t < N && total < S; t++) total += a[t];
        if (total < S) break;
        ans = min(ans, t - s);
        total -= a[s];
    }
    if (ans <= N) cout << ans << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3344
import queue

q = queue.Queue()
K = int(input())

for i in range(1, 10):
    q.put(i)

ans = 0
for i in range(K):
    ans = q.get()
    if ans % 10 != 0:
        q.put(ans * 10 + (ans % 10) - 1)

    q.put(ans * 10 + (ans % 10))

    if ans % 10 != 9:
        q.put(ans * 10 + (ans % 10) + 1)


print(ans)


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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	a.erase(unique(a.begin(),a.end()),a.end());
	n=a.size();

	if(n==1){ cout<<1<<endl; return 0; }

	int ans=1;
	rep(i,n-1){
		bool flag=(a[i]<a[i+1]);
		for(;i<n-1;i++){
			if     ( flag && a[i]>a[i+1]){ ans++; break; }
			else if(!flag && a[i]<a[i+1]){ ans++; break; }
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 640
N,M=list(map(int,input().split()))
l=[list(map(int,input().split()))[1:] for i in range(M)]
p=list(map(int,input().split()))
ans=0
for i in range(2**N):
   sw=[0]*N
   n=0
   for k in range(N):
      if (i >> k)&1:
         sw[k] = 1
   for s,j in enumerate(l):
      tmp=0
      for x in j:
         if sw[x-1]==1:
            tmp+=1
      if tmp%2==p[s]:
         continue
      else:
         n=1
         break
   if n==1:
      n=0
      continue
   else:
      ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  // int n;
  // int m;
  // cin >> n;
  // cin >> m;
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans=0;
  for(int i = 0; i <= a; ++i)
    for(int j = 0; j <= b; ++j)
      for(int k = 0; k <= c; ++k)
        if(500 * i + 100 * j + 50 * k == x)
          ++ans;
  


  cout << ans << endl;
  return 0;
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	double L;
	cin >> L;
	L /= 3;
	double ans = L * L*L;
	cout << fixed << setprecision(12) << ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
 #pragma GCC optimize("unroll-loops")
 #pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

signed main() {
    accell();
    int n, m;
    cin >> n >> m;
    vector<bool>used(n);
    vector<int>cnt(n, 1);
    used[0] = true;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        if (used[x]) used[y] = true;
        cnt[y]++;
        cnt[x]--;
        if (cnt[x] == 0)
            used[x] = false;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
        ans += used[i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	g = zeros(Int,n,n)
	a = Array{Int}(2,m)
	for i in 1:m
		a[:,i] = readline() |> split |> parseMap
		g[a[1,i],a[2,i]] = 1
		g[a[2,i],a[1,i]] = 1
	end
	l = zeros(Int,n,n)-g
	d = g*ones(Int,n)
	for i in 1:n
		l[i,i] = d[i]
	end
	count = 0
	for i in 1:m
		l[a[1,i],a[2,i]] += 1
		l[a[2,i],a[1,i]] += 1
		l[a[1,i],a[1,i]] -= 1
		l[a[2,i],a[2,i]] -= 1
		if rank(l) < n-1
			count += 1
		end
		l[a[1,i],a[2,i]] -= 1
		l[a[2,i],a[1,i]] -= 1
		l[a[1,i],a[1,i]] += 1
		l[a[2,i],a[2,i]] += 1
	end
	println(count)
end

main()


Measured memory_bytes: 177920
a = []
for i in range(3):
    a.append(tuple(map(int, input().split( ))))
a2 = [[0]*3 for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k]==b[i]:
                a2[j][k]=1
for i in range(3):
    flag = True
    for j in range(3):
        if a2[i][j]==0:
            flag = False
            break
    if flag:
        print("Yes")
        exit()
for j in range(3):
    flag = True
    for i in range(3):
        if a2[i][j]==0:
            flag = False
            break
    if flag:
        print("Yes")
        exit()
if a2[0][0]==1 and a2[1][1]==1 and a2[2][2]==1:
    print("Yes")
    exit()
if a2[0][2]==1 and a2[1][1]==1 and a2[2][0]==1:
    print("Yes")
    exit()
print("No")




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MX = 10000;

int n;

bitset<MX> val;
vector<int> primes;

map<int, int> cnt;

void sieve() {
    val.set();
    for (int i = 2; i < MX; ++i) {
        if (val[i]) {
            primes.push_back(i);
            for (int j = i + i; j < MX; j += i) 
                val[j] = 0;
        }
    }
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    sieve();
    cin >> n;
    
    for (int i = 2; i <= n; ++i) {
        int num = i;
        for (auto prime : primes) {
            while (!(num % prime)) {
                num /= prime;
                cnt[prime]++;
            }
        }
        
        if (num != 1) cnt[num]++;
    }
    
    // int fours = 0, twos = 0;
    
    int count[5] = { 0 };
    for (auto i : cnt) {
        // cout << i.first << ' ' << i.second << '\n';
        if (i.second >= 74) count[4]++;
        else if (i.second >= 24) count[3]++;
        else if (i.second >= 14) count[2]++;
        else if (i.second >= 4) count[1]++;
        else if (i.second >= 2) count[0]++;
    }
    
    // if (fours < 2 || fours + twos < 3) {
        // cout << 0;
        // return 0;
    // }
    
    for (int i = 3; i >= 0; --i) count[i] += count[i + 1];

    if (count[1] < 2 || count[0] < 3) {
        cout << 0;
        return 0;
    }

    int ans = 0;
    ans += count[4];
    ans += count[3] * (count[0] - 1);
    ans += count[2] * (count[1] - 1);
    ans += count[1] * (count[1] - 1) / 2 * (count[0] - 2);

    cout << ans;
}


Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<bitset>
#include<map>
#include<math.h>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
typedef long long LL; 
using namespace std;
const int maxn=10002;
const int INF=999999999;
int n;
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int same=x>y?y:x;
	int partSame=0;
	if(a+b>2*c){
		partSame=2*c*same;
	}else{
		partSame=(a+b)*same;
	}
	int rest,restPart;
	if(x>y){
		rest=x-same;
		if(2*c<a) restPart=rest*c*2;
		else restPart=rest*a;
	}else{
		rest=y-same;
		if(2*c<b) restPart=rest*c*2;
		else restPart=rest*b;
	}
	cout<<partSame+restPart<<endl;
	return 0;
}            

Measured memory_bytes: 256
fun main(args: Array<String>) {
	val MOD : Long = java.lang.Math.pow(10.0, 9.0).toLong() + 7

	var s = readLine()!!.trim().toCharArray().map{ x -> x.toString() }

	var dp = Array(13) { 0L }
	dp[0] = 1L

	for (i in (0 .. (s.size - 1) )) {
		var dp_next = Array(13) { 0L }
	
		if (s[i] == "?") {
			for (j in 0..12){
				for (k in 0..9){
					dp_next[(j * 10 + k) % 13] += dp[j]
				}
			}
		} else {
			for (j in 0..12){
				dp_next[(j * 10 + s[i].toInt()) % 13] += dp[j]
			}
		}

		for (j in 0..12){
			if (dp_next[j] > MOD) {
				dp_next[j] = dp_next[j] % MOD
			}
		}
		
		dp = dp_next
	}

	println(dp[5] % MOD)
}

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

int main() {
  int n, o = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    while(!(a.at(i) % 2) && a.at(i)) {
      o++;
      a.at(i) /= 2;
    }
  }
  cout << o << endl;
}

Measured memory_bytes: 256
//test for std

#include <cstdio>
  #include <cstdlib>
  #include <cstring>
  #include <cmath>
  #include <algorithm>
  #include <map>
  #include <set>
  #include <queue>
  using namespace std; typedef long long LL; const int inf = 1 << 30; const LL INF = 1LL << 60; const int MaxN = 2e5; //const double PI = 3.1415926535897932384626;
  const double PI = acos(-1); LL sx, sy, tx, ty; int n, tot; double res; struct point { LL x, y; }tmp[MaxN + 5]; bool cmpx(point a, point b) { if(a.x == b.x) return a.y < b.y; else return a.x < b.x; }
  //----------------LIS---------------------
  int len; LL a[MaxN + 5], d[MaxN + 5]; int bin_search(LL x) { int l = 0, r = len; int mid = 0, ans = 0; while(l <= r) { mid = (l + r) >> 1; if(d[mid] >= x) ans = mid, r = mid - 1; else l = mid + 1; } return ans; } void get_LIS(bool c) { len = 0; d[len] = -INF; //初始d[0] == 0的,如果LIS中有0,就会少算一个
  if(c == 1) { for(int i = 1; i <= tot; i++) a[i] = tmp[i].y; } else { //求下降时将数组倒过来求最长
  for(int i = 1; i <= tot; i++) a[i] = tmp[tot - i + 1].y; } for(int i = 1; i <= tot; i++) { if(a[i] > d[len]) d[++len] = a[i]; else { int pos = bin_search(a[i]); d[pos] = a[i]; } } } //----------------------------------------
  int main() { tot = 0; res = 0.0; scanf("%lld %lld %lld %lld", &sx, &sy, &tx, &ty); if(sx > tx) { //让起点在左边
  swap(sx, tx); swap(sy, ty); } scanf("%d", &n); for(int i = 1; i <= n; i++) { LL x, y; scanf("%lld %lld", &x, &y); //将在 起点和终点所形成的矩形 中的点给抠出来
  if((min(sx, tx) <= x && x <= max(sx, tx)) && (min(sy, ty) <= y && y <= max(sy, ty))) tmp[++tot].x = x, tmp[tot].y = y; } sort(tmp + 1, tmp + tot + 1, cmpx); if(sy > ty) { //取最长下降子序列
  get_LIS(0); } else if(sy <= ty) { //取最长上升子序列
  get_LIS(1); } int num = min(abs(tx - sx), abs(ty - sy)) + 1; if(len == num) { //肯定会直线经过一个喷泉,其他都是拐角
  res = (100.0 * (abs(tx - sx) + abs(ty - sy)) - 20.0 * (LL)len) + (LL)(len - 1) * 5 * PI + 10 * PI; } else { //全是拐角经过
  res = (100.0 * (abs(tx - sx) + abs(ty - sy)) - 20.0 * (LL)len) + (LL)len * 5 * PI; } printf("%.15lf\n", res); return 0; }


Measured memory_bytes: 6400
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
n = ni()
A = lma()
mod=10**9+7
tot = 0
for a in A:
    tot = (tot+a)%mod
ans = 0
for a in A:
    tot =(tot-a)%mod
    ans+=(tot*a)%mod
print(ans%mod)


Measured memory_bytes: 32176
#include <iostream>
#include <string>

using namespace std;


int main() {

  int n;
  string buf;

  int a,b,c;
  int sum;

  
  while(cin >> n,n) {

    sum=1;

    a=1;
    b=2;   
    c=3;

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

      int tmp;

      cin >> buf;

      if(buf=="North") {

	tmp=a;
	a=b;
	b=7-tmp;
      
      }

      else if(buf=="East") {

	tmp=c;
	c=a;
	a=7-tmp;

      }

      else if(buf=="West") {

	tmp=a;
	a=c;
	c=7-tmp;

      }

      else if(buf=="South") {

	tmp=b;
	b=a;
	a=7-tmp;

      }

      else if(buf=="Right") {

	tmp=b;
	b=c;
	c=7-tmp;

      }

      else if(buf=="Left") {

	tmp=c;
	c=b;
	b=7-tmp;

      }

      sum+=a;

    }

    cout << sum << endl;

  }

  return 0;

}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N, A, B;
  cin >> N >> A >> B;
  if ((B-A)%2 == 0) {
    cout << (B-A)/2 << endl;
  } else {
    if (A > B) swap(A, B);
    int64 rl = A-1;
    rl += (B-rl) /2;
    int64 rr = N-B;
    rr += (N-(A+rr)+1)/2;
    cout << min(rl, rr) << endl;
  }
}


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

int main() {
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if (a * a + b * b <= d * d) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
const int INF=1001001001;

int gcd3(int x,int y,int z){
    int tmp=gcd(x,y);
    int ans=gcd(tmp,z);
    
    return ans;
    
    
    
}

int main() {
    int k;
    cin>>k;
    long long ans =0;
    rep(i,k){
        rep(j,k){
            rep(l,k){
                ans+=gcd3(i,j,l);
                
                
            }
            
            
        }
        
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

void no() {
  cout << "No" << endl;
  exit(0);
}

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

int N;
int a[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  int mn = INF, mx = -INF;
  REP(i, N) {
    cin >> a[i];
    chmin(mn, a[i]);
    chmax(mx, a[i]);
  }
  if (mx - mn > 1) no();
  int L = 0, R = 0;
  REP(i, N) {
    L += (a[i] == mn);
    R += (a[i] == mx);
  }
  if (mn == mx) {
    if (mn == N-1 || mn*2 <= N) yes();
    else no();
  } else {
    if (R >= 2 && (L+1 <= mx && mx <= L+R/2)) yes();
    else no();
  }

  return 0;
}

Measured memory_bytes: 1024
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Jul 20 21:12:29 2019
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	arr := make([]int, n)
	m := map[int]int{}
	for i := range arr {
		fmt.Scan(&arr[i])
		m[arr[i]]++
	}

	var nums []int
	for k := range m {
		nums = append(nums, k)
	}
	sort.Ints(nums)
	max := nums[len(nums)-1]
	for i := range arr {
		if arr[i] != max {
			fmt.Println(max)
		} else {
			if m[arr[i]] > 1 {
				fmt.Println(max)
			} else {
				fmt.Println(nums[len(nums)-2])
			}
		}
	}
}


Measured memory_bytes: 18304
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n,cnt4=0,cnt2=0,cnt=0;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (a[i] % 4 == 0)cnt4 += 1;
		else if (a[i] % 2 == 0)cnt2 += 1;
		else cnt++;
	}
	cout << (cnt4 >= (cnt2%2) + cnt  - 1 ? "Yes" : "No") << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int cnt[1000010];

void solve(int ca){
    int N; cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }

    sort(a.begin(),a.end());

    if(cnt[1]==1){
        cout<<1<<endl;
        return;
    }else if(cnt[1]>1){
        cout<<0<<endl;
        return;
    }

    int ans=0ll;
    for(auto i:a){
        bool f=true;
        if(cnt[i]>1) continue;
        for(int j=1;j*j<=i;++j){
            if(i%j==0){
                if(binary_search(a.begin(),a.end(),j)||(j!=1&&binary_search(a.begin(),a.end(),i/j))){
                    f=false;
                    break;
                }
            }
        }
        if(f) ans++;
    }

    cout<<ans<<endl;



}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


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

int main(void){
  int A,B;
  cin>>A>>B;
  for(int i=1;i<=1000;i++){
    int tax_A=i*0.08;
    int tax_B=i*0.10;
    if(tax_A==A&&tax_B==B){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


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

int main()
{
    ll num;
    cin>>num;
    vector<ll> p(num), q(num), temp(num);
    for (int i = 0; i < num; ++i) {
        cin>>p[i];
        temp[i] = p[i];
    }
    for (int i = 0; i < num; ++i) {
        cin>>q[i];
    }
    sort(temp.begin(), temp.end());
    ll counter = 0;
    vector<ll> result;
    if(p == temp || q == temp)
    {
        if(p == q)
        {
            result.push_back(counter);
            result.push_back(counter);
        }
        else
            result.push_back(counter);
    }
    while (next_permutation(temp.begin(), temp.end()))
    {

        counter++;
        if(p == temp || q == temp)
        {
            if(p == q)
            {
                result.push_back(counter);
                result.push_back(counter);
            }
            else
                result.push_back(counter);
        }
        if(result.size() == 2)
            break;
    }
    cout<<result[1] - result[0];
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int day[]={31,29,31,30,31,30,31,31,30,31,30,31};
int main(){
	int m,d;
	map<int,string>v;
	v[0]="Wednesday";
	v[1]="Thursday";
	v[2]="Friday";
	v[3]="Saturday";
	v[4]="Sunday";
	v[5]="Monday";
	v[6]="Tuesday";
	while(cin>>m>>d){
		if(m==0&&d==0)
			break;
		int temp=d;
		for(int i=1;i<m;i++)
			temp+=day[i-1];
		temp%=7;
		cout<<v[temp]<<endl;
	}
	return 0;
}


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


int main (){
    int N;
    cin>>N;
    vector<int> Vec(N);
    int sum=0;
    for (int i=0; i<N; i++){
        cin>>Vec.at(i);
        sum += Vec.at(i);
    }
    int minof =100*N;
    int sum1=0;
    int sum2;
    for (int i=0; i<N; i++){
        sum1+=Vec.at(i);
        sum2=sum-sum1;
        int dif=abs(sum1-sum2);
        minof=min(minof, dif);
    }
    cout<<minof<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define n 5

int main(void){
    int x[n]={0};

    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }

    for(int i=0;i<n;i++){
        if(x[i]!=i+1){
            printf("%d\n",i+1);
        }
    }
    return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	int A[3];
	REP(i, 3)cin >> A[i];
	VS S(N);
	REP(i, N)cin >> S[i];
	VI ans;

	REP(i, N) {
		int n1, n2;
		int a, b;
		int res;
		if (S[i] == "AB")a = 0, b = 1;
		if (S[i] == "AC")a = 0, b = 2;
		if (S[i] == "BC")a = 1, b = 2;
		
		if (A[a] < A[b])res = a;
		else res = b;

		if (i != N - 1) {
			if (S[i + 1] == "AB")n1 = 0, n2 = 1;
			if (S[i + 1] == "AC")n1 = 0, n2 = 2;
			if (S[i + 1] == "BC")n1 = 1, n2 = 2;

			if (A[n1] + A[n2] <= 1) {
				if (res == a && (b == n1 || b == n2) && S[i] != S[i + 1])res = b;
				if (res == b && (a == n1 || a == n2) && S[i] != S[i + 1])res = a;
			}
		}


		ans.push_back(res);
		A[res]++;
		if (res == a)A[b]--;
		else A[a]--;

		if (A[0] < 0 || A[1] < 0 || A[2] < 0) {
			cout << "No" << endl;
			return 0;
		}

	}


	cout << "Yes" << endl;
	REP(i, N) {
		if (ans[i] == 0)cout << "A" << endl;
		if (ans[i] == 1)cout << "B" << endl;
		if (ans[i] == 2)cout << "C" << endl;
	}

	return 0;
}



Measured memory_bytes: 7408
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int X, Y;
  cin >> X >> Y;
  cout << X + Y/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;

ll solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


ll solve(void)
{
	ll n, k, q;

	cin >> n >> k >> q;

	vector<ll> a(q), p(n, k);

	ll m = 0;
	for(auto& v: a) {
		cin >> v;
		p[v - 1] ++;
		m = max(m, p[v]);
	}

	for(auto& v: p)
		v -= q;

	for (auto &v : p)
		cout << ((v > 0) ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 2176
#include<stdio.h>

int main(){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(y<h-r+r && x<w-r+r && x>=r && y>=r){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 1988
#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;
    vector <int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];

    int counta=0;
    int countb=0;

    vector <int> nums(n);
    iota(all(nums),1);

    
    int count=0;

    do{
        bool oka = true;
        bool okb = true;
        for(int i=0; i<n; i++){
            if(nums[i] != p[i]) {
                oka = false;
            }
            if(nums[i] != q[i]){
                okb = false;
            }
        }
        if(oka) counta = count;
        if(okb) countb = count;
        count ++;
    }while(next_permutation(all(nums)));

    cout << abs(counta - countb) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const LL INF = 1e14;
const LL MOD = 1e9 + 7;

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;}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VI h(n);
  INPUT(h);
  int ans = 0;
  REPx(x, h) if (x >= k) ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<string>
#include<queue>
#include<iomanip>
#include<bitset>
#include<math.h>
#include<stack>
#include<set>
using namespace std;
#define int long long
int mod = 1000000007;
int bp(int a, int b) {
	if (!b) {
		return 1;
	}
	if (b & 1) {
		return ((a * bp(a, b - 1)) % mod);
	}
	else {
		return (bp((a * a)%mod, b / 2) % mod);
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	int n, k;
	cin >> n >> k;
	int r = 0;
	vector<int> v(k+1);
	for (long long i = k; i >= 1; i--) {
		int banana = bp(k / i, n);
		for (long long j = 2; i*j <= k; j++) {
			banana = (banana - v[j * i] + mod)%mod;
		}
		v[i] = banana;
		r += (v[i]*i)%mod;
		r %= mod;
		//cout <<i << ' '<< v[i] << endl;
	}
	cout << r;
}
	

Measured memory_bytes: 4036
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

TE = []
for i in range(K):
    TE.append([])

for i, ti in enumerate(T):
    TE[i%K].append(ti)


def f(te):
    if te == 'r':
        return P
    elif te == 's':
        return R
    elif te == 'p':
        return S
    else:
        return 0

# print(TE)
ans = 0
for te in TE:
    for i in range(len(te)):
        if i == 0:
            continue
        elif te[i] == te[i-1]:
            te[i] = '!'

# print(TE)

ans = 0
for te in TE:
    for ti in te:
        ans += f(ti)
print(ans)

Measured memory_bytes: 13436