akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n, d; cin >> n >> d;
    vector<ll> x(n), y(n);
    ll cnt = 0;
    rep(i, n){
        cin >> x[i] >> y[i];
        double dis = sqrt(x[i]*x[i]+y[i]*y[i]);
        if(dis <= d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6484
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int result = (int) Math.pow(3, n);
        int evenCount = Arrays.stream(a).filter(i -> i % 2 == 0).toArray().length;
        int minus = (int) Math.pow(2, evenCount);
        result -= minus;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 27092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr 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;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
  int k,x;
  cin>>k>>x;
  if(500*k>=x)cout<<"Yes\n";
  else cout<<"No\n";
}
 
int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) - 1 for _ in range(D)]


def cal_score():
  S = 0
  last = [-1] * 26
  score = 0
  for d in range(D):
    S += s[d][t[d]]
    last[t[d]] = d
    for i in range(26):
        S -= c[i] * (d - last[i])
    score += max(10 ** 6 + S, 0)
    print(S)
    

if __name__ == "__main__":
  cal_score()

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0'; ch=getchar();} while ('0'<=ch&&ch<='9');t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
int n,k;
ll ans,a[maxn],sum;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k);
	int pos=n+1;
	for (int i=1;i<=n;i++) {
		read(a[i]);
		if (a[i]>=0&&pos>n) pos=i;
	}
	ans=1e18;
	for (int i=max(1,pos-k);i<=min(n,pos)&&i+k-1<=n;i++) {
		if (a[i+k-1]<=0)
			sum=-a[i];
		else if (a[i]>=0)
			sum=a[i+k-1];
		else sum=min(abs(a[i]),abs(a[i+k-1]))+abs(a[i])+abs(a[i+k-1]);
		ans=min(ans,sum);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(INF)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
//	ios::sync_with_stdio(false);
//	cin.tie(0);
	
	int n,m; cin>>n>>m;
	vector<pii> v(n);  //pair<cost,value>
	for(auto &i:v){
		cin>>i.F>>i.S;
	}
	sort(all(v));
	int now=0,ans=0;
	priority_queue<int> pq;
	For(i,1,m){
		for(;now<n && v[now].F<=i;now++) pq.emplace(v[now].S);
		if(!pq.empty()){
			ans+=pq.top();
			pq.pop();
		}
	}
	cout<<ans<<"\n";
	return 0;
}




























Measured memory_bytes: 2936
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(Enumerable.Range(1, Math.Min(h[0], h[1])).Reverse().Where(i => h[0] % i == 0 && h[1] % i == 0).ElementAt(h[2] - 1));
	}
}


Measured memory_bytes: 13396
t = int(input())

