akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
typedef unsigned long long ll;
typedef long double lb;
using namespace std;
//for (int i=0;i<n;i++){
//
//}

//vector <int> v1;vector <int> v2;vector <ll> v3;vector <int> v4;

void solve(){

}

int main(){ios_base::sync_with_stdio(false);cin.tie(NULL);
    lb d,t,s,ans;
    cin>>d>>t>>s;
    t=t*60;
    ans=60*d/s;
    if(ans>t) cout<<"No";
    else cout<<"Yes";

return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	
	ll ans = 1000;
	REP(i, N - 1) if (A[i] < A[i + 1]) ans = ans / A[i] * A[i + 1] + ans % A[i];
	cout << ans << endl;
	return 0;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int H = input(), W = input();
    auto s = make_vector(H + 1, W + 1, '.');
    range(i, 1, H + 1) range(j, 1, W + 1) cin >> s[i][j];

    auto dist = make_vector(H + 1, W + 1, inf);
    dist[1][1] = s[1][1] == '#';
    range(i, 1, H + 1) range(j, 1, W + 1) {
        if (s[i][j] == '#') {
            chmin(dist[i][j], dist[i - 1][j] + (s[i - 1][j] == '.'));
            chmin(dist[i][j], dist[i][j - 1] + (s[i][j - 1] == '.'));
        } else {
            chmin(dist[i][j], min(dist[i - 1][j], dist[i][j - 1]));
        }
    }
    
    cout << dist[H][W] << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 384
input = readlines()

target = input.shift().chomp.to_i
list = input.shift().chomp.split("\s").map{|x| x.to_i}

found = false
(list[0]..list[1]).each do |n|
  found = true if n % target == 0
  break if found
end

puts found == true ? 'OK' : 'NG'

Measured memory_bytes: 14388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
ll mod1=1000000007ll;
ll mod2=998244353ll;

bool vis[200002];
ll ma[200002],bit[200005],rank1[200005],parent[200005];
ll c=0,x=0,n,an=0;
ll gcd(ll a, ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
ll power(ll x,ll y)
{   if(y==0) return 1;
    ll p=power(x,y/2);
    p=(p*p)%mod2;
    if(y%2) return  (p*x)%mod2;
    return p;
}
ll sum(ll in)
{   in++;
    ll sum1=0;
    while(in>0)
    {
        sum1+=bit[in];
        in-=in & (-in);
    }
    return sum1;
}
void update(ll in,ll val)
{   in++;
    while(in<=200002)
    {
        bit[in]+=val;
        in+=in & (-in);
    }
}
 struct vec {
    vector<ll> v;
    bool operator<( const  vec& a) const
    { return a.v[0] < v[0]; }
  };

ll find(ll x)
{
    if(x==parent[x])
    return x;
    else
    return find(parent[x]);
}
void merged(ll x, ll y)
{
    x=find(x);
    y=find(y);
    if(rank1[x]>rank1[y])
    {
        parent[y]=x;
        rank1[x]+=rank1[y];
    }
    else
    {
        parent[x]=y;
        rank1[y]+=rank1[x];
    }

}
void solve()
{
   ll n,m=0,ans=0;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++)
     cin>>a[i];
     for(ll i=1;i<n;i++)
     { //cout<<a[i]<<a[i-1]<<endl;
       if(a[i]<=a[i-1])
            ans++;
       else
       { // cout<<"i="<<i<<endl;
           if(ans>m)
            m=ans;
           ans=0;
       }
      // cout<<ans<<endl;
       //cout<<m<<endl;
     }
      if(ans>m)
            m=ans;
   cout<<m;
}

int main()
{
 /*ios::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);*/
 int t=1;
 //cin>>t;
 while(t--)
    solve();
 return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
using namespace std;
typedef pair<int, int> pii;

const int MAXN = 2055;

struct BIT {
	int d[MAXN];
	void upd(int x, int r) {
		for(x += 5; x < MAXN; x += rb(x))
			d[x] += r;
	}
	int get(int x) {
		int r = 0; for(x += 5; x; x -= rb(x))
			r += d[x];
		return r;
	}
	int get(int s, int e) { return s <= e ? get(e) - get(s-1) : 0; }
} bit;

set<pii> PQ;

int A[MAXN], O[MAXN];

int N, K, Q, Ans = INF, Sum;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> K >> Q;
	for(int i = 1; i <= N; i++) cin >> A[i];
	iota(O, O+N+1, 0); sort(O+1, O+N+1, [&](int a, int b) {
		return A[a] < A[b];
	});

	PQ.insert(pii(1, N));
	for(int s = 1, e = 1; s <= N; s++) {
		for(; Sum < Q && e <= N; e++) {
			int i = O[e];
			auto it = prev(PQ.lower_bound(pii(i, INF)));
			int p, q; tie(p, q) = *it;

			Sum -= max(0, min(bit.get(p, q), q-p+2-K));
			bit.upd(i, 1);
			Sum += max(0, min(bit.get(p, q), q-p+2-K));
		}
		if(Sum < Q) break;
		int t = A[O[e-1]] - A[O[s]];
		if(t < Ans) Ans = t;

		int i = O[s];
		auto it = prev(PQ.lower_bound(pii(i, INF)));
		int p, q; tie(p, q) = *it;
		PQ.erase(it);

		Sum -= max(0, min(bit.get(p, q), q-p+2-K));
		bit.upd(i, -1);

		if(p < i) {
			PQ.insert(pii(p, i-1));
			Sum += max(0, min(bit.get(p, i-1), i-p+1-K));
		}
		if(i < q) {
			PQ.insert(pii(i+1, q));
			Sum += max(0, min(bit.get(i+1, q), q-i+1-K));
		}
	}

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N , M ;
	cin >> N >> M ;
	vector<int> vec(N+1,0);
	for (int i = 0 ; i < M ; i++){ 
		//M本の道路なのでM回サーチさせないとね。
		//1が出てきたら要素の0番目に1を足す
		int a , b ;
		cin >> a >> b ;

	//if ( a == 1   if (a==2ってやるとしんどいので、これもちょっと趣向を凝らしてみよう
	//aとｂで出てきた値をｘ、ｙ として vec.at(x)に＋１という風にすれば楽かな
	//そんなことするまでもない 俺がコードを見せてやる
	vec.at(a) ++;//17、18行をa+1 ,b+1からえービーにした。
	vec.at(b) ++;
	}
	for (int i = 1 ; i < N+1 ; i++){// iを1からにして、N個出力させたいので N+1にした
		cout << vec.at(i) <<endl;
	}
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map { it.toInt() }
    val m = readLine()!!.toInt()
    val t = readLine()!!.split(" ").map { it.toInt() }

    val groupD = d.groupBy { it }.mapValues { it.value.size }
    val groupT = t.groupBy { it }.mapValues { it.value.size }

    val ans = groupT.all { it.value <= (groupD[it.key]?:0) }
    println(if(ans) "YES" else "NO")
}

Measured memory_bytes: 187384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100010;
char op[N],var[N];

vector<int> G[N];

int X,Y;
int dfs(int v, int p, int dep, int val){
    int ret = 0;
    if(dep%2==1) ret = N;

    int ch = 0;
    for(int e:G[v])if(e!=p){
        ++ch;
        int xy = 0;
        if(var[e]=='X') xy=X;
        else xy=Y;

        int nv = val;
        if(op[e]=='&') nv &= xy;
        else if(op[e]=='|') nv |= xy;
        else nv ^= xy;

        if(dep%2==1) ret = min(ret, dfs(e,v,dep+1,nv));
        else ret = max(ret, dfs(e,v,dep+1,nv));
    }

    // printf(" %d :: %d, %d\n", v, ret,val);
    if(ch==0) return val;
    else return ret;
}

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

    for(int i=1; i<n; ++i){
        string s;
        cin >>s;
        op[i] = s[3];
        var[i] = s[4];
    }

    rep(i,n-1){
        int u,v;
        cin >>u >>v;
        G[u].pb(v);
        G[v].pb(u);
    }

    vector<int> x(m),y(m),ans(m);
    map<vector<int>, vector<int>> q;
    rep(i,m){
        cin >>x[i] >>y[i];

        int ct[4]={};
        vector<int> vv;
        for(int j=15; j>=0; --j){
            int bx = x[i]>>j&1, by = y[i]>>j&1;
            int bb = bx*2+by;
            if(ct[bb]==0){
                vv.pb(bb);
                ++ct[bb];
            }
        }

        rep(j,4){
            if(ct[j]==0) vv.pb(j);
        }

        q[vv].pb(i);
    }

    vector<int> p(4);
    iota(all(p),0);

    do{
        X = 0;
        Y = 0;
        rep(i,4){
            if(p[i]>=2) X = 2*X + 1;
            else X = 2*X;
            if(p[i]%2==1) Y = 2*Y + 1;
            else Y = 2*Y;
        }

        int res = dfs(0,-1,0,0);

        int a[4]={};
        rep(i,4){
            int b = (res>>(3-i))&1;
            a[p[i]] = b;
        }

        for(int idx:q[p]){
            for(int j=15; j>=0; --j){
                int bx = x[idx]>>j&1, by = y[idx]>>j&1;
                int bb = bx*2+by;

                ans[idx] <<= 1;
                ans[idx] += a[bb];
            }
        }
    }while(next_permutation(all(p)));

    rep(i,m) cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 19936
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int h,w,n;
int main(){
    cin>>h>>w>>n;
    cout<<min((n+w-1)/w,(n+h-1)/h)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {	
	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int S = Integer.parseInt(str);
		int h = S / 3600;
		int m = (S % 3600) / 60;
		int s = S % 60;
		System.out.println(h + ":" + m + ":" + s);
	}
}

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

typedef long long ll;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0);
//#define cerr if(false)cerr
#define PRINT(x) cerr<<"\n" << (#x) << " is " << (x) << endl;
//Erase duplicates in vector
#define REMOVE_DUP(x) x.erase(unique(x.begin(), x.end()), x.end());
#define UP toupper // lowercase to uppercase;
#define DOWN tolower
#define SZ(a) (int)a.size()
#define EB emplace_back
#define PB push_back
#define REP(i, a, b) for(int i=a; i<b; i++)
#define PER(i, a, b) for(int i=a; i>=b; i--)
ostream_iterator<int> output(cout, " ");
#define MOD 1e9+7
#define INF INT_MAX;
#define lim_size 200007


