akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m; cin >> n >> m;
    ll T = (n - m) * 100 + 1900 * m;
    ll ans = T;
    rep(i, m) ans *= 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
s=list(map(int,input().split()))
s.sort()
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if s[i]+s[j]>s[k] and s[i]+s[k]>s[j] and s[j]+s[k]>s[i]:
                if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                    cnt+=1
            else:
                break
print(cnt)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
	fast;
	int n,k;cin>>n>>k;
	int v[n];
	for(int i=0;i<n;i++) cin>>v[i];
	vector<int> dp(n,1000000000);
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=i-k && j>=0 ; j--)
		dp[i]=min(dp[j]+abs(v[j]-v[i]),dp[i]);
	}
	cout<<dp[n-1]<<endl;
	
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int n, m, p;
vector<int> d;

int dist(int s, int t) {
    return (t >= s) ? (t - s) : ((t + n) - s);
}

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

    cin >> n >> m >> p;
    rep(i, m) {
        int a;
        cin >> a;
        d.push_back(a);
    }
    sort(d.begin(), d.end());
    if(d.size() == 1) {
        cout << min(dist(d[0], p), dist(p, d[0])) * 100 << endl;
    }
    else {
        int res = INF;
        rep(i, m) {
            int a = min(dist(d[i], p), min(dist(d[(i + 1) % m], p), min(dist(p, d[(i + 1) % m]), dist(p, d[i]))));
            chmin(res, a + (n - dist(d[i], d[(i + 1) % m])));
        }
        cout << res * 100 << endl;
    }
    return 0;
}

Measured memory_bytes: 3180
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float("inf")


class UnionFind(object):
    def __init__(self, N):
        self.tree = [-1]*N

    def root(self, i):
        if self.tree[i] < 0:
            return i
        else:
            self.tree[i] = self.root(self.tree[i])
            return self.tree[i]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.tree[y] < self.tree[x]:
                x, y = y, x
            self.tree[x] += self.tree[y]
            self.tree[y] = x
        return x == y


def main():
    # 1. 座圧します
    # 2. 座標ごとに線分が乗っているかどうかを示す配列を作ります
    # 3. 面ごとに同じ領域内かどうか、グルーピングします
    # 4. 牛と同じグループの面積を数え上げます

    # 入力
    N, M = map(int, readline().split())
    x_coord, y_coord = {-INF, 0, INF}, {-INF, 0, INF}
    A, B, C = [0]*N, [0]*N, [0]*N
    for i in range(N):
        a, b, c = map(int, readline().split())
        A[i], B[i], C[i] = a, b, c
        x_coord.add(a)
        x_coord.add(b)
        y_coord.add(c)
    D, E, F = [0]*M, [0]*M, [0]*M
    for i in range(M):
        d, e, f = map(int, readline().split())
        D[i], E[i], F[i] = d, e, f
        x_coord.add(d)
        y_coord.add(e)
        y_coord.add(f)

    # 1. 座圧
    mx = list(sorted(x_coord))
    my = list(sorted(y_coord))
    invx, invy = {}, {}
    for i, x in enumerate(mx):
        invx[x] = i
    for i, y in enumerate(my):
        invy[y] = i
    H = len(my)
    W = len(mx)

    # 2. 線分ごとに線分が乗っているかどうかを示す配列を作ります(imos法)
    # segx[i][j]は座標(i, j)と(i+1, j)をつなぐ線分
    # segy[i][j]は座標(i, j)と(i, j+1)をつなぐ線分
    segx = [[0]*H for _ in range(W)]
    segy = [[0]*H for _ in range(W)]

    for a, b, c in zip(A, B, C):
        segx[invx[a]][invy[c]-1] += 1
        segx[invx[b]][invy[c]-1] -= 1
    for i in range(W-1):
        for j in range(H):
            segx[i+1][j] += segx[i][j]

    for d, e, f in zip(D, E, F):
        segy[invx[d]-1][invy[e]] += 1
        segy[invx[d]-1][invy[f]] -= 1
    for i in range(W):
        for j in range(H-1):
            segy[i][j+1] += segy[i][j]

    # 3. 面ごとに同じ領域内かどうか、グルーピングします
    # UnionFindで検査していく
    uf = UnionFind(W*H)

    # segx[i][j]は座標(i, j)と(i+1, j)をつなぐ線分であり
    # 面[i][j-1]と面[i][j]の境界にあたる
    # segy[i][j]は座標(i, j)と(i, j+1)をつなぐ線分であり
    # 面[i-1][j]と面[i][j]の境界にあたる
    for i in range(W):
        for j in range(H):
            if i+1 < W and segy[i][j] == 0:
                uf.unite(i+j*W, i+1+j*W)
            if j+1 < H and segx[i][j] == 0:
                uf.unite(i+(j+1)*W, i+j*W)

    # 4. 牛と同じグループの面積を数え上げます
    # 無限の彼方と同じグル-プなら、INF
    ushi = invx[0]+invy[0]*W
    if uf.same(ushi, 0):
        print("INF")
        return

    area = 0
    for i in range(W-1):
        for j in range(H-1):
            if uf.same(ushi, i+j*W):
                area += (mx[i+1]-mx[i])*(my[j+1]-my[j])
    print(area)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 285252
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	hh := make([]int, n)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		hh[i] = getNextInt(scanner) - 1
	}
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}
	dec := newDecomposition(n)
	for i := 0; i < n; i++ {
		m := dec.max(0, hh[i])
		dec.maximize(hh[i], m+aa[i])
	}
	fmt.Fprintln(writer, dec.max(0, n))
}

