akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn g_dfs(g: &Vec<Vec<usize>>, v: &mut Vec<bool>,
         path: (usize, usize), exclude: (usize, usize)) -> bool {
    if path.0 == path.1 {
        return true;
    }
    for x in &g[path.0] {
        if path.0 == exclude.0 && *x == exclude.1 {
            continue;
        }
        if v[*x] {
            continue;
        }
        v[*x] = true;
        if g_dfs(g, v, (*x, path.1), exclude) {
            return true;
        }
    }
    return false;
}

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize1,usize1);m]
    }
    let mut g = vec![Vec::new();n];
    for &(a,b) in &ab {
        g[a].push(b);
        g[b].push(a);
    }
    let mut res = 0;
    for &exclude in &ab {
        let mut reachable = true;
        for a in 0..n {
            for b in 0..n {
                let mut v = vec![false;n];
                if !g_dfs(&g, &mut v, (a,b), exclude) {
                    reachable = false;
                    break;
                }
            }
        }
        if reachable {
            res += 1;
        }
    }
    println!("{}", m - res);
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 200010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

int a[maxN];
vector<pii> v[maxN];
ll power(ll x,ll p)
{
	if(p == 0)
	{
		return 1;
	}
	ll t = power(x,p/2);
	t = t*t;
	if(p%2 == 1)
	{
		t = t*x;
	}
	return t;
}

int main()
{
	ll x;
	scanf("%lld",&x);
	vector<ll> ans;
	for(int k=0;k<=1000;k++)
	{
		for(int y=-1000;y<=1000;y++)
		{
			if(power(k,5) - power(y,5) == x)
			{
				ans = {k,y};
				break;	
			} 
		}
		if(ans.size() != 0)
			break;
	}
	printf("%lld %lld\n",ans[0],ans[1]);
	return 0;
}

Measured memory_bytes: 8480
n = int(input())
a_list = [int(a) - 1 for a in input().split()]
count = [0] * n
for a in a_list:
  count[a] += 1
comb = 0
for c in count:
  comb += c * (c - 1) // 2
for a in a_list:
  c = count[a]
  print(comb - c + 1)

Measured memory_bytes: 25768
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef unsigned long long ll;
#define endl '\n'

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

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

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

	int N; cin >> N;
	vector<int> S(N), T(N);
	vector<ll> U(N), V(N);

	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> U[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}

	vector<vector<ll>> ans(N, vector<ll>(N, 0));

	for (int b = 0; b < 64; b++) {
		ll k = 1; k <<= b;

		vector<vector<bool>> flag(N, vector<bool>(N, false));
		vector<vector<ll>> temp(N, vector<ll>(N, 0LL));

		for (int i = 0; i < N; i++) {
			if (S[i] == 0 && (U[i] & k) == k) {
				for (int j = 0; j < N; j++) {
					temp[i][j] = k;
					flag[i][j] = true;
				}
			}
			if (S[i] == 1 && (U[i] & k) == 0) {
				for (int j = 0; j < N; j++) {
					temp[i][j] = 0;
					flag[i][j] = true;
				}
			}
		}
		for (int j = 0; j < N; j++) {
			if (T[j] == 0 && (V[j] & k) == k) {
				for (int i = 0; i < N; i++) {
					temp[i][j] = k;
					flag[i][j] = true;
				}
			}
			if (T[j] == 1 && (V[j] & k) == 0) {
				for (int i = 0; i < N; i++) {
					temp[i][j] = 0;
					flag[i][j] = true;
				}
			}
		}
		const int M = 100;
		int m;
		for (m = 0; m < M; m++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					if (flag[i][j]) { continue; }
					if (S[i] == T[j]) {
						temp[i][j] = (S[i] ? k : 0);
						flag[i][j] = true;
					}
					else {
						bool f = rand() >= (RAND_MAX / 2);
						temp[i][j] = (f ? k : 0);
					}
				}
			}
			bool result = true;
			for (int i = 0; i < N; i++) {
				if (result == false) { break; }
				ll t;
				if (S[i] == 0) {
					t = k;
					for (int j = 0; j < N; j++) {
						t &= temp[i][j];
					}
				}
				else {
					t = 0;
					for (int j = 0; j < N; j++) {
						t |= temp[i][j];
					}
				}
				if (t != (U[i] & k)) { result = false; break; }
			}
			for (int j = 0; j < N; j++) {
				if (result == false) { break; }
				ll t;
				if (T[j] == 0) {
					t = k;
					for (int i = 0; i < N; i++) {
						t &= temp[i][j];
					}
				}
				else {
					t = 0;
					for (int i = 0; i < N; i++) {
						t |= temp[i][j];
					}
				}
				if (t != (V[j] & k)) { result = false; break; }
			}
			if (result == true) { break; }
		}

		if (m == M) {
			cout << "-1" << endl;
			return 0;
		}

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				ans[i][j] += temp[i][j];
			}
		}
	}

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

	return 0;
}

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

