akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    ll N;
    cin >> N;
    vector<ll>A(N);
    for (ll i=0; i<N; i++)cin >> A[i];

    ll prev = -1;
    ll ans = 0;

    for (ll i=0; i<N; i++){
        if (prev > A[i]){
            ans += prev-A[i];
            A[i] = prev;
        }
        prev = A[i];

    }
    cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }
    int t, min = 100, left = 0, right = 0;
    
    for (int i = 0; i < n - 1; i++) {
        t = i;
        for (int j = 0; j <= t; j++) {
            left += w[j];
        }
        for (int j = t + 1; j < w.size(); j++) {
            right += w[j];
        }
        if (min > abs(left - right)) {
            min = abs(left - right);
        }
        left = 0;
        right = 0;
    }
    cout << min;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;cin>>n>>m;
	int a[n];for(int &i:a) cin>>i;
	int sum=accumulate(a,a+n,0);
	int cnt=0;
	for(int i:a)
		if(4*m*i>=sum) ++cnt;
	cout<<(cnt>=m?"Yes":"No")<<"\n";
	return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    int s = 0;
    for(int i=0; i<m; i++){
        int e; cin >> e;
        s += e;
    }
    if(s > n)
        cout << -1 << endl;
    else
        cout << n - s << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;

#define INF 987654321
#define ll long long

int N;
string s;

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

	cin >> N;
	int lo = 0, hi = N, lt; //[lo, hi)

	cout << 0 << endl;
	cin >> s;
	if (s == "Vacant") return 0;
	if (s == "Male") lt = 0;
	else lt = 1;

	for (int i = 0; i < 20; i++)
	{
		int mid = (lo + hi) / 2, t;
		cout << mid << endl;
		cin >> s;
		if (s == "Vacant") return 0;
		if (s == "Male") t = 0;
		else t = 1;

		//빈 칸이 왼쪽에 있는 경우
		if (((mid - lo) % 2 == 0 && lt != t) || ((mid - lo) % 2 == 1 && lt == t))
			hi = mid;
		else
		{
			lo = mid;
			lt = t;
		}
	}
	
	return 0;
}

Measured memory_bytes: 852
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

sx,sy,tx,ty=mint()
ans=[]
dx,dy=tx-sx,ty-sy
R,L,U,D='R','L','U','D'
ans.extend([R]*dx)
ans.extend([U]*dy)
ans.extend([L]*dx)
ans.extend([D]*(dy+1))
ans.extend([R]*(dx+1))
ans.extend([U]*(dy+1))
ans.extend([L,U])
ans.extend([L]*(dx+1))
ans.extend([D]*(dy+1))
ans.extend([R])
lprint(ans,'')

Measured memory_bytes: 75024
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_10_B: Matrix Chain Multiplication

#include <algorithm>
#include <climits>
#include <cstdio>

using uint = unsigned int;

static uint matrix_chain_multiplication(const uint p[], const uint n)
{
  uint m[n][n];
  for (auto i = 0u; i < n; ++i) m[i][i] = 0u;

  for (auto d = 1u; d < n; ++d) {
    for (auto i = 0u, j = i+d; j < n; ++i, ++j) {
      auto min = UINT_MAX;
      for (auto k = i; k < j; ++k) {
        // min(Mi..j = (Mi..k) * (Mk+1..j)
        //           = (Mi..k) + (Mk+1..j) + p[i]*p[k+1]*p[j+1])
        auto cost = m[i][k] + m[k+1][j] + p[i]*p[k+1]*p[j+1];
        min = std::min(min, cost);
      }
      m[i][j] = min;
    }
  }
  return m[0][n-1];
}

int main()
{
  uint n;
  std::scanf("%u", &n);
  uint p[n+1];
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u %u", &p[i], &p[i+1]);
  }
  auto c = matrix_chain_multiplication(p, n);
  std::printf("%u\n", c);
}

// eof

Measured memory_bytes: 2780
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 500 + 2;
const int M = 1e5 + 2;
const ll mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}
 
int n, was[N][N];
ll a[N], dp[N][N], sum;