def floor_sum(n,m,a,b):
    ans = 0
    if a >= m:
        ans += (n - 1) * n * (a // m) // 2;
        a %= m
    if b >= m:
        ans += n * (b // m)
        b %= m

    y_max = (a * n + b) // m
    x_max = (y_max * m - b)
    if y_max == 0:
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ans
for _ in range(t):
    n,m,a,b = map(int,input().split())
    print(floor_sum(n,m,a,b))

Measured memory_bytes: 9180
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	N, K = map(int, input().split(" "))
	S = input()
		
	S0 = S.split("0")
	S1 = S.split("1")
	
	S0 = [x for x in S0 if x]
	S1 = [x for x in S1 if x]
	
	if K == 0:
		ans = 0
		for val in S0:
			tmp = len(val)
			if tmp > ans:
				ans = tmp
		print(ans)
		sys.exit()
		
	if K >= len(S1):
		print(len(S))
		sys.exit()
	
	fst = []
	snd = []
	guu = False
	kii = False
	if S[0] == "1":
		fst = S0
		snd = S1
		kii = True
	else:
		fst = S1
		snd = S0
		guu = True
	
	ansList = []
	while True:
		if len(fst) != 0:
			ansList.append(fst.pop(0))
		if len(snd) != 0:
			ansList.append(snd.pop(0))
		if len(fst) == 0 and len(snd) == 0:
			break
			
	total = []
	for i, val in enumerate(ansList):
		if i == 0:
			total.append(len(val))
			continue
		total.append(total[i-1] + len(val))
	
	ans = 0
	if kii == True:
		for i, val in enumerate(total):
			tmp = 0
			if i == 0:
				tmp = total[2 * K]
			elif i % 2 == 1:
				tmptmp = i+1+(K-1)*2
				if tmptmp >= len(total):
					tmptmp = len(total)-1
				tmp = total[tmptmp] - total[i-1]
			else:
				tmptmp = i+K*2
				if tmptmp >= len(total):
					tmptmp = len(total)-1
				tmp = total[tmptmp] - total[i-1]
			
			if ans < tmp:
				ans = tmp
	else:
		for i, val in enumerate(total):
			tmp = 0
			if i == 0:
				tmp = total[2 * (K-1) + 1]
			elif i % 2 == 1:
				tmptmp = i + K*2
				if tmptmp >= len(total):
					tmptmp = len(total)-1
				tmp = total[tmptmp] - total[i-1]
			else:
				tmptmp = i+1+(K-1)*2
				if tmptmp >= len(total):
					tmptmp = len(total)-1
				tmp = total[tmptmp] - total[i-1]
			
			if ans < tmp:
				ans = tmp
	
	print(ans)
		
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 8748
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)
typedef long long ll;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = (1LL << 32);
    for (int i = 0; i <= max(X, Y) * 2; i++) {
        ans = min(ans, (ll)i * 2 * C + (ll)max(0, X - i) * A + (ll)max(0, Y - i) * B);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string s;
        ll n;
        cin >> s;
        n = len(s);

        rep(i, 0, n-1) {
                if (s[i] == s[i+1]) {
                        cout << i+1 << ' ' << i+2 << endl;
                        return 0;
                }
        }

        rep(i, 0, n-2) {
                if (s[i] == s[i+2]) {
                        cout << i+1 << ' ' << i+3 << endl;
                        return 0;
                }
        }

        cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 3732
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
n = N % 10

ans = None
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    ans = "hon"
elif n == 0 or n == 1 or n == 6 or n == 8:
    ans = "pon"
elif n == 3:
    ans = "bon"

print(ans)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if(a.second == b.second){
        return a.first < b.first;
    }
    return a.second < b.second;
}
int main()
{
    fio;
    ll a, b;
    cin >> a >> b;
    for(int i = 1; i <= 100000; i ++){
        ll k = (i * 8) / 100;
        ll kk = (i * 10) / 100;
        if(k == a && kk == b){
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
M = N
result = []
i = 2
while i * i <= N:
    while N % i == 0:
        N //= i
        result.append(i)
    i += 1
if N > 1:
    result.append(N)
print(str(M) + ": " + " ".join(map(str, result)))


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>

int main() {
    int A, B;
    std::cin >> A >> B;
    
    bool possible = (A % 3 == 0) || (B % 3 == 0) || ((A+B) % 3 == 0);
    std::cout << (possible ? "Possible" : "Impossible") << std::endl;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char s;
  cin >> s;
  char ans;
    if(s == 'A') ans = 'T';
    if(s == 'T') ans = 'A';
    if(s == 'G') ans = 'C';
    if(s == 'C') ans = 'G';
  
  cout << ans << endl;
  
}

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


int main(void){
    string s;
    cin >> s;
    int ans = 700;
    rep(i,s.length()){
        if(s[i]=='o'){
            ans += 100;
        }
    }
    cout << ans <<endl;
    
    
    return 0;
}


























































Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	map<int, int>m;
	rep(i, 4) {
		int N;
		cin >> N;
		m[N]++;
	}
	if (m[1] && m[9] && m[7] && m[4])cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull l, r;
  cin >> l >> r;

  vector<ull> result = {};
  for (ull i=l; i <= r; i++) {
    for (ull j=l; j <= r; j++) {
      if (i == j)
        continue;

      ull r = i * j % 2019;
      if (r == 0) {
        cout << 0 << endl;
        return 0;
      }

      result.push(r);
    }
  }

  cout << min_value(result) <<endl;

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n, m;
 cin >> n;
 cin >> m;
 vector<int> acs(n,0);
 vector<int> was(n,0);
 int prob;
 string stat;
 for (int i = 0; i<m ; i++){
   cin >> prob;
   cin >> stat;
   if(stat == "AC"){
       acs.at(prob-1)  = 1;
   }else{
     if(acs.at(prob-1) != 1){
       was.at(prob-1) += 1;
     }
   }
 }
  int ac_count = 0;
  int wa_count = 0;
  for (int j = 0; j<n; j++){
    ac_count += acs.at(j);
    wa_count += acs.at(j)*was.at(j);
  }
 cout << ac_count <<" " << wa_count << endl ;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int total = 0;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		total += (r - l) + 1;
	}
	cout << total << endl;
}

Measured memory_bytes: 256
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = Console.ReadLine();
            int a;
            int A = int.Parse(b);
            a = 25 - A; string an = "Christmas";
            for (int i = 0; i < a; i++) { an += " Eve"; }
            Console.Write(an);
        }
    }
}