int main(){
    int N;
    int K;
    string S;
    
    cin >> N >> K >> S;
    
    if (S[K - 1] == 'A'){
        S[K - 1] = 'a';
    }
    if (S[K - 1] == 'B'){
        S[K - 1] = 'b';
    }
    if (S[K - 1] == 'C'){
        S[K - 1] = 'c';
    }
    
    cout << S << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m;
vector < int > g[N];
priority_queue < int > q;                                             

int main () {
	SpeedForce;
	cin >> n >> m;
	for (int i = 1, a, b; i <= n; i ++) {
		cin >> a >> b;   
		g[a].pb(b);
	}
	ll sum = 0;
	for (int i = 1; i <= m; i ++) {
		for (auto j : g[i]) q.push(j);
		if (q.size()) {
			sum += q.top();
			q.pop();
		}	
	}
	cout << sum;
	return Accepted;
}

// B...a

Measured memory_bytes: 17408
#include<stdio.h>
#include<math.h>
int reverse(int a){
    return a>=0?a:a*(-1);
}
int main(){
    int i,n,x[1001],y[1001],sub[1001]={0,};
    double d,D1=0,D2=0,D3=0,D=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&y[i]);
        sub[i]=x[i]-y[i];
        d=reverse(sub[i]);
        D1+=d;
        D2+=sub[i]*sub[i];
        D3+=d*d*d;
        if(D<d){
            D=d;   
        }
    }
    D2=sqrt(D2);
    D3=cbrt(D3);
    printf("%lf\n",D1);
    printf("%lf\n",D2);
    printf("%lf\n",D3);
    printf("%lf\n",D);
    return 0;
}


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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef pair <ll ,ll> pll;
typedef pair <int ,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define print(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 2e5 + 2;
const double PI = 3.141592653589 , eps = 1e-8;


void solve(){
    int A , B , m;
    cin >> A >> B >> m;
    vector <int> a(A) , b(B);
    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;

    int ans = *min_element(all(a)) + *min_element(all(b));

    while(m-->0){
        int c , x , y; cin >> x >> y >> c; x-- , y--;
        ans = min(ans , a[x] + b[y] - c);
    }
    cout << ans;
}

int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #endif
    cout.precision(20);

    for (int t = 1; t--;) solve();

    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 H,W,D;
    cin >> H >> W >> D;

    vector<vector<i64>> A(H,vector<i64>(W));

    vector<pair<i64,i64>> pos(100000,make_pair(-1,-1));
    rep(i,0,H) rep(j,0,W){
        cin >> A[i][j];
        pos[A[i][j]]=make_pair(i,j);
    }

    vector<i64> acc(100000);
    rep(i,D,100000){
        int y1=pos[i-D].first,x1=pos[i-D].second;
        int y2=pos[i].first, x2=pos[i].second;
        if(y1==-1 and x1==-1) continue;
        if(y2==-1 and x2==-1) continue;
        acc[i]=acc[i-D]+abs(y1-y2)+abs(x1-x2);
    }

    int Q;
    cin >> Q;

    rep(i,0,Q){
        i64 L,R,ans=0;
        cin >> L >> R;
        cout << acc[R]-acc[L] << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n;
  double t,a;
  cin>>n>>t>>a;
  int id;
  double dif=1e9;
  for(int i=0;i<n;i++){
    double h;
    cin>>h;
    double tmp=abs(a-(t-h*0.006));
    if(tmp<dif){
      id=i;
      dif=tmp;
    }
  }
  cout<<id+1<<endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        q: usize,
        s: chars,
        lrs: [(usize1,usize1);q]
    }
    let mut cnt = 0;
    let mut v = vec![0;n];
    for i in 1..n {
        if s[i-1] == 'A' && s[i] == 'C' {
            cnt += 1;
        }
        v[i] = cnt;
    }
    for (l,r) in lrs {
        println!("{}", v[r] - v[l]);
    }
}


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

using namespace std;

