akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},{1,1},{1,-1},{-1,1},{-1,-1}};

const int MAXN = 1e7 + 1;
int spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        spf[i] = i;

    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
int fun(int x)
{
    int ans = 1;
    int y = x;
    //vector<int> ret;
    while (x != 1)
    {
        //ret.push_back(spf[x]);
        int xx = 0;
        while(y%spf[x]==0){
            xx++;
            y /= spf[x];
        }
        ans *= (xx + 1);
        x = x / spf[x];
    }
    return ans;
}
void solve(){
    int n;
    cin >> n;
    sieve();
    int ans = 0;
    foo(i,1,n+1){
        //deb(fun(i));
        ans += i * fun(i);
    }
    cout << ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;

    while(t--){
        solve();
    }
}


Measured memory_bytes: 81792
S = input()
 
if 1<= int(S[0]+S[1])<=12:
  if 1<= int(S[2]+S[3]) <=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1<= int(S[2]+S[3]) <=12:
    print('YYMM')
  else:  
    print('NA')

Measured memory_bytes: 3060
import bisect
import numpy as np
import math
import itertools
def main():
    H, N = map(int, input().split())
    A = list(map(int, input().split()))
    if sum(A) >= H:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == '__main__':
    main()

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

int main() {
    int x,y;
    cin >> x >> y;

    int res = 2100000000;
    for(int i=0; i<2; ++i) {
        for(int j=0; j<2; ++j) {
            int tx = x, ty = y;
            if(i) tx = -tx;
            if(j) ty = -ty;
            if(tx <= ty) res = min(res, i + j + (ty - tx));
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char number[1001];
    int i,num,sum=0;
    
    while(1) {
        scanf("%s",number);
        for(i=0;number[i]!='\0';i++){
            num=number[i]-'0';
            sum=sum+num;
        }
        if(sum==0) break;
        printf("%d\n",sum);
        sum=0;
        }
    
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
int temp;
void dfs(int x,vector<ll> v[],int visited[])
{
    visited[x]=1;
    temp++;
    for(int i=0;i<v[x].size();i++)
    {
        if(visited[v[x][i]]==0)
        {
            dfs(v[x][i],v,visited);
        }
    }
}
int main()
{
    fastio();
   
    ll n,m;
    cin>>n>>m;
    map<pair<ll,ll>,ll> ma;
    std::vector<ll> v[n+1];
    for(int i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(x>y)
            swap(x,y);
        if(ma[{x,y}]==0)
        {
            ma[{x,y}]=1;
            v[x].pb(y);
            v[y].pb(x);
        }
    }
    int ans=0;
    int visited[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        if(visited[i]==0)
        {
            temp=0;
            dfs(i,v,visited);
            //cout<<i<<" "<<temp<<endl;
            ans=max(ans,temp);
        }
    }
    cout<<ans<<endl;
}

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


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

ll f(ll x,ll c,ll d){//a~bのcの倍数の個数を出す
    ll ans=x;
    ans -= x/c;
    ans -= x/d;
    ans += x/lcm(c,d);
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll res=f(b,c,d)-f(a-1,c,d);
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 998244353
using namespace std;
const int maxn=2e5+10;
ll dp[maxn];
ll sum[maxn];
ll x[15];
ll y[15];
int main() {
	int n,k;
	cin>>n>>k;
	int pos=0;
	for(int i=0;i<k;i++) {
		cin>>x[i]>>y[i];
	}
	//cout<<m<<endl;
	//for(int i=0;i<k*2;i++) cout<<a[i]<<" ";
	//cout<<endl;
	memset(dp,0,sizeof(dp));
	dp[1]=1;
	dp[0]=0;
	sum[1]=1;
	sum[0]=0;
	for(int i=2;i<=n;i++) {
		for(int j=0;j<k;j++) {
			if(y[j]<i) {
				dp[i]=(dp[i]+sum[i-x[j]]-sum[i-y[j]-1])%mod;
			}else if(x[j]<i){
				dp[i]=(dp[i]+sum[i-x[j]]-sum[0])%mod;
			}
		}
		sum[i]=sum[i-1]+dp[i];
		//cout<<dp[i]<<endl;
	}
	cout<<dp[n]<<endl;
}

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

static class PhysicalExperiments
{
    static void Main()
    {
        RepeatInfinite<Func<string>>( Console.ReadLine )
            .Select( x => x() )
            .TakeWhile( x => x != null )
            .Select( double.Parse )
            .Select( v => v / 9.8 )
            .Select( t => 4.9 * t * t )
            .Select( y => ( y + 5 ) / 5.0 )
            .Select( Math.Ceiling )
            .ToList()
            .ForEach( Console.WriteLine );
    }

    static IEnumerable<TSource> RepeatInfinite<TSource>(TSource source)
    {
        while ( true )
            yield return source;
    }
}

Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;

long long a, b, x, c, ans = 0;

int main() {
  cin >> a >> b >> x;
  // (x-a) + (a-b)
  if(x < a)
    ans = x;
  else {
    c = max(0LL, (x - a) / (a - b) + 1);
    ans += (c % N) * (b % N) % N + x % N;
    ans %= N;
  }
  cout << ans % N << endl;
  return 0;
}


Measured memory_bytes: 3076
A, B, C, D = [c for c in input()]
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = A+op1+B+op2+C+op3+D
            if eval(s) == 7:
                print(s+"=7")
                break
        else:
            continue
        break
    else:
        continue
    break


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long get_root(long node, const vector<long> &union_find_vec) {
  if (union_find_vec[node] == -1) return node;
  return get_root(union_find_vec[node], union_find_vec);
}

int main(void) {
  long N;
  cin >> N;
  unordered_map<long, pair<long, long>> points;
  rep (i, N) {
    long x, y;
    cin >> x >> y;
    points[i] = make_pair(x, y);
  }
  vector<pair<long, long>> xs, ys;
  for (auto it: points) {
    xs.push_back(make_pair(it.second.first, it.first));
    ys.push_back(make_pair(it.second.second, it.first));
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());
  vector<pair<long, pair<long, long>>> edges;
  rep (i, N-1) {
    edges.push_back(make_pair(xs[i+1].first - xs[i].first, make_pair(xs[i].second, xs[i+1].second)));
    edges.push_back(make_pair(ys[i+1].first - ys[i].first, make_pair(ys[i].second, ys[i+1].second)));
  }
  sort(edges.begin(), edges.end());

  long result = 0;

  vector<long> union_find_vec(N, -1);
  for (auto it: edges) {
    long a = it.second.first;
    long b = it.second.second;
    long a_root = get_root(a, union_find_vec);
    long b_root = get_root(b, union_find_vec);
    if (a_root == b_root) continue;
    result += it.first;
    union_find_vec[b] = a_root;
    union_find_vec[b_root] = a_root;
  }

  cout << result << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

int factorial(int n) {
    if(n <= 1) return 1;
    else return n * factorial(n - 1);
}

int main() {
    int N;
    cin >> N;
    auto p = vector<pair<int, int>> (N);
    for(auto &x: p) cin >> x.first >> x.second;
    vector<int> A(N);
    for(int i = 0; i < N; i++) A[i] = i;
    long double res = 0;
    do {
        for(int i = 1; i < N; i++) {
            res += sqrt(pow(p[A[i]].first - p[A[i - 1]].first, 2) + pow(p[A[i]].second - p[A[i - 1]].second, 2));
        }
    } while(next_permutation(A.begin(), A.end()));
    cout << setprecision(10) << res / factorial(N) << endl;
}

Measured memory_bytes: 256
k = int(input())
s = input()

n = len(s)
mod = 10**9+7


def framod(n, mod, a=1):
    for i in range(1, n+1):
        a = a * i % mod
    return a


def power(n, r, mod):
    if r == 0:
        return 1
    if r % 2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r % 2 == 1:
        return n * power(n, r-1, mod) % mod


def comb(n, k, mod):
    a = framod(n, mod)
    b = framod(k, mod)
    c = framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


com = [1]*(k+1)
for i in range(k):
    com[i+1] = com[i]*(n+i)*pow(i+1, mod-2, mod) % mod

a25 = [1]*(k+1)
for i in range(k):
    a25[i+1] = a25[i]*25 % mod
a26 = [1]*(k+1)
for i in range(k):
    a26[i+1] = a26[i]*26 % mod
num = 0
for i in range(0, k+1):
    num = (num+com[i]*a25[i] % mod * a26[k-i]) % mod
print(num)


Measured memory_bytes: 193676
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    char x, y;
    scan(x, y);
    if (x > y)
        print(">");
    else if (x == y)
        print("=");
    else
        print("<");

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    S = "00" + S;
    int n = S.length();
    int ans = 0;
    RREP(i, n - 1, 1) {
        if (S[i] > '9') {
            S[i - 1]++;
            S[i] -= 10;
        }
        if (S[i] <= '4') ans += S[i] - '0';
        else if(S[i] >= '6') {
            ans += '9' - S[i] + 1;
            S[i - 1]++;
        }else {
            if (S[i - 1] >= '5') {
                ans += 5;
                S[i - 1]++;
            } else {
                ans += 5;
            }
        }
        //cout << S << endl;
    }
    cout << ans << endl;

    return 0;
}
//     pay  receive
// 065 000  005
//     100  035   

//     pay  receive
// 055 060  005

//     pay receive
// 099 100 001 

Measured memory_bytes: 2332
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=r;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=r;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long n,m,res=1,i;
    scanf("%lld%lld",&n,&m);
    if(max(n,m)-min(n,m) >= 2){printf("0\n");return 0;}
    else if(max(n,m)-min(n,m) == 1){
        for(i=1;i<=n;i++){res*=i;res%=mod;}
        for(i=1;i<=m;i++){res*=i;res%=mod;}
    }
    else{
        res*=2;
        for(i=1;i<=n;i++){res*=i;res%=mod;}
        for(i=1;i<=m;i++){res*=i;res%=mod;}
    }
    printf("%lld\n",res%mod);
    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

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

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long X;
    std::cin >> X;
    long long Y;
    std::cin >> Y;

    ll ans = 0;
    while (X <= Y) {
        ans++;
        X *= 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int d = scanner.nextInt(), x = scanner.nextInt();
			int[] a = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());
			System.out.println(x + IntStream.range(0, n).map(i -> (d - 1) / a[i] + 1).sum());
		}
	}
}


Measured memory_bytes: 28628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N + 1];
		long[] B = new long[N];
		for(int i = 0; i < N + 1; i++) {
			A[i] = sc.nextLong();
		}
		for(int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		sc.close();
		long ans = 0L;
		for(int i = 0; i < N; i++) {
			// 勇者B[i]がモンスターA[i]を倒せる数
			long hit = Math.min(A[i], B[i]);
			// モンスターA[i]の残数
			A[i] -= hit;
			// 勇者B[i]の残機
			B[i] -= hit;
			// 倒した合計の加算
			ans += hit;
			// 勇者B[i]がモンスターA[i + 1]を倒せる数
			hit = Math.min(A[i + 1], B[i]);
			// モンスターA[i + 1]の残数
			A[i + 1] -= hit;
			// 勇者B[i]の残機
			B[i] -= hit;
			// 倒した合計の加算
			ans += hit;
		}
		System.out.println(ans);
	}
}


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

