akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
#define pb push_back
#define mp make_pair
#define taskname "A"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
 
int dp[2][101][501];
int n ,  x;
vector<int> val;
void add(int & x , ll y){
    x += y % mod;
    if(x >= mod)x -= mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> x;
    val.resize(n);
    for(auto & c : val)cin >> c;
    sort(val.begin(),val.end(),greater<int>());
    bool bit = 0;dp[0][0][0] = 1;
    for(auto & l : val){
        for(int i = 0 ; i <= n ; ++i){
            for(int j = 0 ; j <= x ; ++j){
                if(dp[bit][i][j] > 0){
                    if(j + l <= x)add(dp[!bit][i + 1][j + l],(ll)dp[bit][i][j] * (i + 1));
                    if(i >= 1){
                        add(dp[!bit][i][j] , (ll)dp[bit][i][j] * (j - i * (l - 1)));
                        for(int k = 1 ; k <= l && k + j <= x ; ++k){
                            add(dp[!bit][i][j+k],(ll)dp[bit][i][j]*i*2);
                            if(i >= 2){
                                add(dp[!bit][i-1][j+k],(ll)dp[bit][i][j]*(l-k+1)*(i-1));
                            }
                        }
                    }
                    dp[bit][i][j] = 0;
                }
            }
        }
        bit ^= 1;
    }
    cout << dp[bit][1][x];
}

Measured memory_bytes: 640
import sys
import itertools
import numpy
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
if K % 2 == 1 :
    index = N // K
    ans = index**3
else :
    index = N // K
    ans = index**3
    k = K // 2
    indexa = (N // k) - index
    ans += indexa**3
print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<int> mochi(N);
  for(int i = 0; i < N; ++i)
    cin >> mochi.at(i);
  sort(mochi.begin(),mochi.end(),greater<int>());
  mochi.erase(unique(mochi.begin(), mochi.end()), mochi.end());
  cout << mochi.size() << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	
	ll N;
	cin >> N;
	vector<ll> A(N+1),B(N);
	FOR(i,0,N+1)cin>>A[i];
	FOR(i,0,N)cin >> B[i];
	ll ans = 0;
	FOR(i,0,N){
		if(B[i]>=A[i]){
			ans += A[i];
			B[i] -= A[i];
			A[i] = 0;
		}else if(B[i]<A[i]){
			ans += B[i];
			A[i] -= B[i];
			B[i] = 0;
		}
		if(B[i]){
			if(B[i]>=A[i+1]){
				ans += A[i+1];
				A[i+1] = 0;
			}else{
				ans += B[i];
				A[i+1] -= B[i]; 
			}
		}
	}
	cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    s[i]=(s[i]-'A'+n)%26+'A';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
int main() {
    // input
    int n; cin >> n;
    // compute
    vector<vector<bool> > f = vectors(n, n, bool());
    for (int k = 1; k <= n; k *= 2) {
        repeat (y,n) repeat (x,n) {
            if (y % k == 0 and (y + x) % (2*k) == (k-1)) f[y][x] = true;
        }
    }
    repeat (y,n) f[y][0] = f[y][n-1] = true;
    repeat (x,n) f[0][x] = f[n-1][x] = true;
    // output
    int k = 0;
    repeat (y,n) repeat (x,n) if (f[y][x] and (y + x) % 2 == 1) ++ k;
    cout << k << endl;
    repeat (y,n) repeat (x,n) if (f[y][x] and (y + x) % 2 == 1) cout << x << ' ' << y << endl;
    return 0;
}


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

typedef long long ll;

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

int main()
{
    int n;
    cin >> n;
    ll ans;
    for (int i = 0; i < n; i++) {
        ll t;
        cin >> t;
        if (i == 0) {
            ans = t;
        } else {
            if (ans >= t) {
                ans = (ans / gcd(ans, t)) * t;
            } else {
                ans = (t / gcd(ans, t)) * ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N; cin >> N;
  vector<pair<double,double>> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i].first >> A[i].second;
  }
  double ans=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      double x=A[i].first-A[j].first;
      double y=A[i].second-A[j].second;
      ans+=sqrt(x*x+y*y);
    }
  }
  cout << fixed << setprecision(10);
  cout << ans*2/N << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}