type decomposition struct {
	chunk  int
	bucket [][]int64
}

func newDecomposition(n int) decomposition {
	bucket := make([][]int64, 1)
	bucket[0] = make([]int64, n)
	chunk := 8
	for i := 0; n > 1; i++ {
		n = (n-1)/chunk + 1
		bucket = append(bucket, make([]int64, n))
	}
	return decomposition{
		chunk:  chunk,
		bucket: bucket,
	}
}
func (dec *decomposition) upleft(l int) int {
	return (l + dec.chunk - 1) / dec.chunk
}
func (dec *decomposition) upright(r int) int {
	return r / dec.chunk
}
func (dec *decomposition) maximize(index int, value int64) {
	dec.bucket[0][index] = value
	h := len(dec.bucket)
	for i := 0; i < h-1; i++ {
		p := index / dec.chunk
		r := (p + 1) * dec.chunk
		if r >= len(dec.bucket[i]) {
			r = len(dec.bucket[i])
		}
		dec.bucket[i+1][p] = value
		for j := p * dec.chunk; j < r; j++ {
			if dec.bucket[i+1][p] < dec.bucket[i][j] {
				dec.bucket[i+1][p] = dec.bucket[i][j]
			}
		}
		index /= dec.chunk
	}
}
func (dec *decomposition) max(l, r int) int64 {
	return dec.maxh(l, r, 0)
}
func (dec *decomposition) maxh(l, r, h int) int64 {
	m := dec.bucket[h][l]
	ll := dec.upleft(l)
	rr := dec.upright(r)
	for i := l; i < r && i < ll*dec.chunk; i++ {
		if m < dec.bucket[h][i] {
			m = dec.bucket[h][i]
		}
	}
	if ll < rr {
		mm := dec.maxh(ll, rr, h+1)
		if m < mm {
			m = mm
		}
	}
	for i := rr * dec.chunk; i < r && ll <= rr; i++ {
		if m < dec.bucket[h][i] {
			m = dec.bucket[h][i]
		}
	}
	return m
}


Measured memory_bytes: 12696
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
signed main() {
	string s;
	int n;
	cin >> s >> n;
	for (int i = 0; i < s.size(); i += n) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 123;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

void solve(){
    int n;
    cin >> n;
    ll s = 0;
    for (int i = 1; i <= n; i++){
        if (i%3 && i%5) s += i;
    }
    cout << s;
}

int main(){
    #ifdef KAZAKH
        //freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "case #" << i << ": ";
        solve();
    }
    return 0;
}


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

int d[17][17];
int n;
void cal(int x,int y,int num){
	if(num<=n*n){
		if(1<=x && x<=n && 1<=y && y<=n){
			if(d[x][y]==0){
				d[x][y]=num;
				cal(x+1,y+1,num+1);
			}
			else{
				cal(x-1,y+1,num);
			}
			
		}
		else{
			if(x>n){
				cal(1,y,num);
			}
			else if(x<1){
				cal(n,y,num);
			}
			else{
				cal(x,1,num);
				
			}
		}
	}
}


int main(){
	
	
	while(cin>>n,n){
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				d[i][j]=0;
			}
		}
		for(int i=0;i<17;i++)d[0][i]=d[i][0]=d[n+1][i]=d[i][n+1]=-1;
		
		
		cal(n/2+1,n/2+2,1);
		
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(d[j][i]>=0){
					if(d[j][i]<1000)cout<<" ";
					if(d[j][i]<100)cout<<" ";
					if(d[j][i]<10)cout<<" ";
					cout<<d[j][i];
				}
			}
			cout<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 1160
from collections import Counter
n = int(input())
v = [int(a) for a in input().strip().split()]

if n==2:
    print(0)
    exit()

eve = [a for i, a in enumerate(v) if i%2 == 0]
odd = [a for i, a in enumerate(v) if i%2 == 1]

evec = Counter(eve)
oddc = Counter(odd)

evemosts = evec.most_common()
oddmosts = oddc.most_common()
evemostc = 0
oddmostc = 0

if evemosts[0][0] == oddmosts[0][0]:
    if len(evemosts) == 1:
        if len(oddmosts) == 1:
            evemostc = evemosts[0][1]
            oddmostc = 0
        else:
            evemostc = evemosts[0][1]
            oddmostc = oddmosts[1][0]
    elif len(oddmosts) == 1:
        if len(evemosts) == 1:
            evemostc = 0
            oddmostc = oddmosts[0][1]
        else:
            evemostc = evemosts[1][0]
            oddmostc = oddosts[0][1]
    elif evemosts[1][1] > oddmosts[1][1]:
        evemostc = evemosts[1][1]
        oddmostc = oddmosts[0][1]
    else:
        evemostc = evemosts[0][1]
        oddmostc = oddmosts[1][1]