Measured memory_bytes: 11220
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcountll
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
int d[55][55];
int main()
{
	cin>>n;
	const int INF=1e6;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i==j) d[i][j]=0;
			else d[i][j]=INF;
		}
	}
	int a[55], b[55];
	for(int i=0; i<n-1; i++){
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
		d[a[i]][b[i]]=1;
		d[b[i]][a[i]]=1;
	}
	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
			}
		}
	}
	int m;
	cin>>m;
	int u[22], v[22];
	for(int i=0; i<m; i++){
		cin>>u[i]>>v[i];
		u[i]--; v[i]--;
	}
	ll e[22]={};
	for(int i=0; i<m; i++){
		for(int j=0; j<n-1; j++){
			if(d[u[i]][v[i]]==d[u[i]][a[j]]+d[v[i]][a[j]] && d[u[i]][v[i]]==d[u[i]][b[j]]+d[v[i]][b[j]]) e[i]^=(1ll<<j);
		}
	}
	ll ans=0;
	for(int i=0; i<(1<<m); i++){
		ll b1=0;
		for(int j=0; j<m; j++){
			if(i&(1<<j)) b1|=e[j];
		}
		int c=popcount(b1);
		int c1=popcount(i);
		if(c1&1) ans-=(1ll<<(n-1-c));
		else ans+=(1ll<<(n-1-c));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n=gets.to_i
red=n.times.map{gets.split.map(&:to_i)}.sort_by!{|a,b| b}.reverse!
blue=n.times.map{gets.split.map(&:to_i)}.sort_by!{|c,d| c}

ans=0
blue.each do |c,d|
  red.each do |a,b|
    if a<c && b<d
      ans+=1
      red.delete [a,b]
      break
    end
  end
end

puts ans

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
#define     mod            (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
#define     sz(x)           (int)(x).size()
#define     grid            vector<vector<ll> >
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#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;
  //use cerr if u want to display at the bottom
}
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

vector<string> matrix;

grid dp;

int n, m;

int const p = 1000000007;

ll ways(int r, int c)
{
  if (r >= n || c >= m)return 0;

  if (matrix[r][c] == '#')return 0;

  if (r == n - 1 && c == m - 1)return 1;

  ll &ans = dp[r][c];

  if (ans != -1)
    return ans;

  ans = (ways(r + 1, c) % p + ways(r, c + 1) % p) % p;

  return ans % p;
}


int main()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif

  IOS;

  cin >> n >> m;

  matrix.resize(n);

  dp.assign(n, vector<ll>(m, -1));

  for (auto &i : matrix)
  {
    cin >> i;
  }

  cout << ways(0, 0) << endl;

}

Measured memory_bytes: 12536
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Long.parseLong(line[i]);
        }
        Arrays.sort(nums);

        System.out.println(nums[n - 1] - nums[0]);
    }
}


Measured memory_bytes: 23252
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

double rnd(){
	const int INF=1e9;
	return (double)(rng()%INF)/INF;
}

int n;
ll c[26];
ll d[400][26];

void gen(){
	rep(x,0,26) c[x]=rng()%100;
	rep(x,0,n) rep(y,0,26) d[x][y]=rng()%20000;
}

ll calc(vector<int> &contest){
	ll last[26];
	
	memset(last,-1,sizeof(last));
	
	ll res=0;
	rep(x,0,n){
		res+=d[x][contest[x]];
		last[contest[x]]=x;
		
		rep(y,0,26) res-=c[y]*(x-last[y]);
	}
	
	return res;
}

//store curr best
ll best;
vector<int> ans;

