akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int MAXN = 1e5 + 10;
long long a[MAXN],ans[MAXN];
int main()
{
    int N;
  //  freopen("data.txt","r",stdin);
    //freopen("myanswer.txt","w",stdout);
    cin >>N;
    for(int i = 0 ;i < N; i ++)
    {
        cin >> a[i];
    }
    sort(a,a+N);
    //long long ans = 0;
    int mid = N/2;
    int l = 0,r = N-1;
    if(N%2!=0)
    {
        if(abs(a[mid-1]-a[mid])>abs(a[mid+1]-a[mid]))
        {
            int cnt = 0;
            ans[cnt] = a[mid];//0
            cnt++;
            ans[cnt] = a[mid-1];//1
            for(cnt = 2 ; cnt < N ; cnt++)
            {
                if(cnt%2 == 0)
                {
                    ans[cnt] = a[r];
                    r--;
                }
                else{
                    ans[cnt] = a[l];
                    l++;
                }
            }

        }
        else{
            int cnt = 0;
            ans[cnt] = a[mid];//0
            cnt++;
            ans[cnt] = a[mid+1];//1
            for(cnt = 2 ; cnt < N ; cnt++)
            {
                if(cnt%2 == 0)
                {
                    ans[cnt] = a[l];
                    l++;
                }
                else{
                    ans[cnt] = a[r];
                    r--;
                }
            }
        }

    }
    else{
        if(abs(a[mid]-a[l])>abs(a[mid-1]-a[r]))
       {
           int cnt = 0;
           ans[cnt] = a[mid];
           cnt++;
           ans[cnt] = a[l];
           l++;
           for(cnt = 2 ; cnt < N ; cnt++)
            {
                if(cnt%2 == 0)
                {
                    ans[cnt] = a[r];
                    r--;
                }
                else{
                    ans[cnt] = a[l];
                    l++;
                }
            }
       }
       else{
            int cnt = 0;
            ans[cnt] = a[mid-1];//0
            cnt++;
            ans[cnt] = a[r];//1
            r--;
            for(cnt = 2 ; cnt < N ; cnt++)
            {
                if(cnt%2 == 0)
                {
                    ans[cnt] = a[l];
                    l++;
                }
                else{
                    ans[cnt] = a[r];
                    r--;
                }
            }
       }
    }
    long long Ans= 0;
    for(int i = 1 ; i < N ; i++)
    {
        //cout<<a[i]<<" ";
        Ans += abs(ans[i]-ans[i-1]);

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	ll tot_sum=0;
	ll a[n+1];
	ll pre[n+1];
	pre[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pre[i]=pre[i-1]+a[i];
		tot_sum+=a[i];
	}
	ll ans=1e18;
	for(int i=1;i<n;i++)
	{
		ans=min(ans, abs(pre[i]-(tot_sum-pre[i])));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def readinput():
    n=int(input())
    l=list(map(int,input().split()))
    return n,l

def main(n,l):
    count=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if l[i]==l[j] or l[i]==l[k] or l[j]==l[k]:
                    continue
                lmax=max(l[i],l[j],l[k])
                sonota=l[i]+l[j]+l[k]-lmax
                if sonota>lmax:
                    #print(i,j,k)
                    count+=1
    return count

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)


Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;


int main() {

	int n;
	cin >> n;
	vi a(n);
	rep(i, n) {
		int p;
		cin >> p;
		p--;
		a[p] = i;
	}
	
	set<int> se = { -2,-1,n,n + 1 };
	
	ll ans = 0;

	rep(i, n) {

		ll num = n - i;
		int m = a[n - 1 - i];
		auto itr = se.lower_bound(m);itr++;
		int mr2 = *itr;itr--;
		int mr = *itr;itr--;
		int ml = *itr;itr--;
		int ml2 = *itr;

		if (mr < n)ans += num * (m - ml) * (mr2 - mr);
		if (-1 < ml)ans += num * (mr - m) * (ml - ml2);
		se.insert(m);

	}

	cout << ans << endl;

}

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

bool zero(const vector<int> &a) {
  for (int i : a) {
    if (i == 0)
      return true;
  }
  return false;

}

int main() {
  unsigned int N;
  cin >> N;
  int count = 0;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }

  while(not zero(a)) {
      for(int i = 0; i < N; ++i) {
        if (a[i] % 2 != 0) {
          goto label;
        } else {
          a[i] /= 2;
          count += 1;
        }
      }
  }
  label:
  cout << count / N << endl;

}

Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

point={'r':r,'s':s,'p':p}

win = {'r':'p',
       's':'r',
       'p':'s'}

win_hand = ''
for ti in t:
  win_hand += win[ti]

ans = 0
same_flag = [False]*n

for i in range(k):
  ans += point[win_hand[i]]

i=k
while i<n:

  if win_hand[i] == win_hand[i-k]:
    if not same_flag[i-k]:
      same_flag[i]=True
    else:
      ans += point[win_hand[i]]
  else:
    ans += point[win_hand[i]]
  i+=1

print(ans)

Measured memory_bytes: 4212
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

    public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int n = sc.nextInt();
    		int sum =0;
    		int tmp=0;
    		List<Integer> ans = new ArrayList<>();
    		List<Integer> list = new ArrayList<>();
    		for(int i=0;i<n;i++) {
    			tmp=sc.nextInt();
    			list.add(tmp);
    			sum+=tmp;
    		}
    		int m = sc.nextInt();
    		int cur =0;
    		for(int i=0;i<m;i++) {
    			cur=list.get(sc.nextInt()-1);
    			ans.add(sum-cur+sc.nextInt());
    		}
    		for(int i=0;i<m;i++) {
    			System.out.println(ans.get(i));
    		}

    	}
    }