ll rec(int l = 1, int r = n) {
	if (l == r)
		return a[l];
	if (was[l][r])
		return dp[l][r];
	ll ans = INF;
	ll sum = 0;
	for (int i = l; i < r; ++i) {
		sum += a[i];
		ans = min(ans, rec(l, i) + rec(i + 1, r));
	}
	was[l][r] = 1;
	return dp[l][r] = ans + sum + a[r];

}
 
int main() {
	data();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
		sum += a[i];
	}
	printf("%lld", rec() - sum);
}
 
/*
	Timus: 288481RF
	CodeForces: fractal
*/

Measured memory_bytes: 2688
fun main(arr:Array<String>) {
    val mojirtsu = readLine()!!.toMutableList()
    var cnt = readLine()!!.toLong()
    for(i in mojirtsu.indices) {
        if(mojirtsu[i] == 'a') {
            continue
        }
        val diff = 'z'.toInt() - mojirtsu[i].toInt() + 1
        if (cnt >= diff) {
            mojirtsu[i] = 'a'
            cnt -= diff
        }
    }
    mojirtsu[mojirtsu.lastIndex] = (mojirtsu.last().toInt() + (cnt % 26).toInt()).toChar()
    println(mojirtsu.joinToString(""))
}


Measured memory_bytes: 39244
#!/usr/bin/env python3
def solve(x: int):
    for n in range(2, int(x ** 0.5) + 1):
        if x % n == 0:
            return False
    return True


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

    while True:
        if solve(X):
            print(X)
            break
        else:
            X += 1


if __name__ == '__main__':
    main()


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

const int maxn = 20;
int n, m, row[maxn], col[maxn];
bool used[maxn], ans;

string s[20], ss[20];

void check(int u, bool flag)
{
    if(u == (m + 1) / 2) {
        printf("YES"); 
        exit(0); 
        return ;
    }

    for(int i = u; i < m; i ++) {
        if(col[i] == -1) {
            for(int j = i + 1; j < m; j ++) {
                if(col[j] >= 0)
                    continue;
                bool f = true;
                for(int k = 0; k < n; k ++) {
                    if(s[k][i] != s[row[k]][j]) {
                        f = false;
                        break;
                    }
                }
                if(f) {
                    col[i] = j;
                    col[j] = i;
                    check(u + 1, flag);
                    col[i] = col[j] = -1;
                }
            }

            if(flag) {
                bool f = true;
                for(int k = 0; k < n; k ++) {
                    if(s[k][i] != s[row[k]][i]) {
                        f = false;
                        break;
                    }
                }
                if(f) {
                    col[i] = i;
                    check(u + 1, false);
                    col[i] = -1;
                }
            }
            break;
        }
    }
}

