akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll A, B;
  cin >> A >> B;
  for (ll i = 0; i <= 1000000000; i++) {
    if (abs(A - i) == abs(B - i)) {
      cout << i << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A=0,B=0,C=0;
  cin >> A>>B>>C;
  if(A+B<C)Out("No");
  else Out("Yes");
}

Measured memory_bytes: 256
import sys

N=int(input())

flag=0

word=[]

for i in range(N):
    buf=input()
    if word.count(buf)==0:
        word.append(buf)
    else:
        flag=1

if flag!=1:
    for i in range(N-1):
        #print(word[i][-1])
        #print(word[i+1][0])
        if word[i][-1]!=word[i+1][0]:
            print('No')
            sys.exit()
    print('Yes')
else:
    print('No')
    sys.exit()

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

int main(void){
    int m[100001];
    for (int i = 0; i < 100001; i++) {
        m[i] = 0;
    }
    int N, A, sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (m[A] == 0) {
            m[A]++;
        } else {
            sum++;
        }
    }
    if (sum % 2 == 0) {
        cout << N - sum;
    } else {
        cout << N - sum - 1;
    }
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if (a > 0) {
			System.out.println("Positive");
		} else if (a <= 0 && 0 <= b) {
			System.out.println("Zero");
		} else {
			if ((b - a + 1) % 2 == 0) {
				System.out.println("Positive");
			} else {
				System.out.println("Negative");
			}
		}
		in.close();
	}
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <math.h>

#define Max 10000
#define max 500

int main(void){
int n,q,i,j,count=0;

  int S[Max],T[max];
  
  scanf("%d",&n);// ??°???????????´??°????????°???

  for(i = 0; i<n ;i++)//??°?????????????????????
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);// ??°?????´?????´??°????????°q
  for(i = 0; i<q ;i++)//??°???T???????????????
    {
      scanf("%d",&T[i]);
    }

  for (i = 0;i < q;i++)
    {
      for(j = 0;j < n;j++)
        {
          if (S[j] == T[i])
            {
              count++;
              break;
            }
        }

    }
    printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, N;
  string S, T, U;
  string P = "YES";
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N; i++) cin >> vec[i];
  sort(vec.begin(),vec.end());
  
  for (int i=0; i<N; i++) {
    if (vec[i]==vec[i+1]) {
      P = "NO";
      break;
    }
  }
  
  cout << P << endl;
  
  return 0;
  
}

Measured memory_bytes: 1024
def move(dice, order):
  if order == "E":
    temp = dice[0]
    dice[0] = dice[3]
    dice[3] = dice[5]
    dice[5] = dice[2]
    dice[2] = temp
  elif order == "N":
    temp = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = temp
  elif order == "S":
    temp = dice[0]
    dice[0] = dice[4]
    dice[4] = dice[5]
    dice[5] = dice[1]
    dice[1] = temp
  elif order == "W":
    temp = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = temp
  else:
    pass
  return dice
 
def roll(dice):
  temp = dice[1]
  dice[1] = dice[2]
  dice[2] = dice[4]
  dice[4] = dice[3]
  dice[3] = temp
  return dice
 
dice = list(map(int, input().split()))
q = int(input())
for i in range(q):
  up, front = map(int, input().split())
  cnt = 0
  while (dice[0] != up and cnt <= 3):
    dice = move(dice, "E")
    cnt += 1
  while dice[0] != up:
    dice = move(dice, "N")
  while dice[1] != front:
    dice = roll(dice)
  print(dice[2])


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