Measured memory_bytes: 21844
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,d,x,ans,i,a;
    cin>>n>>d>>x;
     ans=x;
    for(i=0;i<n;i++)
    {

        cin>>a;
        ans=ans+(d-1)/a+1;
    }
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a > 0)
    {
        cout << "Positive" << endl;
    }
    else if(a == 0)
    {
        cout << "Zero" << endl;
    }
    else
    {
        if(b >= 0)
        {
            cout << "Zero" << endl;
        }
        else
        {
            if((b-a) % 2 == 1)
            {
                cout << "Positive" << endl;
            }
            else
            {
                cout << "Negative" << endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 2000;

int dp[N+1][N+1];
int p[N+1][N+1];


string lcs(string a, string b){
  int size = (int)a.size();
  //vector< vector<int> > dp(size+1, vector<int>(size+1));
  //vector< vector<int> > p(size+1, vector<int>(size+1));
  fill(dp[0], dp[N+1], 0);
  fill(p[0], p[N+1], 0);
  for(int i=0;i<size;++i){
    for(int j=0;j<size;++j){
      if(a[i] == b[j]){
	dp[i+1][j+1] = dp[i][j] + 1;
	p[i+1][j+1] = 0;
      }else if(dp[i+1][j] < dp[i][j+1]){
	dp[i+1][j+1] = dp[i][j+1];
	p[i+1][j+1] = 1;
      }else{
	dp[i+1][j+1] = dp[i+1][j];
	p[i+1][j+1] = -1;
      }
    }
  }
  string res;
  for(int i=size, j=size;i>0 && j>0;){
    if(p[i][j] > 0) --i;
    else if(p[i][j] < 0) --j;
    else{
      res += a[i-1];
      --i;
      --j;
    }
  }
  reverse(res.begin(), res.end());
  return res;
}

main(){
  string input;
  while(cin >> input){
    string tmp = input;
    reverse(tmp.begin(), tmp.end());
    cout << lcs(input, tmp) << endl;
  }
  return 0;
}

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

int ck(int v1[], int v2[], int n){
    int a=1;;
    for (int i=0; i<n; i++){
        if (v1[i]!=v2[i]){
            a=0;
            break;
        }
    }
    return a;
}
long long a=1,b=1,n,c,d;
string ss,s1,s2;
int main(){
    cin>>n>>ss;
    for (int i=0; i<ss.size(); i++){
        cout<<(char)((((int)ss[i]-65+n)%26)+65);
    }
}


Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n,k,q; cin >> n >> k >> q;
    vi ok(n);
    rep(i,q){
        int a; cin >> a;
        ok[a-1]++;
    }
    rep(i,n){
        if(k-q+ok[i]>0)cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
}


Measured memory_bytes: 3696
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

template<typename T>
class MinCostFlow{
private:
  struct edge{int to; T cap, cost; int rev;};
  using P = pair<int,int>;
  vector<vector<edge> > Graph;
  vector<int> prevv, preve;
  vector<T> h, d; // ??????????????£?????????????????¢
public:
  MinCostFlow(int v){
    // ????????°v??§?????????
    Graph.resize(v);
    prevv.resize(v);
    preve.resize(v);
    h.resize(v);
    d.resize(v);
  }
  T min_cost_flow(int s, int t, T f){
    T res = 0;
    fill(all(h), 0);
    while(f>0){
      priority_queue<P, vector<P>, greater<P>> pq;
      fill(all(d), INF);
      d[s] = 0;
      pq.push(mp(0,s));
      while(!pq.empty()){
        auto p = pq.top(); pq.pop();
        int v = p.se;
        if(d[v] < p.fi) continue;
        rep(i,Graph[v].size()){
          edge &e = Graph[v][i];
          if(e.cap > 0 && d[e.to] > d[v] + e.cost + h[v] - h[e.to]){
            d[e.to] = d[v] + e.cost + h[v] - h[e.to];
            prevv[e.to] = v;
            preve[e.to] = i;
            pq.push(mp(d[e.to], e.to));
          }
        }
      }
      if(d[t] == INF) return -1;
      rep(i,Graph.size()) h[i] += d[i];

      T nf = f;
      for(int v=t; v!=s; v = prevv[v]){
        nf = min(nf, Graph[prevv[v]][preve[v]].cap);
      }
      f -= nf;
      res += nf * h[t];
      for(int v=t; v!=s; v=prevv[v]){
        edge &e = Graph[prevv[v]][preve[v]];
        e.cap -= nf;
        Graph[v][e.rev].cap += nf;
      }
    }
    return res;
  }
  void add_edge(int from ,int to, T cap, T cost){
    Graph[from].pb(((edge){to, cap, cost, (int)Graph[to].size()}));
    Graph[to].pb(((edge){from, 0, -cost, (int)Graph[from].size()-1}));
  }
};

int main(){
  int v,e,f;
  cin>>v>>e>>f;
  MinCostFlow<int> flow(v);
  rep(i,e){
    int a,b,c,d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    flow.add_edge(a, b, c, d);
  }

  cout<<flow.min_cost_flow(0, v-1, f)<<endl;

  return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define mod 1000000007
#define fr first
#define val second
#define N 100000000
#define fo(i,m,n) for(int i=m;i<n;i++)
#define M 7
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
using ul=unsigned long long;
using pii=pair<int,int>;
using vvi=vector<vector<int>>;
using vi=vector<int>;
using pll=pair<ll,ll>;
using vsi=vector<set<int>>;
using vll=vector<ll>;

ll power(ll a,ll n){
    ll j=0;
    ll x=1;
    while(1ll<<j<=n){
        if(1ll<<j&n)
            x=(x*a)%mod;

        a=a*a%mod;
        j++;
    }

    return x;
}

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

}

int lb(vi &a,int x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(x>=a[mid]){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind+1;

}

int up(vll &a,ll x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;

    while(l<=r){
        int mid=(l+r)/2;

        if(a[mid]>x){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind;
}

ll max(ll a,ll b){
    if(a>b)
        return a;
    else
        return b;

}

ll min(ll a, ll b){
    if(a>b)
        return b;
    else
        return a;

}
template<typename T>
void pra(T a[],int n){
    fo(i,0,n)
            cout<<a[i]<<' ';
    cout<<endl;

}

ifstream input;
ofstream output;
int t;
const ll inf=1e16;
int cs;
int tcs;
void build(vll &F,int ind,int tl,int tr,vll &st){

    if(tl==tr)
        st[ind]=F[tl];
    else{
        int mid=(tl+tr)/2;
        build(F,2*ind+1,tl,mid,st);
        build(F,2*ind+2,mid+1,tr,st);
        st[ind]=min(st[2*ind+1],st[2*ind+2]);
    }

}

void update(int j,ll nv,int ind,int tl,int tr,vll &st){

    if(j<tl||j>tr)
        return;
    else if(tl==tr)
        st[ind]=nv;
    else{
        int mid=(tl+tr)/2;
        update(j,nv,2*ind+1,tl,mid,st);
        update(j,nv,2*ind+2,mid+1,tr,st);
        st[ind]=min(st[2*ind+1],st[2*ind+2]);
    }

}


ll query(int ind,int tl,int tr,int l,int r,vll &st){
    int mid=(tl+tr)/2;
    if(r<tl||l>tr)
        return inf;
    else if(tl==l&&tr==r)
        return st[ind];
    else
        return min(query(2*ind+1,tl,mid,l,min(mid,r),st),query(2*ind+2,mid+1,tr,max(mid+1,l),r,st));

}

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

    int cnt=0;

    fo(i,0,n){
        ll x,y;
        cin>>x>>y;

        cnt+=(x*x+y*y<=d*d);


    }

    cout<<cnt<<endl;

}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,T;
map<int,int> t;

int main()
{
	scanf("%d %d",&N,&T);
	for(int i=0;i<N;i++)
	{
		int x;
		scanf("%d",&x);
		if(t.find(x)!=t.end())t[x]++;
		else t[x]=1;
		if(t.find(x+T)!=t.end())t[x+T]--;
		else t[x+T]=-1;
	}

	int cnt=0,sp=0;
	ll res=0;
	for(auto it=t.begin();it!=t.end();it++)
	{
		if(cnt==0&&it->second>0)
		{
			sp=it->first;
			cnt++;
		}
		else if(cnt>0&&it->second<0)
		{
			cnt--;
			if(cnt==0)
				res+=it->first-sp;
		}
		else if(it->second>0)
		{
			cnt++;
		}
	}
	printf("%lld\n",res);
	return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 50;
int n,k;
int v[MAX_N];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> k;
  forn(i,n) cin >> v[i];

  int res = 0;
  // c個までの宝石を捨てる
  for (int c = 0; c <= k; c++) {
    // l個を左から取る
    for (int l = 0; l <= k-c; l++) {
      int r = k-c-l;
      vi gems;
      forn(i,min(l,n)) gems.push_back(v[i]);
      for (int i = n-1; i >= max(l,n-r); i--) gems.push_back(v[i]);

      sort(gems.begin(),gems.end());

      int i = 0;
      while (i < c && i < (int)gems.size() && gems[i] < 0)
        i++;

      int temp = 0;
      for (;i < (int)gems.size(); i++) temp += gems[i];
      chmax(res, temp);
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int NMAX = 301;
const long INF = (long)1e10;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  long a[NMAX][NMAX];
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  long res = 0;
  for (auto i = 0; i < n; i++) {
    for (auto j = i + 1; j < n; j++) {
      long d1 = a[i][j];
      long d2 = INF;
      for (auto k = 0; k < n; k++) {
        if (k == i || k == j) continue;
        long d3 = a[i][k] + a[k][j];
        if (d2 > d3) d2 = d3;
      }
      if (d1 > d2) {
        cout << -1 << endl;
        return 0;
      }
      if (d1 < d2) res += d1;
    }
  }
  cout << res << endl; 
}

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

int a[3];
int main()
{
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a + 3);
    reverse(a, a + 3);
    int t = a[0] - a[1];
    a[2] += t;
    if((a[0] - a[2]) % 2 == 0) {
        printf("%d\n", (a[0] - a[2])  / 2 + t);
    } else {
        printf("%d\n", (a[0] - a[2]) / 2 + t + 2);
    }
    return 0;
}


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

const int MOD=1e9+7;
long long dp[2100][2100];

int main(){
    int N,M; cin >> N >> M;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    int s[N],t[M];
    for(int i=0;i<N;i++) cin >> s[i];
    for(int i=0;i<M;i++) cin >> t[i];
    for(int i=0;i<N+1;i++){
        for(int j=0;j<M+1;j++){
            if(i>0&&j>0&&s[i-1]==t[j-1]){
                dp[i][j]+=dp[i-1][j-1];
            }
            if(i>0) dp[i][j]+=dp[i-1][j];
            if(j>0) dp[i][j]+=dp[i][j-1];
            if(i>0&&j>0) dp[i][j]+=(MOD-dp[i-1][j-1])%MOD;
            dp[i][j]%=MOD;
        }
    }
    cout << dp[N][M] << endl;
}

Measured memory_bytes: 34688
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9`
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

int main(){
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	
	int ans=0;
	int l=0,r=s.size()-1;
	while(l<s.size() and s[l]!='W') l++;
	while(r>=0 and s[r]!='R') r--;
	while(l<r){
		swap(s[l],s[r]);
		ans++;
		while(l<s.size() and s[l]!='W') l++;
		while(r>=0 and s[r]!='R') r--;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  int curr = 1;
  while(curr * 111 < n)curr++;
  cout << curr * 111 << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n float64
	fmt.Scan(&n)

	result := math.Ceil(n / 1.08)
	if n/1.08 <= float64(result) && float64(result) < (n+1)/1.08 {
		fmt.Println(result)
	} else {
		fmt.Println(":(")
	}

}


Measured memory_bytes: 512
N,T = map(int,input().split())
List = list(map(int,input().split()))
dic = {}
min = List[0]
for i in range(N):
  if List[i]<min:
    min = List[i]
  if List[i]-min not in dic:
    dic[List[i]-min] = 1
  else:
    dic[List[i]-min] += 1
dic2 = sorted(dic.items(), reverse=True)
Answer = dic2[0][1]
print(Answer)

Measured memory_bytes: 24228
#include<bits/stdc++.h>
#define sonic ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define fi first
#define se second
#define pb push_back
using namespace std;

const ll INF=1e18;
const int N=1e5+17;

void solve(){
	int n,ans=0;
	cin>>n;
	cout<<!n;
}

int main(){
	sonic
	int TEST=1;
	//cin>>TEST;
	while(TEST--){
		solve();
		cout<<'\n';
	}
}


Measured memory_bytes: 3552
#include<iostream>
#define M 90
#define l long long
using namespace std;
l a[M];
l work(int n)
{
	if(a[n])
		return a[n];
	return(a[n]=work(n-1)+work(n-2));
}
int main()
{
	int n;
	cin>>n;
	a[0]=2;
	a[1]=1;
	cout<<work(n)<<'\n';
	return 0; 
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;
  rep(i, n) {
    if ((i + 1) % 2 == 1) {
      if (a[i] % 2 == 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()

using namespace std;

const int MX = 2e5 + 5;

string s;
int main(){
    cin >> s;
    int n = s.length();
    for(int i=1 ; i<=n ; ++i){
        if( i&1 && s[i-1] == 'L')
            return 0 * puts("No");
        if( !(i&1) && s[i-1] == 'R')
            return 0 * puts("No");
    }
    puts("Yes");
}  

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

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e17;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int a,b,q;
    cin>>a>>b>>q;
    set<int>s,t;
    f(i,1,a)
    {
        int x;
        cin>>x;
        s.insert(x);
    }
    f(i,1,b)
    {
        int x;
        cin>>x;
        t.insert(x);
    }
    f(i,1,q)
    {
        int x;
        cin>>x;
        int lft_s,rgt_s,lft_t,rgt_t;
        set<int>::iterator lo,hi;

        hi=s.lower_bound(x);
        if(hi!=s.end())rgt_s=*hi;
        else rgt_s=inf;
        hi=t.lower_bound(x);
        if(hi!=t.end())rgt_t=*hi;
        else rgt_t=inf;

        lo=s.upper_bound(x);
        if(lo==s.begin())lft_s=-inf;
        else {lo--;lft_s=*lo;}
        lo=t.upper_bound(x);
        if(lo==t.begin())lft_t=-inf;
        else {lo--;lft_t=*lo;}
        int cost,ses=inf;
        cost=max(rgt_t,rgt_s)-x;ses=min(ses,cost);
        cost=x-min(lft_t,lft_s);ses=min(ses,cost);
        cost=(rgt_s-x)+(rgt_s-lft_t);ses=min(ses,cost);
        cost=(rgt_t-x)+(rgt_t-lft_s);ses=min(ses,cost);
        cost=(x-lft_t)+(rgt_s-lft_t);ses=min(ses,cost);
        cost=(x-lft_s)+(rgt_t-lft_s);ses=min(ses,cost);
        cout<<ses<<endl;
    }
    return 0;

}





































Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll a, b, k;
    cin >> a >> b >> k;

    ll x = min(a,k);
    a -= x;
    k -= x;

    ll y = min(b, k);
    b -= y;
    k -= y;

    cout << a << " " << b;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A_list = [int(input()) for _ in range(N)]
A_cnt = defaultdict(int)
for A in A_list:
    A_cnt[A] += 1
A_set = set(A_cnt)
max_A = max(A_set)
if (A_cnt[max_A] > 1):
    for _ in range(N):
        print(max_A)
else:
    A_set.remove(max_A)
    second_A = max(A_set)
    for A in A_list:
        if (A == max_A):
            print(second_A)
        else:
            print(max_A)


Measured memory_bytes: 80328
#include<bits/stdc++.h>
using namespace std;
long long n,m,b[200010],x,ans=1,mod=1000000007;
vector<long long> v;
int main(){
	cin>>n>>m;
	v.push_back(-1);
	for (long long i=0;i<m;i++){
		cin>>x;
		v.push_back(x);
	}
	v.push_back(n+1);
	for (int i=2;i<v.size()-1;i++)
		if (v[i]-v[i-1]==1){
			cout<<0<<endl;
			return 0;
		}
	b[0]=1;b[1]=1;b[2]=1;
	for (int i=3;i<=100001;i++) b[i]=(b[i-1]+b[i-2])%mod;
	for (int i=1;i<v.size();i++) ans=(ans%mod)*b[v[i]-v[i-1]-1]%mod;
	cout<<ans%mod<<endl;
	return 0;
}

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

int main()
{
  char c;
  cin >> c;
  if(c == 'A') cout << 'T';
  if(c == 'T') cout << 'A';
  if(c == 'G') cout << 'C';
  if(c == 'C') cout << 'G';
  
  return 0;
}

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

using namespace std;

typedef vector<int> Vec;
typedef vector<Vec> Mat;

Mat a(5, Vec(5));
int score[5];

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

bool inField(int x, int y)
{
    return (0 <= x && x < 5 && 0 <= y && y < 5);
}

bool up;

int erase(Mat &m)
{
    bool e[5][5] = {{}};
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {                        
            if (m[i][j] == 0) {
                continue;
            }
            int cnt[2] = {1, 1};
            for (int k = 0; k < 4; k++) {
                int ni = i + dy[k];
                int nj = j + dx[k];
                while (inField(ni, nj) &&
                       m[i][j] == m[ni][nj]) {
                    ni += dy[k];
                    nj += dx[k];
                    ++cnt[k&1];
                }
            }
            if (cnt[0] >= 3 || cnt[1] >= 3) {
                e[i][j] = 1;
            }
        }
    }
    int point = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            if (e[i][j]) {
                up = 1;
                point += score[m[i][j]-1];
                m[i][j] = 0;
            }
        }
    }
    return point;
}

void fall(Mat &m)
{
    for (int j = 0; j < 5; j++) {
        for (int i = 4; i >= 1; i--) {
            if (m[i][j] == 0) {                
                for (int k = i-1; k >= 0; k--) {
                    if (m[k][j] != 0) {
                        swap(m[i][j], m[k][j]);
                        break;
                    }
                }
            }
        }
    }
}

int calc(Mat &m, int bp)
{
    int point = erase(m) * bp;
    fall(m);
    return point;
}

int get_point()
{
    Mat b = a;
    int point = 0, bp = 1;
    bool update = 1;
    
    while (update) {
        update = 0;        
        Mat nb = b;
        up = 0;
        int p = calc(nb, bp++);
        if (nb != b) {
            point += p;
            update = 1;
            b = nb;
        }
    }
    return point;
}

int dfs(int y, int x, int n)    
{
    int point = get_point();
    if (n > 0) {
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (inField(nx, ny)) {
                swap(a[ny][nx], a[y][x]);
                point = max(point, dfs(ny, nx, n-1));
                swap(a[ny][nx], a[y][x]);
            }        
        }
    }
    return point;
}

int main()
{
    int n;
    while (cin >> n, n != -1) {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> a[i][j];
            }
        }
    
        for (int i = 0; i < 5; i++) {
            cin >> score[i];
        }

        int max_point = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                max_point = max(max_point, dfs(i, j, n));
            }
        }   
        cout << max_point << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll l,a,b,m,e,ans=0; cin>>l>>a>>b>>m;
    vector<ll> p(19,1);
    rep(i,18) p[i+1]=p[i]*10;
    e=a+b*(l-1);
    ll an=0,en=0,A=a,E=e;
    while(A>0){
        A/=10; an++;
    }
    while(E>0){
        E/=10; en++;
    }
    ll cur=l-1,c=1;
    for(int i=en;i>=an;i--){
        ll num=1,d=(a%m+b%m*(cur%m))%m,ad=b%m,mul=p[i]%m;
        if(i==an) num-=(a+b-(a%b)+b-1)/b;
        else num-=(p[i-1]+b-(a%b)+b-1)/b;
        if(i==en) num+=(e+b-(a%b))/b;
        else num+=(p[i]-1+b-(a%b))/b;
        rep(j,64){
            if(num&(1LL<<j)){
                ans=(ans+(c*d)%m)%m;
                c=c*mul%m;
                d=(m+d-ad)%m;
            }
            d=(m+d-ad)*mul%m+d;
            d%=m;
            ad=(mul+1)*ad%m*2%m;
            mul=mul*mul%m;
        }
        cur-=num;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
	/*input*/
	string s;
	string t;
	cin >> s >> t;
	/*calculation*/
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	bool flag = false;	//true:Yes false:No
	(s < t)?flag = true:flag = false;
	/*output*/
	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int N,M;
int edge[28][2];

void solve(void);
int search(int node,int *state);

int main(void){
  int i;
  scanf("%d%d",&N,&M);
  for(i=0;i<M;i++){
    scanf("%d%d",&edge[i][0],&edge[i][1]);
  }
  solve();
  return 0;
}

void solve(void){
  int array[8]={0};
  printf("%d\n",search(1,array));
}

int search(int node,int *state){
  int i,j,k;
  int ret=0;
  //printf("start node=%d\n",node);
  if(state[node-1]!=0) return 0;

  state[node-1]=1;
  for(i=k=0;i<N;i++) k+=state[i];
  if(k==N){
    state[node-1]=0;
    return 1;
  }
  
  for(i=0;i<M;i++){
    if(edge[i][0]!=node && edge[i][1]!=node) continue;
    k=edge[i][0]+edge[i][1]-node;
    //printf("\t in %d\n",k);
    ret+=search(k,state);
  }
  state[node-1]=0;
  return ret;
}


Measured memory_bytes: 128
import java.util.Scanner;

import java.util.InputMismatchException;

public class Main{
    public static void main(String args[]){
        int time[] = new int[5];

        try{
            Scanner scanner = new Scanner(System.in);
            for(int i = 0; i < time.length; i++){
                time[i] = scanner.nextInt();
            }
            scanner.close();
        } catch(InputMismatchException e){
            System.out.println(e);
        }

        int extraTimes[] = new int[5];
        int tenTimes[] = new int[5];
        int extraTimesMin = 10;
        int minIndex = 0;
        for(int i = 0; i < extraTimes.length; i++){
            extraTimes[i] = time[i] % 10;
            tenTimes[i] = time[i] / 10;
            if(extraTimes[i] < extraTimesMin && extraTimes[i] != 0){
                extraTimesMin = extraTimes[i];
                minIndex = i;
            }
        }

        int totalTime = 0;
        for(int i = 0; i < time.length; i++){
            if(i != minIndex){
                totalTime += tenTimes[i] * 10;
                if(extraTimes[i] != 0){
                    totalTime += 10;
                }
            }
        }
        totalTime += time[minIndex];
        System.out.println(totalTime);
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> iP;
typedef pair< LL, LL > LP;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 300005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a, b;
    cin >> a >> b;
    b <<= 1;
    cout << max( 0, a - b ) << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
vector<int>num(n,0);
  
for(int i=1;i<100;i++){
for(int j=1;j<100;j++){
for(int k=1;k<100;k++){
int suuzi =i*i + j*j + k*k + i*j + j*k + k*i ;
if(suuzi<=n)
num.at(suuzi - 1)+=1;

}
}
}
for(int i=0;i<n;i++){
cout << num.at(i)<<endl;
} 
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, W;
ll w[105], v[105], DP[105][int(1e5+5)];

int main(){
  cin >> N >> W;
  for (int i = 1; i <= N; i++){
    cin >> w[i] >> v[i];
  }

  for (int i = 1; i <= N; i++){
    for (int j = 0; j <= W; j++){
      DP[i][j] = DP[i-1][j];
    }
    for (int j = 0; j + w[i] <= W; j++){
      DP[i][j+w[i]] = max(DP[i][j+w[i]], DP[i-1][j] + v[i]);
    }
    for (int j = 1; j <= W; j++){
      DP[i][j] = max(DP[i][j], DP[i][j-1]);
    }
  }
  cout << DP[N][W] << endl;

  return 0;
}


Measured memory_bytes: 81656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int H[] = CPUtils.readIntArray(N, in);

            int dp[] = new int[N];
            Arrays.fill(dp, Integer.MAX_VALUE);
            dp[0] = 0;

            for (int i = 1; i < N; i++)
            {
                for (int j = 1; j <= 2; j++)
                {
                    if (i >= j)
                    {
                        dp[i] = Math.min(dp[i], dp[i - j] + (Math.abs(H[i - j] - H[i])));
                    }
                }
            }
            out.print(dp[N - 1]);
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 49796
import sys

readline = sys.stdin.readline

def main():
    H, W = map(int, readline().split())
    N = int(readline())
    a = list(map(int, readline().split()))

    ans = [[0] * W for _ in range(H)]
    h = 0; w = 0
    popflag = True
    backflag = False
    for _ in range(H*W):
        if popflag:
            tmp = a.pop()
            tmplist = [len(a)+1]*tmp
            popflag = False
        if backflag:
            ans[h][w] = tmplist.pop()
            if w-1 == -1:
                backflag = False
                h += 1
            else:
                w -= 1
        else:
            ans[h][w] = tmplist.pop()
            if w+1 == W:
                backflag = True
                h += 1
            else:
                w += 1
        if len(tmplist) == 0:
            popflag = True
    
    for i in range(H):
        print(*ans[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  (a:b:c:d:_) <- getLine
  putStrLn $ if b == c && (a == b || c == d) then "Yes" else "No"

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 508
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read.ToArray();
            var ans = S[2] == S[3] && S[4] == S[5];

            WriteLine(ans ? "Yes":"No");
        }

        public void Display(int[] array)
        {
            var txt = "";
            foreach (var item in array)
            {
                txt += " " + item.ToString();
            }
            WriteLine("{0}", txt);
        }

        public void Display(int index,int[] array)
        {
            var txt = "";
            foreach (var item in array)
            {
                txt += " " + item.ToString();
            }
            WriteLine("{0} : {1}", index,txt);
        }

        public void Display(List<int>[] list) 
        {
            for (int i = 0; i < list.Length; i++)
            {
                Display(i, list[i].ToArray());
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 26504
sx, sy, tx, ty = map(int, input().split())

res = []
for i in range(abs(ty - sy)):
    res.append("U")
for i in range(abs(tx - sx)):
    res.append("R")
for i in range(abs(sy - ty)):
    res.append("D")
for i in range(abs(tx - sx) + 1):
    res.append("L")
for i in range(abs(ty - sy) + 1):
    res.append("U")
for i in range(abs(tx - sx) + 1):
    res.append("R")
res.append("D")
res.append("R")
for i in range(abs(ty - sy) + 1):
    res.append("D")
for i in range(abs(tx - sx) + 1):
    res.append("L")
res.append("U")
print("".join(res))

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
long a,b,c,d,k,max;
scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
max=0;
if(a*c>=a*d)
{
  max=a*c;
}
else
{
  max=a*d;
}
if(b*c>=b*d)
{
  k=b*c;
}
else
{
  k=b*d;
}
if(max>=k)
{
  printf("%ld",max);
}
else
{
  printf("%ld",k);
}
return 0;
}

Measured memory_bytes: 1736
package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
    s := strings.Split(sc.Text(), " ")
    a, _ := strconv.Atoi(s[0])
    b, _ := strconv.Atoi(s[1])
    c, _ := strconv.Atoi(s[2])
    
    if b / a < c {
    	fmt.Printf("%d", b / a)
    } else {
    	fmt.Printf("%d", c)
    }      
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> sum(N);
    ll a;
    rep(0, i, N)
    {
        cin >> a;
        if (i == 0)
        {
            sum.at(i) = a;
        }
        else
        {
            sum.at(i) = sum.at(i - 1) + a;
        }
    }

    ll ans = 10000000000000000;
    rep(0, i, N - 1)
    {
        ans = min(ans, abs(2 * sum.at(i) - sum.at(N - 1)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4832
N=int(input())

A=list(map(int,input().split()))
answer=0

for i in range(N):
  if A[i]==i+1:
    if i!=N-1 and A[i+1]!=i+1:
      A[i],A[i+1]=A[i+1],A[i]
      answer+=1
    else:
      A[i],A[i-1]=A[i-1],A[i]
      answer+=1
print(answer)

Measured memory_bytes: 14008
import Control.Applicative
import Control.Monad
import Data.List
import Data.Map.Strict (Map, (!))
import qualified Data.Map.Strict as M

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n
    main

solve :: Int -> IO ()
solve n = do
  getLine
  (s, ls) <- getpi
  let ibf = initBuf s
  let idb = M.insert s ls M.empty
  db <- foldM (\m _ -> do
                  (s, ls) <- getpi
                  return $ M.insert s ls m
              ) idb [1..n-1]
  nop <- readLn
  foldM_ (\b _ -> do
             cs <- words <$> getLine
             case cs of
              ["show"] -> do
                putStrLn $ showBuf b
                return b
              ["back"] -> do
                case backBuf b of
                 Just b' -> return b'
                 Nothing -> return b
              ["forward"] -> do
                case forwardBuf b of
                 Just b' -> return b'
                 Nothing -> return b
              ["click", scx, scy] -> do
                let cx = read scx
                    cy = read scy
                    cp = showBuf b
                case find (\(x1, y1, x2, y2, _) -> x1 <= cx && cx <= x2 && y1 <= cy && cy <= y2) (db ! cp) of
                 Just (_, _, _, _, np) -> return $ addBuf b np
                 Nothing -> return b
              _ -> return b
         ) ibf [1..nop]

getpi :: IO (String, [(Int, Int, Int, Int, String)])
getpi = do
  [np, snbt] <- words <$> getLine
  let nbt = read snbt
  lip <- replicateM nbt $ do
    [sx1, sy1, sx2, sy2, nlp] <- words <$> getLine
    let x1 = read sx1
        y1 = read sy1
        x2 = read sx2
        y2 = read sy2
    return (x1, y1, x2, y2, nlp)
  return (np, lip)

type Buf = ([String], [String])

initBuf :: String -> Buf
initBuf s = ([s], [])

addBuf :: Buf -> String -> Buf
addBuf (as, _) s = (s:as, [])

forwardBuf :: Buf -> Maybe Buf
forwardBuf (_,[]) = Nothing
forwardBuf (as, b:bs) = Just (b:as, bs)

backBuf :: Buf -> Maybe Buf
backBuf ([_],_) = Nothing
backBuf (a:as, bs) = Just (as, a:bs)

showBuf :: Buf -> String
showBuf (a:_, _) = a



Measured memory_bytes: 4512
#include<stdio.h>
#include<math.h>
typedef struct{
  double x,y;
}Point;
void kock(int,Point,Point);
int main(){
  Point p1,p2;
  int n;
  scanf("%d",&n);
  p1.x=0.0;
  p1.y=0.0;
  p2.x=100.0;
  p2.y=0.0;
   printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n,p1,p2);
   printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}

void kock(int n,Point p1,Point p2){
  Point s,u,t;
  double angle = M_PI * 60.0 /180.0;
  if(n==0)return;
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3;
  u.x = (t.x - s.x)*cos(angle)-(t.y - s.y)*sin(angle)+s.x;
  u.y = (t.x - s.x)*sin(angle)+(t.y - s.y)*cos(angle)+s.y;
  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1,t,p2);
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a[30]={};
  for(int i=0,k;i<28;i++){
    cin>>k;
    a[k-1]=1;
  }
  for(int i=0;i<30;i++){
    if(!a[i]) cout<<i+1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3084