akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

lint mypow(lint a, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B, C, K;
	cin >> A >> B >> C >> K;

	cout << A + B + C + max({ A,B,C }) * mypow(2, K) - max({ A,B,C }) << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if( (Math.abs(a - c) <= d) || ((Math.abs(a - b) <= d) && (Math.abs(b - c) <= d)) )
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 23636
#include <iostream>
using namespace std;
int main()
{
    int n;
    int a[200];
    int t = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    bool expression = true;
    while (expression)
    {
        t++;
        for (int i = 0; i < n; i++)
        {
            if (a[i] % 2 == 0)
            {
                a[i] /= 2;
            }
            else
            {
                expression = false;
                t--;
                break;
            }
        }
    }
    cout << t;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int n, a[100001];
  std::cin >> n;
  int adj[5];
  for(int i=0;i<5;++i)adj[i]=0;
  for(int i = 0; i < n; ++i){
    std::cin >> a[i];
    if(a[i] % 4 == 0) adj[2]++;
    else if(a[i] % 2 == 0) adj[1]++;
    else adj[0]++;
  }
  if(adj[1]==0){
    if(adj[0]<=adj[2]+1)std::cout<<"Yes"<<std::endl;
    else std::cout<<"No"<<std::endl;
  }else{
    //adj[2]--;
    if(adj[0]<adj[2]+1)std::cout<<"Yes"<<std::endl;
    else {
      if(adj[0]==0 && adj[2]==0){
        std::cout<<"Yes"<<std::endl;
      }else{
        std::cout<<"No"<<std::endl;
      }
    }
  }

  return 0;
}


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

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

using ll = long long;

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

int main() {
  ll N;
  cin >> N;
  vector<string> S(N);
  for(ll i = 0LL; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    S[i]=s;
  }
  sort(S.begin(),S.end());
  vector<ll> v;
  ll t = 1LL;
  for(ll i = 0LL; i < N; i++) {
    if(i != N-1){
      if(S[i] == S[i+1LL])t++;
      if(S[i]!=S[i+1LL]){
        v.push_back(t);
        t=1LL;
      }
    }
    if(i == N-1) {
      v.push_back(t);
    }
  }
  ll ans = 0LL;
  for(ll i = 0LL; i < (ll)v.size(); i++) {
    ans += v[i]*(v[i]-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6904
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
#include<utility>
#define INF (int)1e9
#define DINF (double)1e9
#define MOD 1000000007
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> p;

//cout<<fixed<<setprecision(15)<<ans;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;
	cin >> s >> t;
	map<char, vector<int>>mps,mpt;
	for (int i = 0; i < s.size(); i++) {
		mps[s[i]].push_back(i);
		mpt[t[i]].push_back(i);
	}
	
	map<int, vector<int>> tt, ss;
	for (auto &itr : mps) {
		ss[itr.second[0]] = itr.second;
	}
	for (auto &itr : mpt) {
		tt[itr.second[0]] = itr.second;
	}
	/*for (auto itr : ss) {
		for (auto it : itr.second) {
			cout << it << " ";
		}
		cout << endl;
	}*/
	
	auto its = ss.begin();
	auto itt = tt.begin();
	while (1) {
		if (its == ss.end()) {
			break;
		}
		if (itt == tt.end()) {
			break;
		}
		if (its->second != itt->second) {
			cout << "No";
			return 0;
			break;
		}
		its++;
		itt++;
	}
	if (its == ss.end()&&itt == tt.end()) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 4372
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int days(int y,int m, int d) {
	if (m < 3) {
		y--;
		m += 12;
	}
	return 365 * y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d;
}

int main(){
	for (int m, d; cin >> m >> d, (m | d) != 0; ) {
		int a = days(2004, m, d) % 7;
		string t[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
		cout << t[a] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
//
//  main.c
//  Algae
//
//  Created by yuta on 2019/05/25.
//  Copyright © 2019 501Software. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {

	int r, D, x;
	
	// スペース区切りの整数の入力
	scanf("%d %d %d",&r,&D,&x);

	
	for (int i = 0; i < 10; i++) {
//		printf("%d\n",x);
		x = r*x-D;
		printf("%d\n",x);
//		printf("%d\n",r);
//		printf("%d\n",D);

	}
	return 0;
}


Measured memory_bytes: 128
N = int(input())
S = input()

rcs = [0] * N
gcs = [0] * N
bcs  = [0] * N

for i in range(N):
    if S[i] == 'R':
        rcs[i] = 1
    elif S[i] == 'G':
        gcs[i] = 1
    elif S[i] == 'B':
        bcs[i] = 1

for i in range(1, N):
    rcs[i] += rcs[i - 1]
    gcs[i] += gcs[i - 1]
    bcs[i] += bcs[i - 1]

result = 0
for i in range(N):
    if S[i] == 'R':
        for j in range(i + 1, N):
            if S[j] == 'R':
                continue
            elif S[j] == 'G':
                result += bcs[N - 1] - bcs[j]
                t = 2 * j - i
                if t < N and S[t] == 'B':
                    result -= 1
            elif S[j] == 'B':
                result += gcs[N - 1] - gcs[j]
                t = 2 * j - i
                if t < N and S[t] == 'G':
                    result -= 1
    elif S[i] == 'G':
        for j in range(i + 1, N):
            if S[j] == 'G':
                continue
            elif S[j] == 'R':
                result += bcs[N - 1] - bcs[j]
                t = 2 * j - i
                if t < N and S[t] == 'B':
                    result -= 1
            elif S[j] == 'B':
                result += rcs[N - 1] - rcs[j]
                t = 2 * j - i
                if t < N and S[t] == 'R':
                    result -= 1
    elif S[i] == 'B':
        for j in range(i + 1, N):
            if S[j] == 'B':
                continue
            elif S[j] == 'R':
                result += gcs[N - 1] - gcs[j]
                t = 2 * j - i
                if t < N and S[t] == 'G':
                    result -= 1
            elif S[j] == 'G':
                result += rcs[N - 1] - rcs[j]
                t = 2 * j - i
                if t < N and S[t] == 'R':
                    result -= 1
print(result)


Measured memory_bytes: 68900
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    vector<string> sss(N);
    rep(i, N){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        sss[i] = s;
    }
    sort(sss.begin(), sss.end());
    ll cnt = 0;
    rep(i, N-1){
        if(sss[i]==sss[i+1]) cnt++;
        else{
            if(cnt>0) ans+=cnt*(cnt+1)/2;
            cnt = 0;
        }
    }
    if(cnt!=0) ans+=cnt*(cnt+1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6388
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;

signed main() {
    int n;
    cin >> n;
    int k, p;

    while (n--) {
        cin >> k >> p;
        OUT((k % p == 0 ? p : k % p));
    }

    return 0;
}




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

using namespace std;
typedef pair<int,int> P;


class Edge
{
	public:
	int from,to,cost;
	Edge(int n,int c)
	{
		to=n;
		cost=c;
	}
};



int main()
{
	while(1)
	{
		int w,h;
		cin>>w>>h;
		if(w==0)
			break;
		
		vector<Edge> g[1000];
		int dist[1000];
		fill(dist,dist+1000,1e8-1);
		for(int i=0;i<2*h-1;i++)
		{
			if(i%2==0)
			{
				for(int j=0;j<w-1;j++)
				{
					int t;
					cin>>t;
					if(t==0)
					{
						g[(i/2)*w+j].push_back(Edge((i/2)*w+j+1,1));
						g[(i/2)*w+j+1].push_back(Edge((i/2)*w+j,1));
					}	
				}
			}else{
				for(int j=0;j<w;j++)
				{
					int t;
					cin>>t;
					if(t==0)
					{
						g[(i/2)*w+j].push_back(Edge((i/2)*w+j+w,1));
						g[(i/2)*w+j+w].push_back(Edge((i/2)*w+j,1));
					}	
				}
			}
		}

		dist[0]=0;
		deque<P> que;
		que.push_back(make_pair(0,0));
		while(!que.empty())
		{
			P p=que.back();
			que.pop_back();
			if(p.second>dist[p.first])
			{
				//cerr<<"err"<<endl;
				continue;
			}
			for(int j=0;j<g[p.first].size();j++)
			{
				Edge e=g[p.first][j];
				if(p.second+e.cost<dist[e.to])
				{
					dist[e.to]=p.second+e.cost;
					que.push_back(make_pair(e.to,dist[e.to]));
				}
			}
		}
		/*
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
				cout<<dist[i*w+j]<<" ";
			cout<<endl;
		}*/
		
		if(dist[w*h-1]==1e8-1)
			cout<<0<<endl;
		else
			cout<<dist[w*h-1]+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 3076
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    
    odd = 0
    even = 0
    spev = 0
    for i in a:
        if i%4 == 0:
            spev += 1
        elif i%2 == 0:
            even += 1
        else:
            odd += 1
            
    if even == 0:
        if spev >= odd-1:
            print("Yes")
        else:
            print("No")
    else:
        if spev >= odd:
            print("Yes")
        else:
            print("No")
            
if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    rrep2(d, n + 1, 1) {
        set<vi> st;
        {
            vi cnt(26);
            rep2(i, - d + 1, n - d + 1) {
                cnt[s[i + d - 1] - 'a']++;
                if (i >= 0) {
                    st.insert(cnt);
                    cnt[s[i] - 'a']--;
                }
            }
        }
        {
            vi cnt(26);
            rep2(i, - d + 1, m - d + 1) {
                cnt[t[i + d - 1] - 'a']++;
                if (st.count(cnt)) {
                    cout << d << endl;
                    return 0;
                }
                if (i >= 0) {
                    cnt[t[i] - 'a']--;
                }
            }
        }
    }
    cout << 0 << endl;
}

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

int main() {
  int p, cnt;
  while (cin >> p) {
    if (p == 0) {
      break;
    }
    cnt = 0;
    int otsu = 1000 - p;
    if (otsu >= 500) {
      otsu -= 500;
      cnt++;
    }

    if (otsu >= 100) {
      cnt += otsu / 100;
      otsu -= otsu / 100 * 100;
    }

    if (otsu >= 50) {
      cnt += otsu / 50;
      otsu -= otsu / 50 * 50;
    }

    if (otsu >= 10) {
      cnt += otsu / 10;
      otsu -= otsu / 10 * 10;
    }

    if (otsu >= 5) {
      cnt += otsu / 5;
      otsu -= otsu / 5 * 5;
    }
    if (otsu >= 1) {
      cnt += otsu;
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3016
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var w = o.l();
  var mn = 1e9;
  for(var i = 0; i < n; i++){
    var s = 0;
    for(var j = 0; j <= i; j++){
      s += w[j];
    }
    for(; j < n; j++){
      s -= w[j];
    }
    s = Math.abs(s);
    if(s < mn)mn = s;
  }
  return mn;
}

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



// E log V
const int MAXV = 101010;
const ll INF = 1e9;
struct edge { int to, cost; edge() {} edge(int t, int c) :to(t), cost(c) {}};
int V;
vector<edge> G[MAXV];
ll d[MAXV];
int prev_node[MAXV]; // 経路復元

void dijkstra(int s) {
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que; //最小
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(make_pair(0, s));

    while (!que.empty()) {
        pair<int, int> p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
                prev_node[e.to] = v;
            }
        }
    }
}

// 頂点tへの最短路
vector<int> get_path(int t) {
    vector<int> path;
    for (; t!=-1; t=prev_node[t]) {
        path.push_back(t);
    }
    reverse(path.begin(), path.end());
    return path;
}

int main() {
    int E, s;
    cin >> V >> E >> s;
    rep(i, E) {
        int x, y, d;
        cin >> x >> y >> d;
        G[x].emplace_back(y, d);
    }
    dijkstra(s);
    rep(i, V) {
        if (d[i] == INF) {
            cout << "INF" << endl;
        }
        else {
            cout << d[i] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 13828
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    ans = int(1e12)
    for i in range(1,int(N ** 0.5) + 1):
        if N % i == 0:
            ans = min(ans,i + (N // i) - 2)
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 40976
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long N, K;
pair<long long, long long> A[1 << 18];

int main() {
	cin >> N >> K; long long cnt = K - 1;
	for (int i = 0; i < N; i++) { cnt++; A[i].first += cnt; }
	for (int i = N / 2; i < N; i++) { cnt++; A[i].first += cnt; A[i].second = cnt; }
	for (int i = 0; i < N / 2; i++) { cnt++; A[i].first += cnt; A[i].second = cnt; }
	sort(A, A + N);

	long long ret = cnt;
	for (int i = 0; i < N; i++) {
		ret++;
		if (A[i].first > ret) { cout << "-1" << endl; return 0; }
	}
	for (int i = 0; i < N; i++) {
		cnt++;
		cout << A[i].first - A[i].second << " " << A[i].second << " " << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3840
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A, B, C = sc.nextInt()

  @scala.annotation.tailrec
  def loop(count: Int, acc: List[Int]): Boolean = {
    val mod = (B * count + C) % A
    if (acc.contains(mod)) false
    else if (mod == 0) true
    else loop(count + 1, mod :: acc)
  }

  println(if (loop(1, List.empty)) "YES" else "NO")
}


Measured memory_bytes: 55140
n,k = map(int,input().split())
a = list(map(int,input().split()))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+100
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
a.sort()

if k == 1:
    print(0)
else:
    ma,mi = 0,0
    for i in range(n-k+1):
        mi = (mi + (a[i] * cmb(n-1-i,k-1,mod))) % mod
        ma = (ma + (a[n-1-i] * cmb(n-1-i,k-1,mod))) % mod
        
    print((ma + mod - mi) % mod)

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

int main() {
	int v[] = {	0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2};
	int i;	cin >> i;
	cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

total = 0
for i in range(N):
    total += b[a[i]-1]
    if i >= 1 and a[i-1] + 1 == a[i]:
        total += c[a[i-1]-1]
print(total)

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

int main() {
  int a, b;
  cin >> a >> b;
  int judge = a * b;
  if(judge % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1000000007;


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N ;

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

      cin >> a[i];
      sum += a[i];
    }
    sort ( a ,a + N);

    int sum2 = 0;
    for ( int i = N-1 ;i >= 0 ; i = i-2){
      sum2 += a[i];
      //if ( i % 2 ==0) sum += a[i];
      //else if( i % 2== 1) sum2 += a[i];
      //sum2 += a[i];
      //cout << sum2<< endl;
      //if (i == 1) goto label;
    }
    int ans = sum2 - (sum -sum2);

    cout << ans << endl;

    return 0;

}



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

int main()

{
    int n,x[20],y,s=0;
    cin>>n;
   for(int i =0;i<n;i++)
   {cin>>x[i];}
for(int i =0;i<n;i++)
   {cin>>y;

      if(x[i]-y>0)
        s=s+(x[i]-y);


   }
   cout<<s;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int i = s.length()-1;
  while(i > 0){
    if(i >= 4 && s[i]=='m' && s[i-1]=='a' && s[i-2]=='e' && s[i-3]=='r' && s[i-4]=='d') i -= 5;
    else if(i >= 6 && s[i]=='r' && s[i-1]=='e' && s[i-2]=='m' && s[i-3]=='a' && s[i-4]=='e' && s[i-5]=='r' && s[i-6]=='d') i -= 7;
    else if(i >= 4 && s[i]=='e' && s[i-1]=='s' && s[i-2]=='a' && s[i-3]=='r' && s[i-4]=='e') i -= 5;
    else if(i >= 5 && s[i]=='r' && s[i-1]=='e' && s[i-2]=='s' && s[i-3]=='a' && s[i-4]=='r' && s[i-5]=='e') i -= 6;
    else break;
  }
  if(i == -1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{

int N;

scanf("%d",&N);

int A[N+1];
int i, j, hozon,min;
int count=0;

for(i=0; i<N; i++)
{
scanf("%d",&A[i]);
}

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

min = i;

for(j=i; j<N; j++)
{

if(A[min] > A[j])
{
min = j;
}

}

if(min != i)
{
hozon = A[i];
A[i] = A[min];
A[min] = hozon;
count++;
}

}

for(i=0; i<N; i++)
{
if(i > 0)
printf(" ");
printf("%d", A[i]);
}

printf("\n");
printf("%d\n", count);
return 0;

}

Measured memory_bytes: 1844
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int cut) {
		int res = 0;
		int dp[5010][5010] = {};
		for (int i = 0; i < cut; i++) {
			for (int j = cut; j < N; j++) {
				if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				chmax(res, dp[i + 1][j + 1]);
			}
		}
		return res;
	};

	// 3分探索
	int lb = 0, ub = N, ans = 0;;
	for (int i = 0; i < 25; i++) {

		int t1 = (2.5 * lb + ub) / 3.5;
		int t2 = ceil((lb + 2.5 * ub))/ 3.5;

		int c1 = check(t1);
		int c2 = check(t2);
		if (c1 < c2) lb = t1;
		else ub = t2;
		DMP(c1, c2, t1, t2);
		chmax(ans, max(c1, c2));
	}

	DMP(ub, lb);
	cout << ans << "\n";

	return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  int N;
  scanf("%d", &N);
  vpii A(N);
  rep(i, N) {
    scanf("%d", &A[i].fst);
    A[i].snd = i;
  }

  sort(ALL(A));
  set<int> p;

  ll ans = 0;

  forr(ai, A) {
    int idx = ai.snd;
    int li = 0;
    int ri = N-1;
    {
      auto l = p.lower_bound(idx);
      auto r = l;
      if (l != p.begin()) {
        l--;
        li = *l + 1;
      }
      if (r != p.end()) {
        ri = *r - 1;
      }
    }
    p.insert(idx);

    ll c = 1LL * (idx - li + 1) * (ri - idx + 1);

    ans += c * ai.fst;
    //_p("%d,(%d,%d):%lld\n", a,li,ri,c);
  }

  _p("%lld\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 11264
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = Arr[0];
            int b = Arr[1];
            int c = Arr[2];

            for (int i = 1; i < b; i++) 
            {
                if ((i * a) % b == c) 
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            Console.WriteLine("NO");
            return;
        }

    }
}


Measured memory_bytes: 28248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> ans(N,0);
    rep(i,N - 1){
        int manager;
        cin >> manager;
        ans[manager - 1]++;
    }
    rep(i,N){
        cout << ans[i] << endl;
    }
}


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

#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define i64 long long int
#define MEM(a,x) memset(a,x,sizeof(x))
#define INF 1000000000
#define mod 998244353

using namespace std ;

#define maxn 1000005

char s[505][505] ;

int main()
{
    int i , j , k , l , m , n;

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

    for(i=0 ; i<n ; i++) scanf("%s",s[i]) ;

    for(i=0 ; i<n ; i++)
    {
        for(j=0 ; j<m ; j++)
        {
            if( (s[i][j]=='#' || i%2==0  || j==0) && j!=m-1 ) printf("#") ;
            else printf(".") ;
        }
        printf("\n") ;
    }
    printf("\n") ;

    for(i=0 ; i<n ; i++)
    {
        for(j=0 ; j<m ; j++)
        {
            if( (s[i][j]=='#' || i%2==1 || j==m-1) && j!=0 ) printf("#") ;
            else printf(".") ;
        }
        printf("\n") ;
    }

    return 0 ;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll, ll> P;

#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 (b < a) { a = b; return 1; } return 0; }

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind() {}

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};
int main() {
	ll n;
	cin >> n;
	vector<ll> as(n);
	vector<P> copy(n);
	rep(i, n) {
		cin >> as[i];
		copy[i] = { as[i], i };
	}
	sort(copy.begin(), copy.end());
	P f = copy[n - 1];
	P s = copy[0];
	if (abs(s.first) <= abs(f.first)) {
		vector<P> ans;
		for (int i = 1; i < n; i++) {
			while (as[i] < as[i-1]) {
				as[i] += f.first;
				ans.emplace_back(f.second+1, i+1);
				if (as[i] > f.first) {
					f = { as[i], i };
				}
			}
			if (as[i] > f.first) {
				f = { as[i], i };
			}
		}
		cout << ans.size() << endl;
		for (auto p : ans) {
			cout << p.first << " " << p.second << endl;
		}
		return 0;
	}
	else {
		vector<P> ans;
		for (int i = n-2; i >= 0; i--) {
			while (as[i] > as[i+1]) {
				as[i] += s.first;
				ans.emplace_back(s.second+1, i+1);
				if (as[i] < s.first) {
					s = { as[i], i };
				}
			}
			if (as[i] < s.first) {
				s = { as[i], i };
			}
		}
		cout << ans.size() << endl;
		for (auto p : ans) {
			cout << p.first << " " << p.second << endl;
		}
		return 0;
	}
}


Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int H = scanner.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];

    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
      b[i] = scanner.nextInt();
    }

    Arrays.sort(a);
    Arrays.sort(b);

    int amax = a[N - 1];

    int count = 0;
    for (int i = N - 1; i >= 0; i--) {
      if (b[i] > amax && H > 0) {
        count++;
        H -= b[i];
      }
    }
    if (H > 0) {
      count += (H - 1) / amax + 1;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 80672
def erase_end(string):
    if string.endswith("dream"):
        string = string[:-5]
    elif string.endswith("dreamer"):
        string = string[:-7]
    elif string.endswith("erase"):
        string = string[:-5]
    elif string.endswith("eraser"):
        string = string[:-6]
    elif string == "":
        string = "YES"
    else:
        string = "NO"
    return string
    
string = input()

while True:
    if string == "YES" or string == "NO":
        break
    string = erase_end(string)

print(string)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    int ans1 = 0;
    int ans2 = 0;
    rep(i, 0, (int)s.size()) {
        if (i % 2 == 0) {
            if (s[i] == '0') ans2++;
            else ans1++;
        } else {
            if (s[i] == '1') ans2++;
            else ans1++;
        }
    }

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


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine().trim();

        StringBuilder sb = new StringBuilder(s.length());
        for (int i = 0; i < s.length(); i++) {
            sb.append('x');
        }

        System.out.println(sb.toString());
//        String[] colors = sc.nextLine().split(" ");
//        int a = sc.nextInt();
//        int b = sc.nextInt();
//        sc.nextLine();
//        String throwAway = sc.nextLine().trim();
//
//        if (throwAway.equals(colors[0].trim())) {
//            a--;
//        } else {
//            b--;
//        }
//
//        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string t[3] = { "Sunny", "Cloudy", "Rainy" };
    for (int i = 0; i < 3; i++) {
        if (s == t[i]) {
            cout << t[(i + 1) % 3] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll da[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n){
        cin>>a;
        if(ans==0)ans=a;
        else ans=__gcd(ans,a);
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll ku=0;
  ll si=0;
  while(s[sz(s)-1]=='#'){
    s.pop_back();
    n--;
  }
  vector<pll> p(n);
  rep(i,n){
    if(s[i]=='#') ku++;
    if(s[i]=='.') si++;
  }
  ll kuro=0;
  ll siro=0;
  rep(i,n){
    if(s[i]=='#'){
      kuro++;
      p[i].F=kuro;
      p[i].S=siro;
    }
    else{
      siro++;
      p[i].S=siro;
      p[i].F=kuro;
    }
  }
  ll ans=min(ku,si);
  rep(i,n){
    ans=min(ans,p[i].F+si-p[i].S);
  }
  COUT(ans);
}

Measured memory_bytes: 3716
N = int(input())
H = list(map(int, input().split()))
H = [0] + H

dp = [None for _ in range(N+1)]

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

print(dp[1])

Measured memory_bytes: 20492
#include<stdio.h>
#include<math.h>

int main(){
	unsigned long long int a, b, d;
	unsigned long long int i, j;
	while(scanf("%lld %lld", &a, &b) != EOF){
		if(a > b){
			d = a;
			a = b;
			b = d;
		}
		j = b;
		i = a;
		while((d = b % a) != 0){
			if(d == 0) break;
			b = a;
			a = d;
		}
		i = i * j / a;
		printf("%lld %lld\n", a, i);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<vector<int>> a(n,vector<int>(n,-1));
    
    for(int i = 0;i < n;i++){
          int A;
          cin >> A;
          for(int j = 0;j < A;j++){
                int x,y;
                cin >> x >> y;
                x--;
                a[i][x] = y;
          }
    }
    int ans = 0;
    for(int i = 0;i < 1 << n;i++){
          int t = __builtin_popcount(i);
          vector<int>v(n);
          for(int j = 0;j < n;j++){
                v[j] = i >> j &1;
            //     cout << v[j] << endl;
          }
          bool ok = true;
          for(int j = 0;j < n;j++){
                if(v[j]){
                      for(int k = 0;k < n;k++){
                            if(a[j][k] == -1)continue;
                            if(a[j][k] != v[k]){
                                  ok = false;
                            }
                      }
                }
          }
          if(ok)ans = max(ans,t);
          
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {
	long long n;

	std::cin >> n;

	std::vector<long long> v(n);

	for (long long i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	long long ans = 0;

	for (long long i = 0; i < n; i++)
	{
		while (v[i] > 0) {
			for (long long j = i; j < n && v[j] > 0; j++)
			{
				v[j]--;
			}
			ans++;
		}
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int A, B;
    cin >> A >> B;

    int ans = A * B - A - B + 1;
    cout << ans << endl;

    return 0;
}


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

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  a += b;
  c += d;
  if(a < c) cout << "Right";
  else if(a > c) cout << "Left";
  else cout << "Balanced";
  cout << endl;
  return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    ll N, A, B;
    cin >> N >> A >> B;

    if ((B - A) % 2 == 0) {
        print((B - A) / 2ll);
    } else {
        if (A - 1ll <= N - B) {
            ll ans = 0;
            ans += A - 1;
            ans++;
            ans += ((B - (A - 1) - 1) - 1) / 2;
            print(ans);
        } else {
            ll ans = 0;
            ans += N - B;
            ans++;
            ans += (N - (A + (N - B) + 1)) / 2;
            print(ans);
        }
    }
}

signed main() {
    solve();
}


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

int iRetSumDigit(char* achValue);

// 入力された整数の各桁の和を計算
// 0が入力されたら終了
int main()
{
	char achInputX[1000];
	int iAns;

	scanf("%s", achInputX);

	while (achInputX[0] != '0')
	{
		iAns = iRetSumDigit(achInputX);
		printf("%d\n", iAns);
		scanf("%s", achInputX);
	}

	return 0;
}

int iRetSumDigit(char* achValue)
{
	int iAns = 0;
	int iCnt = 0;

	while (achValue[iCnt] != '\0')
	{
		iAns += achValue[iCnt] - '0';
		iCnt++;

	}
	return iAns;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
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; }
using namespace std;

template<class Abel> struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<Abel> diff_weight;

  UnionFind(int n = 1, Abel SUM_UNITY = 0) {
    init(n, SUM_UNITY);
  }

  void init(int n = 1, Abel SUM_UNITY = 0) {
    par.resize(n); rank.resize(n); diff_weight.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
  }

  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }

  Abel weight(int x) {
    root(x);
    return diff_weight[x];
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  bool merge(int x, int y, Abel w) {
    w += weight(x); w -= weight(y);
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w;
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    diff_weight[y] = w;
    return true;
  }

  Abel diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

int main(){
  ll N,M;
  cin >> N >> M;
  UnionFind<ll> uni(N);
  rep(i,M){
    ll l,r,d;
    cin >> l >> r >> d;
    --l; --r;

    if(uni.issame(l,r)){
      if(uni.diff(l,r)!=d){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      uni.merge(l,r,d);
    }
  }
  
  cout << "Yes" << endl;



  return 0;
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    cout << (A == B ? 2 * A : max(A, B) * 2 - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> K >> S;
	int cnt = 0;
	rep(x, K+1){
		rep(y, K+1){
			if(0 <= S-x-y && S-x-y <= K) cnt++;
		}
	}
	cout << cnt;
}


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

const int INF = 1001001001;

int main() {
int h,w;
cin >> h >> w;
vector<string> vec(h);
for (int i = 0;i < h;i++) {
    cin >> vec.at(i);
} 

for (int i = 0;i < h;i++) {
  for (int j = 0;j < 2;j++) {
    cout << vec.at(i) << endl;
  }
}



return 0;
}

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

int n,a,b,c,d;
string s;

bool solve() {
    rep(i,n-1){
        if(s[i] == '#' && s[i+1] == '#'){
            if (a < i && i < c) return false;
            if (b < i && i < d) return false;
        }
    }
    if (c < d) return true;
    for (int i = b; i <= d; i++) {
        if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') return true;
    }
    return false;
}

int main(void){
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    a--,b--,c--,d--;
    cout << ((solve()) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 640
/*||>>>> Praveen Ojha <<<<>>>> 15 June 2019 <<<<>>>> 17:26:44 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n,k;
	cin>>n>>k;
	if(k==1)
		return cout<<0<<"\n",0;
	int rem=n-k;
	cout<<rem<<"\n";
return 0;
}

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

using ll = long long;

int main() {
  ll N;
  scanf("%lld", &N);

  ll ans = 0;
  if (N > 1) {
    ans = (1 + N) * N / 2;
    ans -= N;
  }

  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 256