void solve(){
	int n; cin >> n;
	vector<ll> v(n);
	unordered_map<ll, ll> m;
	for(int i=0; i<n; i++){
		cin >> v[i];
		m[v[i]]++;
	}
	ll ans = 0LL;
	for(auto x: m){
		ans += (x.second * (x.second - 1));
	}
	ans/=2;
	for(auto x: v){
		cout << ans - (m[x]*(m[x]-1))/2 + ((m[x]-1)*(m[x]-2))/2 << endl;
	}
}

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


Measured memory_bytes: 9160
abc_s = input()
abc_a = abc_s.split(" ")
abc = [int(x) for x in abc_a]
 
sorted = False
 
while sorted == False:
  sorted = True
  if abc[0] > abc[1]:
    sorted = False
    tmp = abc[0]
    abc[0] = abc[1]
    abc[1] = tmp
  if abc[1] > abc[2]:
    sorted = False
    tmp = abc[1]
    abc[1] = abc[2]
    abc[2] = tmp
 
print("{0[0]} {0[1]} {0[2]}".format(abc))


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;



int wa(int n) {

	int result = 0;

	while (n > 0) {
		result += n % 10;
		n /= 10;
	}

	return result;


}


int main()
{
    
	long long int x;
	cin >> x;

	long long int coin500 = 0, coin5 = 0;

	long long int ans = 0;

	coin500 = x / 500;
	x %= 500;

	coin5 = x / 5;

	ans = coin500 * 1000 + coin5 * 5;

	cout << ans << endl;


	return 0;

}




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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n;
    cin >> n;
    vector<int> s(n);
    int ans = 0;
    rep(i, n)
    {
        cin >> s[i];
        ans += s[i];
    }
    sort(All(s), greater<int>());
    rep(i, n)
    {
        if (ans % 10 != 0)
            break;
        else
        {
            if (s.back() % 10 != 0)
            {
                ans -= s.back();
                break;
            }
            s.pop_back();
        }
        if (s.empty())
            ans = 0;
    }
    c(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a1 = sc.nextInt()
    val a2 = sc.nextInt()
    val a3 = sc.nextInt()
    println(problem147a(a1, a2, a3))
}