ll test(double COOLING_RATE,double SCALE_FACTOR){
	vector<int> curr;
	rep(x,0,n){
		curr.push_back(0);
		
		rep(y,0,26) if (d[x][curr[x]]<d[x][y]) curr[x]=y;
	}
	
	ll val=calc(curr);
	
	best=val;
	ans=curr;
	
	double tempreture=1;
	
	auto begin_time=chrono::steady_clock::now().time_since_epoch().count();
	while (chrono::steady_clock::now().time_since_epoch().count()-begin_time<1950000000){
		int idx=rng()%n;
		int type=curr[idx];
		
		curr[idx]=rng()%26;
	
		ll temp=calc(curr);
		if (temp>val || rnd()<exp((temp-val)*SCALE_FACTOR/tempreture)){
			val=temp;
			
			if (best<val){
				best=val;
				ans=curr;
			}
		}
		else{
			curr[idx]=type;
		}
		
		tempreture*=COOLING_RATE;
	} 
	
	//pls uncomment later
	rep(x,0,n) cout<<ans[x]+1<<endl;
	
	return best;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	//freopen("sample2.in","r",stdin);
	
	cin>>n;
	rep(x,0,26) cin>>c[x];
	
	rep(x,0,n){
		rep(y,0,26) cin>>d[x][y];
	}
	
	test(0.999975,0.000003);
	return 0;
	
	for (double cool=0.99998;cool>=0.99997;cool-=0.000005){
		for (double scale=0.000001;scale<=0.00001;scale+=0.000001){
			ll curr=0;
			rep(x,0,20){
				gen();
				curr+=test(cool,scale);
			}
			
			cout<<cool<<" "<<scale<<" "<<curr<<endl;
		}
	}
}


Measured memory_bytes: 4380
#!/usr/bin/env python3
import sys
from collections import defaultdict

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