const int N=2e5+5, L=1e6+5;
int len[N], trans[L][26], tot=1, cnt[26], sum[L][26];
char pool[N+L], *mem=pool, *s[N];
void insert(int n, char *s) {
	int at=1;
	for(int i=0; i<n; ++i) ++cnt[s[i]-'a'];
	for(int j=0; j<26; ++j) if(cnt[j]) ++sum[at][j];
	for(int i=0; i<n; ++i) {
		int &to=trans[at][s[i]-'a'];
		--cnt[s[i]-'a'];
		if(to==0) to=++tot;
		at=to;
		for(int j=0; j<26; ++j) if(cnt[j]) ++sum[at][j];
	}
}
int query(int n, char *s) {
	int at=1;
	for(int i=0; i<n-1; ++i) at=trans[at][s[i]-'a'];
	return sum[at][s[n-1]-'a'];
}
int main() {
	int n;
	scanf("%d", &n);
	for(int i=1; i<=n; ++i) {
		s[i]=mem;
		scanf("%s", mem);
		len[i]=strlen(s[i]);
		mem+=len[i]+1;
		std::reverse(s[i], s[i]+len[i]);
		insert(len[i], s[i]);
	}
	long long ans=-n;
	for(int i=1; i<=n; ++i) ans+=query(len[i], s[i]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 207584
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    int N, A, B; cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
 
 
    return 0;
}
 

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


int main() {
	int N, L;

	cin >> N >> L;

	int min_abs = 1000;
	int min_val = 0;
	int min_idx = 0;
	int total = 0;
	for(int i=0; i<N; i++){
		int tmp_abs = abs(L+i);
		total += L+i;
		if (tmp_abs < min_abs) {
			min_abs = tmp_abs;
			min_val = L+i;
			min_idx = i;
		}
	}

	cout << total - min_val;


}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;


int main(){
  long int a,b,n;cin>>a>>b>>n;
  
  
  //cout<<ans;
  if(n<b-1)
    cout<<floor(a*(n)/b)-a*floor((n)/b);
  else
    cout<<floor(a*(b-1)/b)-a*floor((b-1)/b);
      
    
  
  
  return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef vector<P> vP;
int main() {
	int n;
	ll c, k;
	cin >> n >> c >> k;
	deque<ll> T;
	for (int i = 0; i < n; i++) {
		ll t;
		cin >> t;
		T.push_back(t);
	}
	sort(T.begin(), T.end());
	
	int ans = 0;
	while (!T.empty()) {
		ll frt = T.front();
		ans++;
		for (int i = 0; i < c; i++) {
			if (T.empty()) {
				cout << ans << endl;
				return 0;
			}
			else if (T.front() <= frt + k) {
				T.pop_front();
			}
		}
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String[] strArray = br.readLine().split(" ");
    String[] strArray2 = new String[n];
    for(int i = 0;i < n;i++) {
      strArray2[i] = strArray[n-i-1];
    }
    for(int i = 0;i < (n-1);i++) {
      System.out.print(strArray2[i] + " ");
    }
    System.out.println(strArray2[n-1]);
  }
}

Measured memory_bytes: 24208
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n;
Int x[15], y[15], p[15];
vector<Int> ans(15, LINF);

vector<Int> xs;
vector<Int> ys;
vector<int> no_train;

int main()
{
    cin >> n;
    Int pow3 = 1;
    for (int i = 0; i < n; i++) {
        pow3 *= 3;
        cin >> x[i] >> y[i] >> p[i];
    }
    for (Int i = 0; i < pow3; i++) {
        xs.clear();
        ys.clear();
        no_train.clear();
        int info = i;
        for (int j = 0; j < n; j++) {
            if (info % 3 == 0)
                no_train.push_back(j);
            if (info % 3 == 1)
                xs.push_back(x[j]);
            if (info % 3 == 2)
                ys.push_back(y[j]);
            info /= 3;
        }
        Int dist_sum = 0;
        for (auto j : no_train) {
            Int dist = min(abs(x[j]), abs(y[j]));
            for (auto x_val : xs) {
                dist = min(dist, abs(x_val - x[j]));
            }
            for (auto y_val : ys) {
                dist = min(dist, abs(y_val - y[j]));
            }
            dist_sum += dist * p[j];
        }
        ans[xs.size() + ys.size()] = min(ans[xs.size() + ys.size()], dist_sum);
    }
    for (int i = 0; i <= n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
 	int n; cin>>n;
  	int a[n];
  	for(int i=0;i<n;i++) cin>>a[i];
  	int ans = 0;
  	int k = 1;
 	for(int i=0;i<n;i++){
    	if(a[i]==k)
          k++;
    }
  	if(k==1) cout<<"-1";
  	else cout<<n-k+1;
  	return 0;
}

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

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

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

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1LL<<30;
const LL MOD = 1e9+7;


void dfs(const auto& G, auto& V, int i, int k) {
   V[i][k] = 1;
   for (int j = 0; j < G[i].size(); ++j) {
      int to = G[i][j];
      if (V[to][(k == 0 ? 1 : 0)]) {
         continue;
      }
      dfs(G, V, to, (k == 0 ? 1 : 0));
   }
}

int main()
{
   LL n, m; cin >> n >> m;
   vector<vector<int>> G(n);
   for (int i = 0; i < m; ++i) {
      int a, b; cin >> a >> b;
      --a; --b;
      G[a].push_back(b);
      G[b].push_back(a);
   }

   auto V = make_v<int>(n, 2);

   dfs(G, V, 0, 0);

   LL a = 0, b = 0;
   for (int i = 0; i < n; ++i) {
      if (V[i][0] && !V[i][1]) ++a;
      if (!V[i][0] && V[i][1]) ++b;
   }

   LL ans = n*(n-1)/2 - a*(a-1)/2 - b*(b-1)/2 - m;
   cout << ans << endl;

   return 0;
}


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

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

set<string> used;
int rec(string s){
    if(s.size() == 1) return 0;
    if(used.count(s)) return 0;
    used.insert(s);
    string ls = s.substr(0, s.size() / 2);
    string rs = s.substr(s.size() / 2);
    return (ls == rs ? 0 : 1) + rec(ls) + rec(rs);
}

int main(){
    int N;
    string s;
    while(cin >> N >> s){
        used.clear();
        cout << rec(s) << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long C = sc.nextLong();
        long[] x = new long[N];
        int[]  v = new int[N];

        for (int i = 0; i <N ; i++) {
            x[i]=sc.nextLong();
            v[i] = sc.nextInt();
        }

        long[] clockSingle = new long[N+1];
        long[] anticlockSingle = new long[N+1];
        long[] clockDual = new long[N+1];
        long[] anticlockDual = new long[N+1];



        long vSum = 0;
        long single =0;
        long singleMax =0;
        long dual =0;
        long dualMax= 0;
        for (int i = 0; i <N ; i++) {
            vSum +=v[i];
            single = vSum- x[i];
            dual = vSum -2*x[i];
            singleMax = Math.max(singleMax, single);
            dualMax = Math.max(dualMax,dual);
            clockSingle[i] = singleMax;
            clockDual[N-i-1] = dualMax;
        }
        vSum=0;
        single=0;dual=0;singleMax=0;dualMax=0;

        for (int i = N-1; i >=0 ; i--) {
            vSum +=v[i];
            single = vSum- (C-x[i]);
            dual = vSum -2*(C-x[i]);
            singleMax = Math.max(singleMax, single);
            dualMax = Math.max(dualMax,dual);
            anticlockSingle[N-1-i] = singleMax;
            anticlockDual[i] = dualMax;
        }

        long ans = 0;

        for (int i = 0; i <N ; i++) {

            ans = Math.max(ans , clockSingle[i]+anticlockDual[i+1]);
            ans = Math.max(ans , anticlockSingle[i]+clockDual[i+1]);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 65208
#include <iostream>

using namespace std;

int main(){
    int N;
    int H[100000];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    H[0]--;
    for(int i = 1; i < N; i++){
        if(H[i] > H[i-1]) H[i]--;
        if(H[i] < H[i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll i,j,ans = 0;
    map<ll,ll> mp;
    for(i=0;i<n;i++){
        cin>>a[i];
        ans = ans+a[i];
        mp[a[i]]++;
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll b,c;
        cin>>b>>c;
        if(mp.find(b)==mp.end())
            cout<<ans<<"\n";
        else
        {
            ans = ans - b*mp[b];
            ans = ans+c*mp[b];
            // cout<<c<<" "<<mp[b]<<" "<<ans;
            mp[c] = mp[c]+mp[b];
            mp[b] = 0;
            cout<<ans<<"\n";
        }
    }
}

Measured memory_bytes: 8968
import math
n, a, b = map(int, input().split())
v = [int(m) for m in input().split()]
v.sort(reverse=True)

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


k = 0
l = 0
maxli = []
for i in range(a, b + 1):
    w = v[:i]
    avgv = sum(w) / i
    x = v[i - 1]
    for u in range(len(w) - 1, -1, -1):
        if u == len(w) - 1:
            l = 1
        else:
            if v[u] == v[u + 1]:
                l += 1
            else:
                break
    for j in range(i - 1, n):
        if j == i - 1:
            k = 1
        else:
            if v[j] == v[j - 1]:
                k += 1
            else:
                break
    k -= 1
    maxli.append([avgv, comb(l + k, l)])

S = 0
K = 0
maxli.sort(reverse=True)
for i in range(len(maxli)):
    if i == 0:
        S = maxli[i][0]
        K = maxli[i][1]
    else:
        if maxli[i][0] == maxli[i - 1][0]:
            K += maxli[i][1]
        else:
            break
print(S)
print(K)

Measured memory_bytes: 3064
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, A, B, C):
    sat = B[A[0]]
    for i in range(1, N):
        sat += B[A[i]]
        if A[i - 1] + 1 == A[i]:
            sat += C[A[i - 1]]
    return sat


def main():
    N = int(inp())
    A = [int(e) - 1 for e in inp().split()]
    B = [int(e) for e in inp().split()]
    C = [int(e) for e in inp().split()]
    print(solve(N, A, B, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
N = int(input())
H = input().split()
H = [0] + [int(h) for h in H]

M = 0 # length of longest decreasing sequence
L = 0 # current length

for i in range(1, N):
    if H[i] >= H[i+1]:
        L += 1
    else:
        M = max(M, L)
        L = 0
M = max(M, L)

print(M)


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	double t, x;
	cin >> t >> x;

	double ans = t / x;
	printf("%.10lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

#define NDEBUG

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int n, m; scanf("%d%d", &n, &m); n++;
	std::string s; cin >> s;

	// solve
	using P = std::pair<int, int>;
	// (val, lifetime)
	
	std::vector<int> dp(n + 1, 1 << 30); dp[0] = 0;
	std::vector<int> from(n + 1, -1);
	std::priority_queue<P, std::vector<P>, std::greater<P>> qu; qu.push({0, -m});
	for(int i = 0; i < n; i++) {
		if(s[i] == '1') continue;
		
		while(!qu.empty() and (i - qu.top().second) > m) qu.pop();
		if(qu.empty()) break;

		dp[i + 1] = qu.top().first + 1;
		from[i + 1] = qu.top().second + 1;
		qu.push({dp[i + 1], i});
	}

	#ifndef NDEBUG
	for(auto v: dp) cerr << v << " "; cerr << endl;
	for(auto v: from) cerr << v << " "; cerr << endl;
	#endif
	
	if(dp[n] == 1 << 30) {
		printf("-1\n");
		return 0;
	}

	int now = n;
	std::vector<int> ans;
	while(now > 1) {
		ans.push_back(now - from[now]);

		now = from[now];
	}
	reverse(begin(ans), end(ans));
	
	for(auto v: ans) printf("%d ", v);
	printf("\n");
	return 0;
}


Measured memory_bytes: 1912
# AtCoder Regular Contest 065
# D - 連結 / Connectivity
# https://atcoder.jp/contests/arc065/tasks/arc065_b
import sys
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, *KL = map(int, input().split())
    uf = [UnionFind(N) for _ in range(2)]
    for i in range(2):
        for j in range(KL[i]):
            p, q = map(int, input().split())
            uf[i].union(p-1, q-1)

    d = defaultdict(int)
    for i in range(N):
        d[(uf[0].find(i), uf[1].find(i))] += 1

    # for i in range(N):
    #     print(d[(uf[0].find(i), uf[1].find(i))], end = " ")
    # print("")
    
    print(" ".join([str(d[(uf[0].find(i), uf[1].find(i))]) for i in range(N)]))

if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    main()


Measured memory_bytes: 60536
import sys
input = sys.stdin.readline
def main():
    n= int(input())
    s = str(input().rstrip())
    r= s.count('R')
    g=s.count('G')
    b = s.count('B')
    ans = 0
    for i in range(n-2):
        for j in range(i+1, (n+i+1)//2):
            k = 2*j-i
            t = {s[i], s[j], s[k]}
            if len(t) ==3:
                ans +=1
    print(r*g*b-ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 73900
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,i,j;
  cin>>n;
  double pg,pk,dp[n+1][(n+1)/2],kotae=0;
  for(i=0;i<n+1;i++){
    dp[i][0]=0;
  }
  cin>>dp[(n+1)/2][0];
  dp[(n-1)/2][0]=1.0-dp[(n+1)/2][0];
  for(j=1;j<(n+1)/2;j++){
    cin>>pg>>pk;
    dp[n][j]=dp[n-1][j-1]*pg*pk;
    dp[0][j]=dp[1][j-1]*(1.0-pg)*(1.0-pk);
    for(i=1;i<n;i++){
      dp[i][j]=dp[i+1][j-1]*(1.0-pg)*(1.0-pk)+dp[i][j-1]*pg*(1.0-pk)+dp[i][j-1]*pk*(1.0-pg)+dp[i-1][j-1]*pg*pk;
    }
  }
  for(i=(n+1)/2;i<n+1;i++){
    kotae+=dp[i][(n-1)/2];
  }
  printf("%12.10lf",kotae);
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
	int n, m, p;
	while (cin >> n >> m >> p, n) {
		int x[n], sum = 0;
		rep (i, n) {
			cin >> x[i];
			sum += x[i];
		}
		if (!x[m - 1]) {
			cout << 0 << endl;
			continue;
		}
		cout << (int) (sum * 100.0 * (100 - p) / 100.0 / x[m - 1]) << endl;
	}
	return 0;
}


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

#define int long long

int l, k;
int dp[101][2];

int dfs(int n, int t) {
  if ( n > l ) return 0;
  if ( dp[n][t] >= 0 ) return dp[n][t];

  int ret = 0; 
  if ( !t ) {
    ret += dfs(n+1, 1) + dfs(n+k, 1);    
  } else {
    ret = 1;    
    ret += dfs(n+1, 0);    
  }

  return dp[n][t] = ret;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> l >> k;

  fill_n(*dp, 101*2, -1);

  cout << dfs(1, 1)+dfs(k, 1) << endl;  
  
  return 0;
}



Measured memory_bytes: 3216
def main():
  n,k=map(int,input().split())
  r=0
  for q in range(n+1):
      if q==0:
          for b in range(1,n+1):r+=max(min(b,k)-1,0)
      else:
          for b in range(1,n//q+1):r+=min(k,n-q*b+1,b)
  print(n*n-r)

if __name__=="__main__":
  main()

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

def main():

    S = input()

    listS = [int(S[:2]), int(S[2:])]

    if 1 <= listS[0] <= 12 and 1 <= listS[1] <= 12:
        ans = 'AMBIGUOUS'

    elif 1 <= listS[0] <= 12:
        ans = 'MMYY'

    elif 1 <= listS[1] <= 12:
        ans = 'YYMM'

    else:
        ans = 'NA'

    print(ans)


if __name__ == "__main__":
    main()

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

using ll = long long int;

const int MAX_N = (int)(2e5 + 5);

int n;
ll a[MAX_N];

ll acca[MAX_N];

ll ans = (ll)(1e18 + 5);

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &(a[i]));
  }

  acca[0] = 0;
  for (int i = 1; i <= n; ++i) {
    acca[i] = acca[i - 1] + a[i];
  }

  int left = 1;
  int right = 3;

  for (int i = 2; i <= n - 2; ++i) {
    ll amountll = (acca[left] - acca[0]);
    ll amountlr = (acca[i] - acca[left]);
    ll amountrl = (acca[right] - acca[i]);
    ll amountrr = (acca[n] - acca[right]);

    ll ldiff = abs(amountll - amountlr);
    ll rdiff = abs(amountrl - amountrr);

    for (int tl = left + 1; tl < i; ++tl) {
      ll tmpll = acca[tl] - acca[0];
      ll tmplr = acca[i] - acca[tl];
      ll tmpldiff = abs(tmpll - tmplr);

      if (ldiff > tmpldiff) {
        left = tl;
        amountll = tmpll;
        amountlr = tmplr;
        ldiff = tmpldiff;
      }
      else break;
    }

    for (int tr = right + 1; tr <= n - 1; ++tr) {
      ll tmprl = acca[tr] - acca[i];
      ll tmprr = acca[n] - acca[tr];
      ll tmprdiff = abs(tmprl - tmprr);

      if (rdiff > tmprdiff) {
        right = tr;
        amountrl = tmprl;
        amountrr = tmprr;
        rdiff = tmprdiff;
      }
      else break;
    }

    ll tmpmax = max(max(amountll, amountlr), max(amountrl, amountrr));
    ll tmpmin = min(min(amountll, amountlr), min(amountrl, amountrr));

    // cout << i << "_" << left << "_" << right << endl;
    // cout << amountll << "_" << amountlr << "_" << amountrl << "_" << amountrr << ":" << tmpmax << "_" << tmpmin << endl;

    ll cand = tmpmax - tmpmin;
    ans = min(ans, cand);
  }

  printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<set>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int n,m1,m2;
int a1[400005],a2[400005];
int f1(int i){
	if(i==a1[i])return i;
	return a1[i]=f1(a1[i]);
}
int f2(int i){
	if(i==a2[i])return i;
	return a2[i]=f2(a2[i]);
}

long long line[1400005],g[400005],h[4000005],num;
int find(long long k){
	int i=1,mid,j=num;
	while(j-i>1){
		mid=(i+j)/2;
		if(k>line[mid])
		     i=mid;
		else j=mid;
		
	}
	if(line[i]==k)return h[i];
	return h[j];
	
}
int main(){
	
	scanf("%d%d%d",&n,&m1,&m2);
	for(int q=1;q<=n;q++)a1[q]=a2[q]=q;
	for(int q=1;q<=m1;q++){
		int i,j;
		scanf("%d%d",&i,&j);
		a1[f1(i)]=f1(j);
		
	}
	for(int q=1;q<=m2;q++){
		int i,j;
		scanf("%d%d",&i,&j);
		a2[f2(i)]=f2(j);
		
	}
	for(int q=1;q<=n;q++){
		int i1=f1(q),i2=f2(q);
		long long ppp=i1;
		ppp=ppp*1000000+i2;
		g[q]=ppp;
		
	}
	sort(g+1,g+1+n);
	
	for(int q=1;q<=n;){
		
		line[++num]=g[q];
		int z=1;
		q++;
		while(g[q]==g[q-1]){
			q++;z++;
		}
		h[num]=z;
		if(q>n)break;
	}
	
	
	for(int q=1;q<=1;q++){
		int i1=f1(q),i2=f2(q);
		long long ppp=i1;
		ppp=ppp*1000000+i2;
		int ans=find(ppp);
		printf("%d",ans);
		
	}
	for(int q=2;q<=n;q++){
		int i1=f1(q),i2=f2(q);
		long long ppp=i1;
		ppp=ppp*1000000+i2;
		int ans=find(ppp);
		printf(" %d",ans);
		
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 6400
import java.util.Scanner;

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

		int[] prime=new int[1229];
		int counter=2;
		prime[0]=2;
		prime[1]=3;

		for(int i=5; i<=10000; i++) {
			for(int j=2; j*j<=i; j++) {
				if(i%j==0) {
					break;
				}
				if(i%j!=0 && (j+1)*(j+1)>i) {
					prime[counter]=i;
					counter++;
				}
			}
		}

		int[] fp=new int[205];
		int counter2=0;
		for(int i=0; i<1228; i++) {
			if(prime[i+1]-prime[i]==2) {
				fp[counter2]=prime[i];
				counter2++;
			}
		}

		while(true) {
			int a=sc.nextInt()-2;
			if(a==-2) {
				System.exit(0);
			}
			int max=0;

			for(int i=0; i<205; i++) {
				if(fp[i]<=a) {
					max=fp[i];
				}
				else if(fp[i]>a) {
					break;
				}
			}

			System.out.println(max+" "+(max+2));
		}
	}
}


Measured memory_bytes: 41072
"""
(sum(j) - sum(i)) % K = j - i
sum(j) % K - sum(i) % K = j- i
j - i < K
"""
n, k = map(int,input().split())
al = list(map(int,input().split()))

import itertools
al_ac = [0] + list(itertools.accumulate(al))

for i in range(n+1):
    al_ac[i] = (al_ac[i] - i) % k

from collections import defaultdict
dic = defaultdict(int)

ans = 0
for i in range(n+1):
    ans += dic[al_ac[i]]
    dic[al_ac[i]] += 1
    if i - k+1 >= 0:
        dic[al_ac[i-k+1]] -= 1

print(ans)


Measured memory_bytes: 114676
#include <stdio.h>

int main() {

    int num;
    scanf("%d", &num);

    int scaffolds[num];
    for (int i=0; i<num; i++) {
        scanf("%d", &scaffolds[i]);
    }

    int costs[num];
    costs[0] = 0;
    costs[1] = scaffolds[1] - scaffolds[0];
    costs[1] = costs[1] < 0 ? -costs[1] : costs[1];
    for (int i=2; i<num; i++) {
        int cost1 = scaffolds[i] - scaffolds[i-1];
        cost1 = cost1 < 0 ? -cost1 : cost1;
        int cost2 = scaffolds[i] - scaffolds[i-2];
        cost2 = cost2 < 0 ? -cost2 : cost2;
        costs[i] = cost1 + costs[i-1] < cost2 + costs[i-2] ? cost1 + costs[i-1] : cost2 + costs[i-2];
    }

    printf("%d\n", costs[num-1]);

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

template <class T>
void print_vec(const vector<T>& v) {

  for (auto t = begin(v); t != end(v);) {
    cout << *t;
    if (++t != end(v)) {
      cout << " ";
    }
  }
  cout << endl;
}

vector<int> insertionSort(const vector<int>& a, const int& n) {
  vector<int> ret = a;
  for (int i = 0; i < n; i++) {
    auto v = ret[i];
    auto j = i - 1;
    while (j >= 0 && ret[j] > v) {
      ret[j+1] = ret[j];
      j--;
    }
    ret[j+1] = v;
    print_vec(ret);
  }
  return ret;
}

int main(int ac, char **av) {
  int n;
  while (cin >> n, n) {
    vector<int> a;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      a.push_back(x);
    }
    insertionSort(a, n);
    // print_vec(b);
    n = 0;
  }
  return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    char a;
    int Jlv=0,Olv=0,Ilv=0,max=0;
    int Jflg=1,Oflg=0,Iflg=0;
    while(scanf("%c",&a) != EOF)
    {
        if(a==10)break;
        //a=getchar();
        if(Jflg==1)
        {
            Jland:
            if(a=='J')Jlv++;
            else if(a=='O')
            {
                Oflg=1;
                Jflg=0;
                goto Oland;
            }
            else Jlv=0;
        }
        if(Oflg==1)
        {
            Oland:
            if(a=='O')Olv++;
            else if(a=='I')
            {
                Iflg=1;
                Oflg=0;
                goto Iland;
            }
            else if(Jlv<Olv)
            {
                Jflg=1;Jlv=0;
                Oflg=0;Olv=0;
            }
            else if(a=='J')
            {
                Jflg=1;Jlv=0;
                Oflg=0;Olv=0;
                Iflg=0;Ilv=0;
                goto Jland;
            }
            else
            {
                Jflg=1;Jlv=0;
                Oflg=0;Olv=0;
            }
        }
        if(Iflg==1)
        {
            Iland:
            if(a=='I')Ilv++;
            if(Olv==Ilv&&Olv<=Jlv&&max<Olv)
            {
                max=Olv;
                Jflg=1;Jlv=0;
                Oflg=0;Olv=0;
                Iflg=0;Ilv=0;
            }
            if(Olv<Ilv)
            {
                Jflg=1;Jlv=0;
                Oflg=0;Olv=0;
                Iflg=0;Ilv=0;
            }
            if(a!='I'&&a!='J')
            {
                Jflg=1;Jlv=0;
                Oflg=0;Olv=0;
                Iflg=0;Ilv=0;
            }
            if(a=='J')
            {
                Jflg=1;Jlv=0;
                Oflg=0;Olv=0;
                Iflg=0;Ilv=0;
                goto Jland;
            }
        }
        //cout<<"ok"<<endl;
        //cout<<Jlv<<Olv<<Ilv<<endl;
    }
    printf("%d\n",max);
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
int n;
void se(string s,char mx){
    if((int)s.size() == n)cout << s << endl;
    else {
        for(char c='a';c<=mx;++c){
            se(s+c,(c==mx)?mx+1:mx);
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    cin>>n;
    se("",'a');
    
    return 0;
}

Measured memory_bytes: 1536
//Noszály Áron 10o Debreceni Fazekas Mihály Gimnázium

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define FORN(i, n) for(int i=0;i<(n);i++)
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, l, r) for ((i) = (l); (i) < (r); (i)++)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

int main() {
	IO;
	
	string t;
	cin>>t;
	if(sz(t)==26) {
		string orig=t;
		if(!next_permutation(all(t))) {
			cout<<-1<<"\n";
		}else {
			for(int i=0;i<sz(orig);++i) {
				cout<<t[i];
				if(orig[i]!=t[i]) break;
			}cout<<"\n";
			
		}
	}else {
		vector<bool> volt(26);
		for(int i=0;i<sz(t);++i) {
			volt[t[i]-'a']=1;
		}
		
		for(int i=0;i<26;++i) {
			if(!volt[i]) {
				cout<<t<<char(i+'a')<<"\n";;
				return 0;
			}
		}
	}
	
	return 0;
}



Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
#print(n)
#print(p)
i=1
l=[]
while i<n-1:
  if p[i-1]<p[i]<p[i+1] or p[i-1]>p[i]>p[i+1]:
    l.append(i)
  else:
    pass
  i+=1
print(len(l))



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

int main() {
	int score[4],a,b,total=0;
	
	for(int i=0;i<4;i++){
		cin>>score[i];
	}
	sort(score,score+4);
	
	for(int i=0;i<3;i++){
		total+=score[3-i];
	}
	cin>>a>>b;
	total+=max(a,b);
	cout<<total<<endl;
	
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    long long int n, a[222222];
    cin >> n;
    cin >> a[0];
    for(int i=1; i<n; ++i){
        int t; cin >> t;
        a[i]=a[i-1]+t;
    }
    long long int mi=1e10;
    for(int i=0; i<n-1; ++i){
        mi = min(abs(a[i]-(a[n-1]-a[i])), mi);
       // cout << a[n-1]-a[i] -a[i] << "\n";
    }
    cout << mi << "\n";

    return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	int k, in;
	bitset<11> bs[11];
	for (int i = 0; i < m; ++i)
	{
		cin >> k;
		for (int j = 0; j < k; ++j)
		{
			cin >> in;
			bs[i][in-1] = 1;
		}
	}
	int p[11];
	for (int i = 0; i < m; ++i)
	{
		cin >> p[i];
	}
	bitset<11> now, check;
	int ans = 0;
	for (int i = 0; i < (2<<(n-1)); ++i)
	{
		now = i;
		int ok = 1;
		for (int j = 0; j < m; ++j)
		{
			check = now & bs[j];
			if(check.count()%2!=p[j])
			{
				ok = 0;
			}
		}
		ans += ok;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  if(N%2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  rep(i,N/2) {
    if(s[i] != s[i+N/2]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
print("U"*dy+"R"*dx+"D"*dy+"L"*dx+"L"+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U")

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

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

    if(h==1){
        cout<<1<<endl;
        return 0;
    }

    ll num=1;
    ll ans=0;

    while(h>1){
        h/=2;
        ans+=num;
        num*=2;
    }

    ans+=num;

    cout<<ans<<endl;

}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanString()
	s, _ := strconv.Atoi(string(n[len(n)-1]))

	switch s {
	case 2, 4, 5, 7, 9:
		fmt.Println("hon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	case 3:
		fmt.Println("bon")
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1756
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

#define rep(i, N) for(ll i=0; i<(N); ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

int main() {
  int N;
  cin >> N;
  vector<int> B(N-1);
  rep(i, N-1) cin >> B[i];
  
  ll sum = 0;
  sum = B[0];
  for(int i=0; i<N-2; ++i) {
    sum += min(B[i], B[i+1]);
  }
  sum += B[N-2];
  
  cout << sum << endl;
}


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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  
  vector<vector<int>> ox(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j ++) {
      for (int k = 0; k < N; k++) {
        if (B.at(k) == A.at(i).at(j)) {
          ox.at(i).at(j) = 1;
        }
      }
    }
  }
  if ((ox[0][1] == 1 && ox[0][2] == 1 && ox[0][0] == 1) ||
      (ox[1][0] == 1 && ox[1][1] == 1 && ox[1][2] == 1) ||
      (ox[2][0] == 1 && ox[2][1] == 1 && ox[2][2] == 1) ||
      (ox[0][0] == 1 && ox[1][1] == 1 && ox[2][2] == 1) ||
      (ox[0][0] == 1 && ox[1][0] == 1 && ox[2][0] == 1) ||
      (ox[0][1] == 1 && ox[1][1] == 1 && ox[2][1] == 1) ||
      (ox[0][2] == 1 && ox[1][2] == 1 && ox[2][2] == 1) ||
      (ox[0][2] == 1 && ox[1][1] == 1 && ox[2][0] == 1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))

dp = [0] * 100010

dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]) 
    
print(dp[N-1])

Measured memory_bytes: 13924
n, m = map(int,input().split())
A = [x * -1 for x in list(map(int,input().split()))]
import heapq
heapq.heapify(A)
for _ in range(m):
    min_ = heapq.heappop(A)
    tmp = min_ * -1 // 2 * -1
    heapq.heappush(A,tmp)
print(sum(A) * -1)


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

using namespace std;
using pii = pair<int,int>;

const int INF = 1e9;
int R,C;
vector<vector<char>> field;
vector<vector<int>> dist;
vector<pii> dirs = {pii(1,0), pii(-1,0), pii(0,1), pii(0,-1)};

bool bfs(){
    queue<pii> que;
    que.push(pii(0,0));
    dist.at(0).at(0) = 0;

    while(!que.empty()){
        auto q = que.front(); que.pop();
        int qr=q.first;
        int qc=q.second;
        int d = dist.at(qr).at(qc);

        for(auto dir : dirs){
            int nr = qr+dir.first;
            int nc = qc+dir.second;

            if(0<=nr && nr<R && 0<=nc && nc<C && field.at(nr).at(nc) == '.' && dist.at(nr).at(nc) == INF){
                que.push(pii(nr,nc));
                dist.at(nr).at(nc) = d+1;

                if(nr == R-1 && nc == C-1)return true;
            }
        }
    }

    return false;
}

void route(){
    int r=R-1, c=C-1;
    while(true){
        field.at(r).at(c) = '#';
        int d = dist.at(r).at(c);
        if(d<=0)break;
        for(auto dir : dirs){
            int nr = r+dir.first;
            int nc = c+dir.second;

            if(0<=nr && nr<R && 0<=nc && nc<C && dist.at(nr).at(nc) == d-1){
                r = nr; c= nc;
            }
        }
    }

}

int main(){
    cin >> R >> C;
    
    field = vector<vector<char>>(R, vector<char>(C));
    dist = vector<vector<int>>(R, vector<int>(C, INF));

    for(int r=0; r<R; r++){
        for(int c=0; c<C; c++)cin >> field.at(r).at(c);
    }

    bool res = bfs();
    if(res){
        route();

        int count = 0;
        for(int r=0; r<R; r++){
            for(int c=0; c<C; c++){
                if(field.at(r).at(c) == '.')count++;
            }
        }

        cout << count << endl;
    }else{
        cout << -1 << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
bool judge(string s,int n){
    for(int i = 0;i<n;i++){
        if(s[i]!=s[i+n]) return false;
    }
    return true;
}
int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 1;i<n;i++){
        if((n-i)%2==0) if(judge(s,(n-i)/2)){
            cout << n-i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  rep(i, n) cin >> a[0][i];
  rep(i, n) cin >> a[1][i];
  vector<int> u(n, 0);
  vector<int> d(n, 0);
  rep(i, n) {
    if (i > 0) u[i] += u[i-1];
    u[i] += a[0][i];
  }
  for (int i = n-1; i >= 0; i--) {
    if (i < n-1) d[i] += d[i+1];
    d[i] += a[1][i];
  }
  int ans = 0;
  rep(i, n) {
    chmax(ans, u[i] + d[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e2+5;
int n, c[N], pos[N], ans[N*N];
pair<int, int> p[N];
int main()
{
    n = read();
    for(int i = 1, x; i <= n; ++i) pos[i] = read(), p[i] = make_pair(pos[i], i);
    sort(p+1, p+1+n);
    for(int i = 1; i <= n; ++i) c[i] = p[i].second-1, pos[p[i].second] = i;
    for(int i = 1, j = 1; i <= n; ++i)
    {
        int l = p[i-1].first+1, r = p[i].first;
        for(int k = l; k < r; ++k) 
        {
            while(!c[j]&&j <= n) ++j; if(j == n+1) break;
            ans[k] = p[j].second; --c[j];
        }
        ans[r] = p[i].second;
    }
    for(int i = 1; i <= n*n; ++i) ++c[pos[ans[i]]];
    for(int i = 1, j = 1; i <= n; ++i)
    {
        int l = p[i-1].first+1, r = p[i].first;
        for(int k = l; k <= r; ++k) 
        {
            if(ans[k]) continue;
            while(c[j] == n&&j <= n) ++j; if(j == n+1) break;
            ans[k] = p[j].second; ++c[j];
        }
        if(i < n) continue;
        for(int k = p[n].first+1; k <= n*n; ++k)
        {
            if(ans[k]) continue;
            while(c[j] == n&&j <= n) ++j; if(j == n+1) break;
            ans[k] = p[j].second; ++c[j];
        }
    }

    for(int i = 1; i <= n; ++i)
    {
        int cnt = 0;
        for(int j = 1; j <= p[i].first; ++j) cnt += p[i].second == ans[j];
        if(cnt != p[i].second) return puts("No"), 0;
    }       
    puts("Yes");
    for(int i = 1; i <= n*n; ++i) printf("%d ", ans[i]);
    return 0;
}

/* 
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 0 0 0 0 0 0 0 0 0 0
*/

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define inf 9223372036854775807;
#define pi 3.141592653589793238;
#define pb push_back;
#define umap unordered_map;
#define uset unordered_set;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void solve(){
    ll n, m;
    cin>>n>>m;
    ll s = 0, x;
    for(ll i=0;i<m;i++){
        cin>>x;
        s+=x;
    }
    if(s>n){
        cout<<-1;
    }
    else{
        cout<<n-s;
    }
}
int main(){
    fast;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
}   

Measured memory_bytes: 3628