fun problem147a(a1: Int, a2: Int, a3: Int): String {
    return if (a1 + a2 + a3 >= 22) {
        "bust"
    } else {
        "win"
    }
}

Measured memory_bytes: 31524
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    long d = sc.nextLong();
    if(d==0)System.out.println((double)(m-1)/n);
    else System.out.println((double)2*(m-1)*(n-d)/(n*n));
  }
}

Measured memory_bytes: 23636
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt() + sc.nextInt();
    int B = sc.nextInt() + sc.nextInt();
    if (A == B) {
      System.out.println("Balanced");
    } else if (A > B) {
      System.out.println("Left");
    } else {
      System.out.println("Right");
    }
  }
}


Measured memory_bytes: 23248
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

int n;
int M = 256;

ld entropy(const vector<int> &v)
{
    ld sum = 0;
    map<int, ld> mp;
    for (int i = 1; i <= n; i++)
    {
        mp[v[i]]++;
    }
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        sum -= itr->second / n * log(itr->second / n);
    }
    return sum;
}

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

    while (cin >> n, n)
    {
        vector<int> R(n + 1), I(n + 1), O(n + 1);
        for (int i = 1; i <= n; i++)
            cin >> I[i];
        int S, A, C;
        ld mi = INF;
        for (int s = 0; s <= 15; s++)
        {
            for (int a = 0; a <= 15; a++)
            {
                for (int c = 0; c <= 15; c++)
                {
                    R[0] = s;
                    for (int i = 1; i <= n; i++)
                    {
                        R[i] = (a * R[i - 1] + c) % M;
                        O[i] = (I[i] + R[i]) % M;
                    }
                    ld e = entropy(O);
                    if (e + EPS < mi){
                        mi = e;
                        S = s;
                        A = a;
                        C = c;
                    }
                }
            }
        }
        cout << S << " " << A << " " << C << endl;
    }
}



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