else:
    evemostc = evemosts[0][1]
    oddmostc = oddmosts[0][1]

ans = n/2 - evemostc + n/2 - oddmostc
print(int(ans))

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

using namespace std;

using ll = long long int;
using vi = vector<int>;
#define f(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define ci(n) cin >> n;
#define ic(n) int n; cin >> n;
#define lc(n) int n; cin >> n;
#define all(a) a.begin(), a.end()
#define pri(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define scl(a, n) ll a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define pb push_back
#define sc(a, n) int a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define eb emplace_back
#define ft first
#define int long long
void prip(int a[], int n){f(n) cout << a[i] << ' '; cout << '\n';}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}, h, w;
bool ok(int x, int y)
{
    return x >= 0 && x < w && y >= 0 && y < h;
}
main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ic(n)
    sc(a, n)
    int x = 0;
    f(n) x ^= a[i];
    f(n) cout << (x ^ a[i]) << ' ';
}


Measured memory_bytes: 5168
from bisect import bisect_left
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
A,B,Q = (int(i) for i in input().split())
st ={"s":[],"t":[]}
x =[0] *Q

for i in range(A):
    aa = int(input())
    st["s"].append(aa)
st["s"].append(10**11)

for i in range(B):
    bb = int(input())
    st["t"].append(bb)
st["t"].append(10**11)


for i in range(Q):
    x[i] = int(input())

#2分探索で近い神社と寺を探す
dist =[]
for xi in x:
    #スタート⇒神社
    xs =bisect_left(st["s"],xi)
    s_l =st["s"][xs-1] #スタート地点から近い神社（左）⓵
    s_r =st["s"][xs  ] #スタート地点から近い神社（右）⓶
    xs_l =abs(xi -s_l)  
    xs_r =abs(xi -s_r)    

    xs_l_t =bisect_left(st["t"],s_l ) 
    t_l =st["t"][xs_l_t -1] #⓵から近い寺（左）
    t_r =st["t"][xs_l_t   ] #⓵から近い寺（右）
    xs_l_t_l =abs(s_l -t_l) 
    xs_l_t_r =abs(s_l -t_r) 
    
    xs_r_t =bisect_left(st["t"],s_r ) 
    t_l =st["t"][xs_r_t -1] #⓶から近い寺（左）
    t_r =st["t"][xs_r_t   ] #⓶から近い寺（右）
    xs_r_t_l =abs(s_r -t_l) 
    xs_r_t_r =abs(s_r -t_r)
    ds =min(xs_l +xs_l_t_l ,xs_l +xs_l_t_r ,xs_r +xs_r_t_l ,xs_r +xs_r_t_r)

     #スタート⇒寺
    xs =bisect_left(st["t"],xi)
    s_l =st["t"][xs-1] #スタート地点から近い寺（左）⓷
    s_r =st["t"][xs  ] #スタート地点から近い寺（右）⓸
    xs_l =abs(xi -s_l)  
    xs_r =abs(xi -s_r)    

    xs_l_t =bisect_left(st["s"],s_l ) 
    t_l =st["s"][xs_l_t -1] #⓷から近い神社（左）
    t_r =st["s"][xs_l_t   ] #⓷から近い神社（右）
    xs_l_t_l =abs(s_l -t_l) 
    xs_l_t_r =abs(s_l -t_r) 
    
    xs_r_t =bisect_left(st["s"],s_r ) 
    t_l =st["s"][xs_r_t -1] #⓸から近い神社（左）
    t_r =st["s"][xs_r_t   ] #⓸から近い神社（右）
    xs_r_t_l =abs(s_r -t_l) 
    xs_r_t_r =abs(s_r -t_r)
    dt =min(xs_l +xs_l_t_l ,xs_l +xs_l_t_r ,xs_r +xs_r_t_l ,xs_r +xs_r_t_r)
    print(min(ds,dt))


Measured memory_bytes: 20980
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;