def solve(N: int, a: "List[int]"):
    A = defaultdict(lambda : 0)
    for x in a:
        A[x] += 1
    if len(A) == 1 and 0 in A:
        print(YES)
        return
    if N % 3 != 0:
        print(NO)
        return
    if len(A) == 2 and A[0] == N // 3:
        print(YES)
        return
    if len(A) != 3:
        print(NO)
        return
    L = list(A.keys())
    if L[0] ^ L[1] != L[2]:
        print(NO)
        return
    if A[L[0]] != A[L[1]] or A[L[0]] != A[L[2]]:
        print(NO)
        return
    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 57504
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = n - 1; i > n-k-1; i--)
    {
        //cout << a[i] << endl;
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#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 rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int dia;
vector<int> as;
vector<int> vs[114];
deque<int> path;

int main() {
  cin >> N;
  as.resize(N);
  rep(v, N) {
    cin >> as[v];
    MX(dia, as[v]);
    vs[as[v]].eb(v);
  }

  if (vs[dia].size() < 2) {
    puts("Impossible");
    return 0;
  }

  int llim = (dia+1)/2;
  rep(d, llim) {
    if (!vs[d].empty()) {
      puts("Impossible");
      return 0;
    }
  }

  reps(d, llim, dia+1) {
    if (d == llim && dia%2 == 0) {
      if (vs[d].size() < 1) {
        puts("Impossible");
        return 0;
      }
      assert(path.empty());
      path.eb(vs[d].back());
      vs[d].pop_back();
    } else {
      if (vs[d].size() < 2) {
        puts("Impossible");
        return 0;
      }
      path.eb(vs[d].back());
      vs[d].pop_back();
      path.push_front(vs[d].back());
      vs[d].pop_back();
    }
  }
  assert(path.size() == dia+1);
  if (!vs[llim].empty()) {
    puts("Impossible");
    return 0;
  }

  //reps(d, llim+1, dia+1) {
  //  for (int v : vs[d]) {
  //    int u = path[d-1];
  //    es.eb(pii(u, v));
  //  }
  //}
  puts("Possible"); 
}


Measured memory_bytes: 256
import math

def can_split(a, t, k):
    m = 0
    for x in a:
        m += math.ceil(x / t) - 1
    return m <= k

n, k = map(int, input().split())
a = list(map(int, input().split()))

min_val = 10 ** 9
l, r = 0, max(a)
while l + 1 < r:
    m = (l + r) // 2
    if can_split(a, m, k):
        r = m
    else:
        l = m
print (r)

Measured memory_bytes: 93816
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
const int INF=2e9;
const db eps=1e-12;
template<typename T>
inline void read(T &x) {
  x=0; int f=1; char ch=getchar();
  while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
  while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
  x*=f;
}
//==========================head template==========================
const int N=100010;
int a[N],b[N];
int tmp[2][N];
int n;
int fat[N];
int father(int x) {return fat[x]==x ? x : fat[x]=father(fat[x]);}
int ans=0;
bool vis[N];
map<int,int> key;
signed main() {
  read(n);
  for(int i=1;i<=n;i++) read(a[i]);
  for(int i=1;i<=n;i++) a[n+1]^=a[i];
  for(int i=1;i<=n;i++) read(b[i]);
  for(int i=1;i<=n;i++) b[n+1]^=b[i];
  memcpy(tmp[0],a,sizeof(a)); memcpy(tmp[1],b,sizeof(b));
  for(int i=0;i<2;i++) sort(tmp[i]+1,tmp[i]+n+2);
  ++n;
  for(int i=1;i<=n;i++) if(tmp[0][i]!=tmp[1][i]) {puts("-1"); return 0;}
  int tot=0;
  for(int i=1;i<=n;i++) if(!key.count(tmp[0][i])) key[tmp[0][i]]=++tot;
  //for(int i=1;i<=tot;i++) ++tmp[0][i];
  //for(int i=1;i<=n;i++) printf("%d ",tmp[0][i]); puts("");
  //tot=unique(tmp[0],tmp[0]+tot+1)-tmp[0]-1;
  //for(int i=1;i<=tot;i++) --tmp[0][i];
  for(int i=1;i<=n;i++) a[i]=key[a[i]];
  for(int i=1;i<=n;i++) b[i]=key[b[i]];
  for(int i=1;i<=tot;i++) fat[i]=i;
  for(int i=1;i<=n;i++) {
    //printf("%d %d\n",a[i],b[i]);
    if(a[i]!=b[i]) ans+=(i<n); else continue;
    int fx=father(a[i]),fy=father(b[i]);
    if(a[i]!=b[i]) {
      fat[fx]=fy;
      vis[fx]=vis[fy]=1;
    }
  }
  if(!ans) {puts("0"); return 0;}
  vis[a[n]]=vis[b[n]]=1;
  for(int i=1;i<=tot;i++)
    if(father(i)==i && vis[i]) ++ans;
  ans-=1;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 8576
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char[] c=sc.next().toCharArray();
    if(c.length>=4){
      if(c[0]=='Y'&&c[1]=='A'&&c[2]=='K'&&c[3]=='I'){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else{
      System.out.println("No");
    }
      
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N, K;
  cin >> N >> K;
  ll ans0{}, ans1{};
  rep(i, 0, N/K+2){
    if(i*K <= N && 0 < i*K) ans0++;
    if(K%2==0 && i*K-K/2 <= N && 0 < i*K-K/2) ans1++;
  }
  cout << ans0*ans0*ans0 + ans1*ans1*ans1 << rt;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    char s[101],t[101],u[201];
    int i=0,j=0;
    scanf("%s%s",s,t);
    while(t[i]!='\0'){
        u[i]=t[i];
        i++;
    }
    while(s[j]!='\0'){
        u[i]=s[j];
        i++;
        j++;
    }
    u[i]='\0';
    printf("%s\n",u);
    return 0;
}

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

int N, Q;
int c[300000];
int d[300010];

int main(){
  cin >> N >> Q;
  for (int i = 0; i < N; i++){
    cin >> c[i];
    d[c[i]]++;
  }
  for (int i = 0; i < Q; i++){
    int q;
    cin >> q;
    for (int j = q - 1; j >= 0; j--){
      for (int k = j; k <= 300000; k += q){
        if (d[k] > 0){
          cout << j << endl;
          goto BREAK;
        }
      }
    }
    BREAK:;
  }
}

Measured memory_bytes: 5392
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
ll dp[100010][2];
void solve()
{
	IN(n)IN(W);
	vl w, v;
	FOR(i, 0, n)
	{
		IN(in1)IN(in2);
		w.push_back(in1);
		v.push_back(in2);
	}
	FOR(j, 0, 1e5+1)
		FOR(i, 0, 2)
			dp[j][i] = MAX;
	dp[0][0] = 0;
	FOR(i, 0, n)
	{
		FOR(j, 1, 1e5+1)
		{
			dp[j][1] = min(dp[j][0], (j-v[i]>=0?dp[j - v[i]][0] + w[i]:MAX));
		}
		FOR(j, 1, 1e5+1)
			dp[j][0] = dp[j][1];
	}
	FORD(i, 1e5, -1)
	{
		if (dp[i][0] <= W)
		{
			cout << i << endl;
			break;
		}
	}

}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define INF 1e12
#define DIV 1000000007
using namespace std;
using ll = long long;

int lcd(int p, int q) {
	int upper, lower, r;

	if (p >= q) upper = p, lower = q;
	else upper = q, lower = p;
	r = upper % lower;
	if (r)return lcd(lower, r);
	else return lower;
}

int main() {
    int K;
    cin >> K;
	
	int gcd[201][201] = { 0 };
	for (int i = 1; i <= 200; i++) {
		for (int j = 1; j <= 200; j++) {
			gcd[i][j] = lcd(i, j);
		}
	}

	ll ans = 0;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				ans += gcd[gcd[i][j]][k];
			}
		}
	}

	cout << ans << endl;


}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(){
  string s; cin >> s;
  bool f = true;
  rep(i,s.size()/2){
    if(s[i] != s[s.size()-1-i]) f = false;
  }
  rep(i,s.size()/4){
    if(s[i] != s[s.size()/2-1-i]) f = false;
    if(s[s.size()/2+1+i] != s[s.size()-1-i]) f = false;
  }
  if(f) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x,a,b = LI()
    n = II()
    ans = x
    for _ in range(n):
        s = S()
        if s == list("nobiro"):
            ans += a
        elif s == list("tidime"):
            ans += b
        else:
            ans = 0
        ans = max(ans, 0)
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()



Measured memory_bytes: 8196
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    long double a;
    long double ans = 0;
    rep(i,n){
        cin >> a;
        ans+=(1/a);
    }
    cout << 1/ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  ll a, b;
  ll v, w;
  ll t;
  cin >> a >> v >> b >> w >> t;
  if (b < a) {
    swap(a, b);
  }
  if (a + v * t >= b + w * t) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3652
var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines[0]);
});