#define CIN1(a) int a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    CIN2(n,x)
    vector<int> v(n);
    rep(i,n){
        CIN1(tmp)
        tmp = abs(tmp - x);
        if(tmp) v[i] = tmp;
    }
    int ans;
    rep(i,n){
        if(i){
            ans = gcd(ans,v[i]);
        }else{
            ans = v[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int need_right=0;
    int need_left=0;
    string ans=S;

    for(int i=0; i<N; i++){
        if(need_right==0 && S[i]==')'){
            need_left++;
        }else if(need_right>0 && S[i]==')'){
            need_right--;
        }else if(S[i]=='('){
            need_right++;
        }
    }
    rep(i,need_left){
        ans= '('+ans;
    }
    rep(i,need_right){
        ans= ans+')';
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    K = int(input())
    A, B = map(int, input().split())

    if A % K == 0 or B % K == 0:
        print('OK')
    elif A // K != B // K:
        print('OK')
    else:
        print('NG')


if __name__ == "__main__":
    main()


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

int main() {
	
	int n, d[50],sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				continue;
			}
			sum += d[i] * d[j];
		}
	}

	cout << sum / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long ll;
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 n, k;

int main() {
    cin >> n >> k;
    vector<bool> candy(n, false);
    for(int i = 0; i < k; ++i) {
        int dd; cin >> dd;
        for(int j = 0; j < dd; ++j) {
            int aa; cin >> aa; aa--;
            candy.at(aa) = true;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        if(!candy.at(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline void read(int &x){
    char c=getchar();
    int p=1;
    x=0;
    while(!isdigit(c)){
        if(c=='-')p=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<1)+(x<<3)+(c^'0');
        c=getchar();
    }
    x*=p;
}
int n,sum,x,y,ans,flag;
signed main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    read(n);
    sum=1e15;
    flag=0;
    for(register int i=1;i<=n;++i){
        read(x);read(y);
        if(x!=y){
            flag=1;
        }
        ans+=x;
        if(x>y)sum=min(sum,y);
    }
    if(!flag)printf("0\n");
    else printf("%lld\n",ans-sum);
    return 0;
}


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

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

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
	int x,i,j,max=1;
	scanf("%d",&x);
	for(i=2;i<=sqrt(x);i++){
		for(j=1;;j++){
			if(x<pow(i,j)){
				j--;
				break;
			}
		}
		max=max<pow(i,j)?pow(i,j):max;
	}
	printf("%d",max);
	return 0;
}

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

int main() {
    ll N, M;
    cin >> N >> M;
    ll ans = min(M / 2, (N * 2 + M) / 4);
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    int n, x = 0, y = 0;
    vector<int> v, c; 
    cin >> n;
    v.resize(n);
    c.resize(n);

    for (auto & vs: v) cin >> vs;

    for (auto & cs: c) cin >> cs;

    for (int i = 0; i < n; ++i)
    {
        if (v[i] - c[i] > 0) {
            x += v[i];
            y += c[i];
        }
    }

    cout << x - y << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  set<int> s;
  int N; cin >> N;
  for (int i = 0; i < N; ++i) {
    int x; cin >> x;
    s.insert(x);
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int plan_A = N * A;
  int plan_B = B;
 
  if (plan_A < plan_B) {
    cout << plan_A << endl;
  }
  
  else if (plan_A == plan_B) {
    cout << plan_A << endl;
  }
  
  else {
    cout << plan_B << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, M;
map<LL, int>D;

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		int d;
		cin >> d;
		D[d]++;
	}
	cin >> M;
	for (int i = 0; i < M; ++i)
	{
		int t;
		cin >> t;
		if (D[t] <= 0)
		{
			cout << "NO\n";
			return 0;
		}
		D[t]--;
	}
	cout << "YES\n";
	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = INF;
    int best_a;
    int best_b;
    int best_c;

    for(int i=0;i<=(max(x,y)+1);i++){
        int cnt_a = max(0, x-i);
        int cnt_b = max(0, y-i);
        int tmp = 2*i*c + a*cnt_a + b*cnt_b;
        if(ans > tmp){
            best_a = cnt_a;
            best_b = cnt_b;
            best_c = i*2;
            ans = tmp;
        }
    }

    //printf("%d, %d, %d\n", best_a, best_b, best_c);

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    ll N, K;
    cin >> N >> K;
    vector<pii> sushi(N);
    REP(i, N) {
        cin >> sushi[i].second >> sushi[i].first;
    }

    sort(all(sushi));
    reverse(all(sushi));

    ll res = 0;
    ll kind = 0;
    vi use(N + 1, 0);

    stack<pii> st;
    REP(i, K) {
        st.push(sushi[i]);
        res += sushi[i].first;
        if (use[sushi[i].second] == 0) {
            kind++;
        }
        use[sushi[i].second]++;
    }
    res += kind * kind;

    ll current = res;
    FOR(i, K, N) {
        if (st.empty()) break;

        if (use[sushi[i].second] != 0) {
            continue;
        }

        pii top = st.top();
        st.pop();

        if (use[top.second] == 1) {
            i--;
            continue;
        } else {
            use[top.second]--;
            current -= top.first;

            // add new
            if (use[sushi[i].second] == 0) {
                current -= kind * kind;
                kind++;
                current += kind * kind;
            }
            use[sushi[i].second]++;
            current += sushi[i].first;
        }

        res = max(res, current);
    }

    return res;
}


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

    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 2176
n = int(input())
a0 = [0,0,0]
ans = "Yes"
for i in range(n):
    ai = list(map(int,input().split()))
    t = ai[0] - a0[0]
    d = abs(ai[1] - a0[1])+ abs(ai[2] - a0[2])
    if t < d or t%2 != d%2:
        ans = "No"
    a0 = ai
print(ans)

Measured memory_bytes: 46228
n = int(input())
lst = map(int, input().split())

gu = [l for l in lst if l%2==0]

flag = True
for g in gu:
    if (g%3 == 0) or (g%5 == 0):
        continue
    else:
        flag = False

if flag:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] > 0:
    print(-1)
    exit()

ans = 0
prev = 0

for a in reversed(A):
    if prev > 0:
        if a == (prev - 1):
            prev = a
            continue
        elif a < prev:
            print(-1)
            exit()
    ans += a
    prev = a

print(ans)


Measured memory_bytes: 11048
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
const int INF = 1001001001;
signed main(){
    int n;cin >> n;
    int a[n+1];

    rep(i,n)cin >> a[i];
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    if(a[n-1] <= a[n])a[n] = INF;
    else if(a[n-1] >= a[n])a[n] = -INF;
    
    int ret = 0;
    for(int i = 0,j;i < n;i = j+1){
        for(j = i;j < n && a[j]>= a[j+1];j++);
        int res1 = j;
        for(j = i;j< n & a[j] <= a[j+1];j++);
        int res2 = j;
        ret++;
        j = max(res1,res2);
        //trace(i,j,res1,res2,ret);
        //if(j == n-1)break;


    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  for(int i=0;i<ty-sy;i++)
    printf("U");
  for(int i=0;i<tx-sx;i++)
    printf("R");
  for(int i=0;i<ty-sy;i++)
    printf("D");
  for(int i=0;i<=tx-sx;i++)
    printf("L");
  for(int i=0;i<=ty-sy;i++)
    printf("U");
  for(int i=0;i<=tx-sx;i++)
    printf("R");
  printf("DR");
  for(int i=0;i<=ty-sy;i++)
    printf("D");
  for(int i=0;i<=tx-sx;i++)
    printf("L");
  printf("U");
  return 0;
}

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

int n,k;
bool dislike[15];

bool cek(int x){
	while(x>0){
		int tmp = x%10;
		x/=10;
		if(dislike[tmp]) return 0;
	}
	return 1;
}

int main(){
	cin >> n >> k;
	for(int i=1;i<=k;i++){
		int x;
		cin >> x;
		dislike[x]=1;
	}
	while(!cek(n)){
		n++;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define ten(n) ((int)1e##n)
#define COUT cout <<
#define SPACE_COUT << " "  <<
#define COMMA_COUT << ", " <<
#define ENDL << endl;

int
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int i = 0;
    while(true) {
        if (s.compare(i, 11,"dreameraser") == 0)
            i+= 11;
        else if(s.compare(i, 10, "dreamerase") == 0)
            i+= 10;
        else if (s.compare(i, 7,"dreamer") == 0)
            i+= 7;
        else if (s.compare(i, 5,"dream") == 0)
            i += 5;            
        else if (s.compare(i, 6,"eraser") == 0)
            i+= 6;
        else if (s.compare(i, 5,"erase") == 0)
            i += 5;            
        else break;
    }
    if (i == s.size()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 512
import sys
H, W, A, B = list(map(int, input().split()))

field = [[0 for i in range(W)] for j in range(H)]
for h in range(B):
  for w in range(A, W):
    field[h][w] = 1
for h in range(B, H):
  for w in range(A):
    field[h][w] = 1
for row in field:
  print("".join(map(str, row)))

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

using namespace std;
 
 


//c++ templte for help............................................................................................................................................



typedef long long ll;

template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;


 
//c++ template for help...........................................................................................................................................


ll solve(){
	ll n,x,t;
	cin>>n>>x>>t;
	
	ll ans=0;
	ll q=0;
	while(q<n){
		ans+=t;
		q+=x;
	}
	
	return ans;
	
}

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ofstream myfile;
	//myfile.open("output.txt");
	

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		ll ans=solve();
		cout<<ans<<endl;
	//}
	//myfile.close();
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long calmin=0;	
	long long n;
	cin>>n;
	vector<long long> a(n);
	for(long long i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<0)
		{
			calmin++; 
			a[i]=a[i]*-1;
		} 
	}
	sort(a.begin(),a.end());
	long long sum=0;
	for(long long i=0;i<n;i++)
	{
		sum=sum+a[i];
	}
	if(calmin%2!=0)
	{
		cout<<sum-2*a[0];
		return 0;
	}
	else
	{
		cout<<sum;
		return 0;
	}
}

Measured memory_bytes: 1024
N,M=map(int,input().split())
XYZ=[list(map(int,input().split())) for _ in range(N)]

ans=0

for i in range(2**3):
  L=[]
  tmp=0
  for j in range(N):
    L.append((XYZ[j][0] if i%2==0 else -XYZ[j][0])
              +(XYZ[j][1] if (i>>1)%2==0 else -XYZ[j][1])
              +(XYZ[j][2] if (i>>2)%2==0 else -XYZ[j][2]))
    L.sort(reverse=True)
    tmp=sum(L[:M])
  ans=max(ans,tmp)
  
print(ans)

Measured memory_bytes: 76324
#include<bits/stdc++.h>
using namespace std;
void solve(){
    string s;cin>>s;
    //SUN, MON, TUE, WED, THU, FRI, or SAT
    if(s=="SUN"){
        cout<<7<<"\n";
        return;
    }
    if(s=="MON"){
        cout<<6<<"\n";
        return;
    }
    if(s=="TUE"){
        cout<<5<<"\n";
        return;
    }
    if(s=="WED"){
        cout<<4<<"\n";
        return;
    }
    if(s=="THU"){
        cout<<3<<"\n";
        return;
    }
    if(s=="FRI"){
        cout<<2<<"\n";
        return;
    }
    if(s=="SAT"){
        cout<<1<<"\n";
        return;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{   char a,b;
    char H,D;
    scanf("%c %c",&a,&b);
    
    if ( a=='H' ) {
	   if (b=='H'){
	       printf("H\n");
	   } else {
	   	   printf("D\n");
	   } }else if (a=='D') {
	       if (b=='H') {
	   	       printf("D\n");
	   } else {
	   	   printf("H\n");
	   } }
	   return 0;
	} 

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int countodd(long long int n) 
{ 
    int count = 0; 
    while (n != 0) { 
        n = n / 10; 
        ++count; 
    } 
    return count; 
} 
int main()
{
     long long int n,odd=0,k;
     cin >> n;
    for(long long int i=n;i>0;i--)
    {  
        k=countodd(i); 
        if(k%2==0)
        {
            continue;
        }
        else
        {
            odd++;
        }
    }
    cout << odd;
    return 0;
}


Measured memory_bytes: 256
var d = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n');
d.some(function(line) {
  if (line === '0 0') return true;
  var nums = line.split(' ');
  var h = nums[0];
  var w = nums[1];
  var edge = '';
  for (var i = 0; i < w; i++) {edge += '#'};

  var inner = '#';
  for (var i = 0; i < w-2; i++) {inner += '.'};
  inner += '#';

  for (var i = 0; i < h; i++) {
    if (i === 0 || i === h-1) console.log(edge);
    else console.log(inner);
  }
  console.log('');
});

Measured memory_bytes: 9504
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int K = sc.nextInt();
        int Q = sc.nextInt();
        if (K > Q) {
            for (int i = 0; i < n; i++) {
                System.out.println("Yes");
            }
            return;
        }
        int[] persons = new int[n];
        for (int i = 0; i < Q; i++) {
            int correct = sc.nextInt();
            persons[correct - 1]++;
        }
        for (int i = 0; i < n; i++) {
            if (persons[i] > Q - K) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 55640
#include<stdio.h>
int main(void){
  char b;
  scanf("%s",&b);
  if(b=='A'){
    printf("T");
  }
  if(b=='T'){
    printf("A");
  }
  if(b=='C'){
    printf("G");
  }
  if(b=='G'){
    printf("C");
  }
  return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  unsigned long long a;cin>>a;
  string s;cin>>s;
  unsigned long long b1=  0,b2 = 0;
  b1 = (s[0]-'0')*100 + (s[2]-'0')*10+(s[3]-'0');
  long long ans = (a*b1)/100;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  int ans = 1e9;
  FOR(x,-100,101){
    int cst = 0;
    REP(i,n) cst += abs(a[i]-x)*abs(a[i]-x);
    ans = min(ans, cst);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import itertools
def modelAnswer(X:int):
   lis = [i for i in range(100,106)]
   C = X//100
   for p in itertools.combinations_with_replacement(lis,C):
      if(sum(p)==X):
         return 1
   return 0

def main():
   X = int(input())
   print(modelAnswer(X))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	int main(){
		int len=read<int>();
		double tmp=1.*len/3;
		printf("%.10lf",tmp*tmp*tmp);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int dp[1010][1010];
string x, y;

int solve(int a, int b) {
    if (dp[a][b] != 1e9) {
        return dp[a][b];
    }
    if (a * b == 0) {
        dp[a][b] = max(a, b);
        return dp[a][b];
    }
    
    if (char(x[a - 1]) == char(y[b - 1])) dp[a][b] = solve(a - 1, b - 1);
    else dp[a][b] = solve(a - 1, b - 1) + 1;
    
    dp[a][b] = min(dp[a][b], min(solve(a - 1, b), solve(a, b - 1)) + 1);
    
    return dp[a][b];
}

int main(void){
    cin >> x >> y;
        
    for (int i = 0; i <= x.size(); i++) {
        for (int j = 0; j <= y.size(); j++) dp[i][j] = 1e9;
    }
    dp[0][0] = 0;
    
    cout << solve(x.size(), y.size()) << endl;
    
    /*
    for (int i = 0; i <= x.size(); i++) {
        for (int j = 0; j <= y.size(); j++) cout << solve(i, j) << " ";
        cout << endl;
    }*/
}



Measured memory_bytes: 7240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    string S, T;
    cin >> S >> T;

    vector<vector<int>> alps(26), alpt(26);

    rep(i, S.size()){
        int tmp = S.at(i) - 'a';
        alps.at(tmp).push_back(i);
    }
    
    rep(i, T.size()){
        int tmp = T.at(i) - 'a';
        alpt.at(tmp).push_back(i);
    }

    set<vector<int>> t_set;
    rep(i, 26){
        t_set.insert(alpt.at(i));
    }

    bool ans = true;
    for(auto i : alps){
        if(!t_set.count(i)){
            ans = false;
            break;
        }
    }
    

    // rep(i, 26){
    //     if(alp.at(i).size() <= 1) continue;
    //     else {
    //         rep(j, alp.at(i).size() - 1){
    //             int s1 = alp.at(i).at(j);
    //             int s2 = alp.at(i).at(j + 1);
    //             if(T.at(s1) != T.at(s2)){
    //                 ans = false;
    //                 goto OUT;
    //             }
    //         }
    //     }
    // }

    // OUT:
    if(ans) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 3756
#include<iostream>
using namespace std;
int n;
string str;

int main(){
  cin>>n;
  getline(cin,str);
  while(n--){
    getline(cin,str);
    for(int i=0;i<(int)str.size()-6;i++){
      if(str.substr(i,7)=="Hoshino"){
	str.replace(i,7,"Hoshina");
      }
    }
    cout<<str<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] data = new char[h][w];
        for (int i = 0; i < h; i++) {
            data[i] = sc.next().toCharArray();
        }

        for (int i = 0; i < h+2; i++) {
            for (int j = 0; j < w+2; j++) {
                if (i == 0 || i == h+1 || j == 0 || j == w+1) {
                    // 端の時は#を出力
                    System.out.print('#');
                } else {
                    System.out.print(data[i-1][j-1]);
                }
            }
            System.out.println();
        }
    }
}


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

int main() {
  string S, T;
  cin >> S >> T;
  bool ans = false;
  for (int i = 0; i < S.size(); ++i) {
    if (S == T) {
      ans = true;
      break;
    }
    rotate(S.begin(), S.begin() + 1, S.end());
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){ 
  std::cout<<std::fixed<<std::setprecision(10);
  long double l;
  cin >> l;
  long double x = l / 3;
  cout << x * x * x << endl;
  return 0;
} 

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i,0,s.size()){
        cout << "x";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int data[40];
int main(){

	for(int i=0;i<40;i++)data[i]=i;
	int w;
	int n;
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		char ch;
		int a,b;
		cin>>a;
		cin>>ch;
		cin>>b;
		int t=data[a];
		data[a]=data[b];
		data[b]=t;
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}

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

int main(){
	int n,b,f,r,v;
	int room[5][4][11];
	cin >> n;

	for( b=1; b<=4;b++){
		for( f=1; f<=3; f++){
			for( r=1; r<=10; r++){
				room[b][f][r]=0;
			}
		}
	}


	for(int x=0; x<n; x++){
		cin >> b >> f >> r >> v;
		room[b][f][r] += v;
	}


	for(int b= 1; b <= 4; b++){
		for(int f = 1; f <= 3; f++){
			for(int r = 1; r <= 10; r++){
				cout << " " << room[b][f][r];
			}
			cout << "\n";
		}
		
		if( b!= 4)
			cout << "####################\n" ;
	}                

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
pair<int,int> P;
#define F first
#define S second
int a,b,c,x,y;
int main(void){
    cin>>a>>b>>c>>x>>y;
    if(a+b<=c*2){
        cout<<a*x+b*y<<endl;
    }else{
        int z=min(x,y);
        int ans=z*c*2;
        if(x<y){
            cout<<min(ans+(y-z)*b,max(x,y)*c*2)<<endl;
        }else {
            cout<<min(ans+(x-z)*a,max(x,y)*c*2)<<endl;
        }
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
const int INF = 1e9;
int n, m; 
int bmemo[160][1010];//b[y][x]
vector<pair<int, int> > b[160];//
int dp[160][1010][80];//dp[y??§?¨?][x??§?¨?][1????£???°????????£??????????????°] = ????????????????°????
int main(void){
	while(1){
		//input
		cin >> n >> m;
		if(n == 0 && m == 0) return 0;
		rep(i, 160)rep(j, 1010) bmemo[i][j] = INF;
		rep(i, 160) b[i].clear();//?????????
		rep(i, n){
			int k; cin >> k;
			rep(j, k){//k???????????§?¨?
				int x, s; cin >> x >> s; x--;
				b[i].push_back(make_pair(x, s));
				bmemo[i][x] = s;
			}
		}

		rep(i, 160)rep(j, 1010)rep(k, 80) dp[i][j][k] = INF;
		for(auto start1 : b[0]){//???????????????????????£??????
			dp[0][start1.fi][0] = 0;
		}

		for(auto start2 : b[1]){//????????????????£???°????????£??????
			dp[1][start2.fi][1] = 0;
		}

		//??????dp
		for (int i = 0; i <  n - 1; ++i){
			for (int j = 0; j < 1010; ++j){
				for (int k = 0; k <= m; ++k){
					if(dp[i][j][k] == INF) continue;
					//??????????????£?????????
					for(auto next : b[i + 1]){
						int score = (bmemo[i][j] + next.se) * abs(j - next.fi);//?????????????????±??????
						dp[i + 1][next.fi][k] = min(dp[i + 1][next.fi][k], dp[i][j][k] + score);
					}
					if(k == m || i == n - 2) continue;
					//???????£???°????????£??????
					for(auto next : b[i + 2]){
						int score = (bmemo[i][j] + next.se) * abs(j - next.fi);//?????????????????±??????
						dp[i + 2][next.fi][k + 1] = min(dp[i + 2][next.fi][k + 1], dp[i][j][k] + score);
					}
				}
			}
		}

		//????°????????????????
		int ans = INF;
		for (int j = 0; j < 1010; ++j){
			for (int k = 0; k <= m; ++k){
				ans = min(ans, dp[n - 1][j][k]);
			}
		}

		for (int j = 0; j < 1010; ++j){
			for (int k = 0; k <= m - 1; ++k){
			 	ans = min(ans, dp[n - 2][j][k]);
			}
		}
		cout << ans << endl;
	}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
ll dp[114514];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vary(ll,v,n+1,0);
  rep(i,n){
    cin >> v[i];
  }
  vary(ll,ans,0,0);
  ans.push_back(v[0]);
  REP(i,0,n){
    if(ans[ans.size()-1] < v[i]){
      ans.pb(v[i]);
    }
    else{
      rep(j,ans.size()){
        if(ans[j] >= v[i]){
          ans[j] = v[i];
          break;
        }
      }
    }
  }
  cout << ans.size()<<endl;
  return 0;
}

Measured memory_bytes: 4504
# -*- coding: utf-8 -*-


def main():
    sx, sy, tx, ty = map(int, input().split())
    first = list()
    second = list()

    for y in range(ty - sy):
        first.append('U')
        second.append('D')

    for x in range(tx - sx):
        first.append('R')
        second.append('L')

    third = ['L', 'U'] + first + ['R', 'D']
    fourth = ['R', 'D'] + second + ['L', 'U']

    print(''.join(map(str, first + second + third + fourth)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }
ll MOD = 1000000007;

int main(void){
  int n,m; cin >> n >> m;
  int k[m];
  int s[m][n];
  int p[m];
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]){
      cin >> s[i][j];
    }
  }
  rep(i,m) cin >> p[i];
  int ans = 0;
  for(int i = 0; i < (1<<n); i++){
    bool a = 1;
    for(int j = 0; j < m; j++){
      int b = 0;
      for(int l = 1; l <= k[j]; l++){
        if((i >> (s[j][l-1]-1)) & 1) b++;
      }
      if(b %2 != p[j]) a = 0;
    }
    if(a) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll a,b; cin>>a>>b;
	ll ans=(a*b)/__gcd(a,b);
	cout<<ans<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int A, B, C ,X, Y, res;
    cin >> A >> B >> C >> X >> Y;
    res = 0;
    if (X >= 1 && Y >= 1) {
        if (A + B > C*2) {
            int minNum = min(X, Y);
            X = X - minNum;
            Y = Y - minNum;
            int res1 = C*minNum*2+A*X+B*Y;
            int res2 = C*minNum*2+C*X*2+C*Y*2;
            res = min(res1, res2); 
        } else {
            res = A*X+B*Y;
        }
    } 
    
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,n = map(int, input().split())
    if b-1<=n:
        res = int((a*(b-1))/b) - a*int((b-1)/b)
    else:
        res = int((a*n)/b) - a*int(n/b)
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9472
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

using ll = long long;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int x, y, z; cin >> x >> y >> z;
	cout << (x + y + z < 22 ? "win" : "bust");
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int x, y;
  cin >> x >> y;
  cout << (x + y) % 24 << endl;
}

Measured memory_bytes: 256
use std::io::*;

const SP: u8 = b' ';
const LF: u8 = b'\n';

struct CharacterInput<'a> {
    locked_stdin: StdinLock<'a>,
    bytes_buffer: Vec<u8>,
}

impl<'a> CharacterInput<'a> {
    fn read(&mut self, delimiter: u8) -> &[u8] {
        self.bytes_buffer.clear();

        let mut len = self
            .locked_stdin
            .read_until(delimiter, &mut self.bytes_buffer)
            .unwrap();

        if len > 0 {
            len -= 1;
        }

        &self.bytes_buffer[0..len]
    }

    fn scan_u(&mut self, delimiter: u8) -> u32 {
        self.read(delimiter)
            .into_iter()
            .fold(0, |accumulator, byte| {
                (byte - b'0') as u32 + accumulator * 10
            })
    }
}

fn create_cin<'a>(input: StdinLock<'a>, buffer_capacity: usize) -> CharacterInput {
    CharacterInput {
        locked_stdin: input,
        bytes_buffer: Vec::with_capacity(buffer_capacity),
    }
}

fn println<T: std::string::ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

fn main() {
    let cin = stdin();
    let cin = &mut create_cin(cin.lock(), 16);

    let n = cin.scan_u(LF) as usize;

    let xor = (0..n - 1)
        .map(|_| cin.scan_u(SP))
        .fold(0, |acc, cur| acc ^ cur)
        ^ cin.scan_u(LF);

    println(if xor == 0 { "Yes" } else { "No" });
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N - 1; i++)
    {
        int idx;
        cin >> idx;
        A[idx - 1]++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << A[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4040
from statistics import median

N = int(input())
A = [0] * N
B = [0] * N
for c in range(N):
    A[c], B[c] = map(int, input().split())

A_med = median(A)
B_med = median(B)

if N % 2 == 0:
    print(round(2 * (B_med - A_med) + 1))
else:
    print(B_med - A_med + 1)


Measured memory_bytes: 28708
#include <cstdio>
#include <algorithm>

long long count[100000];
constexpr long long M = 998244353;

long long power(long long a, long long b)
{
	long long r = 1;
	while (b > 0)
	{
		if ((b & 1) != 0) r = (r * a) % M;
		a = (a * a) % M;
		b >>= 1;
	}
	return r;
}

int main()
{
  int n;
  int a;
  scanf("%d%d", &n, &a);
  if (a != 0)
  {
    puts("0");
    return 0;
  }
  count[0] = 1;
  int maxc = 0;
  for (int i = 1; i < n; ++i)
  {
    scanf("%d", &a);
    count[a]++;
    if (a > maxc) maxc = a;
  }
  if (count[0] != 1)
  {
    puts("0");
    return 0;
  }
  long long ans = 1;
  for (int i = 1; i <= maxc; ++i)
  {
    ans = ans * power(count[i - 1], count[i]) % M;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main()
{
	int m, f, r;
	char ans;

	while(1){
		cin >> m >> f >> r;
		if ((m == -1) && (f == -1) && (r == -1))
			break;

		if ((m == -1) || (f == -1)){
			ans = 'F';
		} else {
			int sum = m + f;
			if (sum >= 80) ans = 'A';
			else if (sum >= 65) ans = 'B';
			else if (sum >= 50) ans = 'C';
			else if (sum >= 30)
				if (r >= 50) ans = 'C';
				else ans = 'D';
			else ans = 'F';
		}
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

ll w,h;
ll c[55][55];
bool u[55][55];
void dfs(ll y,ll x){
    u[y][x]=1;
    rep(i,8){
        ll ny=y+D8[i];
        ll nx=x+D8[i+1];
        if(ny<0||h<=ny||nx<0||w<=nx||!c[ny][nx]||u[ny][nx])continue;
        dfs(ny,nx);
    }
}
void solve(){
    while(1){
        cin>>w>>h;
        if(w==0&&h==0)return;
        rep(i,h)rep(j,w){
            cin>>c[i][j];
            u[i][j]=0;
        }
        ll cnt=0;
        rep(i,h)rep(j,w){
            if(c[i][j]&&!u[i][j]){
                cnt++;
                dfs(i,j);
            }
        }
        cout<<cnt<<endl;
    }
}

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



Measured memory_bytes: 3308
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
int a,b,c,d,i;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>a>>b>>c>>d;
	for(i=1;;i++)
	{
		if(i&1)c-=b;
		else a-=d;
		if(a<=0)rc("No");
		if(c<=0)rc("Yes");
	}
	return 0;
}


Measured memory_bytes: 3652