int main() {
  int N;
  cin >> N;
 
  int sum=0;
  for(int i = 0; i<N ;i++){
    int li,ri;
    cin>>li>>ri;
    sum+=ri-li+1;
    

  }
  cout<<sum<<endl;
  

  // ここにプログラムを追記
}


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

int main(){

  long long int a,b,k;
  cin >> a >> b >> k;
  if (k<=a) cout <<a-k<<" "<<b<<endl;
  else if (a+b>=k) cout << 0 << " "<<b-k+a<<endl;
  else cout<<0<< " " <<0<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int n,a[100002],b[100002];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	a[0]=2e8;
	b[0]=2e8;
	for(int i=2;i<=n;i++)
	{
		if(abs(a[i]-a[i-1])+b[i-1]>abs(a[i]-a[i-2])+b[i-2]) b[i]=abs(a[i]-a[i-2])+b[i-2];
		else b[i]=abs(a[i]-a[i-1])+b[i-1];
	}
	printf("%d",b[n]);
	return 0;
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;

    if(n % 2 != 0) {
        cout << 0 << endl;
        return 0;
    }

    while((n % 5 != 0) && n > 0) n -=2;

    ll ans = 0;
    ll d = 5;
    while(1) {
        ans += (n / d) / 2;
        d *= 5;
        if(d > n) break;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x,y,d,f,c1,c2;
	cin>>x>>y>>d>>f;
	c1=x*y;
	c2=d*f;
	if(c1>c2)
	   cout<<c1;
	else if(c1<c2)
	   cout<<c2;
	   else
	   cout<<c1;
	   	return 0;
}

Measured memory_bytes: 256
import sys

def decodes(x):
	temp = []
	for i in range(len(x)):
		if x[i][0] == 0:
			temp.append(x[i][1])
		elif x[i][0] == 1:
			print(temp[x[i][1]])
		elif x[i][0] == 2:
			temp = temp[:len(temp) - 1]

l = []
for i in sys.stdin:
	l.append(i.split())

for i in range(len(l)):
	for j in range(len(l[i])):
		l[i][j] = int(l[i][j])

decodes(l)


Measured memory_bytes: 59304
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
// a * x + b = a2 * x + b2
// x = (b2 - b) / (a - a2);
struct line {
	ll a, b;
	ll value(ll x) {
		return a * x + b;
	}
	ld intersect(const line& other) const {
		return (ld)(other.b - b) / (a - other.a);
	} 
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	ll C;
	cin >> n >> C;
	vector<ll> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	vector<ll> dp(n);
	vector<line> ch;
	dp[0] = 0;
	ch.push_back({-2 * h[0], 0 + h[0] * h[0]});
	for (int i = 1; i < n; ++i) {
		int l = 0, r = ch.size() - 1;
		while (l <= r) {
			int mid = l + (r - l) / 2;
			ld left_x = -inf64, right_x = inf64;
			if (mid + 1 < (int)ch.size()) {
				right_x = ch[mid].intersect(ch[mid + 1]);
			}
			if (mid - 1 >= 0) {
				left_x = ch[mid].intersect(ch[mid - 1]);
			}
			if (left_x <= h[i] && h[i] <= right_x) {
				dp[i] = ch[mid].value(h[i]) + h[i] * h[i] + C;
				break;
			}
			else if (h[i] < left_x) {
				r = mid - 1;
			}
			else {
				l = mid + 1;
			}
		}
		line my_line = {-2 * h[i], dp[i] + h[i] * h[i]};
		while ((int)ch.size() >= 2) {
			ld a = ch.back().intersect(ch.end()[-2]);
			ld b = ch.back().intersect(my_line);
			if (b > a) {
				break;
			}
			ch.pop_back();
		}
		ch.push_back(my_line);
	}
	cout << dp[n - 1] << '\n';
	return 0;
	
}


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  string S;
  cin >> S;
  if(S == "AAA" || S == "BBB"){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
	unsigned long long h, n, w, N;
	scanf("%llu", &N);
	for(unsigned long long i = 1; i <= 3500; i++){
		h = i;
		for(unsigned long long j = 1; j <= 3500; j++){
			n = j;
			if(4 * h * n - N * n - N * h > 0 && (N * h * n) % (4 * h * n - N * n - N * h) == 0){
				w = (N * h * n) / (4 * h * n - N * n - N * h);
				if(w <= 3500){
					printf("%llu %llu %llu\n", h, n, w);
					return 0;
				}
			}
		}
	}
}

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

int main(void)
{
  int x=0;
  int m=x;
  int n;
  char s[110];
  cin>>n>>s;
  for(int i=0; i<n; i++)
    {
      if(s[i]=='I')
	x++;
      else
	x--;
      m=max(x, m);	
    }
  cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 384
/* be name Khoda */
// VJUDGE
#include <bits/stdc++.h>
using namespace std;

const int N = 3010;
int n;
double dp[N][N], p[N];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i];
	dp[1][1] = p[1];
	dp[1][0] = 1 - p[1];
	for (int i = 2; i <= n; i++)
		dp[i][0] = (1 - p[i]) * dp[i - 1][0];
	for (int i = 2; i <= n; i++)
		for (int j = 1; j <= i; j++)
			dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
	double sum = 0;
	for (int i = n / 2 + 1; i <= n; i++)
		sum += dp[n][i];
 	cout<< setprecision(10) << sum;
 }