int main() {
    string S; cin >> S;
    int tmp = 0;
    int cnt = 0;

    for(int i = 0; i < S.length(); i++) {
        if(S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G') tmp++;
        else{
            cnt = max(cnt, tmp);
            tmp = 0;
        }
    }
    if(tmp != 0) cnt = max(cnt, tmp);

    cout << cnt << endl;
    return 0;
}

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

int main() {
	char  a[100][100];
	int H, W, i, j, icount[100], jcount[100];
	memset(icount, 0, sizeof(icount));
	memset(jcount, 0, sizeof(jcount));

	scanf("%d %d", &H, &W);
	for (i = 0; i < H; i++) {
		scanf("%s", &a[i]);
		for (j = 0; j < W; j++) {
			if (a[i][j] == '.') {
				icount[i]++;
				jcount[j]++;
			}
		}
	}

	for (i = 0; i < H; i++) {
		if (icount[i] != W) {
			for (j = 0; j < W; j++) {
				if (jcount[j] != H) {
					printf("%c", a[i][j]);
				}
			}
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 128
n, m = map(int,input().split())
stairs = [0] * (n + 1)
for _ in range(m):
    stairs[int(input())] = 1

patterns = [1]
if stairs[1]:
    patterns.append(0)
else:
    patterns.append(1)

for i in range(2, n + 1):
    if stairs[i]:
        patterns.append(0)
    else:
        patterns.append(patterns[i - 1] + patterns[i - 2])

print(patterns[-1] % 1000000007)

Measured memory_bytes: 460788
A,B,C,D,E,F = map(int,input().split())
M = []
S = []

for a in range(1+F//100):
    for b in range(1+F//100):
        if 100*(a*A+b*B)<=F:
            M.append(100*(a*A+b*B))

for c in range(1+F//C):
    for d in range(1+F//D):
        if c*C+d*D<=F:
            S.append(c*C+d*D)

ans1 = 0
ans2 = 0
t = -1
for m in M:
    for s in S:
        if m==s==0:
            pass
        elif m+s<=F and s<=E*m//100 and t<(100*s)/(s+m):
            t = (100*s)/(s+m)
            ans1 = m+s
            ans2 = s

print(ans1, ans2)

Measured memory_bytes: 12552
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   int H,W;
   cin>>H>>W;
  string K;
   for(int i=0;i<H;i++){
   cin>>K;
   cout<<K<<endl<<K<<endl;
   }
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int32_t main(){
	int a,b;
	cin>>a>>b;
	if(a<0){
		if(b<a){
			cout<<2+a-b;
			return 0;
		}
		if(b<=0){
			cout<<b-a;
			return 0;
		}
		if(b<-a){
			cout<<1-a-b;
			return 0;
		}
		else {
			cout<<1+b+a;
			return 0;
		}
	}
	else {
		if(b<-a){
			cout<<1-a-b;
			return 0;
		}
		if(b<=0){
			cout<<1+a+b;
			return 0;
		}
		if(b<a){
			cout<<2+a-b;
			return 0;
		}
		else {
			cout<<b-a;
			return 0;
		}
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    ll N = S.size();

    vector<ll> X(N);
    map<ll, ll> Y;
    reverse(S.begin(), S.end());
    ll rem = 0;
    ll ten = 1;
    Y[0]++;
    REP(i,N){
        int x = S[i] - '0';
        ll y = ten*x + rem;
        ten *= 10;
        ten %= 2019;
        y %= 2019;
        Y[y] ++;
        rem = y;
    }

    ll ans = 0;
    for(auto&& p : Y){
        ll n = p.second;
        ans += n * (n-1)/ 2;
    }

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


Measured memory_bytes: 5216
const main = (X,L) => {
    var count = 0
    L.reduce((acc,current) => {
        if (X >= acc+current) {
            count++
        }
        return acc+current
    },0)
    return count+1
}

const input = require('fs').readFileSync('/dev/stdin','utf8').split("\n")
const NX = input[0].split(" ").map(i => Number(i))
const N = NX[0]
const X = NX[1]
const L = input[1].split(" ").map(i => Number(i))
console.log(main(X,L))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct xy {int x; int y;};
struct xyd {
	int x; int y; ll d;
};

int main(){
	int h, w, k; 
	cin >> h >> w >> k;
	xy s, g;
	cin >> s.x >> s.y >> g.x >> g.y;
	s.x--; s.y--; g.x--; g.y--;
	vector<vector<bool>> f(h,vector<bool>(w,0));
	char c;
	REP(i,h)REP(j,w){
		cin >> c;
		if(c=='@')
			f[i][j]=1;
	}
	VVI d(h,VI(w,INF)); d[s.x][s.y]=0;
	queue<xy> q; q.push({s.x,s.y});
	while (!q.empty()) {
		int x=q.front().x, y=q.front().y;
		q.pop();
		REP(i,4){
			for(int j=1;j<=k;j++){
				int tox=x+dx[i]*j, toy=y+dy[i]*j;
				if(tox<0||tox>=h||toy<0||toy>=w)
					break;
				if(f[tox][toy])
					break;
				if(d[tox][toy]<d[x][y]+1)
					break;
				else if(d[tox][toy]==d[x][y]+1)
					continue;
				else{
					d[tox][toy]=d[x][y]+1;
					q.push({tox,toy});
				}
			}
		}
	}
	if(d[g.x][g.y]==INF)
		cout << -1 << endl;
	else
		cout << d[g.x][g.y] << endl;
}

Measured memory_bytes: 19028
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int n;
    cin>>n;
    int A[n],B[n],C[n-1];
    for(int i=0;i<n;++i){
      cin>>A[i];
    }
    for(int i=0;i<n;++i){
      cin>>B[i];
    }
    for(int i=0;i<n-1;++i){
      cin>>C[i];
    }
    int ans=0;
    for(int i=0;i<n;++i){
      ans+=B[A[i]-1];
      if(i>0 && A[i]-A[i-1]==1){
        ans+=C[A[i-1]-1];
      }
    }

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


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

	int x;
	int i = 1;
	

	while (cin >> x, x){

		cout << "Case" << " " << i << ": ";

		cout << x << endl;

		i++;

	}


return 0;
}


/*

while(1)
{
	if(x==0)
	{
		break;
	}
	
	cout << "Case" << " " << i << ": ";

	cout << x << endl;

	i++;



}






*/



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

def solve(s):
    return sum(resolve(s, pfs) for pfs in range(2 ** (len(s) - 1)))

def resolve(s, pfs):
    return eval(addp(s, pfs))

def addp(s, pfs):
    if len(s) == 1:
        return s
    if pfs & 1:
        return addp(s[:-1], pfs >> 1) + '+' + s[-1]
    else:
        return addp(s[:-1], pfs >> 1) + s[-1]

def main():
    s = input()
    print(solve(s))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

inline int signof(int a) {
	if(a>0) return 1;
	if(a<0) return -1;
	return 0;
}

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

	int count = 0;
	for(int i=0;i<n;i++) {
		count++;
		if(i+1==n) goto stop;
		while(a[i+1]-a[i]==0) {
			i++;
			if(i+1==n) goto stop;
		}
		int sign = signof(a[i+1]-a[i]);
		while((a[i+1]-a[i])*sign>=0) {
			i++;
			if(i+1==n) goto stop;
		}
	}

stop:
	print(count);

	return 0;
}


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

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  if (a.at(0) == 5 && a.at(1) == 5 && a.at(2) == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

int main() {
  string s;
  cin >> s;
  int n = s.length() + 1;
  int a[n];
  long long sum =0;
  int dp[n-1];
  dp[n-2] = ( s[n-2] == '<' ) ? 0 : 1;
  for ( int i = n-3; i >= 0; i-- ) {
    dp[i] = ( s[i] == '<' ) ? 0 : dp[i+1]+1;
  }

  a[0] = dp[0];
  for ( int i = 1; i < n-1; i++ ) {
    if ( s[i] == '<' ) {
      if ( s[i-1] == '<' ) {
        a[i] = a[i-1]+1;
      } else {
        a[i] = 0;
      }
    } else {
      if ( s[i-1] == '<' ) {
        a[i] = ( a[i-1]+1 > dp[i] ) ? a[i-1]+1 : dp[i];
      } else {
        a[i] = dp[i];
      }
    }
  }
  a[n-1] = ( s[n-2] == '>' ) ? 0 : a[n-2]+1;

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


  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4740
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    int W, H;
    int island[55][55];
    int ans;
    vector<int> ansarr;
    queue<pair<int, int> > que;
    pair<int, int> state;
    while(true){
        cin>>W>>H;
        if((W==0) && (H==0)) break;
        for(int i=0;i<H;++i){
            for(int j=0;j<W;++j){
                cin>>island[i][j];
            }
        }
        ans = 0;
        for(int i=0;i<H;++i){
            for(int j=0;j<W;++j){
                if(island[i][j]==1){
                    ans++;
                    que.push(mp(i, j));
                    while(!que.empty()){
                        state = que.front();que.pop();
                        if(island[state.fi][state.se]==0) continue;
                        island[state.fi][state.se] = 0;
                        if((state.fi>0) && (island[state.fi-1][state.se]==1)){
                            que.push(mp(state.fi-1, state.se));
                        }
                        if((state.fi<H-1) && (island[state.fi+1][state.se]==1)){
                            que.push(mp(state.fi+1, state.se));
                        }
                        if((state.se>0) && (island[state.fi][state.se-1]==1)){
                            que.push(mp(state.fi, state.se-1));
                        }
                        if((state.se<W-1) && (island[state.fi][state.se+1]==1)){
                            que.push(mp(state.fi, state.se+1));
                        }
                        if((state.fi>0) && (state.se>0) && (island[state.fi-1][state.se-1]==1)){
                            que.push(mp(state.fi-1, state.se-1));
                        }
                        if((state.fi>0) && (state.se<W-1) && (island[state.fi-1][state.se+1]==1)){
                            que.push(mp(state.fi-1, state.se+1));
                        }
                        if((state.fi<H-1) && (state.se>0) && (island[state.fi+1][state.se-1]==1)){
                            que.push(mp(state.fi+1, state.se-1));
                        }
                        if((state.fi<H-1) && (state.se<W-1) && (island[state.fi+1][state.se+1]==1)){
                            que.push(mp(state.fi+1, state.se+1));
                        }
                    }
                }
            }
        }
        ansarr.push_back(ans);
    }
    for(int i=0;i<ansarr.size();++i){
        cout<<ansarr[i]<<endl;
    }
}




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

int a,b,c,d;
int sc(int A,int B){
	return A*a+B*b+A/10*c+B/20*d;
}
int main(){
	int h1,h2,k1,k2;cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d;
	int A=sc(h1,h2),B=sc(k1,k2);
	if(A>B)puts("hiroshi");
	else if(A<B)puts("kenjiro");
	else puts("even");
}

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

int main() {
  string s;
  cin >> s;
  int e = 0;
  rep(i, s.size()) if (i % 2 == 0 && s[i] == '1' || i % 2 == 1 && s[i] == '0') ++e;
  int ans = min(e, (int)s.size() - e);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3704
#include <stdio.h>
#include <stdlib.h>

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int res = 0;
  int i;

  for ( i = 0; i < 10; ++i )
  {
    int d;

    scanf ( "%d", &d );
    res += d;
  }

  printf ( "%d\n", res );

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 600
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np
import functools
 
#  = input()
n  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
t  = [int(input()) for i in range(n)]
#
# c = collections.Counter()

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def multiple(a, b):
    return a*b // euclid(a, b)

def gcd(nums):
    return functools.reduce(euclid, nums)

def lcm(nums):
        return functools.reduce(multiple, nums)

print(lcm(t))


Measured memory_bytes: 15704
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a,x[100005]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a;
    x[a]=i+1;
  }
  for(int i=1; i<=n; i++) {
    cout << x[i] << " ";
  }
  cout << endl;
}

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

bool vis[366][4][4][8][8][8][8]={0};
bool isevent[366][4][4];

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

bool canstay(int day,int tary,int tarx){
  rep(i,2){
    rep(j,2){
      if (isevent[day][tary+i][tarx+j])return false;
    }
  }
  return true;
}

bool is_rain_full(int cur[4][4]){
  rep(i,4){
    rep(j,4){
      if (cur[i][j] == 7)return false;
    }
  }
  return true;
}

void rain(int ney,int nex,int cur[4][4]){
  rep(i,4){
    rep(j,4){
      cur[i][j]++;
    }
  }
  rep(i,2){
    rep(j,2){
      cur[ney+i][nex+j]=0;
    }
  }
}

bool dfs(int n,int now,int y,int x,
       int lu,int ru,int ld,int rd,
	 int cur[4][4]){

  if (!is_rain_full(cur))return false;
  if (n == now){
    return true;
  }


  if (!canstay(now,y,x) )return false;
  rain(y,x,cur);


  if (vis[now][y][x][lu][ru][ld][rd])return false;
  vis[now][y][x][lu][ru][ld][rd]=true;
  



  int tmp[4][4];
  rep(k,9){
    int nex=x+dx[k],ney=y+dy[k];
    if (nex < 0|| ney < 0||
	nex > 2|| ney > 2)continue;
    rep(i,4)rep(j,4)tmp[i][j]=cur[i][j];
    if (dfs(n,now+1,ney,nex,
	    cur[0][0],cur[0][3],
	    cur[3][0],cur[3][3],
	    cur))return true;
    rep(i,4)rep(j,4)cur[i][j]=tmp[i][j];
  }
  return false;
}

main(){
  int n;
  while(cin>>n && n){
    rep(k,n){
      rep(i,4)
	rep(j,4)cin>>isevent[k][i][j];
    }
    rep(i,4)rep(j,4)isevent[n][i][j]=0;
    rep(i,n)
      rep(j,4)
      rep(k,4)
      rep(l,8)
      rep(m,8)
      rep(o,8)
      rep(p,8)
      vis[i][j][k][l][m][o][p]=false;
    
    int cur[4][4]={0};
    cout << dfs(n,0,1,1,0,0,0,0,cur)<<endl;
  }
  return false;
}

Measured memory_bytes: 23000
#include <iostream>
#include <string>
#include <limits.h>
#include <numeric>
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,c) for (int i=0;i<c;i++)
using namespace std;
 
 
int main(){
    int ans = 1000000000;
    int N;

    cin >> N;
    vector<int> X(N);
    rep(i,N) cin>>X[i];
    int L=X[0],R=X[0];
    rep(i,N){
        L = min(L,X[i]);
        R = max(R,X[i]);
    } 
    
    for(int i=L;i<=R;i++){
        int cost = 0;
        rep(j,N) cost += (X[j]-i)*(X[j]-i);
        ans = min(ans,cost);

    }
    cout << ans << endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}



int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b;
	cin >>a >>b;

	if(a>b) swap(a,b);
	string s;
	rep(i, b) s += a+'0';
	cout << s <<"\n";
	return 0;
}


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

template<typename integer>
integer __lcm(integer a, integer b) {
  return (a * b) / __gcd(a, b);
}

int main() {
  int a, b;                                                                     cin >> a >> b;

  if (a > b) {
    cout << a - 1 << endl;
  } else {
    cout << min(a, b) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
  if(b==0) 
    return a;
  return gcd(b,a%b);
}

int main()
{
int N,X;
cin>>N>>X;
vector<int> x(N);
  for(int i=0;i<N;i++)
  {
  	int a;
	cin>>a;
    x.at(i)=abs(X-a);
  }
int ans=x.at(0);
  for(int i=1;i<N;i++)
  {
    ans=gcd(ans,x.at(i));
  }
cout<<ans<<endl;
return 0;
}

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

int main() {
  int n, m, k;
  bool c = 0;
  cin >> n >> m >> k;
  rep(i, n+1){
    rep(j, m+1){
      if(i*(m-j)+(n-i)*j == k){
        c = 1;
        break;
      }
    }
    if(c) break;
  }
  if(c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  string SS = S;
  reverse(SS.begin(), SS.end());
  deque<string> fro;
  deque<string> bac;
  int rev = 0;
  int Q; cin >> Q;
  REP(i, Q){
    int T; cin >> T;
    if(T == 1){
      rev++;
    }else{
      int F; cin >> F;
      string C; cin >> C;
      if(F == 1 && rev%2 == 0 || F == 2 && rev%2 == 1){
        fro.push_front(C);
      }else{
        bac.push_back(C);
      }
    }
  }
  if(rev%2 == 0){
    while(!fro.empty()){
      cout << fro.front();
      fro.pop_front();
    }
    cout << S;
    while(!bac.empty()){
      cout << bac.front();
      bac.pop_front();
    }
    cout << endl;
  }else{
    while(!bac.empty()){
      cout << bac.back();
      bac.pop_back();
    }
    cout << SS;
    while(!fro.empty()){
      cout << fro.back();
      fro.pop_back();
    }
    cout << endl;
  }
}

Measured memory_bytes: 11728
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct P {
  int x,y,cx,cy;
  int cost;
  P(int x,int y,int cx,int cy,int cost) : x(x),y(y),cx(cx),cy(cy),cost(cost) {}
};
const bool operator<(const P &a, const P &b) {
  return a.cost > b.cost;
}

bool visited[7][7][7][7];
int main() {
  int w,h;
  while(cin>>w>>h,w||h) {
    int ba[w][h];
    priority_queue<P> Q;
    int sx,sy,cx,cy;
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
        if (ba[x][y] == 4) {
          sx = x; sy = y;
        } else if (ba[x][y] == 2) {
          cx = x; cy = y;
        }
      }
    }
    Q.push(P(sx,sy,cx,cy,0));
    memset(visited,0,sizeof(visited));
    const int dx[] = {-1,0,1,0};
    const int dy[] = {0,1,0,-1};
    int res = -1;
    while(!Q.empty()) {
      P now = Q.top(); Q.pop();
      int x=now.x,y=now.y,cx=now.cx,cy=now.cy,cost=now.cost;
      if (visited[x][y][cx][cy]) continue;
      visited[x][y][cx][cy] = 1;
      //printf("%d,%d,%d,%d\n",x,y,cx,cy);
      if (ba[cx][cy] == 3) {
        res = cost;
        break;
      }
      REP(k,4) {
        int xx = x+dx[k];
        int yy = y+dy[k];
        if (xx<0||xx>=w||yy<0||yy>=h) continue;
        if (ba[xx][yy] == 1) continue;
        if (xx==cx&&yy==cy) {
          // push
          int xxx = cx+dx[k];
          int yyy = cy+dy[k];
          if (xxx<0||xxx>=w||yyy<0||yyy>=h) continue;
          if (ba[xxx][yyy] == 1 || visited[x][y][xxx][yyy]) continue;
          Q.push(P(x,y,xxx,yyy,cost+1));
        } else {
          if (visited[xx][yy][cx][cy]) continue;
          // move;
          Q.push(P(xx,yy,cx,cy,cost));
        }
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
#include<cstdio>
#include<array>
using uint = unsigned int;

void scan(uint&d) {
	d = 0;
	int c;
	while (c = fgetc(stdin), c == ' ' || c == '\n');
	do
		d = d * 10 + c - '0';
	while (c = fgetc(stdin), c != ' '&&c != '\n');
}
uint read() {
	uint d;
	scan(d);
	return d;
}

constexpr uint N = 502;

int main() {
	::std::array<::std::array<uint, N>, N> sum = {};
	uint n, m, q;
	scan(n);
	scan(m);
	scan(q);
	uint l, r;
	while (m--) {
		scan(l);
		scan(r);
		++sum[1][r];
		--sum[l + 1][r];
	}

	for (uint i = 1;i < N;++i) {
		for (uint j = 1;j < N;++j) {
			sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
		}
	}

	while (q--) {
		scan(l);
		scan(r);
		printf("%u\n", sum[l][r]);
	}
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S.size()<26) {
    vector<int> c(26,0);
    int x;
    for (int i=0;i<S.size();i++) {
      x=S.at(i)-'a';
      c.at(x)++;
    }
    char y;
    for (int i=0;i<26;i++) {
      if (c.at(i)==0) {
        y = i+97;
        cout << S+y << endl;
        break;
      }
    }
  }
  
  else {
    int count,judge=0;
    for (int i=25;i>0;i--) {
      if (i==1) {
        if (S.at(1)=='y') {
          break;
        }
        else {
          judge=2;
          break;
        }
      }
      if (S.at(i-1)-'a' < S.at(i)-'a') {
        int A,B,gap,mingap=30,index;
        A=S.at(i-1)-'a';
        for (int j=25;j>=i;j--) {
          B=S.at(j)-'a';
          gap=B-A;
          if (gap>0 && mingap>gap) {
            mingap=gap;
            index=j;
          }
        }
        S.at(i-1)=S.at(index);
        count=i;
        judge=1;
        break;
      }
    }
    
    if (judge==0) {
      cout << -1 << endl;
    }
    else if (judge==1) {
      for (int i=0;i<count;i++) {
        cout << S.at(i);
      }
      cout << endl;
    }
    else if (judge==2) {
      int x;
      char y;
      x = S.at(0)-'a';
      y = x+98;
      cout << y << endl;
    }
  }     
}

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

int main(){
    int a,b,c;
    cin >> c >> a >> b;
    if(max(a,max(b,c))==a) cout << b*c/2 << endl;
    if(max(a,max(b,c))==b) cout << c*a/2 << endl;
    if(max(a,max(b,c))==c) cout << a*b/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
#define N_max 200

int main(){
    int N;
    long long int A[N_max];
    cin >> N;
    for(int i=0;i<N;i++){
        scanf("%lld",&A[i]);
    }

    int count=0;
    bool flag=true;
    while(1){
        flag=true;
        for(int i=0;i<N;i++){
            if(A[i]%2==0) A[i]/=2;
            else{
                flag=false;
                break;
            }
        }
        if(flag) count+=1;
        else break;
    }
    printf("%d\n",count);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int tam = 100010;int ara[100010], arb[100010];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	cin>>n;
	string dir = "DULR";
	int ar[31];
	ll d[31];
	d[0] = 1;
	fore(i, 1, 31)
		d[i] = d[i -1] * 2;
	bool bo = false;
	pair<int,int> que[n];
	fore(i, 0, n) cin>>que[i].f>>que[i].s;
	fore(i, 0, n-1)
	{
		if((abs(que[i].f + que[i].s) % 2) != (abs(que[i+1].f + que[i+1].s) % 2))
		{
			cout<<"-1\n";
			return 0;
		}
	}
	bo = ((que[0].f + que[0].s) % 2) == 0;
	cout<<31 + bo<<'\n';
	if(bo) cout<<1<<' ';
	fore(i, 0, 31)
	{
		if(i > 0) cout<<' ';
		cout<<d[i];
	}
	cout<<'\n';
	fore(i, 0, n)
	{
		ll a = que[i].f, b = que[i].s;
		string res = "";
		if(bo)
		{
			res += "L";
			a++;
		}
		ll su = abs(a) + abs(b);
		int sen = 1;
		for(int i = 30; i > -1; i--)
		{
			ar[i] = sen;
			if(d[i] > su)
				sen = abs(sen-1);
			su = abs(su - d[i]);
		}
		ll va = 0;
		fore(i, 0, 31)
		{
			if(ar[i])
				va += d[i];
			else
				va -= d[i];
		}
		//cout<<va<<'\n';
		ll ax = abs(a);
		fore(i, 0, 31)
		{
			if(ax & d[i])
			{
				ax += (ar[i] ? -1 : 1) * d[i];
				ar[i] += 2;
			}
		}
		fore(i, 0, 31)
		{
			if(b < 0)
			{
			if((ar[i] < 2))
			{
				ar[i] = abs(ar[i] - 1);
			}	
		}
			if( a < 0)
			{
				if(ar[i] > 1)
				{
					if(ar[i] == 2)
						ar[i] = 3;
					else
						ar[i] = 2;
				}
			}
		}
		fore(i, 0, 31)
			res += dir[ar[i]];
			cout<<res<<'\n';
			ll x = 0, y = 0;

	}
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	if (*(long long int*)a < *(long long int*)b)return 1;
	if (*(long long int*)a > * (long long int*)b)return -1;
	return 0;
}
long long int absll(long long int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	qsort(a, n, sizeof(long long int), asc);
	int x = 1;
	for (i = 1; i < n; i++)
		if (abs(a[0] - 2 * a[i]) < abs(a[0] - 2 * a[x]))
			x = i;
	printf("%lld %lld\n", a[0], a[x]);
	return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;


int main() {
  int N; cin >> N;
  int C[505],S[505],F[505];
  int t[505];
  for ( int i = 1; i < N; i++ ) cin >> C[i] >> S[i] >> F[i];

  for ( int i = 1; i < N; i++ ) {
    int t = S[i]+C[i];
    
    for( int j = i+1; j < N; j++ ) {
      if ( t < S[j] ) {
	t = S[j];
      } else if ( t > S[j] ) {

	if ( t % F[j] != 0 ) {
	  int tmp = t - S[j];
	  	  int k = (tmp-1)/F[j] + 1;
		  //cout << "tmp " << tmp << " " << "k " << " " << k  << endl;
	  	  t = S[j] + F[j] * k;
	  //	  t = t+F[j] - t % F[j];
	}

      }
      t += C[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b;
  scanf("%d %d", &a, &b);

  if(a < b){
    printf("a < b\n");
  }
  else if(a > b){
    printf("a > b\n");
  }
  else{
    printf("a == b\n");
  }

  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong sum;

int main() {
    cin >> n;

    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }

    cout << sum << endl;

    return 0;
}


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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
      cout << "vowel" << endl;
  }
  else {
      cout << "consonant" << endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;++i) cin>>L[i];
  sort(L.begin(), L.end());
  ll ans = 0;
  for(int i=0;i<N;++i) {
    for(int j=i+1;j<N;++j) {
      ans += lower_bound(L.begin(), L.end(), L[i]+L[j])-(L.begin()+j)-1;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3644
#include <stdio.h>

int main(){
  int n, k, lose[1000][2], i, j, a, b;
  int answer;

  scanf("%d",&n);
  scanf("%d",&k);
  for(i = 0 ; i < k ; i++){
    for(j = 0 ; j < 2 ; j++){
      scanf("%d",&lose[i][j]);
    }
  }
  for(i = 0 ; i < k ; i++){
    if(n%2 == 0){
      if(n/2 < lose[i][0])
	a = n - lose[i][0]+1;
      else a = lose[i][0];
      if(n/2 < lose[i][1])
	b = n - lose[i][1]+1;
      else b = lose[i][1];
    }
    else if(n%2 == 1){
      if((n+1)/2 < lose[i][0])
	a = n - lose[i][0]+1;
      else a = lose[i][0];
      if((n+1)/2 < lose[i][1])
	b = n - lose[i][1]+1;
      else b = lose[i][1];
    }
    if(a < b){
      answer = a % 3;
      if(answer == 0)
	answer = 3;
    }
    else if(a > b){
      answer = b % 3;
      if(answer == 0)
	answer = 3;
    }
    else {
      answer = a % 3;
      if(answer == 0)
	answer = 3;
    }
    printf("%d\n",answer);
  }
  return 0;
}

Measured memory_bytes: 604
/*****************************************
Author: lizi
Email: lzy960601@outlook.com
****************************************/
  
#include<bits/stdc++.h>
  
using namespace std;
  
const double eps=1e-10;
const double pi=3.1415926535897932384626433832795;
const double eln=2.718281828459045235360287471352;
  
#define LL long long
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define scan(x) scanf("%d", &x)
#define mp make_pair
#define pb push_back
#define sqr(x) (x) * (x)
#define pr(x) printf("Case %d: ",x)
#define prn(x) printf("Case %d:\n",x)
#define prr(x) printf("Case #%d: ",x)
#define prrn(x) printf("Case #%d:\n",x)
#define lowbit(x) (x&(-x))

const int maxn=100005;
int a[maxn],n;
int b[3];
int now,cnt;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(int i=n;i>=1;i--)
    {
        if(now!=a[i]){now=a[i];continue;}
        if(now==a[i])
        {
            b[0]++;
            b[b[0]]=a[i];
            if(b[0]>=2)break;
            now=0;
        }
    }
    printf("%lld\n",1ll*b[1]*b[2]);
    return 0;
}


Measured memory_bytes: 640