akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N;


signed main(){
	int ans = 0;
	cin >> N;
	rep(i, 0, N){
		int a;
		cin >> a;
		ans += a-1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[200000];
ll dp[200000];
ll ans;
int n;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     //freopen("output.txt", "w", stdout);
    // #endif

    cin >> n;
    ll k;
    cin >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    dp[1] = 0;
    dp[0] = 0;
    int i = 2;
    while (i <= n)
    {
        ll temp = INT_MAX;
        for (int m = i - 1; m >= 1 && m >= i - k; m--)
        {
            ll cost = abs(arr[i] - arr[m]) + dp[m];
            if (temp > cost)
            {
                temp = cost;
            }
        }
        dp[i] = temp;
        i++;
    }
    cout << dp[n] << endl;
    return 0;
}


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

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

    int ans = T.size();

    for (int i = 0; i < S.size(); i++) {
        if (i + T.size() > S.size()) break;
        int diff = 0;

        for (int j = 0; j < T.size(); j++) {
            if (S.at(i + j) != T.at(j)) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3552
N = int(input())
T, A = map(int, input().split())
height = list(map(int, input().split()))

tempurature = []

for i in height:
    n = T - (i * 0.006)
    tempurature.append(abs(A - n))

print(tempurature.index(min(tempurature)) + 1)

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;


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

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N*A, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a,b,c=0;
    scanf("%d %d %d", &a,&b,&c);
    
    if(a >= b){
        printf("No\n");
        return 0;
    }
    else if (b < c){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;    
}


Measured memory_bytes: 2076
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int e=0,w=0;
    int ans=300000+1;
    for(int i=0;i<n;i++){
        if(s[i]=='E') e++;
        else w++;
    }
    int ee=0,ww=0;
    for(int i=0;i<n;i++){
        if(s[i]=='E'){
            e--;
        }else{
            w--;
        }
        chmin(ans,e+ww);
        if(s[i]=='E') ee++;
        else ww++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 900
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct UnionFind{
    vl par;
    vl rank;
    map<ll, ll> size;
    UnionFind(ll N) : par(N, 0), rank(N, 0){
        for(int i = 0; i < N; i++){
            par[i] = i; size[i] = 1;
        }
    }
    
    ll root(ll x){
        if(par[x] == x) return x;
        else{
            par[x] = root(par[x]); // compression
            return par[x];
        }
    }
    
    void unite(ll x, ll y){
        ll rx = root(x); ll ry = root(y);
        if(rx == ry) return;
        if(rank[rx] < rank[ry]) swap(rx, ry);
        if(rank[rx] == rank[ry]) ++rank[rx];
        par[ry] = rx;
        if(rx != ry) size[rx] = size[rx] + size[ry];
        else{
            size[rx] = max(size[rx], size[ry]);
        }
    }
    
    ll get_size(ll x){
        return size[root(x)];
    }
    
    bool same(ll x, ll y){
        return root(x) == root(y);
    }
};


int main(){
    ll N, M; cin >> N >> M;
    vl as(M, 0), bs(M, 0);
    REP(i, M){
        ll a, b;
        cin >> a >> b; as[i] = a-1; bs[i] = b-1;
    }
    
    auto uf = UnionFind(N);
    vl ans(M, 0); ans[M-1] = N * (N-1) / 2;
    ll res = ans[M-1]; vb init(M, true);
    for(ll i = M-1; i >= 0; i--){
        if(!uf.same(as[i], bs[i])){
            res -= uf.get_size(as[i]) * uf.get_size(bs[i]);
        }
        uf.unite(as[i], bs[i]);
        if(i>=1) ans[i-1] = max(res, 0ll);
    }
    REP(i, M) cout << ans[i] << endstr;
    return 0;
}


Measured memory_bytes: 11520
// AOJ 2224 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2224)
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#define rep(i,a) for(int i=0;i<(a);++i)
#define all(a) (a).begin(), (a).end()

struct edge
{
	int from, to;
	double cost;

	edge( int from, int to, double cost )
	:	from(from), to(to), cost(cost)
	{}

	bool operator< ( const edge &e ) const
	{ return cost < e.cost; }
};

struct UnionFind
{
	std::vector<int> par, rank;

	UnionFind( std::size_t sz )
	:	par(sz), rank(sz)
	{
		rep( i, sz )
			par[i] = i;
	}

	int find( int x )
	{ return x==par[x]?x:par[x]=find(par[x]); }

	void unite( int x, int y )
	{
		x = find(x); y = find(y);
		if( x == y )
			return;

		if( rank[x] < rank[y] )
			par[x] = y;
		else
		{
			par[y] = x;

			if( rank[x] == rank[y] )
				++rank[x];
		}

		return;
	}

	bool same( int x, int y )
	{ return find(x)==find(y); }
};

const int MAX_N = 10000;

int N, M;
int x[MAX_N], y[MAX_N];
std::vector<edge> es;
double ans;

int main()
{
	scanf( "%d%d", &N, &M );
	rep( i, N )
		scanf( "%d%d", x+i, y+i );
	rep( i, M )
	{
		int p, q;
		scanf( "%d%d", &p, &q );
		--p; --q;
		
		double c = sqrt((x[p]-x[q])*(x[p]-x[q])+(y[p]-y[q])*(y[p]-y[q]));
		es.push_back( edge( p, q, -c ) );
		ans += c;
	}

	std::sort( all(es) );

	UnionFind uf( N );
	rep( i, M ) if( !uf.same( es[i].from, es[i].to ) )
	{
		ans += es[i].cost;
		uf.unite( es[i].from, es[i].to );
	}

	printf( "%.3f\n", ans );

	return 0;
}

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

#define     int          long long int
#define     fast() 	     ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;

void solve()
{
 int n,k;
 
 cin>>n>>k;
 
 int x,cnt;
 long double ans=0;
 
 for(int i=1;i<=n;++i)
 {
  x=i;     
  cnt=0;
  while(x<k)
  x*=2,++cnt;
  
  ans+=pow(0.5,cnt);
 }
 
 long double m=(long double)n;
 ans*=1/m;
 
 cout<<fixed<<setprecision(12)<<ans;
}

int32_t main()
{
    fast();
    
	int t=1;
	//cin>>t;
	while(t--)
    {
     solve();
	}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

bool a[100005] = {};
bool b[4][100005] = {};
int main() {
	ll n; string s; cin >> n >> s;

	rep(i, 0, s.size() + 2)	a[i] = ((s[i % n] == 'o') ? true : false);

	b[0][0] = 1; b[0][1] = 1; // SS
	b[1][0] = 1; b[1][1] = 0; // SW
	b[2][0] = 0; b[2][1] = 1; // WS
	b[3][0] = 0; b[3][1] = 0; // WW
	rep(i, 0, 4) {
		rep(j, 1, n + 2) {
			if (b[i][j]) {
				if (a[j]) b[i][j + 1] = b[i][j - 1];
				else  b[i][j + 1] = !b[i][j - 1];
			}
			else {
				if (a[j]) b[i][j + 1] = !b[i][j - 1];
				else  b[i][j + 1] = b[i][j - 1];
			}
		}

		if (b[i][n] == b[i][0] && b[i][n + 1] == b[i][1]) {
			rep(j, 0, n) cout << (b[i][j] ? 'S' : 'W');
			cout << endl;
			return 0;
		}
	}
	cout << -1 << endl;

	return 0;
}

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

using namespace std;

#define ll long long
#define MAXN 100000

ll sum[MAXN + 1], sa[MAXN + 1];

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

    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        sum[i] = x + sum[i - 1];
        sa[i] = sa[i - 1];
        if (x > 0)
            sa[i] += x;
    }

    ll ans = 0;
    for (int i = 1; i <= n - k + 1; i++)
        ans = max(ans, sa[i - 1] + sa[n] - sa[i + k - 1] + max(0LL, sum[i + k - 1] - sum[i - 1]));

    cout << ans;

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int a, b;
  
  scanf("%d %d", &a, &b);
  
  if(a % 2 != 0 && b % 2 != 0){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
[N, M] = list(map(int, input().split(' ')))
AB = []
for _ in range(N):
    line = tuple(map(int, input().split(' ')))
    AB.append(line)

AB.sort(key=lambda x: x[0])

money = 0
buy_num = 0

while buy_num < M:
    store = AB.pop(0)
    if store[1] >= M - buy_num:
        money = money + (M - buy_num) * store[0]
        buy_num = buy_num + (M - buy_num)
    else:
        money = money + store[1] * store[0]
        buy_num = buy_num + store[1]

print(money)


Measured memory_bytes: 19348
def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans, b = 1000, 0
    def buy(a):
        nonlocal b, ans
        b += ans // a
        ans %= a
    def sell(a):
        nonlocal b, ans
        ans += b * a
        b = 0
    if A[0] < A[1]: buy(A[0])
    for i in range(1, n - 1):
        if A[i - 1] >= A[i] < A[i + 1]:
            buy(A[i])
        elif A[i - 1] <= A[i] > A[i + 1]:
            sell(A[i])
        else:
            continue
    if b > 0:
        sell(A[-1])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include <iostream>


std::string buildString(int character, int count)
{
    char c = '0' + character;
    std::string s;
    for(int i = 0; i < count; ++i)
    {
        s += c;
    }
    return s;
}

int main()
{
    int a, b;
    std::cin >> a >> b;
    
    if(a < b)
    {
        std::cout << buildString(a, b);
    }
    else
    {
        std::cout << buildString(b, a);
    }
}

Measured memory_bytes: 256
#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(){
  int n;
  cin >> n;
  vector <int> a(n);
  rep(i,n)cin >> a[i];
  int curr=1,cnt=0;
  bool flag=false;
  rep(i,n){
    if(a[i]==curr){
      flag=true;
      curr++;
    }
    else cnt++;
  }
  if(flag==true)cout << cnt << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 1024
// 154 B

#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

int main(){
    int n, m, tmp, sum;
    cin >> n >> m;
    vector<int > v;
    for(int i=0; i<m; i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    sum = accumulate(v.begin(), v.end(), 0);
    if(n-sum < 0) cout << -1 << endl;
    else cout << n-sum << endl;
    return 0;
}


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

int main(){
  int a, b;
  string s;
  
  cin >> a >> b >> s;
  
  for ( int i = 0; i < a + b + 1; i++ ){
    if ( i < a || a < i ){
      if ( s[i] < '0' || '9' < s[i] ){
        cout << "No" << endl;
        return 0;
      }
    }
    
    if ( i == a && s[i] != '-' ){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int,input().split())
B = []
C = np.zeros(N)
e = 0
for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for j in range(1, N + 1):
    B.append(A.count(j))
  for k in range(N):
    C[k] += B[k] 
  B = []
for l in range(N):
  if C[l] == 0:
    e += 1
print(e)


Measured memory_bytes: 27196
# coding: utf-8
N, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
sum = 0
count = [0 for _ in range(K+1)]
pows = [0 for _ in range(K+1)]

def cal_pow(k, pows):
    if pows[k] == 0:
        pows[k] = pow(k,N, mod)
        return pows[k]
    else:
        return pows[k]

for h in range(K):
    k = K-h
    sub, alpha = 0,2
    while True:
        if alpha*k <= K:
            sub += count[alpha*k]
            alpha += 1
        else:break
    count[k] = (cal_pow(K//k, pows) - sub) % mod

for k, c in enumerate(count):
    sum += k * c % mod
print(sum % mod)

Measured memory_bytes: 12168
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    if(N % 2) Out((double)(N / 2 + 1) / N);
    else Out(0.5);

    return 0;
}


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

int N, K, R, S, P;
string T;
bool is_win[100100];
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K >> R >> S >> P >> T;
    int ans = 0;
    rep(i, N) {
        if (T[i]=='r') {
            if (i<K) {
                ans += P;
                is_win[i] = true;
            }
            else {
                if (T[i-K]!='r' || !is_win[i-K]) {
                    ans += P;
                    is_win[i] = true;
                }
            }
        }
        else if (T[i]=='s') {
            if (i<K) {
                ans += R;
                is_win[i] = true;
            }
            else {
                if (T[i-K]!='s' || !is_win[i-K]) {
                    ans += R;
                    is_win[i] = true;
                }
            }
        }
        else {
            if (i<K) {
                ans += S;
                is_win[i] = true;
            }
            else {
                if (T[i-K]!='p' || !is_win[i-K]) {
                    ans += S;
                    is_win[i] = true;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll Q,H,S,D,N;cin>>Q>>H>>S>>D>>N;
    Q = Q*4;
    H = H*2;
    int mn = min(S,min(H,Q));
    ll ans = min((N/2)*D + (N%2)*mn,N*mn);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
bool match(string s, string s2){
  return (s.find(s2)!=std::string::npos);
}
int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string s;cin>>s;
  if(match(s, "RRR")){
    puts("3");
  }
  else if(match(s, "RR")){
    puts("2");
  }
  else if(match(s, "R")){
    puts("1");
  }else{
    puts("0");

  }

  
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int x;
    long long maxn=-1,minn = 1e+9;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        if(x>maxn) maxn=x;
        if(x<minn) minn=x;
    }
    printf("%d",maxn-minn);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>

int num_of_point[7] = {2,5,17,65,257,1025,4097},n,points_index = 0;

struct Point{
	double x;
	double y;
};

Point points[4097];

Point roll(Point div1,Point div2){
	Point tmp_start = { div2.x-div1.x,div2.y-div1.y };
	Point tmp_end = { tmp_start.x*cos(M_PI/3) -tmp_start.y*sin(M_PI/3),
			tmp_start.x*sin(M_PI/3) + tmp_start.y*cos(M_PI/3) };
	Point ret = { tmp_end.x + div1.x,tmp_end.y + div1.y };
	return ret;
}

void calc(Point left,Point right,int count){
	Point div1 = {	(2*left.x + right.x)/3,(2*left.y + right.y)/3 };
	Point div2 = {(2*right.x + left.x)/3,(2*right.y + left.y)/3	};
	Point peek = roll(div1,div2);

	points[points_index++] = div1;
	points[points_index++] = div2;
	points[points_index++] = peek;

	if(count > 1){
		calc(left,div1,count-1);
		calc(div1,peek,count-1);
		calc(peek,div2,count-1);
		calc(div2,right,count-1);
	}else{
		printf("%.8f %.8f\n",left.x,left.y);
		printf("%.8f %.8f\n",div1.x,div1.y);
		printf("%.8f %.8f\n",peek.x,peek.y);
		printf("%.8f %.8f\n",div2.x,div2.y);
	}
}

int main(){
	Point left = {0,0},right = {100,0};
	points[points_index++] = left;
	points[points_index++] = right;
	scanf("%d",&n);

	if(n == 0){
		printf("%.8f %.8f\n",left.x,left.y);
		printf("%.8f %.8f\n",right.x,right.y);
	}else{
		calc(left,right,n);
		printf("%.8f %.8f\n",right.x,right.y);
	}
}

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

int main(){
  long N;
  cin >> N;
  long rootN = (long)sqrt(N);
  long out;

  
  for(long i=rootN; i>=1; i--){
    if(N%i == 0){//a
      out = N/i + i - 2;//a+b
      cout << out;
      return 0;
    }
  }
  
  return 0;
}





Measured memory_bytes: 256
function main()
  
  (X,Y) = map(x -> parse(BigInt,x), split(readline()))
  
  count = 0
  
  while true
    if 2X <= Y
      count += 1
      X *= 2
    else
      break
    end
  end
  
  println(count+1)
  
end

main()

Measured memory_bytes: 112900
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
bool use[100010];
int arr[256];
void Sequence() {
	ll n, m;
	cin >> n >> m;
	if((n * 2) > m){
		cout << (m / 2) << endl;
	}
	else {
		cout << (n + ((m - (n * 2)) / 4)) << endl;
	}

}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=2005;
const int mod=924844033;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int nx[MAXN],n,K,dp[MAXN][MAXN][2],ri[MAXN][MAXN];
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
bool vis[MAXN];
int f[MAXN],cnt,tf;
void getri(int x)
{
	++cnt;vis[x]=1;
	if(x+2*K<=n)getri(x+2*K);
	else if(x+K<=n)tf=1;
}
int pre[MAXN],inv[MAXN],fi[MAXN];
int dp1[MAXN][MAXN][2];
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	dp[1][1][0]=1;
	for(int i=1;i+1<MAXN;i++)for(int j=0;j<=i;j++)for(int k=0;k<=1;k++)if(dp[i][j][k])
	{
		ad(dp[i+1][j][1],dp[i][j][k]);
		ad(dp[i+1][j+1][0],dp[i][j][k]);
		if(k)ad(dp[i+1][j+1][1],dp[i][j][k]);
	}
	dp1[2][0][1]=1;dp1[2][1][0]=dp1[2][1][1]=1;
	for(int i=2;i+1<MAXN;i++)for(int j=0;j<i;j++)for(int k=0;k<=1;k++)if(dp1[i][j][k])
	{
		ad(dp1[i+1][j][1],dp1[i][j][k]);
		ad(dp1[i+1][j+1][0],dp1[i][j][k]);
		if(k)ad(dp1[i+1][j+1][1],dp1[i][j][k]);
	}
	n=read();K=read();
	int tot=0;f[0]=1;
	for(int i=1;i<=n;i++)if(!vis[i])
	{
		cnt=tf=0;getri(i);int tf1=(i-K>=1);
		for(int j=tot;j>=0;j--)if(f[j])
			for(int k=cnt;k>=0;k--)
			{
				if(k)ad(f[j+k],1LL*f[j]*(dp1[cnt][k][0]+dp1[cnt][k][1])%mod);
				if(tf&&tf1)
				{
					ad(f[j+k],2LL*f[j]*(dp[cnt][k][0]+dp[cnt][k][1])%mod);
					ad(f[j+k+1],1LL*f[j]*dp[cnt][k][1]%mod);
				}
				if((tf&&!tf1)||(tf1&&!tf))ad(f[j+k],1LL*f[j]*(dp[cnt][k][0]+dp[cnt][k][1])%mod);
			}
		tot+=cnt-1+tf+tf1;
	}

	int ans=0;
	for(int i=0;i<=n;i++)
	{
		int g=1LL*f[i]*pre[n-i]%mod;
		if(i&1)dl(ans,g);else ad(ans,g);
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 62976
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

bool Solve(vec &d, ll N){
    if(d[N-1]>d[0]+1) return false;
    ll S=d[N-1];
    if(d[N-1]==d[0]){
        if(S==N-1) return true;
        if(S*2>N) return false;
        return true;
    }
    ll One=lower_bound(ALL(d),S)-d.begin();
    ll Two=N-One;
    if(Two==1) return false;
    Two/=2;
    if(S<One+1) return false;
    if(S>One+Two) return false;
    return true;

}
int main(){
    ll N; cin>>N;
    vec d(N);
    rep(i,N) cin>>d.at(i);
    sort(ALL(d));
    if(Solve(d,N)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

Measured memory_bytes: 1152
def aaa():
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = 1;
	for i in range(n):
		if a[i]==0:
			print(0)
			return
	for i in range(n):
		ans *= a[i]
		if ans>1000000000000000000:
			print(-1)
			return
	print(ans)

aaa()

Measured memory_bytes: 21788
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
def main(): #startline------------------------------------------
    N,K = map(int,input().split())
    x = list(map(int,input().split()))
    ans = float("inf")
    flag = False
    for i in range(N-K+1):
        flag = True
        l = x[i]
        r = x[K+i-1]
        p = abs(l)+abs(r-l)
        q = abs(r)+abs(r-l)
        s = min(p,q)
        if ans > s:
            ans = s
    print(ans if flag else abs(x[0]))
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)


if __name__ == "__main__":
    main()

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define BR "\n"

vector<int> face(6);
void rotate(char d) {
  vector<int> newFace(6);
  newFace = face;
  if (d == 'N') {
    newFace[0] = face[1];
    newFace[1] = face[5];
    newFace[5] = face[4];
    newFace[4] = face[0];
  } else if (d == 'S') {
    newFace[0] = face[4];
    newFace[1] = face[0];
    newFace[5] = face[1];
    newFace[4] = face[5];
  } else if (d == 'E') {
    newFace[0] = face[3];
    newFace[2] = face[0];
    newFace[5] = face[2];
    newFace[3] = face[5];
  } else if (d == 'W') {
    newFace[0] = face[2];
    newFace[2] = face[5];
    newFace[5] = face[3];
    newFace[3] = face[0];
  }
  face = newFace;
}

int main() {
  rep0(i, 6) cin >> face[i];

  vector<int> face2(6);
  rep0(i, 6) cin >> face2[i];

  string s = "NEWS";

  rep0(i, 10000) {
    char c = s[rand() % 4];
    rotate(c);
    bool check = true;
    rep0(j, 6) {
      if (face[j] != face2[j]) check = false;
    }
    if (check) {
      cout << "Yes" << BR;
      return 0;
    }
  }

  cout << "No" << BR;
  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'

using namespace std;

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

  string s; cin >> s;
  int n = s.size(), k; cin >> k;

  vector<pair<char, int>> compressed;
  for (int i = 0, j; i < n; i = j) {
    j = i;
    while (j < n && s[i] == s[j]) {
      ++j;
    }
    compressed.emplace_back(s[i], j - i);
  }
  
  if ((int)compressed.size() == 1) {
    cout << 1LL * n * k / 2 << endl;
    return 0;
  }

  long long intern = 0;
  for (auto &p : compressed) {
    intern += p.second / 2;
  }
  long long no_ends = intern - 
    compressed[0].second / 2 -
    compressed.back().second / 2;
  if (k == 1) {
    cout << intern << endl;
    return 0;
  }
  long long ans = no_ends * k;
  if (compressed[0].first == compressed.back().first) {
    ans += 1LL * (k - 1) * ((compressed[0].second + compressed.back().second) / 2);
    ans += compressed[0].second / 2;
    ans += compressed.back().second / 2;
  } else {
    ans = intern * k; 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[8100];
vector<int>X;
vector<int>Y;
int dp[8100];
int main(){
	scanf("%s",in);
	int x,y;scanf("%d%d",&x,&y);
	int e=0;
	int m=0;
	int fl=0;
	for(int i=0;in[i];i++){
		if(in[i]=='F')e++;
		else{
			if(m%2==0){
				if(fl==0)x-=e;
				else X.push_back(e);
			}else{
				Y.push_back(e);
			}
			m++;
			e=0;
			fl=1;
		}
	}
				if(m%2==0){
				if(fl==0)x-=e;
				else X.push_back(e);
			}else{
				Y.push_back(e);
			}
			m++;
			e=0;
			fl=1;

//	for(int i=0;i<X.size();i++)printf("%d ",X[i]);
	dp[0]=1;
	int ff=0;
	for(int i=0;i<X.size();i++){
		ff+=X[i];
		for(int j=8050;j>=0;j--){
			if(dp[j]){
				dp[j+X[i]]=1;
			}
		}
	}
	if(ABS(ff-x)%2||ff<x||!dp[(ff-x)/2]){
		printf("No\n");return 0;
	}
	ff=0;
	for(int i=0;i<8100;i++)dp[i]=0;
	dp[0]=1;
	for(int i=0;i<Y.size();i++){
		ff+=Y[i];
		for(int j=8050;j>=0;j--){
			if(dp[j]){
				dp[j+Y[i]]=1;
			}
		}
	}
	if(ABS(ff-y)%2||ff<y||!dp[(ff-y)/2]){
		printf("No\n");return 0;
	}
	printf("Yes\n");
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
    int N = 0, A = 0, B = 0;
    cin>>N>>A>>B;
    string s = "";
    cin>>s;
    int countAll = 0, countB = 0;
    for(int i = 0; s[i]; ++i){
        if(s[i] == 'c'){
            cout<<"No"<<endl;
            continue;
        }
        countAll++;
        if(countAll <= A+B){
            if(s[i] == 'a') cout<<"Yes"<<endl;
            if(s[i] == 'b'){
                countB++;
                if(countB <= B) cout<<"Yes"<<endl;
                else countAll--, cout<<"No"<<endl;
            }
        } 
        else cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
    int N, Y;
    cin >> N >> Y;

    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; a++) {
        for (int b = 0; b + a <= N; b++) {
            int c = N - a - b;
            int sum = 10000*a + 5000*b + 1000*c;
            if (sum == Y) {
                res10000 = a;
                res5000  = b;
                res1000  = c;
            }
        }
    }
    cout << res10000 << ' ' << res5000 << ' ' << res1000 << endl;
    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr 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;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  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; }
};

using mint = modular<power(10, 9) + 7>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? fact[i - 1] * i : 1;
  inv_fact[n] = power(fact[n], mint::mod - 2);
  for (int i = n; i--; ) inv_fact[i] = (i + 1) * inv_fact[i + 1];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template <> mint& mint::operator/=(mint b) {
  return *this *= b.v < minv.size() ? minv[b.v] : power(b, mod - 2);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = size(s);
  prepare(n + k);
  mint res;
  for (int m = n; m <= n + k; ++m) {
    res += binom(n + k, m) * power<mint>(25, n + k - m);
  }
  cout << res.v << '\n';
}


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

long long int M=1e+9+7;
const int N=2e+3+10;
long long int dp[N],n;

int main()
{
	cin>>n;
	dp[3]=1;
	for(int x=4;x<=n;x++)
	{
		dp[x]=1;
		int j=3;
		for(j=3;j<=x;j++)
		{
			if(x-j>=3)
				dp[x]=(dp[x]+dp[j])%M;
		}
		//dp[x]=((dp[x]*2LL)%M+1)%M;
		//if(j==x-j)
			//dp[x]=(dp[x]+(dp[x-j]*dp[j])%M)%M;
	}
	cout<<dp[n];
}



Measured memory_bytes: 3636
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *A = map(int, read().split())

    vec = [INF] * N
    for a in reversed(A):
        vec[bisect_right(vec, a)] = a

    try:
        print(vec.index(INF))
    except:
        print(N)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
/**
 * C - たくさんの数式 / Many Formulas
 * https://atcoder.jp/contests/abc045/tasks/arc061_a
 **/
#include<iostream>
#include<string>

using namespace std;


#define ll long long

int main() {
    string s;
    cin >> s;
    int n = s.length();
    ll ans = 0;
    if(n==1) {
        cout << stoll(s) << endl;
        return 0;
    }
    for(int bit=0; bit<(1<<n-1); bit++) {
        int ptr=n-1;
        for(int i=0; i<n-1; i++) {
            if(bit&(1<<i)) {
                string num_s = s.substr(n-1-i, ptr-(n-1-i)+1);
                ll num = stoll(num_s);
                ans += num;
                ptr = n-2-i;
            }
            if(i==n-2) {
                string num_s = s.substr(0, ptr+1);
                ll num = stoll(num_s);
                ans += num;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		int t = 1;
		for(int i = 0; i < N; i++) {
			t = Math.min(2 * t, t + K);
		}
		System.out.println(t);
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<string>
#include<vector>
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
    int n,cnt=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int nx, ny;
  nx = tx - sx;
  ny = ty - sy;
  for(int i = 0; i < nx; i++){
    cout << "R";
  }
  for(int i = 0; i < ny; i++){
    cout << "U";
  }
  for(int i = 0; i < nx; i++){
    cout << "L";
  }
  for(int i = 0; i < ny; i++){
    cout << "D";
  }
  cout << "D";
  for(int i = 0; i <= nx; i++){
    cout << "R";
  }
  for(int i = 0; i <= ny; i++){
    cout << "U";
  }
  cout << "LU";
    for(int i = 0; i <= nx; i++){
    cout << "L";
  }
  for(int i = 0; i <= ny; i++){
    cout << "D";
  }
  cout << "R" << endl;
}
  


Measured memory_bytes: 256
import sys
can = True; input()
e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin]
for a, b in zip(e[1:], e):
    t = a[0] - b[0] - abs(a[1] - b[1]) - abs(a[2] - b[2])
    if t < 0 or t % 2 == 1: can = False; break
print(['No', 'Yes'][can])

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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n, a, b;
  cin >> n >> a >> b;
  vector<i64> h(n);
  i64 hmax = 0;
  REP(i, n) {
    cin >> h[i];
    hmax = max(hmax, h[i]);
  }

  i64 gap = a - b;
  auto check = [&](i64 cnt) -> bool {
    i64 acnt = 0;
    REP(i, n) {
      i64 rest = h[i] - b * cnt;
      if (rest <= 0) continue;
      acnt += (rest + gap - 1) / gap;
      if (acnt > cnt) return false;
    }
    return true;
  };

  DEBUG(hsum);
  i64 ng = -1, ok = hmax;
  while (ok - ng > 1) {
    i64 mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      DEBUG(mid);
      ng = mid;
    }
  }
  cout << ok << endl;
}

Measured memory_bytes: 3976
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        sc.close();

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                sb.append("0");
            } else if (s.charAt(i) == '1') {
                sb.append("1");
            } else if (sb.length() != 0) {
                sb.deleteCharAt(sb.length() - 1);
            }
        }

        System.out.println(sb.toString());
    }
}

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

int main() {
    //
    int num;

    cin >> num;

    vector<int> vec(num);
    vector<int> vec2(num);

    for (int i = 0; i < num; i++) cin >> vec.at(i);

    vec2 = vec;
    sort(vec2.begin(), vec2.end());

    int cnt = 0;
    for (int i = 0; i < num; i++) {
        if (vec.at(i) != vec2.at(i)) cnt++;
    }

    if (cnt <= 2) cout << "YES";
    else cout << "NO";
    //
}


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

int main() {
    int n;
    int x, y;
    int64_t A = 1, B = 1;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> x >> y;
        int64_t t = std::max((A + x-1) / x, (B + y-1) / y);
        A = x * t;
        B = y * t;
    }
    cout << A + B << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()

typedef struct record_tbl
{
	int no;
	double time;
} record_t;

record_t alternate[6];
int ix;

int
cmp_func(const void *l_, const void *r_)
{
	const record_t *l = (const record_t*) l_;
	const record_t *r = (const record_t*) r_;

	if (l->time < r->time)
		return -1;

	if (l->time > r->time)
		return 1;

	return 0;
}

void
ope_group()
{
	record_t record[8];

	for (int i = 0; i < 8; ++i)
		scanf("%d%lf", &record[i].no, &record[i].time);

	qsort(record, 8, sizeof(record_t), cmp_func);
	for (int i = 0; i <= 1; ++i)
		printf("%d %.2f\n", record[i].no, record[i].time);

	for (int i = 2; i <= 3; ++i)
		alternate[ix++] = record[i];
}

int
main(int argc, char **argv)
{

	ix = 0;
	ope_group();
	ope_group();
	ope_group();

	qsort(alternate, ix, sizeof(record_t), cmp_func);
	for (int i = 0; i < 2; ++i)
		printf("%d %.2f\n", alternate[i].no, alternate[i].time);

	return 0;
}

Measured memory_bytes: 1700
n = int(input())
hanako_p = 0
taro_p = 0
for i in range(0,n):
    t, h = input().split()
    if t < h:
        hanako_p += 3
    elif t > h:
        taro_p += 3
    else:
        taro_p += 1
        hanako_p += 1

print(str(taro_p)+' '+str(hanako_p))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t a, b;
    cin >> a >> b;

    cout << max(a - 2 * b, 0L) << endl;
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let s = read_one::<String>().chars()
        .filter(|&c| c == '1').count();
    println!("{}", s);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

void sieve(int n, vector<int> &primes)
{
    vector<bool> v(n + 1, true);

    // check
    for (int i = 2, end = sqrt(n); i <= end; i++) {
        if (!i)
            continue;
        for (int j = i + i; j <= n; j += i)
            v[j] = false;
    }

    for (int i = 2; i <= n; i++)
         if (v[i])
            primes.push_back(i);
}

int main()
{
    vector<int> primes;
    vector<int> inputs;
    int i;

    // read all inputs
    for (int x; cin >> x;)
        inputs.push_back(x);

    // init sieve
    sieve(*max_element(inputs.begin(), inputs.end()), primes);

    for (auto x : inputs) {
        for (i = 0; i < primes.size(); i++) // find
            if (primes[i] == x) {
                i++;
                break;
            } else if (primes[i] > x)
                break;
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

X, A = [int(x) for x in stdin.readline().rstrip().split()]

if X<A:
  print(0)
else:
  print(10)

Measured memory_bytes: 21600