Measured memory_bytes: 69120
#include "bits/stdc++.h"

using namespace std;

int main() {
	int H1 , M1 ,M2 , H2 , K;
	cin >> H1>> M1 >> H2 >>M2 >> K;
	int min = (H2 * 60 + M2) - (H1 * 60 + M1) -K;
	cout << min  << endl;


	return 0;
}

Measured memory_bytes: 3536
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i=0;i<n;i++) {
			a[i]=sc.nextInt()-i;
		}
		
		Arrays.sort(a);
		int b =a[(n-1)/2];
		long ans = 0;
		for (int i=0;i<n;i++) {
			ans += (Math.abs(a[i]-b));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 66476
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	if(s.size()!=t.size())
	{
		cout<<0;
		return 0;
	 } 
	for(int i = s.size(); i >=0 ; i--)
	{
		string x=s.substr(i,s.size())+s.substr(0,i);
		if(x==t)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = (1 << 18) + 50;
const int maxw = 100000;
const int INF = LLONG_MAX/4;

int A[maxn];
int32_t main() {
	FAST
	for (int i =1;i<=5;i++) {
		cin >> A[i];
	}
	for (int i =1;i<=5;i++) {
		if (A[i] != i) {
			cout << i;
			return 0;
		}
	}
	
	
	
}









Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b) <= d && abs(b-c) <= d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int n;
    cin >> n;
    long long int a[n];
    unordered_map<long long int, long long int> umap;int maxx = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        umap[a[i]]++;
        if(a[i] > maxx)
        maxx = a[i];
    }
    long long int total = 0;long long int x = 0;
    for(int i = 1; i < maxx+1; i++)
    {
        if(umap[i] >= 2)
        {
            x = umap[i]*(umap[i]-1);
            x = x/2;
            total = total + x;
        }
    }
    //cout << total << endl;
    long long int ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans = 0;
        if(umap[a[i]] >= 2)
        {
            ans = total-(((umap[a[i]])*(umap[a[i]]-1))/2);
            ans = ans + (((umap[a[i]]-2)*(umap[a[i]]-1))/2);
            cout << ans << endl;
        }
        else
        cout << total << endl;
    }

}


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

//euler(n):n以下の自然数でnと互いに素の個数
int euler(int num){
	 int ret = num;
	 for(int i = 2; i*i <= num;  i++){
			if(num%i == 0) {
				  ret  = ret/i*(i-1);
				  while(num%i == 0)num /= i;
			}
	  }
	  if(num != 1) ret = ret/num*(num-1);
	  return ret;
}

int main(){
	int N;
	scanf("%d",&N);
	printf("%d\n",euler(N));
	return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	char s[5];
cin>>s;
int i,flag=0;
for(i=0;i<3;i++){
if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')

{flag=1;
break;
}
else
flag=0;
}
if(flag==1)
cout<<"ARC";
else
cout<<"ABC";
}

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

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


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

int a[100];
long long int dp[100][21];
int n;

long long int rec(int i, int j) //i番目の
{
	if (j < 0 || 20 < j)
	{
		return 0;
	}

	if (i == n - 2)
	{
		if (j == a[n - 1])
		{
			return 1;
		}
		return 0;
	}

	if (dp[i][j] > -1)
	{
		return dp[i][j];
	}
	
	dp[i][j] = rec(i + 1, j + a[i + 1]) + rec(i + 1, j - a[i + 1]);
	return dp[i][j];
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << rec(0, a[0]) << endl;
	return 0;
}

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