function main(line) {
  const [a, b] = line.split(' ').map(s => s.trim());
  let hasOdd = false;
  for (let c = 1; c <= 3; c++) {
    const result = isOdd(a * b * c);
    if (result) hasOdd = true;
  }
  console.log(hasOdd ? 'Yes' : 'No');
}

function isOdd(num) {
  return num % 2 === 1;
}


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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    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
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    const N = tmp[0], K = tmp[1];
    const hs = N.iota.map!(_ => readln.chomp.to!long).array.sort!"a<b".array;
    long ans = long.max;
    foreach (i; 0..N-K+1) {
        ans = min(ans, hs[i+K-1] - hs[i]);
    }
    writeln(ans);
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int c=min(a,b);
    int ans=0;
    for(int i=c;i>0;i--){
        if(a%i==0 && b%i==0){
            ans++;
            if(ans == k)
              cout<<i<<endl;;
        }
    }
    
}



Measured memory_bytes: 256
function main()
    N = parse(Int, readline())
    c = readline()

    r = 0
    w = 0
    for i in 1:N
        if c[i] == 'R'
            r += 1
        else
            w += 1
        end
    end

    if r == N || w == N
        println(0)
        return
    end

    mw = 0
    for i in 1:r
        if c[i] == 'W'
            mw += 1
        end
    end

    mr = 0
    for i in r:N
        if c[i] == 'R'
            mr += 1
        end
    end


    println(min(mr, mw))

    #if mr == mw
    #    println(mr)
    #elseif mw > mr
    #    println(mr + (mw - mr))
    #else
    #    println(mw + (mr - mw))
    #end
end

main() 

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct edge{
  ll u,v,lev;
};

ll n;
vector<edge> dfs(ll l,ll r){
  if(l+1==r){
    return vector<edge>();
  }
  ll mid=(l+r)/2;
  vector<edge> les=dfs(l,mid);
  vector<edge> res=dfs(mid,r);
  vector<edge> ans;
  ll levmx=0;
  rep(i,les.size()){
    ans.push_back(les[i]);
    maxch(levmx,les[i].lev);
  }
  rep(i,res.size()){
    ans.push_back(res[i]);
    maxch(levmx,res[i].lev);
  }
  levmx++;
  repl(u,l,mid)repl(v,mid,r){
    ans.push_back((edge){u,v,levmx});
  }
  return ans;
}

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

  cin>>n;
  vector<edge> res=dfs(0,n);
  vector<vector<ll>> g(n,vector<ll>(n,-1));
  rep(i,res.size()){
    g[res[i].u][res[i].v]=g[res[i].v][res[i].u]=res[i].lev;
  }
  rep(i,n){
    repl(j,i+1,n){
      cout<<g[i][j]<<" ";
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 6152