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

const int MAXN = 2005, mod = 924844033, g = 5;

int dp[2][MAXN][MAXN][2];

int n, k;
int T[MAXN];

int rev[1<<12|1], cur[1<<12|1], A[1<<12|1];

inline int power(int a, int n)
{
	int ans = 1;
	for (; n; n >>= 1) {
		if (n&1) ans = (long long)ans*a%mod;
		a = (long long)a*a%mod;
	}
	return ans;
}

inline int inv(int a)
{ return power(a, mod-2); }

void NTT(int a[], int n, int lgn, int flag)
{
	for (int i = 1; i < n; i++) rev[i] = ((rev[i>>1]>>1)|((i&1)<<(lgn-1)));
	for (int i = 1; i < n; i++)
		if (rev[i] < i)
			swap(a[i], a[rev[i]]);
	for (int k = 2; k <= n; k <<= 1) {
		int dw = power(g, (mod-1)/k);
		if (flag == -1) dw = inv(dw);
		for (int i = 0; i < n; i += k) {
			int w = 1, u, v;
			for (int j = 0; j < k>>1; j++) {
				u = a[i+j], v = (long long)w*a[i+j+(k>>1)]%mod;
				a[i+j] = (u+v)%mod, a[i+j+(k>>1)] = ((u-v)%mod+mod)%mod;
				w = (long long)w*dw%mod;
			}
		}
	}
	if (flag == -1) {
		int invn = inv(n);
		for (int i = 0; i < n; i++)
			a[i] = (long long)a[i]*invn%mod;
	}
}

int pre[MAXN];

int fac[MAXN], ifac[MAXN];

inline int choose(int n, int m)
{ return (long long)fac[n]*ifac[m]%mod*ifac[n-m]%mod; }