int n, m;
int x, y;
int p[maxn];
vector<int> e[maxn];
bool vis[maxn];
int ans;
set<int> pos;
void dfs(int u)
{
    vis[u] = true;
    pos.insert(u);
    for(int &x : e[u]) if(!vis[x]) dfs(x);
}
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &p[i]);
    }
    for(int i = 1; i <= m; ++i) {
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    for(int i = 1; i <= n; ++i) {
        if(!vis[i]) {
            dfs(i);
            for(int x : pos) if(pos.find(p[x]) != pos.end()) ans++;
            pos.clear();
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int x,y;
    int ans=0;
    cin >>x>>y;
    cout<<x+y/2<<endl;
}

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

struct node{
	int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

void init()
{
	nil = NULL;
}

void insert(int key)
{
	struct node *newcell;

	newcell = (struct node*)malloc(sizeof(struct node));
	if (newcell == NULL) {
		puts( "malloc failed." );
		return;
	}

	if (nil == NULL) {
		nil = newcell;
		nil->next = nil;
		nil->prev = nil;
		nil->key = key;
		return;
	} else if (nil->next == nil) {
		nil->prev = newcell;
	} else if (nil->next->next == nil) {
		nil->prev->prev = newcell;
	}
	newcell->key = nil->key; 
	newcell->prev = nil;
	newcell->next = nil->next;
	nil->next->prev = newcell;
	nil->next = newcell;
	nil->key = key;
	return;
}

void deleteLast()
{
	struct node *last;
	if (nil->next == nil) {
		free(nil);
		nil = NULL;
		return;
	} else {
		last = nil->prev;
		nil->prev->prev->next = nil;
		nil->prev = last->prev;
		free(last);
	}
}

void deleteFirst()
{
	struct node *first;
	if (nil->prev == nil) {
		free(nil);
		nil = NULL;
		return;
	} else {
		first = nil;
		nil = nil->next;
		nil->prev = first->prev;
		first->prev->next = nil;
		free(first);
	}
}

void _delete(int key)
{
	struct node *p;
	if (nil->key == key) {
		deleteFirst();
		return;
	}
	for (p = nil->next; p != nil; p = p->next) {
		if (p->key == key) {
			p->prev->next = p->next;
			p->next->prev = p->prev;
			free(p);
			return;
		}
	}
}

void printList()
{
	struct node *p;
	printf("%d", nil->key);
	for (p = nil->next; p != nil; p = p->next) {
		printf(" %d", p->key);
	}
	printf("\n");
	return;
}

int main(){
	int i, n, key;
	char com[12];
	struct node *p;

	scanf("%d", &n);
	init();

	for ( i = 0; i < n; i++ ){
		scanf("%s", com);

		if ( com[0] == 'i' ) {
			scanf("%d", &key);
			insert(key);
		} else if ( com[0] == 'd' ) {
			if (strlen(com) > 6){
				if ( com[6] == 'F' ) {
					deleteFirst();
				} else if ( com[6] == 'L' ) {
					deleteLast();
				}
			} else {
				scanf("%d", &key);
				_delete(key);
			}
		}
	}
	printList();
	return 0;
}

Measured memory_bytes: 31660
import sys
reader=(token for line in sys.stdin for token in line.split())

while 1:
  try:
    n=int(next(reader))
    m=int(next(reader))
  except: break

  a=[1]*(n+1)
  for i in range(m):
    c=int(next(reader))-1
    d=int(next(reader))-1
    for i in range(c,d):
      a[i]=3
  print(sum(a))

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

typedef struct{
    char name[20];
    int exe_time;
    int fin_time;
}QueueData;

typedef struct _node
{
    QueueData data;
    struct _node *next;
}node;

typedef struct
{
    node *head, *tail;
}queue;

queue* init_queue()
{
    queue* qp = malloc(sizeof(queue));
    qp -> head = NULL;
    qp -> tail = NULL;
    return qp;
}

int empty(queue* q)
{
    return (q->head == NULL);
}

void enqueue(queue* q, QueueData d)
{
    node *np = malloc(sizeof(node));
    np->data = d;
    np->next = NULL;
    if(empty(q)){
        q -> head = np;
        q -> tail = np;
    }
    else{
        q -> tail -> next = np;
        q -> tail = np;
    }
}

QueueData dequeue(queue *q)
{
    if(empty(q)){
        printf("none\n");
        exit(1);
    }
    QueueData hold = q -> head -> data;
    node* temp = q -> head;
    q -> head = q -> head -> next;
    if(q->head == NULL) q->tail = NULL;
    free(temp);
    return hold;
}

int compare_find_time(const void* a, const void* b){
    QueueData *pa = (QueueData*) a;
    QueueData *pb = (QueueData*) b;

    return pa->fin_time - pb->fin_time;
}

int find_proc(char *s, QueueData *x, int total_proc){
    for(int i=0; i<total_proc; i++){
        if(strcmp(s,x[i].name)==0) return i;
    }
}

int main(){
    int proc_num, rr_time;
    queue *q = init_queue();
    scanf("%d %d", &proc_num, &rr_time);
    QueueData *proc = malloc(proc_num*sizeof(QueueData));
    for(int i=0; i<proc_num; i++){
        scanf("%s %d", proc[i].name, &proc[i].exe_time);
        enqueue(q, proc[i]);
    }

    
    int total_time = 0;
    while(!empty(q)){
        if((q->head->data).exe_time > rr_time){
            (q->head->data).exe_time -= rr_time;
            total_time += rr_time;
            //enqueue
            enqueue(q, q->head->data);
            //pop from queue
            node *temp_x = q->head;
            q -> head = q->head->next;
            free(temp_x);
        }
        else if
            ((q->head->data).exe_time>0&&(q->head->data).exe_time<=rr_time){
            total_time += (q->head->data).exe_time;
            (q->head->data).exe_time = 0;
            (q->head->data).fin_time = total_time;
            printf("%s %d\n", 
                    (q->head->data).name, total_time);
            /*int proc_no = find_proc((q->head->data).name, proc, proc_num);
            proc[proc_no].fin_time = total_time;*/
            //pop from queue
            node *temp_x = q->head;
            q -> head = q->head->next;
            free(temp_x);
        }
    }
    
    /*qsort(proc, proc_num, sizeof(*proc), compare_find_time);

    for(int i=0; i<proc_num; i++){
        printf("%s %d\n", proc[i].name, proc[i].fin_time);
    }*/

    
    /*while(!empty(q)){
        printf("%s %d\n", dequeue(q).name, dequeue(q).num);
    }*/
    //printf("\n");
}



Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    char v[5] = {'a', 'e', 'i', 'o', 'u'};
    char c;
    cin >> c;
    rep(i, 5)
    {
        if (v[i] == c)
        {
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char q;
cin >> q;
if (q == 'a' || q == 'i' || q == 'u' || q == 'e' || q == 'o') {
cout << "vowel" << endl;
}
else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M, X;
  cin >> N >> M >> X;
  vl A(M);
  rep(i, M) cin >> A[i];

  ll cnt = lower_bound(A.begin(), A.end(), X) - A.begin();

  cout << min(cnt, M - cnt) << endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	b := sc.Bytes()
	x := 1
	if b[0] == 45 {
		x *= -1
		b = b[1:]
	}
	for _, v := range b {
		n = n*10 + int(v-48)
	}
	return n * x
}

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

func isSquare(n int) bool {
	if x := n % 10; x == 2 || x == 3 || x == 7 || x == 8 {
		return false
	}
	y := math.Sqrt(float64(n))
	return y == math.Trunc(y)
}

func main() {
	sc.Split(bufio.ScanWords)
	n, d := ri(), ri()
	x := make([][]int, n)
	for i := 0; i < n; i++ {
		x[i] = make([]int, d)
		for j := 0; j < d; j++ {
			x[i][j] = ri()
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			cur := 0
			for k := 0; k < d; k++ {
				cur += abs(x[i][k]-x[j][k]) * abs(x[i][k]-x[j][k])
			}
			if isSquare(cur) {
				ans++
			}
		}
	}
	fmt.Println(ans / 2)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n,a,b;
	cin >> n >> a >> b;

	if((b-a)%2==1){
		cout << ((n-b)>=a ? b-1-(b-a)/2 : (n-a)-(b-a)/2) << '\n';
	}else{
		cout << (b-a)/2 << '\n';
	}
	return 0;
}



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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  reverse (s.begin(), s.end());
  for (int i=0; i<4; i++) reverse(divide[i].begin(), divide[i].end());

  bool end_flag = false;
  bool f;

  int i = 0;

  while (!end_flag) {
    f = false;
    for (int j=0; j<4; j++) {
      if (s.substr(i, divide[j].size()) == divide[j]) {
        i += divide[j].size();
        f = true;
        break;
      }
    }
    if (!f || i == s.size()) end_flag = true;
  }

  if (f) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, M; cin >> N >> M;
    int max_l = -1, min_r = INF;
    rep (i, 0, M) {
        int l, r; cin >> l >> r;
        max_l = max(max_l, l);
        min_r = min(min_r, r);
    }

    int ans = 0;
    rrep (i, 1, N) {
        if (max_l <= i and min_r >= i) ++ans;
    }

    cout << ans << endl;
}

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

typedef long long ll;

ll GCD(ll a, ll b){
  if(a<b){
    ll tmp = a;
    a = b;
    b = tmp;
  }
  if(b==0) return a;
  else return GCD(b, a%b);   
}

ll LCM(ll j, ll k){
  ll c = GCD(j, k);
  return j / c * k;
}
 
int main(){
  int n;
  cin >> n;
  ll ans = 1LL;
  for(int i=0; i<n; i++){
    ll a;
    cin >> a;
    ans = LCM(ans, a);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str=s.next();
		long result=0;
		
		for(int i=0;i<str.length();i++){
			int no = Integer.parseInt(""+str.charAt(i));
			for(int j=0;j<str.length()-i;j++){
				result += no*Math.pow(10, j)*Math.pow(2, i)*Math.pow(2, Math.max(str.length()-2-j-i,0));
			}
		}
			
		System.out.println(result);
	}
}

Measured memory_bytes: 9940
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 100000;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static int [] Ft = new int  [max+1];
    public static void main(String args[]) throws IOException {
        int N = in.nextInt();
        for(int i=0;i<N;i++){
            update(in.nextInt());
        }
        int K = 0;
        for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        }
        out.println(K);
        out.flush();
        }
        static int lsb(int i){return i&-i;};
        static int prefix(int idx){
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        }
        static void update(int idx){
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

Measured memory_bytes: 34060
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include<cstring>


using namespace std;
int main(void){
  int ans=0;
  int len;
  char s[101];
  cin >> s;
  len=strlen(s);
  int i,j;
  for(i=0;i<len/2;i++){
    if(s[i]!=s[len-1-i]){
      ans++;
    }
  }
  cout <<ans;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[3][105],n,ans=-1;
int main()
{
    cin>>n;
    for(int i=1;i<=2;i++) 
    {
        for(int j=1;j<=n;j++) cin>>a[i][j];
    }
    for(int down=1;down<=n;down++)
    {
        int now=0;
        for(int i=1;i<=down;i++) now+=a[1][i];
        for(int i=down;i<=n;i++) now+=a[2][i];
        if(now>ans) ans=now;
    }
    cout<<ans;
    
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{

  ll X, N, ans1, ans2, ans;
  cin >> X >> N;
  ans1 = X;
  ans2 = X;
  ans = X;
  bool flag1 = false;
  bool flag2 = false;
  vector<ll> p(N);
  rep(i, N)
  {
    cin >> p.at(i);
  }
  rep(i, 101)
  {
    flag1 = true;
    rep(j, N)
    {
      if (p.at(j) == ans1)
      {
        flag1 = false;
      }
    }
    if (flag1)
    {
      // cout << "ans1 = " << ans1 << endl;
      break;
    }
    ans1++;
  }
  rep(i, 101)
  {
    flag2 = true;
    rep(j, N)
    {
      if (p.at(j) == ans2)
      {
        flag2 = false;
      }
    }
    if (flag2)
    {
      // cout << "ans2 = " << ans2 << endl;
      break;
    }
    ans2--;
  }

  if (abs(ans1 - X) > abs(ans2 - X))
  {
    cout << ans2 << endl;
    return 0;
  }
  if (abs(ans2 - X) > abs(ans1 - X))
  {
    cout << ans1 << endl;
    return 0;
  }

  cout << min(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n,h,w;
    cin>>n>>h>>w;
    cout<<(n+1-h)*(n+1-w)<<endl;
}


Measured memory_bytes: 256
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;
//double dp[MAX][MAX];
vector<ll>v;
void solve()
{    ll i,j,n,a,k;
     cin>>n>>k;
     for(i=0;i<n;i++)
      cin>>a,v.pb(a);
    ll dp[k+1]={0};// number of ways that we used i candies so far;
    dp[0]=1;
    for(i=0;i<n;i++)
    {    vector<ll>v2(k+1,0);
    	for(j=k;j>=0;j--)
    	{    
    		ll temp=dp[j];
    		ll L=j+1;
    		ll R=min(v[i],k-j)+j;
    		if(L<=R)
    		{
    			v2[L]=(v2[L]+temp)%hell;
    			if(R+1<=k)
    			{
    				v2[R+1]=(v2[R+1]-temp+hell)%hell;
    				//cout<<v2[L]<<" "<<v2[R+1]<<" //"; 
    			}
    		}
           
    	}
    	ll prefix=0;
    	for(j=0;j<=k;j++)
    	{   prefix=(prefix+v2[j])%hell;
    		dp[j]=(dp[j]+prefix)%hell;
    	}
    }
    cout<<dp[k];
}
           
int main(){ 
cut; 
ll t; 
//cin>>t;
//T=t;
 t=1;
while(t--)
solve();
return 0;
}
     


Measured memory_bytes: 5208
import numpy as np
import queue
from collections import deque

H, W = map(int, input().split())

maze = np.zeros((H, W))

for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == '.':
            maze[i, j] = 1

max_run = 0

tan = [[1, 0], [-1, 0], [0, 1], [0, -1]]
g = (100, 100)

def max_route(h, w):
    # q = queue.Queue()
    q = deque()
    checker = maze.copy()
    q.append((h, w))
    checker[h, w] = 2
    q.append(g)

    run = 0

    while len(q):
        target = q.popleft()
        if target == g:
            if len(q):
                run += 1
                q.append(g)
        else:
            for t in tan:
                check = [target[0]+t[0], target[1]+t[1]]
                if 0 <= check[0] < H and 0 <= check[1] < W:
                    if checker[check[0], check[1]] == 1:
                        q.append((check[0], check[1]))
                        checker[check[0], check[1]] = 2

    return run


for h in range(H):
    for w in range(W):
        if maze[h, w] == 0:
            continue
        cur = max_route(h, w)
        if cur > max_run:
            max_run = cur

print(max_run)


Measured memory_bytes: 14456
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
#include<numeric>
using namespace std;


int main(void) {

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int d[4] = {ty-sy, ty-sy, tx-sx, tx-sx};
  string a = "UDLR";
  string ans = "";
  for(int i=0; i<d[0]; i++) ans += 'U';
  for(int i=0; i<d[3]; i++) ans += 'R';
  for(int i=0; i<d[1]; i++) ans += 'D';
  for(int i=0; i<d[2]; i++) ans += 'L';

  ans += 'L';
  d[0]++;
  d[3]++;
  for(int i=0; i<d[0]; i++) ans += 'U';
  for(int i=0; i<d[3]; i++) ans += 'R';
  ans += 'D';

  ans += 'R';
  d[1]++;
  d[2]++;
  for(int i=0; i<d[1]; i++) ans += 'D';
  for(int i=0; i<d[2]; i++) ans += 'L';
  ans += 'U';

  cout << ans << endl;

  return 0;
}


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

int main() {
    double r;
    cin >>r;
    double S=r*r*M_PI;
    double L=r*2*M_PI;
    cout <<fixed <<setprecision(10) <<S <<' ' <<L <<endl;
    return 0;
}


Measured memory_bytes: 3228
N, M = gets.chomp.split.map(&:to_i)
abab = []
N.times do
  abab << gets.chomp.split.map(&:to_i)
end
cdcd = []
M.times do
  cdcd << gets.chomp.split.map(&:to_i)
end

abab.each do |ab|
  temp = 300000000
  aans = -1
  cdcd.each_with_index do |cd, i|
    md = (ab[0] - cd[0]).abs + (ab[1] - cd[1]).abs
    if md < temp
      temp = md
      aans = i + 1
    end
  end
  puts aans
end

Measured memory_bytes: 1788
n,m=map(int,input().split())
ans=list(map(int,input().split()))
arr=[list(map(int,input().split())) for _ in range(m)]
arr=sorted(arr,reverse=True,key=lambda x:x[1])
tmp=0
for cnt,val in arr:
  ans+=[val]*cnt
  tmp+=cnt
  if tmp>=n:
    break
ans=sorted(ans,reverse=True)
print(sum(ans[:n]))

Measured memory_bytes: 37572
#include<bits/stdc++.h>
using namespace std;
inline int readint(){
    char x;int f=1,r=0;
    while(1){x=getchar();if(x>' ')break;}
    while(1){
        if(x=='-')f=-1;
        else r=r*10+x-'0';
        x=getchar();
        if(!isdigit(x))break;
    }
    return r*f;
}
/*
    |
  B |  A
----P------
  C |  D
*/
#define ll long long
const int maxn=2e5+9;
struct point{
    int x,y;
    int ix;//ix for index_X {1..n} , equals b+c+1
};
int n;
point D[maxn];
void init(){
    n=readint();
    for(int i=1;i<=n;++i)
        D[i].x=readint(),D[i].y=readint();
}

struct tree_node{
    int l,r;
    int num;
};
tree_node T[maxn*3];
void maketree(int p,int l,int r){
    T[p].l=l;T[p].r=r;
    T[p].num=0;
    if(l==r){return;}
    int m=(l+r)/2;
    maketree(p*2,l,m);
    maketree(p*2+1,m+1,r);
}
int insert(int p,int x){
    if(T[p].l==T[p].r /*&& T[p].l==x*/){
        T[p].num+=1;
        return 0;
    }
    int m=(T[p].l+T[p].r)/2;
    T[p].num+=1;
    if(x<=m){
        return insert(p*2,x);
    }else{
        return insert(p*2+1,x)+T[p*2].num;
    }
}

const int MOD=998244353;
int p2[maxn];
void initp2(){
    p2[0]=1;
    for(int i=1;i<n;++i)
        p2[i]=(p2[i-1]*2)%MOD;
}
int p(int i){
    return p2[i];
}
int mul(int a,int b,int c,int d){
    ll r=a;
    r=(r*b)%MOD;
    r=(r*c)%MOD;
    r=(r*d)%MOD;
    return r;
}
int calc(int a,int b,int c,int d){
    /*
    对于某个点P,计算它被覆盖到的次数 in {所有可能性}
    若P被选 则一定被覆盖 情况数=2^(n-1)
    若P不被选 情况数=|BD都至少有1点|+|AC都至少有1点|-|BDAC都至少有1点|;
        |至少有1点|=总情况数-"所以点都不选"这唯一的情况
    |BD都至少有1点|=(2^B - 1)*(2^D -1)*(2^A)*(2*C);
    AC类似
    */
    int ret;
    ret=p(n-1);
    ret=(ret+mul(p(b),p(d),p(a)-1,p(c)-1))%MOD;
    ret=(ret+mul(p(a),p(c),p(b)-1,p(d)-1))%MOD;
    ret=(ret-mul(p(a)-1,p(b)-1,p(c)-1,p(d)-1)+MOD)%MOD;
    return ret;
}

bool cmp_x(point a,point b){return a.x<b.x;}
bool cmp_y(point a,point b){return a.y<b.y;}
int solve(){
    sort(D+1,D+n+1,cmp_x);
    for(int i=1;i<=n;++i){
        D[i].ix=i;
    }
    sort(D+1,D+n+1,cmp_y);
    int a,b,c=0,d=0;
    initp2();
    maketree(1,1,n);
    int sum=0;
    for(int i=1;i<=n;++i){
        c=insert(1,D[i].ix);
        d=i-1-c;// i-1 equals c+d
        b=D[i].ix-1-c;// ix-1 equals b+c
        a=n-D[i].ix-d;// n-ix equals a+d
        sum=(sum+calc(a,b,c,d))%MOD;
    }
    return sum;
}
int main(){
    init();
    cout<<solve()<<endl;
    return 0;
}



Measured memory_bytes: 10496
a = [[[0 for room in range(10)] for floor in range(3)] for house in range(4)]
N = int(input())
for i in range(N):
    h, f, r, v = map(int, input().split())
    a[h - 1][f - 1][r - 1] += v


for h in range(4):
    for f in range(3):
        print(' ' + ' '.join([str(x) for x in a[h][f]]))
    if not h == 3:
        print('####################')



Measured memory_bytes: 5612
import Data.List

get_all_info::[Integer]->Int->Int->(Double,Integer)
get_all_info xs a b = let srtd = reverse (sort xs)in
                      let first_a = head srtd in
                      let last_a = srtd!!(a-1) in
                      if first_a /= last_a then let able = length (filter (\x-> x==last_a) (srtd)) in
                                                let takes= length (filter (\x-> x==last_a) (take a srtd)) in
                                                (average (take a srtd),comb (fromIntegral able) (fromIntegral takes))
                                           else let able = length (filter (\x-> x==first_a) (srtd)) in
                                                (fromIntegral first_a,sum [comb (fromIntegral able) (fromIntegral t)|t<-[a..(min b able)]])
fact::Integer -> Integer
fact 0=1
fact n = n*(fact (n-1))

comb::Integer->Integer->Integer
comb n k = fromIntegral (div (div (fact n) (fact k)) (fact (n-k)))

average::[Integer]->Double
average xs = (fromIntegral (sum xs))/(fromIntegral (length xs))

main::IO()
main=do
  nab<-getLine
  let n:a:b:[]= map read (words nab)
  dat<-getLine
  let xs = map read (words dat)
  let (av,pat)=(get_all_info xs a b)
  print av
  print pat

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main()
{
    int r; int d; int x;int y;int z;
    cin>>r>>d>>x;


y=(r *x) -d;

cout<<y<<endl;

    for(int i=0;i<9;i++){
            y=(r *y) -d;
            cout<<y<<endl;


}







    return 0;
}


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

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

    return 0;
}

Measured memory_bytes: 256
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		Map<Integer, Integer> nums = new TreeMap<Integer, Integer>();
		try {
			sc = new Scanner(System.in);
			int maxValue = 0;
			while (sc.hasNextInt()) {
				int num = sc.nextInt();
				int count = 0;
				nums.put(num, nums.containsKey(num) ? count = nums.get(num) + 1
						: 1);
				if (maxValue < count) {
					maxValue = count;
				}
			}
			for (Entry<Integer, Integer> entry : nums.entrySet()) {
				if (maxValue == entry.getValue()) {
					System.out.println(entry.getKey());
				}
			}

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 26152
#include<iostream>
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define modn 1000000007
using namespace std;
#include <bits/stdc++.h>
using namespace std;
char arr[55][55];
int visited[55][55];
int dist[55][55];
int main()
{
    int tc;
    //cin>>tc;
    tc = 1;
    while(tc--)
    {
        int n,m;
        cin>>n>>m;
        int whitecount = 0;
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
            {
                cin>>arr[i][j];
                if(arr[i][j] == '.') whitecount++;
            }
        queue<pair<int,int>> q;
        q.push(make_pair(0,0));
        visited[0][0] = 1;
        dist[0][0] = 1;
        while(!q.empty())
        {
            pair<int, int> p = q.front();
            q.pop();
            int i = p.first;
            int j = p.second;
            if(arr[i][j+1] == '.' && visited[i][j+1] == 0) { q.push(make_pair(i, j+1)); dist[i][j+1] = dist[i][j]+1; visited[i][j+1] = 1; }
            if(arr[i][j-1] == '.' && visited[i][j-1] == 0) { q.push(make_pair(i, j-1)); dist[i][j-1] = dist[i][j]+1; visited[i][j-1] = 1; }
            if(arr[i+1][j] == '.' && visited[i+1][j] == 0) { q.push(make_pair(i+1, j)); dist[i+1][j] = dist[i][j]+1; visited[i+1][j] = 1; }
            if(arr[i-1][j] == '.' && visited[i-1][j] == 0) { q.push(make_pair(i-1, j)); dist[i-1][j] = dist[i][j]+1; visited[i-1][j] = 1; }
        }
        if(dist[n-1][m-1] == 0) cout<<-1<<endl;
        else cout<<whitecount - dist[n-1][m-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

int main()
{
  int n, t, a, h;
  scanf("%d %d %d %d", &n, &t, &a, &h);
  double temp = t - h * .006;
  int ans = 0;
  for (int i = 1; i < n; ++i)
  {
    int h;
    scanf("%d", &h);
    if (std::abs(temp - double(a)) > std::abs(t - h * .006 - a))
    {
      temp = t - h * .006;
      ans = i;
    }
  }
  printf("%d\n", ans + 1);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
typedef pair<int, int> P;
 
int main(){
	int N, M; cin >> N >> M;
	vector<P> vec(M);
	for(int i = 0; i < M; i++) cin >> vec[i].second >> vec[i].first;
	sort(vec.begin(), vec.end());
	int start = 0, ans = 0;
	for(int i = 0; i < M; i++){
		if(start <= vec[i].second) start = vec[i].first, ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024