int main(){
	int n;
	cin>>n;
	int data[4][3][10];
	memset(data,0,sizeof(data));
	int b,f,r,v;
	for(int i=0;i<n;i++){
		cin>>b;
		cin>>f;
		cin>>r;
		cin>>v;
		data[b-1][f-1][r-1]+=v;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout<<" "<<data[i][j][k];
			}
			cout<<endl;
		}
		if(i<3) cout<<"####################"<<endl;
	}
	return 0;
}

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

int main(){
  int N,K,count=0,c=0;
  cin>>N>>K;
  vector<int> d(K);
  vector<vector<int>> A(K,vector<int>(N));
  for(int i=0;i<K;i++){
    cin>>d.at(i);
    for(int j=0;j<d.at(i);j++){
      cin>>A.at(i).at(j);
    }
  }
  
  for(int i=1;i<=N;i++){
    for(int j=0;j<K;j++){
      for(int l=0;l<N;l++){
        if(i==A.at(j).at(l)){
          c=1;
          break;
        }
      }
      if(c==1)
        break;
    }
    if(c==0)
      count++;
    c=0;
  }
  cout << count<<endl;
}


Measured memory_bytes: 3604
#include <stdio.h>
int n, a, b;
int main(){
    scanf("%d", &n);
    a=n/100;
    b=n%100;
    if((1<=a)&&(a<=12)&&(1<=b)&&(b<=12))
        printf("AMBIGUOUS");
    else if((1<=a)&&(a<=12))
        printf("MMYY");
    else if((1<=b)&&(b<=12))
        printf("YYMM");
    else
        printf("NA");
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    int a, b;

    scanf("%d %d", &a, &b);

    int d, r;
    double f;

    d = a / b;
    r = a % b;
    f = (double)a / b;

    printf("%d %d %f\n", d, r, f);

    return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
         
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
       
		signed main()
		{
			int n,k;
			cin>>n>>k;
			int a[k];
			loop(i,k)
			cin>>a[i];
			int d=0;
			loop(i,k-1)
			{
			    d=max(d,a[i+1]-a[i]);
			}
			d=max(d,n-a[k-1]+a[0]);
			cout<<n-d;
		}

Measured memory_bytes: 1792
import sys
from collections import defaultdict
range = xrange
input = raw_input

inp = sys.stdin.read().split(); ii = 0

mapper = {'U':0, 'D':1, 'R':2, 'L':3}

n = int(inp[ii]); ii += 1
X = []
Y = []
D = []
for _ in range(n):
    x = int(inp[ii]); ii += 1
    y = int(inp[ii]); ii += 1
    d = mapper[inp[ii]]; ii += 1
    
    X.append(x)
    Y.append(y)
    D.append(d)

listdict = lambda: defaultdict(list)

Y0 = listdict()
Y1 = listdict() 
X2 = listdict() 
X3 = listdict() 

pos0 = listdict() 
pos1 = listdict() 
pos2 = listdict() 
pos3 = listdict() 

neg0 = listdict()
neg1 = listdict() 
neg2 = listdict()
neg3 = listdict()

Xset = set()
Yset = set()
posset = set()
negset = set()

for i in range(n):
    d = D[i]
    x = X[i]
    y = Y[i]

    pos = x+y
    neg = x-y

    Xset.add(x)
    Yset.add(y)
    posset.add(pos)
    negset.add(neg)

    if d == 0:
        Y0[x].append(y)
        pos0[pos].append(2 * x)
        neg0[neg].append(2 * x)
    elif d == 1:
        Y1[x].append(y)
        pos1[pos].append(2 * x)
        neg1[neg].append(2 * x)
    elif d == 2:
        X2[y].append(x)
        pos2[pos].append(2 * x)
        neg2[neg].append(2 * x)
    elif d == 3:
        X3[y].append(x)
        pos3[pos].append(2 * x)
        neg3[neg].append(2 * x)
    else:
        assert False

def sorter(A):
    for a in A.values():
        a.sort()

sorter(Y0)
sorter(Y1)
sorter(X2)
sorter(X3)

sorter(pos0)
sorter(pos1)
sorter(pos2)
sorter(pos3)

sorter(neg0)
sorter(neg1)
sorter(neg2)
sorter(neg3)

best = -1
def check(A0, A1):
    # searching for A0[i] < A1[j]
    global best
    i = 0
    n = len(A1)
    for a in A0:
        while i < n and a >= A1[i]:
            i += 1
        if i == n:
            break
        score = (A1[i] - a) * 5
        if best == -1 or best > score:
            best = score


#Y0 
#Y1  
#X2  
#X3  
#
#pos0  
#pos1  
#pos2  
#pos3  
#
#neg0 
#neg1  
#neg2 
#neg3 

for x in Xset:
    check(Y0[x], Y1[x])
for y in Yset:
    check(X2[y], X3[y])

for neg in negset:
    check(neg2[neg], neg1[neg])
    check(neg0[neg], neg3[neg])

for pos in posset:
    check(pos2[pos], pos0[pos])
    check(pos1[pos], pos3[pos])

print 'SAFE' if best == -1 else best


Measured memory_bytes: 340016
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000000

int main(){
	
	int q = 0;
	int N;
	cin>>N;
	
	vector<string> s;
	rep(i,N){
		string S;
		cin>>S;
		s.push_back(S);
	}
	
	string e;
	cin>>e;
	
	int l = 1;int r = 1;
	rep(i,N){
		string t = s[i];
		rep(j,t.size()){
			if(t[j]=='?')t[j] = 'a';
		}
		if(t<=e)r++;
	}
	
	rep(i,N){
		string t = s[i];
		rep(j,t.size()){
			if(t[j]=='?')t[j] = 'z';
		}
		if(t<e)l++;
	}
	
	for(int i=l;i<=r;i++){
		if(i!=l)cout<<' ';
		cout<<i;
	}
	cout<<endl;
	
    return 0;
}



Measured memory_bytes: 3932
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
typedef long long lint;
const int N=2e5+5;
const int mod=1e9+7;
int n,lim1,lim2,npos1,npos2,col[N],wgt[N],lpos[N];
int fac[N],ifac[N];
std::vector <int> list[N];

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

template <class T> inline int fpow(int x,T t){
	int ans=1;
	for(; t; x=(lint)x*x%mod,t>>=1){
		if(t&1) ans=(lint)ans*x%mod;
	}
	return ans;
}

inline void init(){
	fac[0]=1;
	for(int i=1; i<=n; ++i){
		fac[i]=(lint)fac[i-1]*i%mod;
	}
	ifac[n]=fpow(fac[n],mod-2);
	for(int i=n; i; --i){
		ifac[i-1]=(lint)ifac[i]*i%mod;
	}
}

namespace U{
	int fa[N];
	int find_rt(const int x){
		return fa[x]?fa[x]=find_rt(fa[x]):x;
	}
	inline void link(int x,int y){
		x=find_rt(x),y=find_rt(y);
		if(x!=y) fa[x]=y;
	}
}

int solve(const int x){
	static int buk[N];
	int res=fac[list[x].size()];
	for(std::vector <int> ::iterator it=list[x].begin(); it!=list[x].end(); ++it){
		++buk[col[*it]];
	}
	for(std::vector <int> ::iterator it=list[x].begin(); it!=list[x].end(); ++it){
		if(!buk[col[*it]]) continue;
		res=(lint)res*ifac[buk[col[*it]]]%mod;
		buk[col[*it]]=0;
	}
	return res;
}

int main(){
	n=nxi(),lim1=nxi(),lim2=nxi();
	init();
	wgt[0]=mod;
	for(int i=1; i<=n; ++i){
		col[i]=nxi(),wgt[i]=nxi();
		if(!lpos[col[i]]||wgt[lpos[col[i]]]>wgt[i]){
			lpos[col[i]]=i;
		}
	}
	for(int i=1; i<=n; ++i){
		if(i!=lpos[col[i]]&&wgt[i]+wgt[lpos[col[i]]]<=lim1){
			U::link(i,lpos[col[i]]);
		}
	}
	for(int i=1; i<=n; ++i){
		if(!lpos[i]) continue;
		int tmp=lpos[i];
		if(wgt[npos1]>wgt[tmp]) std::swap(npos1,tmp);
		if(wgt[npos2]>wgt[tmp]) std::swap(npos2,tmp);
	}
	assert(npos1);
	for(int i=1; i<=n; ++i){
		if(npos1&&col[i]!=col[npos1]&&wgt[i]+wgt[npos1]<=lim2){
			U::link(i,npos1);
		}
		if(npos2&&col[i]!=col[npos2]&&wgt[i]+wgt[npos2]<=lim2){
			U::link(i,npos2);
		}
	}
	for(int i=1; i<=n; ++i){
		list[U::find_rt(i)].push_back(i);
	}
	int ans=1;
	for(int i=1; i<=n; ++i){
		if(U::find_rt(i)==i){
			ans=(lint)ans*solve(i)%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define LINE_BUFSIZ 128

int main(int argc, char **argv)
{
  char buf[LINE_BUFSIZ], *t;
  int a, b;

  if (!fgets(buf, LINE_BUFSIZ, stdin)) {
    perror("fgets");
    exit(1);
  }

  t = strchr(buf, ' ');

  if (!t) {
    perror("strchr");
    exit(1);
  }

  *t++ = 0;

  a = atoi(buf); b = atoi(t);

  if (a <= 8 && b <= 8)
    printf("Yay!\n");
  else
    printf(":(\n");

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>

class Node {
    public:
        int value;
        Node* left;
        Node* right;
        Node* parent;
        Node(int);
        void join_left(Node* node);
        void join_right(Node* node);
};

Node::Node(int num)
{
    this->value = num;
    this->left = nullptr;
    this->right = nullptr;
    this->parent = nullptr;
}

void Node::join_left(Node* node)
{
    this->left = node;
    node->parent = this;
}

void Node::join_right(Node* node)
{
    this->right = node;
    node->parent = this;
}

void add_node(Node* root, Node* new_node)
{
    Node* current_node = root;
    Node* prev_node = nullptr;
    while(current_node != nullptr) {
        prev_node = current_node;
        if(current_node->value < new_node->value) {
            current_node = current_node->right;
        } else {
            current_node = current_node->left;
        }
    }
    if(prev_node->value < new_node->value) {
        prev_node->join_right(new_node);
    } else {
        prev_node->join_left(new_node);
    }
}

bool find_node(int target_value, Node* node)
{
    if(node == nullptr) {
        return false;
    }
    if(node->value == target_value) {
        return true;
    } else if(target_value < node->value) {
        return find_node(target_value, node->left);
    } else {
        return find_node(target_value, node->right);
    }
}

void print_preorder(std::list<Node>& data, Node* node)
{
    if(node == nullptr) {
        return;
    }
    printf(" %d", node->value);
    print_preorder(data, node->left);
    print_preorder(data, node->right);
}

void print_inorder(std::list<Node>& data, Node* node)
{
    if(node == nullptr) {
        return;
    }
    print_inorder(data, node->left);
    printf(" %d", node->value);
    print_inorder(data, node->right);
}

int main()
{
    char buffer[32];
    int size_of_input;
    scanf("%d", &size_of_input);
    std::list<Node> data;
    for(int i = 0; i < size_of_input; i++) {
        scanf("%32s", buffer);
        if(strcmp(buffer, "insert") == 0) {
            int value;
            scanf("%d", &value);
            if(data.empty()) {
                data.push_back(Node(value));
                continue;
            }
            data.push_back(Node(value));
            add_node(&data.front(), &data.back());
        } else if(strcmp(buffer, "print") == 0) {
            print_inorder(data, &data.front());
            putchar('\n');
            print_preorder(data, &data.front());
            putchar('\n');
        } else if(strcmp(buffer, "find") == 0) {
            int value;
            scanf("%d", &value);
            if(find_node(value, &data.front())) {
                puts("yes");
            } else {
                puts("no");
            }
        } else {
            fputs("Invalid command.\n", stderr);
            exit(EXIT_FAILURE);
        }
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 27828
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	
	cin >> s;

	cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14) << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>

using namespace std;

int main(){
    int n;
    unordered_map<int,int> mp;
    cin >> n;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        mp[num] += 1;
    }
    int distinct = 0;
    int even = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        distinct++;
        if(itr->second % 2 == 0){
            even++;
        }
    }
    if(even % 2 == 1) cout << distinct - 1 << endl;
    else cout << distinct << endl;
    return 0;
}

Measured memory_bytes: 4388
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize,
        x: usize,
    }
    if 500 * k >= x {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
  int a=0;
  scanf("%d\n",&a);
  char * array=(char *)malloc(a);
  array[a]='\0';
  int ret=0;
  for(int i=0;i<a;i++)
	  array[i]=getchar();
  char ch='\0';
  for(int i=0;i<a;i++){
	  if(ch!=array[i]){
		  ret++;
	  }
	  ch=array[i];
  }
  printf("%d",ret);
  return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
g1 = {1, 3, 5, 7, 8, 10, 12}
g2 = {4, 6, 9, 11}
g3 = {2}
if x in g1 and y in g1:
    print('Yes')
elif x in g2 and y in g2:
    print('Yes')
elif x in g3 and y in g3:
    print('Yes')
else:
    print('No')

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    for(int i=111;;i+=111)if(i>=N){
        cout<<i<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string.h> //for strlen
#include <cmath>
using namespace std;
int m[1000000];
int N, A, B;

/*int find_max_monster(int N, int B){
	int max = 0;
	int index = 0;
	for(int i = 0; i < N; i++){
		if(m[i] > max) {
			max = m[i];
			index = i;
		}
		m[i] -= B;
	}
	if(max <= 0) return -1;

	return index;
}

void bomb(int N, int ex, int A, int B){
	for(int i = 0; i < N; i++){
		if(i == ex) m[i] -= A;
		else m[i] -= B;
	}

}
*/

int check(long long k){
	long long c = 0;
	for(int i = 0; i < N; i++){
		if(k * B >= m[i]) continue;
		long long tmp = m[i] - k*B;
		c += (tmp-1)/(A - B) + 1;
		if(c > k) return 0;
	}
	return 1;
}




int main (){
	
	cin >> N >> A >> B;

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

	long long count = 0;
	int l = 1;
	int r = 1000000000;
	while(l<=r){
		int mid = (l+r) >> 1;
		if(check(mid)) count = mid, r = mid - 1;	
		else l = mid + 1;
		//bomb(N, t, A, B);
		/*for ( int i = 0; i < N; i++){
			cout << m[i] << " ";

		}*/
		//cout << endl;
		
	}

	cout << count << endl; 
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<memory.h>
#include<map>
#include<vector>
#define PRE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
const int Mod = 1e9 + 7;
int lst[Max];
const int max_n = 1e4 + 100;
struct oper {
	int i, j, x;
};
struct nde {
	int val, id;
	bool operator<(nde& n2) {
		if (val % id == 0)return true;
		if (n2.val % n2.id == 0)return true;
		int t1 = id - val % id;
		int t2 = n2.id - n2.val % n2.id;
		if (t1 != t2)return t1 < t2;
		return val > n2.val;
	}
}a[max_n];
int n;
int main() {
	PRE;
	int n;
	cin >> n;
	map<int, int> ma;
	for (int i = 1;i <= n;i++)
	{
		cin >> lst[i];
		ma[lst[i]]++;
	}
	ll res = 0;
	for (auto i = ma.begin();i != ma.end();i++)
	{
		if (i->second == i->first) continue;
		if (i->second < i->first) res += i->second;
		else
		{
			res += (i->second - i->first);
		}
	}
	cout << res;


}



Measured memory_bytes: 7880
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    rep(i, ty - sy) {
        cout << "U";
    }
    rep(i, tx - sx) {
        cout << "R";
    }
    rep(i, ty - sy) {
        cout << "D";
    }
    rep(i, tx - sx) {
        cout << "L";
    }
    cout << "L";
    rep(i, ty - sy + 1) {
        cout << "U";
    }
    rep(i, tx - sx + 1) {
        cout << "R";
    }
    cout << "D";
    cout << "R";
    rep(i, ty - sy + 1) {
        cout << "D";
    }
    rep(i, tx - sx + 1) {
        cout << "L";
    }
    cout << "U" << endl;


    return 0;
}

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>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

char oth(char a, char b) {
    if ((a == 'R' && b == 'G') || (a == 'G' && b == 'R')) return 'B';
    if ((a == 'B' && b == 'G') || (a == 'G' && b == 'B')) return 'R';
    return 'G';
}

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

    vector<int> r, g, b;
    for (int i=0; i<N; ++i) {
        if (s[i] == 'R') r.push_back(i);
        else if (s[i] == 'G') g.push_back(i);
        else if (s[i] == 'B') b.push_back(i);
    }

    ll res = 0;
    for (int i=0; i<N; ++i) {
        for (int j=i+1; j<N; ++j) {
            if (s[i] == s[j]) continue;
            if (oth(s[i], s[j]) == 'R') {
                res += r.end() - upper_bound(r.begin(), r.end(), j);
                if (j+j-i < N && s[j+j-i] == 'R') res --;
            } else if (oth(s[i], s[j]) == 'G') {
                res += g.end() - upper_bound(g.begin(), g.end(), j);
                if (j+j-i < N && s[j+j-i] == 'G') res --;
            } else {
                res += b.end() - upper_bound(b.begin(), b.end(), j);
                if (j+j-i < N && s[j+j-i] == 'B') res --;
            }
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>

#define L 1002
#define LINE_LENGTH L*3

void print(const char *str, int a, int b);
void reverse(char *str, int a, int b);
void replace(char *str, int a, int b, char *p);

int main(){
	
	char str[L], backup[L];
	char *p;
	int q;
	char line[LINE_LENGTH];
	char *order;
	int i;
	char *token;
	char *replaceToken;
	int a, b;
	
	fgets(str, sizeof(str), stdin);
	str[strlen(str) - 1] = '\0';
	strcpy(backup, str);
	
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d", &q);
	
	for(i = 0; i < q; i++){
		a = 0;
		b = 0;
		p[0] = '\0';
		
		fgets(line, sizeof(line), stdin);
		line[strlen(line) - 1] = '\0';
		
		token = strtok(line, " ");
		order = token;
		
		
		token = strtok(NULL, " ");
		
		if(strcmp(order, "print") == 0){
			sscanf(token, "%d", &a);
			token = strtok(NULL, " ");
			sscanf(token, "%d", &b);
			print(backup, a, b);
		}
		else if(strcmp(order, "reverse") == 0){
			sscanf(token, "%d", &a);
			token = strtok(NULL, " ");
			sscanf(token, "%d", &b);
			reverse(backup, a, b);
		}
		else if(strcmp(order, "replace") == 0){
			sscanf(token, "%d", &a);
			token = strtok(NULL, " ");
			sscanf(token, "%d", &b);
			token = strtok(NULL, " ");
			p = token;
			replace(backup, a, b, p);
		}
		
//		printf("order = %s\n", order);
//		printf("a = %d\n", a);
//		printf("b = %d\n", b);
//		if(strlen(p) > 0){
//			printf("p = %s\n", p);
//		}
		
	}
	
	return 0;
}


void print(const char *str, int a, int b){
	
	int i;
	for(i = a; i <= b; i++){
		printf("%c", str[i]);
	}
	puts("");
}

void reverse(char *str, int a, int b){
	
	char head[L] = "";
	char tail[L] = "";
	char tempS[L] = "";
	char tempC;
	int i;
	int len;
	strncpy(head, str, a);
	strncpy(tempS, str + a, b - a + 1);
	strcpy(tail, str + b + 1);
	tempS[b+1] = '\0';
	len = strlen(tempS);
	
	for(i = 0; i < len / 2; i++){
		tempC = tempS[i];
		tempS[i] = tempS[len - 1 - i];
		tempS[len - 1 - i] = tempC;
	}
	
	str[0] = '\0';
	strcpy(str, head);
	strcat(str, tempS);
	strcat(str, tail);
	
//	printf("Reverse:%s\n", str);
}

void replace(char *str, int a, int b, char *p){
	
	char head[L] = "";
	char tail[L] = "";
	char target[L];
	int len = strlen(str);
	
	strncpy(head, str, a);	head[a] = '\0';
	strncpy(target, str + a, b - a + 1);	target[b - a + 1] = '\0';
	strcpy(tail, str + b + 1);
	
	str[0] = '\0';
	strcpy(str, head);
	strcat(str, p);
	strcat(str, tail);
	
//	printf("head: %s\n", head);
//	printf("target: %s, length = %d\n", target, strlen(target));
//	printf("tail: %s\n", tail);
//	printf("Replace:%s\n", str);
	
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
  vector<double> x(n);
  vector<string> u(n);
  double otoshidama; double BTC;
  for(int i = 0;i < n;i++){
	cin >> x.at(i) >> u.at(i);
  }
  for(int i = 0;i < n;i++){
      if(u.at(i) == "JPY"){
        otoshidama = x.at(i) + otoshidama;
      }else if(u.at(i) == "BTC"){
        BTC = x.at(i) + BTC;
      }
  }

  otoshidama = otoshidama + BTC * 380000;
  cout << fixed << setprecision(9) << otoshidama << endl;

     return 0;
}

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

int main(){
	int c[6] = {500, 100, 50, 10, 5, 1};
	int x;
	while( cin >> x , x ){
		x = 1000 - x;
		int ans = 0;
		while( x ){
			for(int i=0 ; i < 6 ; i++ ){
				if( x >= c[i] ){
					x -= c[i];
					ans++;
					break;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
char s[4005];
int a[4005],b[4005],c[4005];
int main()
{
	int n,count=0;
	sc(n);
	getchar();scs(s+1);
	ll cou=0;
	dep(i,n,1){
		a[i]=a[i+1];
		b[i]=b[i+1];
		c[i]=c[i+1];
		if(s[i]=='R')a[i]++;
		if(s[i]=='G')b[i]++;
		if(s[i]=='B')c[i]++;
	}
	rep(i,1,n-2){
		rep(j,i+1,n-1){
			int u=s[i]+s[j],v='R'+'G'+'B';
			if(v-u=='R')cou+=a[j+1];
			if(v-u=='G')cou+=b[j+1];
			if(v-u=='B')cou+=c[j+1];
		}
	}
	for(int i=1;i<=n/2;i++){
		for(int j=1;j+2*i<=n;j++){
			if(s[j]!=s[j+i]&&s[j+i]!=s[j+2*i]&&s[j]!=s[j+2*i])cou--;
		}
	}pf("%lld\n",cou);
}


Measured memory_bytes: 3824