void dfs(int u, int flag)
{
    if(u == (n + 1) / 2) {
        check(0, m & 1);
        return;
    }

    for(int i = u; i < n; i ++) {
        if(row[i] == -1) {
            for(int j = i + 1; j < n; j ++) {
                if(row[j] >= 0 || ss[i] != ss[j])
                    continue;
                row[i] = j;
                row[j] = i;
                dfs(u + 1, flag);
                row[i] = row[j] = -1;
            }
            if(flag) {
                row[i] = i;
                dfs(u + 1, false);
                row[i] = -1;
            }
            break;
        }
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    memset(row, -1, sizeof(row));
    memset(col, -1, sizeof(col));
    for(int i = 0; i < n; i ++) {
        cin >> s[i];
        ss[i] = s[i];
        sort(ss[i].begin(), ss[i].end());
    }

    if(n & 1)
        dfs(0, true);
    else
        dfs(0, false);
    printf("NO");
    return 0;
}


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

int main(){
    int n,c;
    cin >> n >> c;
    vector<pair<pair<int, int>, int> > stc(n);
    for(int i=0; i<n; i++){
        int s,t,c;
        cin >> s >> t >> c;
        stc[i] = make_pair(make_pair(s,t), c);
    }
    sort(stc.begin(), stc.end());
    
    int ans=0;
    vector<pair<int,int> > end; //(endtime, channel)
    for(int i=0; i<n; i++){
        for(int j=end.size()-1; j>=0; j--){
            if(stc[i].first.first > end[j].first){
                end.erase(end.begin() +j);
            }
        }
        int just = -1;
        for(int j=end.size()-1; j>=0; j--){
            if(stc[i].first.first == end[j].first && stc[i].second == end[j].second){
                just = j;
            }
        }
        if(ans > (int)end.size()){
        }else if(just != -1){
            end.erase(end.begin() +just);
        }else{
            ans++;
        }
        end.push_back(make_pair(stc[i].first.second, stc[i].second));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
N, W = map(int, input().split())

dp = [0] * (W+1)

value = []
weight = []

for i in range(N):
    v, w = map(int, input().split())
    value.append(v)
    weight.append(w)

for i in range(N):
    for j in range(W, -1, -1):
        if j - weight[i] >= 0:
            dp[j] = max(dp[j], dp[j-weight[i]] + value[i])
print(dp[W])


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

using namespace std;

int main() {
  while (1) {
    string n;
    int sum = 0;
    cin >> n;
    if (n == "0") break;
    int i = n.length();
    while (i) {
      i--;
      sum += n[i]-'0';
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define rrep(i,a) for(int i=a; i>=0; --i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N,M;
    cin>>N>>M;
    priority_queue<int> A;
    rep(i,N){
        int a; cin>>a;
        A.push(a);
    }
    rep(i,M){
        int b = A.top();
        A.pop();
        b/=2;
        A.push(b);
    }
    ll ans=0;
    rep(i,N){
        ans += A.top();
        A.pop();
    }
    cout<<ans<<endl;
}

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

int main() {
  int n;
  cin>>n;
  long long count=0;
  for(int i=0;i<n;i++){
    if((i+1)%3==0||(i+1)%5==0)continue;
    count+=i+1;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3504
N = int(input())
dp = [10**6]*(N+1)
dp[0] = 0
pow6=1
for i in range(N):
    pow6=1
    pow9=1
    while pow6+i <=N: 
        dp[i+pow6] = min(dp[i+pow6],dp[i]+1)
        pow6 = pow6*6
    while pow9+i <=N:
        dp[i+pow9] = min(dp[i+pow9],dp[i]+1)
        pow9 = pow9*9
print(dp[N])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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


	int A, B, C;
	cin >> A >> B >> C;

	int kotae = A + B + C - max(max(A, B), C);

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

template <unsigned M> struct modular {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
  static constexpr unsigned mod = M;
  using m = modular;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
#pragma GCC diagnostic pop
};
using mint = modular<inf>;

template <class T, class Op = multiplies<T>>
T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n;
    cin>>n;
    mint p = 10;
    mint x = power(p, n);
    // cout<<x.v<<endl;
    p = 9;
    x -= power(p, n)*2;
    p = 8;
    x += power(p, n);
    cout<<x.v<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int h, w, n;
    cin >> h >> w >> n;
    int ma = max(h, w);
    int i = 1;
    while (ma * i < n) {
        i++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;

const ll NINF = -1e17;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[2003], b[2003];
    ll c[2003];
    vector<P> v[2003];
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        v[a[i]].push_back(P(b[i], c[i]));
    }
    ll d[1003];
    fill(d, d + n, NINF);
    d[0] = 0;
    bool f = true;
    int t = 0;
    ll memo;
    while(f){
        f = false;
        for(int i = 0; i < n; i++){
            if(d[i] != NINF){
                for(P next : v[i]){
                    if(d[next.first] < d[i] + next.second){
                        d[next.first] = d[i] + next.second;
                        f = true;
                    }
                }
            }
        }
        t++;
        if(t == n){
            memo = d[n - 1];
        }
        if(t == n * 2){
            if(memo != d[n - 1]){
                cout << "inf" << endl;
                return 0;
            }
            break;
        }
    }
    cout << d[n - 1] << endl;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String s = scanner.next();
        String t = scanner.next();
        char[] charray = s.toCharArray();
        Arrays.sort(charray);
        String s2 = new String(charray);
        charray = t.toCharArray();
        Arrays.sort(charray);
        reverse(charray);
        String t2 = new String(charray);
        if (s2.compareTo(t2) < 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static final void reverse(char[] arr) {
        final int len = arr.length;
        char tmp;
        for (int i = 0; i < len / 2; i++) {
            tmp = arr[i];arr[i] = arr[len - 1 - i];arr[len - 1 - i] = tmp;
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


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

int main(){
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >>r;
  // 左端のNG条件, 右端のNG条件, 下のNG条件, 上のNG条件
  if(x < r || x + r > w || y < r || y + r > h){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3112
a = input()

flag = True
c = False

for i in range(len(a)):
    if i == 0 and a[i] != 'A':
        flag = False
        break
    elif i != 0:
        if not c:
            if a[i] == "C":
                if i == 1 or i == len(a)-1:
                    flag = False
                    break
                else:
                    c = True
            elif not a[i].islower():
                flag = False
                break
        else:
            if not a[i].islower():
                flag = False
                break


if flag and c:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 9076
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    T = LI()
    res = 0
    past = T[0]
    for i in range(1, N):
        now = T[i]
        if now < past:
            res += (past-now)
        else:
            past = now
    print(res)
if __name__ == "__main__":
    main()

Measured memory_bytes: 103136
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n, m = Input()
    x = sorted(Input())

    data = sorted((abs(x[i]-x[i+1]) for i in range(m-1)), reverse=True)
    print(sum(data[n-1:]))


main()

Measured memory_bytes: 20744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;

long dp[100001][4];

int main() {string s;
cin >> s;
dp[0][0] = 1;
for(long i = 0; i < s.size(); i++){
    if(s[i] == 'A' || s[i] == '?'){
        rep(j, 4){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] = dp[i+1][j] % MOD;
        }
        dp[i+1][1] += dp[i][0];
            dp[i+1][1] = dp[i+1][1] % MOD;
    }
    if(s[i] == 'B' || s[i] == '?'){
        rep(j, 4){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] = dp[i+1][j] % MOD;
        }
        dp[i+1][2] += dp[i][1];
            dp[i+1][2] = dp[i+1][2] % MOD;
    }
    if(s[i] == 'C' || s[i] == '?'){
        rep(j, 4){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] = dp[i+1][j] % MOD;
        }
        dp[i+1][3] += dp[i][2];
            dp[i+1][3] = dp[i+1][3] % MOD;
    }
}
show(dp[s.size()][3]);



  return 0;
 
}



Measured memory_bytes: 3584
function Main(input) {
  nums = input.split(" ");
  a = nums[0];
  b = nums[1];

  if (a * b % 2 === 0) {
    console.log("Even");
  } else {
    console.log("Odd");
  }

  }
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
// Begin Header {{{
#define ll long long
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<ll>>;
using P = pair<int, int>;
// }}} End Header
struct edge{
	int to;
	int cost;
};
int main() {
	ll n, ans=1;
	cin >> n;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		if(a[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i,n){
		if(a[i] > (1000000000000000000/ans)){
			cout << -1 << endl;
			return 0;
		}
		ans*=a[i];
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

char ch;

void solve()
{
	if(ch >= 'A' && ch <= 'Z') cout << "A\n";
	else cout << "a\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> ch;
	solve();
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i=0; i<N; i++)cin >> a[i];
	sort(a,a+N);
	int ans = 0;
	int count=0;
	int num=0;
	for(int i=0; i<N; i++){
		if(num!=a[i]){
			ans+=(count-num)>=0?count-num:count;
			num = a[i];
			count = 0;
		}
		count++;
		if(i==N-1){
			ans+=(count-num)>=0?count-num:count;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;


unsigned digits_sum(unsigned n);

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;

    if(n % digits_sum(n))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    
    return 0;
}

unsigned digits_sum(unsigned n)
{
    unsigned place = 1;
    unsigned sum = 0;

    while (n)
    {
        unsigned place_value = n % (unsigned) 10;
        sum += place_value;
        n -= place_value;
        n /= 10;
    }
    
    return sum;
}

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

int main() {
  int i, total, area;
  string land;
  stack<int> s1;
  stack<pair<int, int> > s2;  // pos, area
  stack<int> pool;

  cin >> land;

  total = 0;
  for (i = 0; i < (int) land.length(); i++) {
    if (land[i] == '\\') {
      s1.push(i);
    } else if (land[i] == '/') {
      if (!s1.empty()) {
        int j = s1.top();
        // s1
        s1.pop();
        total += i - j;
        // s2
        area = i - j;
        while (!s2.empty() && s2.top().first > j) {
          area += s2.top().second;
          s2.pop();
        }
        s2.push(make_pair(j, area));
      }
    }
  }
  
  while (!s2.empty()) {
    pool.push(s2.top().second);
    s2.pop();
  }



  // output
  cout << total << endl;
  cout << pool.size();
  while (!pool.empty()) {
    cout << " " << pool.top();
    pool.pop();
  }          
  cout << endl;  

  return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(void){
	int A, B;
	cin >> A >> B;
	int cnt = 0;
	for(int i = A; i <= B; i++){
		string S = to_string(i);
		string T = S;
		REVERSE(T);
		if(S == T)cnt++;
	}
	cout << cnt << endl;
}

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

signed main(){
    int N;
    string S;
    cin >> N >> S;
    string ans = "Yes";
    if(N % 2 == 1){
      ans = "No";
    }
    REP(i,N/2){
      if(N % 2 ==0){
        if(S.at(i) != S.at(i+N/2)){
          ans = "No";
          break;
        }
        else{
         
        }
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<math.h>
using namespace std;
int a[100005];
long long int inf = 1000000000000;
int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}
int main(){
	int n,k,i,j;
	scanf("%d%d",&n,&k);
	int ma = inf;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		ma = max(ma,a[i]);
	}
	int re = a[0];
	for(i=0;i<n;i++){
		re = gcd(re,a[i]);
	}
	if(ma >= k && k%re == 0){
		printf("POSSIBLE\n");
	}else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
      string s;
      cin>>s;
      if(s[0]=='7' or s[1]=='7' or s[2]=='7'){
        printf("Yes\n");
      }     
      else{
        printf("No\n");
      }

        //printf("Case %d: ",++te);
    }
    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    long long h,w;
    cin >> h >> w;
    long long ans = 0;
    if(h == 1 || w == 1){
        ans = 1;
    }else{
        ans = (h*w+1)/2;
    }
    
    cout << ans << endl; 
    return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
  int N,X;
  cin>>N>>X;
  int a[N];
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  int ans = 0;
  int temp = 0;
  for(int i = 0;i<N;i++){
    temp += a[i];
    if(temp<=X){
      ans++;
    }
    else{
      break;
    }
  }
  cout << ans+1 << endl;
  return 0;
}

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

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

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll lcm = (c/gcd(c,d))*d;
  ll e = b/c - (a-1)/c;
  ll f = b/d - (a-1)/d;
  ll g = b/lcm - (a-1)/lcm;
  ll ans = b - a + 1 - e - f + g;
  cout << ans <<endl;
}
  

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0, y = count(ALL(s), 'R');
  int ans = y;
  rep(i, n){
    x += s[i] == 'W';
    y -= s[i] == 'R';
    chmin(ans, max(x, y));
  }
  print(ans);
}


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int n;
  string s;
  cin >> n >> s;
  int i=0,ans=0;
  int k=0;
  
  while (i < s.size()-1){
    if(s[i]!=s[i+1]){
      ans++;
    }
    i++;
  }
  ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
x,y = map(int, input().split())

getMoney = 0

if(x == 1):
  getMoney += 300000
elif(x == 2):
  getMoney += 200000
elif(x == 3):
  getMoney += 100000
  
if(y == 1):
  getMoney += 300000
elif(y == 2):
  getMoney += 200000
elif(y == 3):
  getMoney += 100000
  
if( x == 1 and y == 1):
  getMoney += 400000
  
print(getMoney)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define PRINT_ARRAY_H(i,a) REPALL(i,a) {cout<<a[i]<<(i != a.size()-1 ? " " : "");} newline;
#define e1 first
#define e2 second
#define newline putchar('\n')
#define cspace ' '
#define sspace " "
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};


int main()
{
    int n, m, ans = 0;
    string s, t;
    cin>>n;
    cout<<(1000-(n%1000))%1000<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

const int MAXN = 310;

int n, a[MAXN], cnt[4];
double f[MAXN][MAXN][MAXN];

inline double calc(int p, double val)
{
	return (p*1.0/n*val);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]), ++cnt[a[i]];
	for(int k=0;k<=n;k++){
		for(int j=0;j<=n;j++){
			for(int i=0;i<=n;i++){	
				if(!i && !j && !k) continue;
				f[i][j][k] += i ? f[i-1][j][k]   * i * 1.0 / (i+j+k) : 0;
				f[i][j][k] += j ? f[i+1][j-1][k] * j * 1.0 / (i+j+k) : 0;
				f[i][j][k] += k ? f[i][j+1][k-1] * k * 1.0 / (i+j+k) : 0;
				f[i][j][k] += (double) n * 1.0 / (i+j+k);
			}
		}
	}
	printf("%.14lf",f[cnt[1]][cnt[2]][cnt[3]]);
	return 0;
}

Measured memory_bytes: 227584
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int p = 1000000007;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int H, W, K;
	cin >> H >> W >> K;
	vector<int> bits;
	for (int bit = 0;bit < (1 << (W - 1));bit++) {
		int prev = 0;
		bool ok = true;
		int tmp = bit;
		while (tmp) {
			if (tmp % 2 && prev) {
				ok = false;
				break;
			}
			prev = tmp % 2;
			tmp /= 2;
		}
		if (ok) bits.push_back(bit);
	}
	int n = bits.size();
	//REP(k, n) cout << bits[k] << "\n";
	vector<int> left(W, 0), mid(W, 0), right(W, 0);
	for (int j = 0;j < W;j++) {
		for (int k = 0;k < n;k++) {
			left[j] += (j > 0) ? (bool)(bits[k] & (1 << (j - 1))) : 0;
			mid[j] += ((j > 0) ? (bool)(~bits[k] & (1 << (j - 1))) : 1) && ((j < W - 1) ? (bool)(~bits[k] & (1 << j)) : 1);
			right[j] += (j < W - 1) ? (bool)(bits[k] & (1 << j)) : 0;
			//printf("%d %d %d\n", left[j], mid[j], right[j]);
		}
		
	}
	vector<vector<ll>> dp(H + 1, vector<ll>(W + 2, 0));
	dp[0][1] = 1;
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			dp[i + 1][j + 1] = (left[j] * dp[i][j] % p + mid[j] * dp[i][j + 1] % p + right[j] * dp[i][j + 2] % p) % p;
		}
	}
	cout << dp[H][K] << "\n";

	return 0;
}


Measured memory_bytes: 256
h,w=gets.split.map(&:to_i)
s=h.times.map{gets.chomp}
i,j=0,0
s[0][0]=?.
while i<h-1||j<w-1
  if j<w-1&&s[i][j+1]==?#
    j+=1
    s[i][j]=?.
  elsif i<h-1&&s[i+1][j]==?#
    i+=1
    s[i][j]=?.
  else
    puts "Impossible"
    exit
  end
end
puts s==h.times.map{?.*w} ? :Possible: :Impossible

Measured memory_bytes: 1916
n=int(input())
rng = [[] for _ in range(n)]
for i in range(n):
  x,l=map(int,input().split())
  rng[i] = [x-l,x+l]
rng.sort(key=lambda y:y[1])
cnt=0
t_mx=-(10**10)
for i in range(n):
  if t_mx > rng[i][0]:
    cnt += 1
  else:
    t_mx = rng[i][1]
print(n-cnt)

Measured memory_bytes: 25260
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.q = l
        heapq.heapify(self.q)
        return

    def push(self, n):
        heapq.heappush(self.q, n)
        return

    def pop(self):
        return heapq.heappop(self.q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    S = Scanner.string()
    L = 'AKIHABARA'
    i = 0
    while len(L) > i:
        if len(S) <= i:
            S = S + 'A'
        if S[i] != 'A' and L[i] == 'A':
            S = S[:i] + 'A' + S[i:]
        i += 1
    if S == L:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    ll A[N], res = 0;
    REP(i, N){
        cin >> A[i];
        res += A[i];
    }

    if(res >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4316
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    X_bin = readline().strip()
    n = X_bin.count("1")
    X = int(X_bin, 2)

    X_pop_p = X % (n + 1)
    if n != 1:
        X_pop_m = X % (n - 1)

    
    def count(x):
        cnt = 1
        while x:
            x %= bin(x).count("1")
            cnt += 1
        return cnt
        
    ans = []
    for i in range(N):
        X_i = X ^ (1 << i)
        if X_i == 0:
            ans.append(0)
        else:
            if X_bin[-(i+1)] == "1":
                mod = (X_pop_m - pow(2, i, n - 1)) % (n - 1)
                ans.append(count(mod))
            else:
                mod = (X_pop_p + pow(2, i, n + 1)) % (n + 1)
                ans.append(count(mod))

    print("\n".join(map(str, ans[::-1])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 26920
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stack>
#include<string.h>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<list>

#define ln 1e6
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define sortvac(a,b) sort(akash.begin(),akash.end())
#define sortvdc(a,b) sort(akash.begin(),akash.end(),greater<int>())

#define sortaac(a,b) sort(arr,arr+b)
#define sortadc(a,b) sort(arr,arr+b,greater<int>())

#define searchv(data) binary_search(akash.begin(),akash.end(),data)
#define searcha(data) binary_search(arr,arr+b,data)

#define reversev(akash) reverse(akash.begin(),akash.end())
#define reversea(arr) reverse(arr,arr+b)

#define removev(data) remove(akash.begin(),akash.end(),data);
#define removea(data) remove(arr,arr+b,data);

#define maxv(akash) *max_element(akash.begin(),akash.end())
#define maxa(arr) *max_element(arr,arr+b)

#define minv(akash) *min_element(akash.begin(),akash.end())
#define mina(arr) *min_element(arr,arr+b)

#define fori(i,a,b) for(int i=0;i<b;i++)
#define ford(i,a,b) for(int i=b-1;i>=0;i--)

using namespace std;

int main()
{
    long long num;
    cin>>num;
    
    double swarna=0.0;
    long long ans=0,akash=100;
    long long count1=0;
    
    while(true){
        
        count1++;
        
        swarna=(1.0/100.0)*akash;
        
        akash+=swarna;
        
        ans=akash;
            
        if(ans>=num){
            break;
        }
    }
    cout<<count1<<"\n";
    return 0;
}







Measured memory_bytes: 3168
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        double a = sc.nextInt();
        double b = sc.nextInt();
        double t = 3.305785;
        double S;
        
        S = a * b;
        
        System.out.println(S / t);
    }
}


Measured memory_bytes: 26296
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    string ans;
    for(int i=0; i<s.length(); i++){
        if(s[i] == 'B') {
            if(ans.empty()) continue;
            else ans.erase(--ans.end());
        }
        else ans += s[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
s = input()
n = len(s)

square = [0 for _ in range(n)]
i = 0
while i < n:
    start = i
    char = s[i]
    i += 1
    while i < n and char == s[i]:
        i += 1

    if char == "L":
        num = i - start
        if num % 2 == 0:
            square[start - 1] += num // 2
            square[start] += num // 2
        else:
            square[start] += num // 2 + 1
            square[start - 1] += num // 2
    else:  # R
        num = i - start
        if num % 2 == 0:
            square[i] += num // 2
            square[i - 1] += num // 2
        else:
            square[i] += num // 2
            square[i - 1] += num // 2 + 1
    # if i == n - 1:
    #     i += 1


print(square[0], end="")
for i in range(1, n):
    print(" ", end="")
    print(square[i], end="")


Measured memory_bytes: 5524
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define PI 3.14159265
#define cbrt cbrtl
using namespace std;

ll n,dp[200005];
int main()
{
  cin>>n;
  ll a[n+5];
  ll i;
  for(i=1;i<=n;i++)
    cin>>a[i];
  dp[1]=0;
  dp[2]=dp[1]+abs(a[2]-a[1]);
  for(i=3;i<=n;i++)
  {
     dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
  }
  cout<<dp[n];
  return 0; 
}


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


int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N) cin >> d[i];
  
  Int ans = 0;
  rep(i,N - 1) {
    for (int j = i + 1; j < N; j++) {
      ans += d[i] * d[j];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256