int main()
{
	cin >> n >> k;
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = (long long)fac[i-1]*i%mod;
		ifac[i] = (long long)ifac[i-1]*inv(i)%mod;
	}
	int tot = 0;
	for (int i = 1; i <= n; i++) {
		T[i] = 1, pre[i] = i;
		if (i > 2*k)
			T[i] = T[i-2*k]+1, pre[i] = pre[i-2*k];
		tot = max(tot, T[i]);
	}
	dp[0][0][0][1] = 1;
	dp[1][0][0][0] = 1;
	for (int y = 0; y < 2; y++) {
		for (int i = 1; i <= tot; i++)
			for (int j = 0; j <= i; j++) {
				dp[y][i][j][0] = (dp[y][i-1][j][0]+dp[y][i-1][j][1])%mod;
				if (j)
					dp[y][i][j][0] = (dp[y][i][j][0]+dp[y][i-1][j-1][0])%mod;
				if (j)
					dp[y][i][j][1] = (dp[y][i-1][j-1][0]+dp[y][i-1][j-1][1])%mod;
			}
	}
	cur[0] = 1;
	int highest = 0;
	int N = 1, lgn = 0;
	while (N <= n) N <<= 1, lgn++;
	NTT(cur, N, lgn, 1);
	for (int i = n; i >= 1 && i+2*k > n; i--) {
		memset(A, 0, sizeof A);
		for (int j = 0; j <= T[i]; j++) {
			if (i+k > n)
				A[j] = dp[pre[i]-k>=1][T[i]][j][0];
			else A[j] = dp[pre[i]-k>=1][T[i]][j][0]+dp[pre[i]-k>=1][T[i]][j][1];
			// cerr << A[j] << " ";
		}
		// cerr << endl;
		NTT(A, N, lgn, 1);
		for (int j = 0; j < N; j++) cur[j] = (long long)cur[j]*A[j]%mod;
	}
	NTT(cur, N, lgn, -1);
	int ans = 0, flag = 1;
	for (int j = 0; j <= n; j++) {
		(ans += (long long)flag*cur[j]%mod*fac[n-j]%mod) %= mod;
		flag = (long long)flag*(mod-1)%mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 33664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define int long long
#define elif else if
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
signed main(){
  
  string s;
  cin >> s;
  int n = s.size();
  //cout << n / 2 << "\n";
  rep(i, 0, n / 2){
    //cout << s[i] << " " << s[n - i - 1] << "\n";
    if(s[i] != s[n - i - 1]){
      cout << "No\n";
      return 0;
    }
  }
  
  int nn = (n - 1) / 2;
  //cout << nn << "\n";
  rep(i, 0, nn / 2){
    //cout << s[i] << " " << s[nn - 1 - i] << "\n";
    if(s[i] != s[nn - 1 - i]){
      cout << "No\n";
      return 0;
    }
  }
  nn = (n + 3) / 2;
  int m = n - nn;
  nn--;
  rep(i, 0, m / 2){
   // cout << s[nn + i]  << " " << s[n - 1 - i] << "\n";
    if(s[nn + i] != s[n - 1 - i]){
      cout << "No\n";
      return 0;
    }
  }
  
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include<algorithm> 
#include <numeric>
#include <vector>
using namespace std;
int main(void){
    int a,b,k;
    cin>>a>>b>>k;
    vector<int> v;
    for (int i = 1; i<=a; i++){
        if (a%i==0 && b%i==0){
            v.push_back(i);
        }
    }
    reverse(v.begin(), v.end());
    cout<<v.at(k-1);
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <limits>
#include <unordered_map>

int f(int n, int x)
{
	int count = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i+1; j <= n; j++)
		{
			for (int k = j+1; k <= n; k++)
			{
				if (i + j + k == x) count++;
			}
		}
	}
	return count;
}

int main()
{
	while(true)
	{
		int n, x;
		std::cin >> n >> x;
		if (n == 0 && x == 0) return 0;
		std::cout << f(n, x) << std::endl;
	}
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
inline int gi() {
  char ch=getchar(); int q=0,x=0;
  while(ch<'0'||ch>'9') q=(ch=='-'?1:q),ch=getchar();
  while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int main(){
  int n=gi(),k=gi(); --n,--k;
  cout<<(n/k+(n%k!=0));
  return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back


ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

int main()
{
    ll N, K;
    cin >> N >> K;

    vec C(K+1, 0);
    for(ll i=K; i>=1; --i) {
        C[i] = modpow(K/i, N, MOD);
        for(ll j=i*2; j<=K; j+=i) {
            C[i] = (C[i] - C[j]) % MOD;
        }
    }

    ll sum = 0;
    REP(i,1,K+1) {
        sum = (sum + (i * C[i]) % MOD) % MOD;
    }
    sum = (sum < 0 ? sum + MOD : sum);
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 4016
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int64_t ans = 0;

    std::map<int64_t, int> counts;
    for (int n = input<int>(); n != 0; --n)
        counts[input<int>()] += 1;

    vector<int> lst;
    for (auto& p: counts) {
        if (p.second >= 4)
            ans = max(ans, int64_t(p.first) * p.first);
        if (p.second >= 2)
            lst.push_back(p.first);
    }
    
    if (lst.size() >= 2)
        ans = max(ans, int64_t(lst.back()) * lst[lst.size() - 2]);
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define N 100010
#define M 200010
#define endl "\n"

ll gcd(ll a_,ll b_){if(b_>a_)swap(b_,a_);return (b_==0?a_:gcd(b_,a_%b_));}

ll n, k, ar[12];

bool check(ll n){
	while(n != 0){
		if(ar[n % 10] > 0) return false;
		n /= 10;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(NULL);
	
	cin >> n >> k;
	REP(i, k) {
		int x;
		cin >> x;
		ar[x]++;
	}
	
	for(ll i = n; ; i++){
		if(check(i)){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int q = int.Parse(Console.ReadLine());

			int max = 100001;
			var primes = new bool[max];
			for (int i = 2; i < max; i++) {
				primes[i] = true;
			}

			for (int i = 2; i < max; i++) {
				if (primes[i] == false) {
					continue;
				}

				int num = i * 2;
				while (num < max) {
					primes[num] = false;
					num += i;
				}
			}

			int count = 0;
			int[] ruis = new int[max];
			for (int i = 3; i < max; i++) {
				if (primes[i] && primes[(i + 1) / 2]) {
					++count;
				}

				ruis[i] = count;
			}

			var sb = new StringBuilder();
			for (int i = 0; i < q; i++) {
				var lr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				int val = ruis[lr[1]] - ruis[lr[0] - 1];
				sb.AppendLine(val.ToString());
			}

			Console.Write(sb.ToString());
		}
	}
}

Measured memory_bytes: 17776
#include <iostream>
#define FOR0(var, max) for (ui var = 0; var < max; ++var)

using namespace std;

using ui = unsigned int;
using uc = unsigned char;

int main(int ac, char **av) {
  ui N;
  cin >> N;
  cout << N * N * N << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 main(){
ll n,m;
cin>>n>>m;
V<int> a(m+1,0);
for(int i=0;i<n;i++){
    int t;cin>>t;
    for(int j=0;j<t;j++){
        int v;cin>>v;
        a[v]++;
    }
}
sort(all(a),greater<ll>());
int ans=0;
for(int i=0;i<m+1;i++){
    if(a[i]==n)ans++;
    else break;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    long long int N,M;
    cin >> N >> M;
    if((N == 1 && M != 1) || (N != 1 && M == 1)) {
        cout << max(M,N)-2 << endl;
    }else {
        cout << (N-2) * (M-2) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let H: usize = sc.get();
    let W: usize = sc.get();
    let mut a: Vec<Vec<i64>> = sc.mat(H, W);
    let mut ans = Vec::new();
    for i in 0..H {
        for j in 0..W {
            if a[i][j] % 2 != 0 {
                if j + 1 < W {
                    a[i][j] -= 1;
                    a[i][j+1] += 1;
                    ans.push(((i+1, j+1), (i+1, j+2)));
                } else if i + 1 < H {
                    a[i][j] -= 1;
                    a[i+1][j] += 1;
                    ans.push(((i+1, j+1), (i+2, j+1)));
                }
            }
        }
    }
    println!("{}", ans.len());
    for ((i1, j1), (i2, j2)) in ans {
        println!("{} {} {} {}", i1, j1, i2, j2);
    }
}


Measured memory_bytes: 13304
import sys
sys.setrecursionlimit(10**6)
n=int(input())
INF=9999999999
d=[INF for _ in range(n)]
g=[[] for _ in range(n)]


for i in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append([b-1,c])
    g[b-1].append([a-1,c])

def dfs(v,p,dv):
    d[v]=dv
    for gi,c in g[v]:
        if(gi==p):
            continue
        dfs(gi,v,dv+c)

q,k=map(int,input().split())

dfs(k-1,-1,0)

for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])


Measured memory_bytes: 137936
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    vector<int> numbers(5);

    for (int i = 0; i < 5; ++i) {
        cin >> numbers[i];
    }

    int min = 9;
    bool changed = false;
    for (int i = 0; i < numbers.size(); ++i) {
        int number = numbers[i];
        number = number % 10;

        if (number != 0 && min >= number) {
            min = number;
            changed = true;
        }
    }

    if (!changed) {
        int sum = 0;
        for (int i = 0; i < numbers.size(); ++i) {
            sum += numbers[i];
        }
        cout<< sum << endl;
        return 0;
    }


    int sum = 0;
    for (int i = 0; i < numbers.size(); ++i) {
        int number = numbers[i];

        if (number % 10 == 0) {
            sum += number;
        } else {
            sum += (number / 10 + 1) * 10;
        }
    }

    cout << sum - 10 + min << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	long long int a[100000], l, a1[100000];
	scanf("%d %lld", &n, &l);
	int e=0, i0;
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		if(i>0){
			a1[i]=a[i]+a[i-1];
			if(a1[i]>=l){
				e=1;
				i0=i;
			}
		}
	}
	if(e==0){
		printf("%s\n", "Impossible");
	}else{
		printf("%s\n", "Possible");
		for(int i=0; i<i0-1; i++){
			printf("%d\n", i+1);
		}
		for(int i=n-2; i>=i0; i--){
			printf("%d\n", i+1);
		}
      printf("%d\n", i0);
	}
	return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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 A, B;
    cin >> A >> B;
    if(A == B) {
        cout << A + B << endl;
        return 0;
    } else if(A < B) swap(A, B);
    cout << A + A - 1 << endl;

}


Measured memory_bytes: 256
//In the name of 'ALLAH'//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a , b ;
    cin >> a >> b ;
    string s[a] ;
    for( int i =0; i < a; i++ )
    {
        cin>>s[i];
    }
    sort( s , s+a );
    for( int i =0; i < a; i++)
    {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int x,y;
int now;
int main(){
    scanf("%d %d",&x,&y);
    if(x<=3)  now+=(4-x)*100000;
    if(y<=3)  now+=(4-y)*100000;
    if(x==1 && y==1)  now+=400000;
    printf("%d\n",now);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, a, b, c;
	cin >> n >> a >> b >> c;
	
	/*a = min(a, 1LL);
	b = min(b, 1LL);
	c = min(c, 1LL);*/

	vector<string>s(n);
	for (ll i = 0; i < n; i++) cin >> s[i];

	if (max({ a,b,c }) == 0) {
		cout << "No";
		return 0;
	}
	
	string ans = "";

	unordered_map<char, ll> m;
	m['A'] = a;
	m['B'] = b;
	m['C'] = c;

	vector<char> kek = { 'A', 'B', 'C' };


	auto check = [&]() {
		for (auto c : kek) {
			if (m[c] < 0) {
				cout << "No";
				exit(0);
			}
		}
	};

	auto go = [&](char c1, char c2) {
		m[c1]++;
		m[c2]--;
		ans += c1;
	};

	for (ll i = 0; i < n; i++) {
		auto c1 = s[i][0], c2 = s[i][1];
		if (m[c1] == 0) {
			go(c1, c2);
		} else if (m[c2] == 0) {
			go(c2, c1);
		} else if (m[c1] == m[c2]) {
			if (i == n - 1) {
				go(c1, c2);
			} else {
				auto cc1 = s[i + 1][0], cc2 = s[i + 1][1];
				if (c1 == cc1 and c2 == cc2) {
					go(c1, c2);
				} else {
					if (c1 == cc1 or c1 == cc2) {
						go(c1, c2);
					} else {
						go(c2, c1);
					}
				}
			}
		} else {
			//assert(m[c1] == 2 or m[c2] == 2);
			if (m[c1] > m[c2]) go(c2, c1);
			else go(c1, c2);
		}

		check();
	}

	cout << "Yes\n";
	for (auto c : ans) {
		cout << c << '\n';
	}



	return 0;
}

/*

*/

Measured memory_bytes: 6752
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
using namespace std;
typedef long long int ll;

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

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

const ll INF = 1LL << 60;

int N, W, w[110], v[110];

// dp[i][w]:最初のi個の品物を容量w以下で持ち帰るときの価値の総和の最大値
ll dp[110][110000];

int main() {

  cin >> N >> W;
  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

  for (int i = 0; i <= N; i++)
    for (int j = 0; j <= W; j++)
      dp[i][j] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      chmax(dp[i+1][j], dp[i][j]);
      if (j + w[i] <= W) chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 88192
fun int() = readLine()!!.toInt()
fun ints() = readLine()!!.split(" ").map {it.toInt()}.toIntArray()

fun triangle(n:Int) = n*(n+1)/2

fun main() {
	val day = int()
	val days = 0 until day
	val types = 0..25

	val penalty = ints()
	val advantage = Array(day) {ints()}

	var r = 0L
	val t = IntArray(day) {-1}

	fun lastLeft(d:Int,type:Int) = (d downTo 0).find {t[it]==type} ?: -1

	fun calcPenaltySum(d:Int,type:Int) = penalty[type]*triangle(d-lastLeft(d,type))

	for(d in days) {
		val ct = types.maxBy {advantage[d][it]+calcPenaltySum(d,it)}!!
		t[d] = ct
		r += advantage[d][ct]-calcPenaltySum(d-1,ct)
	}

	for(ct in types)
		r -= calcPenaltySum(364,ct)

	System.err.println(r)
	t.forEach {println(it+1)}
}


Measured memory_bytes: 43036
program main
  implicit none
  
  integer :: i,j,n,m,l(50)=0,a,b
  
  read(*,*)n,m
  do i = 1, m
    read(*,*)a,b
    l(a) = l(a) + 1
    l(b) = l(b) + 1
  end do
  
  do i = 1, n
    write(*,*)l(i)
  end do
end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
string s;
int main() {
	cin>>s;
	if(s=="KIHBR"||s=="KIHBRA"||s=="KIHBAR"||s=="KIHBARA"||s=="KIHABR"||s=="KIHABRA"||s=="KIHABAR"||s=="KIHABARA"||s=="AKIHBR"||s=="AKIHBRA"||s=="AKIHBAR"||s=="AKIHBARA"||s=="AKIHABR"||s=="AKIHABRA"||s=="AKIHABAR"||s=="AKIHABARA")
		puts("YES");
	else	puts("NO");
	return 0;
}

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

const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
const int MAXN = 5010;
int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void addedge(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int n, rtv, rt, sz[MAXN];
void getroot(int u, int f = 0) {
	int ma = 0; sz[u] = 1;
	for (int i = head[u]; i; i = nxt[i])
		if (to[i] != f) {
			getroot(to[i], u);
			ma = std::max(ma, sz[to[i]]);
			sz[u] += sz[to[i]];
		}
	ma = std::max(ma, n - sz[u]);
	ma < rtv ? (rtv = ma, rt = u) : 0;
}
int fac[MAXN], inv[MAXN];
int li[MAXN], bak;
int dp[MAXN];
int C(int a, int b) {
	return (LL) fac[a] * inv[b] % mod * inv[a - b] % mod;
}
int D(int a, int b) {
	return (LL) fac[a] * inv[a - b] % mod;
}

int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fac[i] = (LL) fac[i - 1] * i % mod;
		inv[i] = (LL) inv[mod % i] * (mod - mod / i) % mod;
	}
	for (int i = 2; i <= n; ++i) inv[i] = (LL) inv[i] * inv[i - 1] % mod;
	for (int i = 1, t1, t2; i < n; ++i)
		std::cin >> t1 >> t2, addedge(t1, t2);
	rtv = n + 1; getroot(1);
	int ans = 0;
	if (rtv * 2 == n) ans = (LL) fac[n / 2] * fac[n / 2] % mod;
	else {
		for (int i = head[rt]; i; i = nxt[i])
			if (sz[to[i]] <= n / 2) li[++bak] = sz[to[i]];
		if (sz[rt] != n) li[++bak] = n - sz[rt];
		for (int i = *dp = 1, hi = 0; i <= bak; hi += li[i++])
			for (int j = hi + li[i]; ~j; --j) {
				LL t = 0;
				for (int k = std::min(j, hi); j - k <= li[i] && ~k; --k)
					t += (LL) dp[k] * C(li[i], j - k) % mod * D(li[i], j - k) % mod;
				dp[j] = t % mod;
			}
		for (int i = 0; i <= n; ++i) {
			int t = (LL) dp[i] * fac[n - i] % mod;
			if (i & 1) reduce(t = -t);
			reduce(ans += t - mod);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=3e4+2;

int main(){
	int N;
	cin>>N;
	int a[MAX];
	rep(i,N)cin>>a[i];

	int ans=0;
	rep(i,N)ans+=a[i];
	ans-=N;
	cout<<ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(A: int, V: int, B: int, W: int, T: int):
    d = abs(A - B)
    if V > W and d / (V - W) <= T:
        ret = YES
    else:
        ret = NO
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, V, B, W, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61784
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	string a, b, c; cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    if(n / 100 == 7 || n % 100 / 10 == 7 || n % 10 == 7) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;


int K;

// *********************************************************
int main(){

    cin >>  K;

    rep(i,K){
        cout<<"ACL";
    }
    cout <<endl;




    return 0;
}

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

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

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

  int count4=0, countx=0, count2=0;
  rep(i,n){
    ll a;
    cin >> a;
    if(a%4==0) count4++;
    else if(a%2==0)count2++;
    else countx++;
  }
  
  //cout << count4 << " " << countx;

  if(count2==0&&count4+1>=countx) cout << "Yes";
  else if(count4>=countx) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int a[100005],Cnt;
map<int,int> mp;
int main(){
//	freopen("test_15.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i],Cnt+=(a[i]==a[i-1]);
	if(Cnt==n) return puts("Yes"),0;
	if(n%3!=0) puts("No");
	else{
		int cnt=0;
		for(int i=1;i<=n;++i)
			mp[a[i]]++;
		int A=0,B=0,C=0;
		for(int i=1;i<=n;++i)
			if(mp[a[i]]==n/3){
				cnt++,mp[a[i]]--;
				if(cnt==1) A=a[i];
				if(cnt==2) B=a[i];
				if(cnt==3) C=a[i];
			} 
	//	cout<<cnt<<" "<<A<<" "<<B<<" "<<C<<endl;
		if(cnt==1 && A==0) return puts("Yes"),0;
		if(cnt==3 && (A^B)==C) puts("Yes");
		else puts("No");
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
#define PI acos(-1.0)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

int main()
{
    
    int a, b, c, d, sum=0;
    vi v;
    cin>>a>>b>>c;
    v.pb(abs(a-b)+abs(b-c));
    v.pb(abs(a-c)+abs(c-b));
    v.pb(abs(b-a)+abs(a-c));
    v.pb(abs(b-c)+abs(c-a));
    v.pb(abs(c-b)+abs(b-a));
    v.pb(abs(c-a)+abs(a-b));
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e3 + 10, inf = 0x3f3f3f3f;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    ll n, ans = 1, p = 1;
    cin >> n;
    while (n > 1){
        p <<= 1;
        n >>= 1;
        ans += p;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    
    if(a<b) printf("%s\n","a < b");
    else if(a == b) printf("%s\n","a == b");
    else printf("%s\n","a > b");
    
    
    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  string s; cin>>s;
  
  ll ans=0;
  
  ll l=0, r=n-1;
  while(l<r){
    while(l<n && s[l]=='R') l++;
    while(r>=0 && s[r]=='W') r--;
    if(l<r){
      ans++;
      swap(s[l],s[r]);
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3656
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().trim.toInt
  val lst1 = StdIn.readLine().trim.split(' ').map(_.toInt)
  val t = StdIn.readLine().trim.toInt
  val lst2 = StdIn.readLine().trim.split(' ').map(_.toInt)

  def search(key: Int): Boolean = {
    var left = 0
    var right = n
    var ret = false
    while(left < right && !ret) {
      val mid = (right + left) / 2
      if (lst1(mid) == key) {
        ret = true
      } else if(key < lst1(mid)) {
        right = mid
      } else {
        left = mid + 1
      }
    }
    ret
  }

  val result = lst2.foldLeft(0){ (acc, e) =>

    if(search(e)) acc + 1 else acc
  }
  
  println(result)

}



Measured memory_bytes: 76276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  multiset<int> s;
  vector<pii> v;
  rep(i, n) v.eb(a[i], i);
  sort(all(v), greater<>());
  s.insert(-1); s.insert(-1);
  s.insert(n); s.insert(n);
  auto i_ = s.lower_bound(n);
  ll ans = 0;
  rep(i, n) {
    // cerr << v[i] << endl;
    auto it3 = s.lower_bound(v[i].S);
    auto it4 = ++it3;
    --it3;
    auto it2 = --it3;
    ++it3;
    auto it = --it2;
    ++it2;
    // cerr << *it << " " << *it2 << " " << *it3 << " " << *it4 << endl;
    s.insert(v[i].S);
    ans += 1LL * v[i].F * (*it2 - *it) * (*it3 - v[i].S);
    ans += 1LL * v[i].F * (*it4 - *it3) * (v[i].S - *it2);
    // cerr << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9000
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
// #pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                int li = l[i], lj = l[j], lk = l[k];
                if (li==lj || li == lk || lj == lk){
                    continue;
                }
                if (abs(lk-lj) < li && li < lk+lj){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
L = [int(input()) for _ in range(4)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip

ans = 0
for i in range(L[0] + 1):
    for j in range(L[1] + 1):
        for k in range(L[2] + 1):
            if 500 * i + 100 * j + 50 * k == L[3]:
                ans += 1

print(ans)

Measured memory_bytes: 39664
/* ARC058-Eストック - 和風すぬけ */
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N, X, Y, Z; 
	cin >> N >> X >> Y >> Z; 
	int L = X+Y+Z;
	long long mod = 1000000007; 
	long long dp[41][131080] = {}; 
	dp[0][1] = 1; 
	for(int i = 0; i < N; i++){
		for(int j = 1; j < (1 << L); j++){
			if(!dp[i][j]) continue; 
			int x = (j & ((1 << X) - 1)); 
			int y = ((j & ((1 << (X + Y)) - 1)) >> X); 
			int z = (j >> (X + Y));
			for(int k = 1; k <= 10; k++){
				int nx = x; int ny = y; int nz = z; 
				nx <<= k; ny <<= k; nz <<= k; 
				nx &= ((1 << (X+1)) - 1); 
				ny &= ((1 << (Y+1)) - 1); 
				nz &= ((1 << (Z+1)) - 1); 
				if(nz >> Z) continue; 
				ny <<= X; nz <<= X+Y; 
				int n = (nx | ny | nz | 1); 
				dp[i+1][n] += dp[i][j]; 
				if(dp[i+1][n] >= mod) dp[i+1][n] -= mod; 
			}
		}
	}
	long long ans = 1; 
	for(int i = 0; i < N; i++){
		ans *= 10; ans %= mod; 
	}
	ans += mod * 194194; 
	for(int i = 0; i < (1 << L); i++){
		ans -= dp[N][i]; 
	}
	cout << ans % mod << "\n"; 
}

Measured memory_bytes: 45592
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  double w,h,x,y;
  cin>>w>>h>>x>>y;

  printf("%6f\n",w*h/2);
  if(x*2==w && y*2==h) cout<<1;
  else cout<<0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
main(){
  long long N,NN;
  scanf("%lld",&N);
  if(N==2){printf("1");return 0;}
  long long ans=2;
  for(long long K=2;K*K<=N;K++){
    if((N-1)%K){
      NN=N;
      while(!(NN%K)){
        NN=NN/K;
      }
      if(NN%K==1)ans++;
    }else{
      if(K*K==N-1)ans++;
      else ans+=2;
    }
  }
  printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
const ll MOD=1e9+7;
using namespace std;

int main(){
  ll N;
  cin >> N;
  vector<ll> a(N);
  ll cnt = 1, key = 0;
  bool f1,f2;
  cin >> a[0];
  for(ll i=1;i<N;i++){
    cin >> a[i];
    if(key == 0){
      if(a[i-1]<a[i]) {
        f1 = true;
        f2 = false;
      }else if(a[i-1]>a[i]){
        f1 = false;
        f2 = true;
      }else{
        continue;
      }
      key++;
    }else{
      if(f1){
        if(a[i-1]>a[i]){
          key = 0;
          cnt++;
          continue;
        }
      }else if(f2){
        if(a[i-1]<a[i]){
          key = 0;
          cnt++;
          continue;
        }
      }
      key++;
    }
  }
  cout << cnt << endl;
}

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

int main(){
	int f[5],sum = 0, min = 10, temp;
	bool l = false;
	for(int i = 0; i < 5; i++){
		cin >> f[i];
		sum += f[i] / 10;
		temp = f[i] % 10;
		if(temp){
			l = true;
			sum++;
			if(temp < min){
				min = temp;
			}
		}
	}
	if(l){
		sum--;
	}
	sum *= 10;
	if(min != 10){
		sum += min;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
  wi, vi = map(int, input().split())
  w.append(wi)
  v.append(vi)
dp = [[0]*(W+1) for _ in range(N+1)]
3
for i in range(N):
  for sum_w in range(W+1):
    if sum_w-w[i] >= 0:
      dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-w[i]]+v[i])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
      
print(dp[N][W])

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

int main(){
	int n,m,c;
	cin >> n >> m >> c;
	vector<int> b(m);
	for(int i=0; i<m; i++) cin >> b[i];

	int ans = 0;
	for(int i=0; i<n; i++){
		vector<int> a(m);
		int wa = 0;
		for(int j=0; j<m; j++){
		       	cin >> a[j];
			wa += a[j]*b[j];
		}
		if(wa+c>0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine();


			Console.WriteLine(input.Count(c => c == '+') - input.Count(c => c == '-'));
		}
	}
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define x first
#define y second

vector<vector<int>> dp, arr;
int main() {
    fast;
    int n, w;
    cin>>n>>w;
    vector<int> weight(n), value(n);
    for (int i = 0; i < n; ++i) {
        cin>>weight[i]>>value[i];
    }
    ll dp[n+1][w+1];
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= w; ++j) {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else{
                ll leave = dp[i-1][j], take = -1;
                if(weight[i-1] <= j)
                    take = dp[i - 1][j - weight[i-1]] + value[i-1];
                dp[i][j] = max(take, leave);
            }

        }
    }
    cout<<dp[n][w];
}

Measured memory_bytes: 79104
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    for x in range(1,3501):
        for y in range(x,3501):
            bunshi = x*y*N
            bunbo  = 4*x*y-(x+y)*N
            if bunbo>0 and bunshi%bunbo==0:
                print(x,y,bunshi//bunbo)
                exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 9104
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  vector<int> b(n);
  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  for(int i=0;i<n;i++){
    if(b[i]>i+1){
      printf("-1\n");
      return 0;
    }
  }
  vector<int> ans;
  for(int i=0;i<n;i++){
    vector<int> temp(i+1);
    for(int j=0;j<b[i]-1;j++){
      temp[j]=ans[j];
    }
    temp[b[i]-1]=b[i];
    for(int j=b[i]-1;j<i;j++){
      temp[j+1]=ans[j];
    }
    ans=temp;
  }
  for(int i=0;i<n;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long INF=LONG_MAX;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

long dp[100003];
int main(){
	int N;cin>>N;
	vector<long>a(N);
	fill(dp,dp+N,INF);//?????????i??§??????????????????????¢??????¨?????????????°????????°?
	REP(i,N)cin>>a[i];
	REP(i,N){
		*lower_bound(dp,dp+N,a[i])=a[i];
	}
	cout<<lower_bound(dp,dp+N,INF)-dp<<endl;
	return 0;
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[3][3],b[3][3];
  vector<pair<int,int> >p(101);
  vector<int>c(101);
  for(int i=0;i<3;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>a[i][j];
      c[a[i][j]]=1;
      p[a[i][j]]=make_pair(i,j);
    }
  }
   for(int i=0;i<3;i++)
  {
    for(int j=0;j<3;j++)b[i][j]=0;
  }
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int t;
    cin>>t;
    if(c[t])b[p[t].first][p[t].second]=1;
  }
    for(int i=0;i<3;i++)
  {
    if((b[i][0] && b[i][1] && b[i][2]) || (b[0][i] && b[1][i] && b[2][i]))
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if((b[0][0] && b[1][1] && b[2][2]) || b[0][2] && b[1][1] && b[2][0])
  {
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  
  
  
  return 0;
}
  

Measured memory_bytes: 256
strn = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a, b = map(int, input().split())
a_idx = strn.index(a)
b_idx = strn.index(b)

ans = 'Draw'
if a_idx < b_idx:
    ans = 'Bob'
elif a_idx > b_idx:
    ans = 'Alice'
print(ans)


Measured memory_bytes: 2940
using System;

namespace _0049
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = 0;
            int B = 0;
            int AB = 0;
            int O = 0;
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null)
                {
                    break;
                }
                string[] x = s.Split(',');
                if (x[1] == "A")
                {
                    A++;
                }
                if (x[1] == "B")
                {
                    B++;
                }
                if (x[1] == "AB")
                {
                    AB++;
                }
                if (x[1] == "O")
                {
                    O++;
                }
            }
            Console.WriteLine(A);
            Console.WriteLine(B);
            Console.WriteLine(AB);
            Console.WriteLine(O);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 8848