int main() {
    int r,g,b,n;cin >> r >> g >> b >> n;
    ll ans=0;
    for(int i = 0; i < 3001; i++) {
        for(int j = 0; j < 3001; j++) {
            if(n-i*r-j*g>=0 && (n-i*r-j*g)%b==0){
                ans++;
            }
        }
    }
 cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>

using namespace std;

int n, m, a;

int main()
{
	while(cin >> n >> a)
	{
		if(n % 500 <= a) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
  
	map<string, int> m;
	int q;
	cin >> q;
	while(q--){
		int op;
		cin >> op;
		string s;
		cin >> s;
		if(op == 1)cout << m[s] << '\n';
		else if(op == 2)m.erase(s);
		else{
			int x;
			cin >> x;
			m[s] = x;
		}
	}
    return 0;
}



Measured memory_bytes: 25824
#include <iostream>
#include <utility>
#include <queue>
using namespace std;

const int limit = 1000;
char grid[limit+1][limit+1];
int h, w, n;

class state{
public:
  int x, y, t;
  state(int x, int y, int t):
    x(x), y(y), t(t){}
};

int solve();
int bfs(int, int, int, int);

int main(){

  cout << solve() << endl;

  return 0;
}

int solve(){
  cin >> h >> w >> n;
  //スタート地点を取って来る
  int sx[n], sy[n];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++) {
      cin >> grid[i][j];
      if(grid[i][j]=='.' || grid[i][j]=='X') continue;

      else if(grid[i][j]=='S'){
        sx[0] = j; sy[0] = i;
      }

      else{ //grid[i][j] == int
        int num = grid[i][j]-'0';
        sx[num] = j; sy[num] = i;
      }
    }
  }

  int ans=0;

  for(int i=0; i<n; i++){
    ans += bfs(sx[i], sy[i], sx[i+1], sy[i+1]);
  }

  return ans;
}

int bfs(int sx, int sy, int gx, int gy){
  bool visited[h][w];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++) visited[i][j] = false;
  }

  queue<state> q;
  q.push(state(sx, sy, 0));
  visited[sy][sx] = true;

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

  int ans;
  while(!q.empty()){
    state now = q.front(); q.pop();
    if(now.x==gx && now.y==gy){
      ans = now.t;
      break;
    }

    for(int i=0; i<4; i++){
      int nx = now.x+dx[i], ny = now.y+dy[i];
      if(!visited[ny][nx] && 0<=nx && nx<w && 0<=ny && ny<h && grid[ny][nx] != 'X'){
        visited[ny][nx] = true;
        q.push(state(nx, ny, now.t+1));
      }
    }
  }

  return ans;
}



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


int main(){
  int x ;
  cin >>x;
  if (x==2){
    cout <<x<<endl;
    return 0;
  }
  bool check = false;
  for (int i = 2;i<(x/2);i++){
    if((x%i)==0){
      check =true;
      break;
    }
  }

  while(check){
    bool ans =false;
    x+=1;
    for(int i = 2;i<(x/2);i++){
      if ((x%i)==0){
        ans =true;
        break;
      }
    }
    check = ans;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr ll INF = 9223372036854775807LL;
ll N, A, B, C, D;
map<ll, ll> res;

ll _solve(ll n){
    // cout << "Called : _solve(" << n << ")" << endl;
    if (n < 0) return INF;
    if (n == 0)
        return res[0] = 0;
    else if (n == 1) res[1] = D;
    if (res[n] > 0) return res[n];
    ll tmp;
    if (n <= INF / D) tmp = n * D;
    else tmp = INF;
    const vector<int> lis = {2, 3, 5};
    for (auto op : lis){
        ll cost = (op == 2 ? A : op == 3 ? B : C);
        if (n % op == 0)
            tmp = min(tmp, cost + _solve(n / op));
        ll prv = (n - 1) / op * op;
        tmp = min(tmp, (n - prv) * D + cost + _solve(prv / op));
        prv += op;
        if (prv != n)
            tmp = min(tmp, (prv - n) * D + cost + _solve(prv / op));
    }
    return res[n] = tmp;
}

void solve(){
    res.clear();
    cin >> N >> A >> B >> C >> D;
    cout << _solve(N) << endl;
} 

int main(){
    int T; cin >> T;
    while (T--) solve();
    return 0;
}

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(STL) STL.begin(), STL.end()
#define stl_rep(itr, STL) for (auto itr = STL.begin(); itr != STL.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_ceil(T a, T b) {
    return (a + (b - 1)) / b;
}

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    llong n, t, a;
    cin >> n;
    llong ballot_Takahashi = 1, ballot_Aoki = 1;
    rep(i, n) {
        cin >> t >> a;
        llong k = max(my_ceil(ballot_Takahashi, t), my_ceil(ballot_Aoki, a));
        ballot_Takahashi = t * k;
        ballot_Aoki = a * k;
    }

    cout << ballot_Takahashi + ballot_Aoki << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


struct SegmentTree{
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v){
        int sz = v.size();
        n = 1;
        while(n < sz) n *= 2;
        node.resize(2*n-1,INF);
        for (int i = 0; i < sz; i++) node[i+n-1] = v[i];
        for (int i = n-2; i >= 0; i--) node[i] = min(node[2*i+1],node[2*i+2]);
    }

    void update(int x,int val){
        x += n-1;
        node[x] = val;
        while(x > 0){
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1],node[2*x+2]);
        }
    }

    int getmin(int a, int b, int k=0, int l=0, int r=-1){
        if (r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];
        int vl = getmin(a, b, 2*k+1, l , (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2,r);
        return min(vl, vr);
    }
};



