akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll INF = (ll)1e16;
int N;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    vll a(3 * N), ma(3 * N, -INF), mi(3 * N, +INF);
    rep(i, 3*N)cin >> a[i];

    {
        priority_queue<ll, vector<ll>, greater<ll> > q;
        ll sm = 0;
        rep(i, 3 * N) {
            if (sz(q) < N) {
                sm += a[i];
                q.push(a[i]);
            } else {
                ll b = q.top();
                if (b < a[i]) {
                    sm += a[i] - b;
                    q.pop();
                    q.push(a[i]);
                }
                
            }
            if (sz(q) == N)ma[i] = sm;
        }
    }

    {
        priority_queue<ll> q;
        ll sm = 0;
        for (int i = 3 * N - 1; i >= 0; --i) {
            if (sz(q) < N) {
                sm += a[i];
                q.push(a[i]);
            } else {
                ll b = q.top();
                if (b > a[i]) {
                    sm -= b - a[i];
                    q.pop();
                    q.push(a[i]);
                }
                
            }
            if (sz(q) == N)mi[i] = sm;
        }
    }

    ll ans = -INF;
    rep(i, 3 * N - 1) {
        smax(ans, ma[i] - mi[i + 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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 rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 105;
typedef v(string) vs;
const int di[] = {-1,0,1,0}, dj[] = {0,-1,0,1}; //^<v>
//const int di[] = {-1,0,1,-1,1,-1,0,1}, dj[] = {-1,-1,-1,0,0,1,1,1};

bool used[MX][MX];

int main() {
  int h,w;
  scanf("%d%d",&h,&w);
  vs s(h);
  cin>>s;
  deque<P> q;
  q.pb(P(0,0));
  vvi dist(h,vi(w,INF));
  dist[0][0] = 0;
  while (sz(q)) {
    int i = q.front().fi;
    int j = q.front().se;
    q.pop_front();
    if (used[i][j]) continue;
    used[i][j] = true;
    rep(v,4) {
      if (v < 2) continue;
      int ni = i+di[v], nj = j+dj[v];
      if (ni<0||nj<0||ni>=h||nj>=w) continue;
      int c = 0;
      if (s[ni][nj] != s[i][j]) c = 1;
      int nd = dist[i][j]+c;
      if (dist[ni][nj] <= nd) continue;
      dist[ni][nj] = nd;
      if (c == 0) q.emplace_front(ni,nj);
      else q.eb(ni,nj);
    }
  }
  int ans = dist[h-1][w-1];
  if (s[0][0] == '#') ++ans;
  if (s[h-1][w-1] == '#') ++ans;
  ans = dup(ans,2);
  cout<<ans<<endl;
  return 0;
}






















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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K, a[100];
ll ans[5050],mk;
vector<pll> av;
ll i,j,k;
int main(){
    scanf("%lld%lld", &N,&K);
    fornum(i,0,N){
        scanf("%lld", &a[i]);
    }
    mk = -1;
    fornum(i,0,K+1){
        pll minns = mp(99999,-1);
        fornum(j,0,N){
            if(mk!=j&&a[j]<minns.first){
                minns = mp(a[j],j);
            }
        }
        if(minns.first==0)
            break;
        
        fornum(j,0,N){
            if(j!=mk&&j!=minns.second){
                ans[k++] = j + 1;
                a[j]--;
            }
        }
        mk = minns.second;
        ans[k++]=mk+1;
        a[mk]--;
    }
    if(i!=K+1){
        printf("-1");
        return 0;
    }
    printf("%lld\n", k);
    fornum(i,0,k){
        printf("%lld ", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s = 0;
        int temp = n;
        while (n  > 0) {
           s += n % 10;
           n /= 10;
        }

        if (temp % s == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

Measured memory_bytes: 22484
///**Bismillahir Rahmanir Rahim.**

#include <bits/stdc++.h>
#define clr(a, v)             memset(a, v, sizeof a)
#define all(v)                v.begin(), v.end()
#define ast(v)                sort(v.begin(),v.end())
#define dst(v)                sort(v.begin(),v.end(), greater <int> ())
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ass(tmp, v)           tmp.assign(v.begin(), v.end())
#define rep(i, l, r)          for (int i = l; i < r; i++)
#define rep2(i, l, r)         for (int i = l-1; i >= r; i--)
#define sf(n)                 scanf("%d", &n)
#define sff(n, m)             scanf("%d %d",&n,&m)
#define sfl(n)                scanf("%lld", &n)
#define sfu(n)                scanf("%llu", &n)
#define sffl(n, m)            scanf("%lld %lld",&n,&m)
#define sfff(n, m, o)         scanf("%d %d %d",&n,&m, &o)
#define pf(n)                 printf("%d", n)
#define sp                    printf(" ")
#define nl                    printf("\n")
#define prln(n)               printf("%d\n", n)
#define pfl(n)                printf("%lld", n)
#define pfu(n)                printf("%llu", n)
#define pb                    push_back
#define pii                   pair<int,int>
#define mp                    make_pair
#define S                     second
#define F                     first
#define PI                    3.1415926

struct greaters
{
    bool operator()(const long& a, const long& b) const
    {
        return a > b;
    }
};

//-----------------------------------***********************----------------------------------------------//


typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int N = 200050;
const int mod = 1e9+7;


int main()
{
    //freopen("test.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;
    int tcase = 1, cas = 0;
    while(tcase--)
    {
        int m, d;
        cin >> m >> d;

        int cnt = 0;
        for(int i = 22; i <= d; i++)
        {
            int x = i;
            int a = x%10;
            x /= 10;
            int b = x%10;
            if(a >= 2 and b >= 2 and (a*b) <= m)
                cnt++;
        }
        cout << cnt;

        //printf("Case %d: %lld\n", ++cas, ans);
    }


    return 0;

}

//-----------------------------------***********************----------------------------------------------//



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_071
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] array = ReadLongs();
            var dict = new Dictionary<long, bool>();
            var pairList = new List<long>();
            for(int i = 0; i < n; i++)
            {
                if (dict.ContainsKey(array[i]))
                {
                    pairList.Add(array[i]);
                    dict.Remove(array[i]);
                }
                else
                {
                    dict.Add(array[i], true);
                }
            }
            pairList.Sort();
            if (pairList.Count < 2)
            {
                Console.Write(0);
            }
            else
            {
                Console.Write(pairList[pairList.Count - 1]
                    * pairList[pairList.Count - 2]);
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 24416
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}


const int MAX = 1000100;
const int INF = 1<<29;

int adp[MAX], odp[MAX];

int main() {
    for (int i = 0; i < MAX; ++i) adp[i] = odp[i] = MAX;
    adp[0] = 0;
    odp[0] = 0;
    
    for (int i = 1;; ++i) {
        int num = i * (i+1) * (i+2) / 6;
        if (num >= MAX) break;
    
        for (int j = num; j < MAX; ++j) {
            adp[j] = min(adp[j], adp[j-num]+1);
            if (num & 1) odp[j] = min(odp[j], odp[j-num]+1);
        }
    }
    
    int n;
    while (scanf("%d", &n)) {
        if (n == 0) break;
        printf("%d %d\n", adp[n], odp[n]);
    }
        
    return 0;
}


Measured memory_bytes: 9000
/**
     *      ABC 59 A
     *      author  : kyomukyomupurin
     *      created : 2018-09-05 02:14:26
    **/
     
    #include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        
        string s1, s2, s3; cin >> s1 >> s2 >> s3;
        transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
        transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
        transform(s3.begin(), s3.end(), s3.begin(), ::toupper);
        cout << s1[0] << s2[0] << s3[0] << endl;
     
        return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<iterator>
#include<map>
#include<queue>
#include<string.h>
#define maxn 100005
using namespace std;
int main()
{
	int n,k,temp;
	multiset<int>num;
	while(scanf("%d%d",&n,&k)!=EOF)
	{
		int ans=0;
		while(n--)
		{
			cin>>temp;
			num.insert(num.begin(),temp);
		}
		multiset<int>::reverse_iterator it;
		for(it=num.rbegin();k>0;k--)
		ans+=*it++;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 1;
  if(a != b){
    ans += 1;
  }
  if(c != b && c != a){
    ans += 1;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	ll ans=a+b+c;
	ans-=max({a,b,c});
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    int H[N];

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

    int ans = 1;
    
    for(int i = 1; i < N; i++) {
        int j;

        for(j = 0; j < i; j++) {
            if(H[i] < H[j]) {
                break;
            }
        } 

        if(j == i) {
            ans++;
        }
    }

    cout << ans;
    
    cout << endl;
    return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

int A, B, C;
int func(vector<int> l, int i, int a, int b, int c, int cost)
{
    if (i == l.size()) {
	if (a == 0 || b == 0 || c == 0)
	    return INF;
	else
	    return cost + (abs(A - a) + abs(B - b) + abs(C - c));
    }

    return min({func(l, i+1, a, b, c, cost),
		func(l, i+1, a+l[i], b, c, (a == 0) ? cost : cost+10),
		func(l, i+1, a, b+l[i], c, (b == 0) ? cost : cost+10),
		func(l, i+1, a, b, c+l[i], (c == 0) ? cost : cost+10)});
}


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

    int n;
    cin >> n >> A >> B >> C;

    vector<int> l(n);
    rep (i, 0, n)
	cin >> l[i];

    int res = func(l, 0, 0, 0, 0, 0);
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	fmt.Println(abc049c(s))
}

func abc049c(s string) string {
	s = reverse(s)
	s = strings.Replace(s, "resare", "", -1)
	s = strings.Replace(s, "esare", "", -1)
	s = strings.Replace(s, "remaerd", "", -1)
	s = strings.Replace(s, "maerd", "", -1)

	if len(s) == 0 {
		return "YES"
	} else {
		return "NO"
	}
}

func reverse(s string) string {
	var res string
	for i := len(s) - 1; i >= 0; i-- {
		res += string(s[i])
	}
	return res
}



Measured memory_bytes: 11904
if __name__ == "__main__":
    N = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    moncnt = 0
    for i in range(N):
        if a[i] < b[i]:
            moncnt += min(b[i],a[i])
            b[i] -= a[i]
            if b[i] < 0:
                b[i] = 0
            moncnt += min(a[i+1],b[i])
            a[i+1] -= min(a[i+1],b[i])
        else:
            moncnt += b[i]
    print(moncnt)

Measured memory_bytes: 19156
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll extgcd(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = (a >= 0) ? 1 : -1;
		y = 0;
		return abs(a);
	}
	else {
		ll res = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
		return res;
	}
}

ll mod_inverse(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

ll f[200001], fi[200001];

ll C(int N, int K) {
	return f[N] * fi[K] % MOD * fi[N - K] % MOD;
}

int main() {
	f[0] = fi[0] = 1;
	for (int i = 1; i <= 200000; i++) {
		f[i] = f[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * mod_inverse(i, MOD) % MOD;
	}
	int H, W; cin >> H >> W;
	int A, B; cin >> A >> B;
	ll ans = C(H + W - 2, H - 1);
	for (int x = 0; x < B; x++)
		ans = (ans - C(H - A - 1 + x, x) * C(A - 1 + W - x - 1, W - x - 1)) % MOD;
	cout << (ans + MOD) % MOD << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int n; cin >> n;
        vector<int> v(n);
        lp(i, n) cin>> v[i];
        sort(all(v));
        reverse(all(v));
        int an = v[0];
        int k= n- 2, j= 1;
        while (k) {
                if (k>= 2) {
                        an+= v[j]* 2;
                        k-= 2;
                } else {
                        an+= v[j];
                        k-= 1;
                }
                j++;
        }
        cout << an<< "\n";
}

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


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> S(h);
	rep(i, h) cin >> S[i];
	int ans = inf;
	for (int bit = 0; bit < (1 << h - 1); ++bit) {
		int tmp = 0;
		rep(i,h-1)if(bit&(1<<i)) tmp++;
		vector<int> sum(tmp + 1, 0);
		int cnt_w = 0;
		bool elf = true;

		rep(i, w) {
			int now = 0;
			vector<int> res(tmp + 1, 0);
			rep(j, h) {
				if (S[j][i] == '1') res[now]++;
				if (bit & (1 << j)) now++;
			}
			rep(j, tmp + 1) {
				if (res[j] > k) elf = false;
				if (sum[j] + res[j] > k) {
					cnt_w++;
					rep(k, tmp + 1) {
						sum[k] = res[k];
					}
					break;
				}
				else {
					sum[j] += res[j];
				}
			}
		}
		if (elf) {
			ans = min(ans, cnt_w + tmp);
		}
	}
	dunk(ans);
	return 0;
 }


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

int N,A,B,C;
int l[9];

int dfs(int cur,int a,int b,int c){
  
  if (cur == N) {
    if (a == 0 || b == 0 || c == 0) {
      return 10e5;
    }
    return abs(A-a) + abs(B-b) + abs(C-c) - 30;
  }
  int r1 = dfs(cur+1, a+l[cur+1], b,          c) + 10;
  int r2 = dfs(cur+1, a,          b+l[cur+1], c) + 10;
  int r3 = dfs(cur+1, a,          b,          c+l[cur+1]) + 10;
  int r4 = dfs(cur+1, a,          b,          c);
  return min(min(r1, r2), min(r3, r4));
}

int main(int argc, char const* argv[])
{
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    cin >> l[i+1];
  }
  int ans = dfs(0,0,0,0);
  cout << ans << endl;
  return 0;
}


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

#define int long long

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

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

int N;
int A[222222];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    int sum=accumulate(A,A+N,0ll);

    int ans=LLONG_MAX;

    int sum2=0;
    rep(i,N-1){
        sum2+=A[i];
        sum-=A[i];
        chmin(ans,abs(sum-sum2));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
n,k = map(int,input().split())
s=list(input())
if s[k-1]=="A":
  s[k-1]=str("a")
elif s[k-1]=="B":
  s[k-1]=str("b")
else:
  s[k-1]=str("c")

mojiretu = ''.join(s)
    
print(mojiretu)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B&lang=ja

using Graph = vector<vector<int>>;
vector<bool> seen;
int STS[105];
int EDS[105];
int s = 0;

static void dfs(const Graph &G, int v) {
    seen[v] = true;

    STS[v] = ++s;
    
    for (auto t : G[v]) {
        if (seen[t]) continue;
        dfs(G, t);
    }

    EDS[v] = ++s;
}

int main() {
    int n; cin >> n;
    Graph G(n+1);
    REP(i, n) {
        int u, k; cin >> u >> k;
        REP(i, k) {
            int v; cin >> v;
            G[u].push_back(v);
        }
    }

    seen.assign(n, false);

    for (int i = 1; i <= n; i++) {
        if (!seen[i]) {
            dfs(G, i);
        }
    }


    REP(i, n) {
        cout << i+1 << " " << STS[i+1] << " " << EDS[i+1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
 
const int maxn = 1e3 + 20;
int vis[maxn],n;
double x[maxn],y[maxn],r[maxn],dist[maxn],mp[maxn][maxn];
 
void SPFA(int s)
{
    queue<int>q;
    for(int i = 1;i <= n;i++) dist[i] = 1e10;
    memset(vis,0,sizeof(vis));
    while(!q.empty()) q.pop();
    dist[s] = 0;
    vis[s] = 1;
    q.push(s);
 
    while(!q.empty())
    {
        int v = q.front();
        q.pop();
        vis[v] = 0;
        for(int i = 1;i <= n;i++)
        {
            if(dist[i] > dist[v] + mp[v][i])
            {
                dist[i] = dist[v] + mp[v][i];
                if(!vis[i])
                {
                    vis[i] = 1;
                    q.push(i);
                }
            }
        }
    }
}
 
int main()
{
    while(scanf("%lf%lf%lf%lf",&x[1],&y[1],&x[2],&y[2]) != EOF)
    {
        scanf("%d",&n);
        n += 2;
        r[1] = r[2] = 0;
        mp[1][2] = mp[2][1] = sqrt((x[1] - x[2]) * (x[1] - x[2]) + (y[1] - y[2]) * (y[1] - y[2]));
        for(int i = 3;i <= n;i++)
        {
            scanf("%lf%lf%lf",&x[i],&y[i],&r[i]);
        }
        for(int i = 1;i <= n;i++)
        {
            for(int j = 1;j <= n;j++)
            {
                mp[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
                mp[i][j] -= r[i] + r[j];
                if(mp[i][j] < 0)
                {
                    mp[i][j] = 0;
                }
            }
        }
        SPFA(1);
        printf("%.10f\n",dist[2]);
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, n - 1)
    {
        if (s[i] != s[i + 1])
            ans++;
    }
    ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	string S;
	cin >> N >> S;
	int ret = 0;
	for(int i = 0;i < N;i++) {
		string A = S.substr(0,i + 1);
		string B = S.substr(i + 1,S.size() - i - 1);
		int ret2 = 0;
		for(int j = 0;j < 26;j++) {
			bool Acount = false;
			bool Bcount = false;
			for(int k = 0;k < A.size();k++) {
				if(A.at(k) == 'a' + j) {
					Acount = true;
				}
			}
			for(int k = 0;k < B.size();k++) {
				if(B.at(k) == 'a' + j) {
					Bcount = true;
				}
			}
			if(Acount == true && Bcount == true) {
				ret2++;
			}
		}
		ret = max(ret,ret2);
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
    int n,x;cin >> n >> x;
    if(x==1||x==2*n-1) cout << "No" << endl;
    else{
        vector<int> a(2*n-1);
        iota(a.begin(),a.end(),1);
        swap(a[n-1],a[x-1]);
        if(a[n-1]<a[n-2]&&a[n-1]<a[n]) swap(a[0],a[n-2]);
		else if(a[n-1]>a[n-2]&&a[n-1]>a[n]) swap(a[n],a[2*n-2]);
        cout << "Yes" << endl;
        for(auto &i:a) cout << i << endl;
    }
}

Measured memory_bytes: 2304
from collections import deque
q = deque(list(input()))
n = int(input())
han = 0
zengo = 0
for i in range(n):
    a = input().split()
    # print(a[1])
    if len(a)==1:
        zengo ^=1
        han += 1
    else:
        a[1] = int(a[1])-1
        if a[1] == 0:
            if zengo == 0:#0
                q.appendleft(a[2])
            else:#0
                q.append(a[2])
        else:#1
            if zengo == 0:
                q.append(a[2])
            else:
                q.appendleft(a[2])
q = list(q)
if han >2 and han%2 :
    q.reverse()
print("".join(q))


Measured memory_bytes: 8548
program prob1
    implicit none
    integer(8) :: a, b, k, i
    read(*,*) a, b, k
    do i = 1, k
        if(mod(i, 2) == 1)then
            if(mod(a, 2) == 1)then
                a = a - 1
            end if
            b = b + a / 2
            a = a / 2
        else
            if(mod(b, 2) == 1)then
                b = b - 1
            end if
            a = a + b / 2
            b = b / 2
        end if
    end do
    write(*,*) a, b

    stop
contains
end program prob1

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

int main(){
    int D, G; cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i = 0; i < D; i++) cin >> p[i] >> c[i];
    int res = 1e5;
    for(int i = 0; i < 1 << D; i++){
        int score = 0;
        int num = 0;

        for(int j = 0; j < D; j++){
            if(i >> j & 1){
                num += p[j];
                score += p[j] * (j + 1) * 100 + c[j];
            }
        }
        //cout << "i " << i << " score " << score << " num " << num << endl; 
        if(score < G){
            for(int j = D - 1; j >= 0; j--){
                if(!(i >> j & 1)){
                    if(score + p[j] * (j + 1) * 100 + c[j] >= G){
                        if((G - score) / (j + 1) / 100 >= p[j]) num += p[j];
                        else num += ceil((double)(G - score)/ (j+1) / 100.0);
                        break;
                    }else{
                        num += p[j];
                        score += p[j] * (j + 1) * 100 + c[j];
                    }
                }
            }
        }
        res = min(res, num);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
//#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int par[10004];
int rnk[10004];

void init(int n){
  rep(i,n){
    par[i]=i;
    rnk[i]=0;
  }
}

int find(int x){
  if(par[x]==x)return x;
  else return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rnk[x]<rnk[y])par[x]=y;
  else{
    par[y]=x;
    if(rnk[x]==rnk[y])rnk[x]++;
  }
}

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

signed main(){
  int n,q;
  cin>>n>>q;
  init(n);
  rep(i,q){
    int com,x,y;
    cin>>com>>x>>y;
    if(com){
      cout<<same(x,y)<<endl;
    }else{
      unite(x,y);
    }
  }
  return 0;
}

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

int main(){
    int n,m;
    cin>>m>>n;
    char **arr=new char*[m];
    for(int i=0;i<m;i++)    arr[i]=new char[n];

    long long **path=new long long*[m];
    for(int i=0;i<m;i++)    path[i]=new long long[n];

    for(int i=0;i<m;i++){
        string s;
        cin>>s;
        for(int j=0;j<n;j++){
            arr[i][j]=s[j];
            path[i][j]=0;
        }
    }

    path[0][0]=1;

    for(int i=1;i<m;i++){
        if(arr[i][0]=='.') path[i][0]=path[i-1][0];
    }

    for(int i=1;i<n;i++){
        if(arr[0][i]=='.') path[0][i]=path[0][i-1];
    }

    for(int i=1;i<m;i++){
        for(int j=1;j<n;j++){
            if(arr[i][j]=='.'){
                path[i][j]=((path[i-1][j]%MOD)+(path[i][j-1]%MOD))%MOD;
            }
        }
    }

    cout<<path[m-1][n-1];
    return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	string s;
	cin >> s;
	string res="";
	for(int i=0;i<s.size();i++){
		if(s[i]=='?'){
			res+='D';
		}else{
			res+=s[i];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3920
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut a: Vec<usize> = vec![0; n];
    let mut xy: Vec<Vec<(usize, i32)>> = vec![vec![]; n];
    for i in 0..n {
        a[i] = read();
        for _ in 0..a[i] {
            let x: usize = read();
            let y: i32 = read();
            xy[i].push((x, y));
        }
    }

    let mut ans = 0;
    for i in 0..(1 << n) {
        let mut syojiki: Vec<i32> = vec![-1; n]; // 1:正直 0:不親切 -1:未定
        let mut mujun = false;
        for j in 0..n {
            let singi = 1 & (i >> j);
            if singi == 0 {
                if syojiki[j] == 1 {
                    mujun = true;
                    break;
                }
                syojiki[j] = 0;
                continue;
            }
            if syojiki[j] == 0 {
                mujun = true;
                break;
            }
            syojiki[j] = 1;
            for &(x, y) in &xy[j] {
                if (y == 1 && syojiki[x-1] == 0) || (y == 0 && syojiki[x-1] == 1) {
                    mujun = true;
                    break;
                }
                syojiki[x-1] = y;
            }
            if mujun {
                break;
            }
        }
        let mut cnt = 0;
        if !mujun {
            for j in 0..n {
                if syojiki[j] == 1 {
                    cnt += 1;
                }
            }
        }
        ans = std::cmp::max(ans, cnt);
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t A, B;
int a, b, c;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	in >> A >> B;
	out << (N - A + 1)*(N - B + 1) << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>

using namespace std;

using VVI = vector<vector<int>>;
using PII = pair<int, int>;

void show(VVI &vv) {
	for (int i = 0; i < vv.size(); i++) {
		printf("%2d: ", i);
		for (auto x: vv[i]) {
			printf(" %2d", x);
		}
		printf("\n");
	}
}


int main() {
	int n, m, s, t, u, v;
	cin >> n >> m;

	VVI ken(n);

	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		u--;
		v--;

		ken[u].emplace_back(v);
	}
	cin >> s >> t;
	s--;
	t--;


	// cout << "----- ken" << endl;
	// show(ken);

	VVI dist(n, vector<int>(3, -1));
	queue<PII> que;
	que.push(make_pair(s, 0));
	dist[s][0] = 0;

	while (!que.empty()) {
		auto p = que.front();
		que.pop();

		int pos = p.first;
		int val = p.second;
		int val2 = val + 1;

		for (auto x: ken[pos]) {
			if (dist[x][val2 % 3] == -1) {
				dist[x][val2 % 3] = val2;

				if (x == t && val2 % 3 == 0) {
					cout << dist[x][0] / 3 << endl;
					return 0;
				}

				que.push(make_pair(x, val2));
			}
		}
	}

	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, M;
    cin >> N >> M;
    map<int64_t, int64_t> m;
    int64_t last = 0;
    m[0] = 1;
    for(int i = 0; i < N; i++) {
        int64_t tmp;
        cin >> tmp;
        last = (last + tmp) % M;
        if(m.count(last) == 0) {
            m[last] = 0;
        }
        m[last]++;
    }
    int64_t ans = 0;
    for(auto i = m.begin(); i != m.end(); i++) {
        ans += (i->second * (i->second - 1) ) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>

using namespace std;


int main(){
  int n,Y,M,D,total;
  cin >> n;
  while(n-- > 0){
    total = 0;
    cin >> Y >> M >> D;
    while(!(Y==1000 && M ==1 && D== 1)){

 	D++;
	total++;
      if(Y%3 == 0){
	if(D == 21){
	  D = 1;
	  M++;
	  if(M==11){
	    M=1;
	    Y++;
	  }
	}
      }else{
	if(M%2 == 1){
	  if(D == 21){
	    D = 1;
	    M++;
	    if(M == 11){
	      M=1;
	      Y++;
	    }
	  }
	}
	else{       
	  if(D == 20){
	    D=1;
	    M++;
	    if(M == 11){
	      M=1;
	      Y++;
	    }
	  }

	}//fin else

      }

    }
    cout <<  total << endl;
  }
  return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int n;
int solve(vector<int> a){
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i!=j){
				ans=max(ans,abs(a[j]-a[i]));
			}
		}
	}
	return ans;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.push_back(x);
	}
	cout<<solve(a)<<endl;
	return 0;
}

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

 using namespace std;

 static const int MMAX = 20;
 static const int NMAX = 50000;
 static const int INFTY = (1 << 29);

 main() {
     int n, m;
     int C[21];
     int T[NMAX + 1];
    
     cin >> n >> m;
    
     for ( int i = 1; i <= m; i++ ) {
       cin >> C[i];
       }
    
     for ( int i = 0; i <= NMAX; i++ ) T[i] = INFTY;
     T[0] = 0;
     for ( int i = 1; i <= m; i++ ) {
         for ( int j = 0; j + C[i] <= n; j++ ) {
             T[j + C[i]] = min(T[j + C[i]], T[j] + 1 );
             }
         }
    
     cout << T[n] << endl;
    
     return 0;
     }


Measured memory_bytes: 3300
#include <algorithm>
#include <iostream>
#include <deque>
#include <vector>

using namespace std;

typedef long long ll;

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

int main(void) {
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    deque<char> deq;
    for (int i = 0; i < (int) S.size(); i++) {
        deq.push_front(S[i]);
    }

    int direction = 1;

    for (int i = 0; i < Q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            direction *= -1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (direction == 1) {
                if (f == 1) {
                    // add top
                    deq.push_back(c);
                } else {
                    // add back
                    deq.push_front(c);
                }
            } else {
                if (f == 1) {
                    // add top
                    deq.push_front(c);
                } else {
                    // add back
                    deq.push_back(c);
                }
            }
        }
    }

    if (direction > 0) {
        for (int i = deq.size() - 1; i >= 0; i--) {
            printf("%c", deq[i]);
        }
    } else {
        for (int i = 0; i < (int) deq.size(); i++) {
            printf("%c", deq[i]);
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, m;

void sitA(string& s) {
  for (int i = 0; i < n; i++) {
    if (s[i] != '#') continue;
    s[i] = 'A';
    return;
  }
}

void sitB(string& s) {
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] != '#') continue;
    if (i - 1 >= 0 && s[i - 1] == 'A') continue;
    if (i + 1 < n && s[i + 1] == 'A') continue;
    s[i] = 'B';
    return;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != '#') continue;
    s[i] = 'B';
    return;
  }
}

void sitC(string& s) {
  for (int i = 0; i < n; i++) {
    if (s[i] == '#') continue;
    if (i + 1 < n && s[i + 1] == '#') {
      s[i + 1] = 'C';
      return;
    }
    if (i - 1 >= 0 && s[i - 1] == '#') {
      s[i - 1] = 'C';
      return;
    }
  }
  if (n & 1) s[(n + 1) / 2 - 1] = 'C';
  else s[n / 2] = 'C';
}

void sitD(string& s) {
  bool none = true;
  for (int i = 0; i < n; i++) {
    none &= s[i] == '#';
  }
  if (none) {
    s[0] = 'D';
    return;
  }
  vector<int> diff(n, 0);
  int diff_max = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != '#') continue;
    int l = i, r = i;
    while (l >= 0 && s[l] == '#') l--;
    if (l < 0) l = -1000;
    while (r < n && s[r] == '#') r++;
    if (r >= n) r = 1000;
    diff[i] = min(i - l, r - i);
    diff_max = max(diff_max, diff[i]);
  }
  for (int i = 0; i < n; i++) {
    if (diff[i] != diff_max) continue;
    s[i] = 'D';
    return;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n >> m, n) {
    string ans = string(n, '#');
    for (int i = 0; i < m; i++) {
      char ch;
      cin >> ch;
      if (ch == 'A') sitA(ans);
      if (ch == 'B') sitB(ans);
      if (ch == 'C') sitC(ans);
      if (ch == 'D') sitD(ans);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3172
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
  int count5 = 0;
  int count7 = 0;
  int a;
  for(int i = 0; i < 3; i++){
    cin >> a;
    if(a == 5) count5++;
    else if(a == 7) count7++;
    else break;
  }

  if(count5 == 2 && count7 == 1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

Measured memory_bytes: 61788
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const ll MOD = 1000000007;
 
using namespace std;

int main(){
    int N;  cin >> N;
    int t, x, y, lx, ly, lt, tmp;
    lx = 0;
    ly = 0;
    lt = 0;
    for(int i=0; i<N; i++){
        cin >> t >> x >> y;
        tmp = abs(x-lx) + abs(y-ly);
        if(tmp > t-lt){
            cout << "No";
            return 0;
        }else if(tmp%2 != (t-lt)%2){
            cout << "No";
            return 0;
        }else{
            lx = x;
            ly = y;
            lt = t;
        }
    }
    cout << "Yes";
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int rcnt = 0;
  int lcnt = 0;
  int pos = 0;
  int ans[n];
  for(int i=0;i<n;i++){
    ans[i] = 0;
  }

  for(int i=0;i<n;i++){
    if(s[i] == 'R'){
      if(lcnt != 0){
        if(lcnt % 2 == 0){
        ans[pos]+= (lcnt / 2);
        ans[pos-1]+= (lcnt / 2);
        pos=0;lcnt=0;
        }else{
           ans[pos] += ((lcnt-1) / 2); 
           ans[pos-1] += 1 + ((lcnt-1) / 2);
           pos=0;lcnt=0;
        } 
      }
      rcnt++;
    }else{ 
      if(i==n-1 && rcnt ==0){
        lcnt++;
        if(lcnt % 2 == 0){
        ans[pos]+= (lcnt / 2);
        ans[pos-1]+= (lcnt / 2);
        pos=0;lcnt=0;
        }else{
           ans[pos] += ((lcnt-1) / 2); 
           ans[pos-1] += 1 + ((lcnt-1) / 2);
           pos=0;lcnt=0;
        } 
      }
      if(rcnt != 0){
        pos = i;
        if(rcnt % 2 == 0){
           ans[i] += 1 + (rcnt / 2); 
           ans[i-1] += (rcnt / 2);
           rcnt = 0;
        }else{
          ans[i] += ((rcnt+1) / 2); 
          ans[i-1] += ((rcnt+1) / 2);
          rcnt = 0;
        } 
      }else{
        lcnt++;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << ans[i] << " ";
  }
}

Measured memory_bytes: 1024
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, k] <- getIntList

  let solve i | i == 1    = k
              | otherwise = (k-1) * solve (i-1)

  print $ solve n

Measured memory_bytes: 508
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		
		Integer[] array = new Integer[5];
		for(int i = 0; i < 5; ++i) {
		    int tmp = sc.nextInt();
		    array[i] = tmp;
		}
		int k = Integer.parseInt(sc.next());
		
		
		
		
		
		if(array[4] - array[0] <= k) System.out.println("Yay!");
		else System.out.println(":(");
	}
}

Measured memory_bytes: 21844
S = list(map(str, input().strip()))
num_of_zero = S.count('0')
num_of_one = S.count('1')
if num_of_zero <=  num_of_one:
    delete_num = 2 * num_of_zero
else:
    delete_num = 2 * num_of_one
print(delete_num)

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

int main(){
  long long s = 0; int n; scanf("%d", &n);
  map<int, int> m;
  rep(i, n){
    int a; scanf("%d", &a);
    m[a]++;
  }
  priority_queue<int> p;
  for(auto q: m){
    if(q.second > 3) p.push(q.first);
    if(q.second > 1) p.push(q.first);
  }
  if(p.size() > 1){
    s = p.top(); p.pop(); s *= p.top();
  }
  printf("%ld\n", s);
  return 0;
}

Measured memory_bytes: 4992
using System;
using System.Linq;

namespace abc126A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(b);
            int counter = 0;
            for (int i = 0; i < a[1]; i++)
            {
                counter = counter + b[i];
            }
            Console.WriteLine(counter);
        }
    }
}


Measured memory_bytes: 28448
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := []rune(Scanner())[0]
	b := []rune(Scanner())[0]
	if int(a) < int(b) {
		fmt.Println("<")
	} else if int(a) == int(b) {
		fmt.Println("=")
	} else {
		fmt.Println(">")
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s, t;
    cin >> s >> t;

    for (int i = s.size() - t.size(); i >= 0; i--)
    {
        int k = i, l = 0;
        while (s[k] == t[l] || s[k] == '?')
        {
            k++;
            l++;
            if (l >= t.size())
            {
                rep(m, s.size())
                {
                    if (i == m)
                    {
                        cout << t;
                        m += t.size() - 1;
                    }
                    else
                        s[m] == '?' ? cout << "a" : cout << s[m];
                }
                cout << endl;
                return 0;
            }
        }
    }
    OP("UNRESTORABLE");
    return 0;
}

Measured memory_bytes: 256