int main(){
    int n,m;cin >> n >> m;
    string s;cin >> s;
    vector<int> x(n+2,-1);
    SegmentTree seg(vector<int> (n+2,INF));
    seg.update(0,0);
    int l = 0;
    for (int i = 1; i <= n; i++) {
        if(s[i]=='1') continue;
        int t = seg.getmin(max(l,max(0,i-m)),i);
        l = max(l, i - m);
        if(t >= INF){
            cout << -1 << endl;
            return 0;
        }
        seg.update(i,t+1);
        while(seg.getmin(l,l+1) != t) l++;
        x[i] = l;
    }
    vector<int> ans;
    int t=n,now=n;
    while(now != 0){
        t = x[now];
        ans.pb(now-t);
        now = t;
    }
    reverse(ALL(ans));
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << (i+1==ans.size()?"\n":" ");
    }
    return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>


using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		} else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right) {
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main(void) {
	int n, stk, ans = 0;
	int divof[7] = { 1,2,4,8,16,32,64 };
	cin >> n;
	int div_num;
	for (int i = 0; i < n; i++) {
		cin >> stk;
		div_num = 6;
		while (stk % 2 == 0) {
			if (stk % divof[div_num] == 0) {
				stk /= divof[div_num];
				ans += div_num;
			} else {
				div_num--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// class point	の練習（クラスの高度な実装）
#include <iostream>
using namespace std;



int main() {
	int buf;
	int counter = 1;

	do {
		cin >> buf;
		if (!buf)break;
		else {
			cout << "Case " << counter << ": " << buf << endl;
			counter++;
		}
	} while (1);
	
	return 0;
}



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

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

  char a[4];
  for(int i=0;i<4;++i){
    a[i] = (char)(input[i]);
  }

  sort(a,a+4);

  if(a[0]==a[1] && a[2]==a[3] && a[0]!=a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int sx, sy, tx, ty;

int main() {
	cin >> sx >> sy >> tx >> ty;
	for (int i = sy; i < ty; i++) {
		cout << "U";
	}
	for (int i = sx; i < tx; i++) {
		cout << "R";
	}
	for (int i = sy; i < ty; i++) {
		cout << "D";
	}
	for (int i = sx; i < tx; i++) {
		cout << "L";
	}
	cout << "L";
	for (int i = sy; i <= ty; i++) {
		cout << "U";
	}
	for (int i = sx; i <= tx; i++) {
		cout << "R";
	}
	cout << "D";
	cout << "R";
	for (int i = sy; i <= ty; i++) {
		cout << "D";
	}
	for (int i = sx; i <= tx; i++) {
		cout << "L";
	}
	cout << "U" << endl;
	//system("pause");
}

Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

from numba import njit


def getInputs():
    D = int(readline())
    CS = np.array(read().split(), np.int32)
    C = CS[:26]
    S = CS[26:].reshape((-1, 26))
    return D, C, S


@njit('(i8, i4[:], i4[:, :], i4[:], )', cache=True)
def _compute_score1(D, C, S, out):
    score = 0
    last = np.zeros(26, np.int32)
    for d in range(len(out)):
        i = out[d]
        score += S[d, i]
        last[i] = d + 1
        score -= np.sum(C * (d + 1 - last))
    return last, score


def _update_score():
    pass

@njit('(i8, i4[:], i4[:, :], i4[:], i8, )', cache=True)
def _ramdom_update(D, C, S, out, score):
    d = np.random.randint(0, D)
    q = np.random.randint(0, 26)
    p = out[d]
    out[d] = q

    if p == q:
        return out, score

    last, new_score = _compute_score1(D, C, S, out)
    if score < new_score:
        score = new_score
    else:
        out[d] = p

    return out, score



def _random_swap():
    pass


def step1(D, C, S):
    out = []
    LAST = 0
    for d in range(D):
        max_score = -10000000
        best_i = 0
        
        for i in range(26):
            out.append(i)
            last, score = _compute_score1(D, C, S, np.array(out, np.int32))
            if max_score < score:
                max_score = score
                LAST = last
                best_i = i
            out.pop()

        out.append(best_i)

    return np.array(out), LAST, max_score


def step2(D, C, S, out, score):
    for _ in range(2 * 10 ** 4):
        out.dtype = np.int32
        out, score = _ramdom_update(D, C, S, out, score)
    return out, score


def output(out):
    out += 1
    print('\n'.join(out.astype(str).tolist()))


D, C, S = getInputs()
#out, _, score = step1(D, C, S)
#print(score)
out = np.zeros(D, np.int32)
score = -10000000
out, score = step2(D, C, S, out, score)
output(out)
#print(score)

Measured memory_bytes: 107616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 110

void calc(int n){
  int m,s[SIZE],d[SIZE],sumd = 0;
  int dp[1<<15],sum[1<<15];
  
  scanf("%d",&m);

  for(int i=0;i<n;i++) scanf("%d\n",s+i);
  for(int i=0;i<m;i++){
    scanf("%d\n",d+i);
    sumd += d[i];
  }

  for(int i=0;i<(1<<n);i++) dp[i] = -INF;
  dp[0] = 0;
  sum[0] = 0;
  
  for(int i=0;i<(1<<n)-1;i++){

    for(int j=0;j<n;j++){
      if((i>>j) & 1) continue;

      int add = 0;
      
      for(int k=0;k<m;k++){
        if(sum[i] + s[j] <= d[k]){
          add += s[j];
        }else if(sum[i] < d[k] && d[k] < sum[i] + s[j]){
          
          if(d[k] - sum[i] > sum[i]+s[j] - d[k]){
            add += (d[k] - sum[i]) - (sum[i]+s[j] - d[k]);
          }
        }   
      }
      dp[i + (1<<j)] = max(dp[i + (1<<j)], dp[i] + add);
      sum[i + (1<<j)] = sum[i] + s[j];
    }
    
  }

  printf("%d\n",sumd - dp[(1<<n)-1]);
}

int main(){

  int n;

  while(1){
    scanf("%d",&n);
    if(n == 0) break;
    calc(n);
  }
  
  
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  
  for (int i = 0; i < n; i++) {
    cout << s[i];
    cout << t[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int W, H, x, y, r;

int main() {
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (x >= r && y >= r && (H-r) >= y && (W-r) >=x){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2092
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        Console.Write($"{a[a.Length - 1]}");
        for (int i = a.Length - 3; i >= 0; i -= 2)
        {
            Console.Write($" {a[i]}");
        }
        for (int i = a.Length & 1; i < a.Length; i += 2)
        {
            Console.Write($" {a[i]}");
        }
    }
}

Measured memory_bytes: 37928
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    if(K <= A) {
        cout << A - K << " " << B << endl;
    } else {
        cout << 0 << " " << max(B - (K - A), 0LL) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main() {
    long a, b;
    cin >> a >> b;
    long base = pow(100, a);
//    long cnt = 0;
//    long i = 0;
//    if(a == 0) {
//        while(cnt < b) {
//            if(i % 100 == 0) {
//                i++ ; continue;
//            }
//            cnt++;i++;
//        }
//        cout << i-1 << endl;
//        return 0;
//    }
//    while(cnt < b) {
//        if(i % base == 0) {
//            i++;
//            continue;
//        }
//        i++;
//        cnt ++;
//    }
//    cout << base * (i-1) << endl;
        if (b != 100) {

            cout  << base * b << endl;
        }
        else {

            cout << base * 101 << endl;
        }

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int wins = 15 - s.size();
    for (char c: s) {
        if (c == 'o')
            wins++;
    }
    cout << ((wins < 8) ? "NO" : "YES") << endl;
    return 0;
}


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

using namespace std;

const int md = int(1e9) + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

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

  int h, w;
  cin >> h >> w;
  vector<string> Map(h);
  for (int i = 0; i < h; i++) {
    cin >> Map[i];
  }

  vector< vector<int> > dp(h + 1, vector<int>(w + 1));
  dp[0][1] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (Map[i][j] == '.') {
        add(dp[i + 1][j + 1], dp[i][j + 1]);
        add(dp[i + 1][j + 1], dp[i + 1][j]);
      }
    }
  }
  cout << dp[h][w] << '\n';
  return 0;
}

Measured memory_bytes: 5248