akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
 
const int maxi=1000;
int a,b,c,d,e,f;
 
int main()
{
    cin>>a>>b>>c>>d>>e>>f;
 
   int ans1=100*a;
   int ans2=0;
 
    for (int i=0;i<=40/a;i++)
    for (int j=0;j<=(40-i*a)/b;j++)
    if (i*100*a + j*100*b<=f && i*100*a+j*100*b>0)
    {
        for (int k=0;k<=3200/c;k++)
            for (int l=0;l<=(3200-i*a*100-j*b*100-k*c)/d;l++)
            if (k*c+d*l+i*100*a + j*100*b<=f && (double)(k*c+d*l)/ (1.00*(i*a+j*b))<=e)
            {
                if (((1.00*100*ans2)/(1.00*ans1))< (double) (100.00*(k*c+l*d))/(k*c+d*l+i*100.00*a + j*100*b))
                {
                    ans2=k*c+l*d;
                    ans1=(k*c+d*l+i*100*a + j*100*b);
                }
            }
    }
    cout<<ans1<<" "<<ans2<<"\n";
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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 INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    ll n,k;
    ll h[100005];
    cin >> n >> k;
    rep(i,n) cin >> h[i];
    sort(h,h+n);
    ll ans = INF;
    rep(i,n-k+1){
        chmin(ans,h[i+k-1]-h[i]);
    }
    PRINT(ans);
}

Measured memory_bytes: 1024
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_FLOAT(): return float(INPUT())
def MULTIPLE_FLOAT_LIST(): return list(map(float, INPUT().split()))
def MULTIPLE_FLOAT_MAP(): return map(float, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

N = SINGLE_INT()

ratings = []

for i in range(N):
    c, s = MULTIPLE_STRING()
    s_int = int(s)

    ratings.append((c, s_int, i+1))

ratings.sort(key=lambda x: x[1], reverse=True)
ratings.sort(key=lambda x: x[0])

for c, s_int, id in ratings:
    print(id)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(i>1&&i<a&&j<b&&j>1)printf(".");
	  else printf("#");
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}



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

public class Main {

	public static int check(int[] list) {
		boolean[] leached = new boolean[list.length];
		Arrays.fill(leached, false);
		int count=0;
		int current=0;
		while(!leached[current]) {
			// push button
			count++;
			leached[current]=true;
			current=list[current];
			if(current==1)
				return count;
		}
		return -1;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] buttons_light=new int[n];
		for(int i=0; i<n; i++)
			buttons_light[i]=sc.nextInt()-1;
		sc.close();

		System.out.println(check(buttons_light));
	}
}


Measured memory_bytes: 50292
#include<bits/stdc++.h>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define mod 998244353
#define db double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
    int x,ch;while((ch=gc)<'0'||ch>'9');
    x=ch^'0';while((ch=gc)>='0'&&ch<='9')
        x=(x<<1)+(x<<3)+(ch^'0');return x;
}
const int N=1000010;int fac[N],facinv[N];
inline int fast_pow(int x,int k,int ans=1) { for(;k;k>>=1,x=(lint)x*x%mod) if(k&1) ans=(lint)ans*x%mod;return ans; }
inline int prelude(int n)
{
    rep(i,fac[0]=1,n) fac[i]=(lint)fac[i-1]*i%mod;
    facinv[n]=fast_pow(fac[n],mod-2);
    for(int i=n-1;i>=0;i--) facinv[i]=(i+1ll)*facinv[i+1]%mod;
    return 0;
}
inline int C(int n,int m) { if(n<0||m<0||n<m) return 0;return (lint)fac[n]*facinv[m]%mod*facinv[n-m]%mod; }
inline int calc(int a,int b,int c,int d) { return C(c-a+d-b,c-a); }
int main()
{
    int a=inn(),b=inn();lint ans=0;if(a<b) swap(a,b);prelude(a+b);
    for(int i=1;i<=b;i++) ans+=(lint)calc(0,0,i,i)*calc(i,i,a,b)%mod;
    return !printf("%lld\n",(ans%mod*fast_pow(2,mod-2)%mod*fast_pow(C(a+b,a),mod-2)+a)%mod);
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    double pi = 3.141592653589793;
    long long a, b, h, m;
    cin >> a >> b >> h >> m;
    double x = abs(30 * h - 5.5 * m);
    // cout << x << endl;
    if (x > 180) {
        x = 360 - x;
    }
    cout << sqrt(a * a + b * b - 2 * a * b * cos(pi * (double(x) / 180))) << endl;
}

Measured memory_bytes: 4208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static long Gcd(long a, long b)
        {
            Func<long, long, long> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static IEnumerable<long> PrimeFactors(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n)
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;
        }
        static void Main(string[] args)
        {
            string[] h2 = Console.ReadLine().Split(' ');
            long A = long.Parse(h2[0]);
            long B = long.Parse(h2[1]);
            long gcd = Gcd(A, B);
            var fs = PrimeFactors(gcd);
            int ans = 1;
            HashSet<long> s = new HashSet<long>();
            foreach(var f in fs)
            {
                s.Add(f);
            }
            ans += s.Count();
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
n=int(input())

def func(start,goal,t):
    distance=abs(start[0]-goal[0])+abs(start[1]-goal[1])
    if distance<=t and (t-distance)%2==0:
        return True
    return False
now=0
can=1
start=[0,0]
for i in range(n):
    t,x,y=[int(i) for i in input().split()]
    goal=[x,y]
    if not func(start,goal,t-now):
        can=0
        break
    else:
        start=goal
        now=t

if can==1:
    print("Yes")
else:
    print("No")


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

int main() {
	string t;
	cin >> t;
	for (int i = 0; i < t.length(); i++) {
		if (t.at(i) == '?') cout << "D";
		else cout << t.at(i);
	}
}

Measured memory_bytes: 3720
#include <cstdio>
#include <cstring>
#include <string>
#include <cctype>
#include <iostream>
using namespace std;

string str;
string dp[51][51];

string memo(int l,int r){
	if(dp[l][r]!="")return dp[l][r];
	bool flag=true;
	string num="";
	for(int i=l;i<r;i++){
		if(str[i]>='0' && str[i]<='9')num+=str[i];
		else if(str[i]=='?')num+='9';
		else flag=false;
	}
	if(flag && (num[0]!='0' || num.size()==1) && num.size()>0){
		return (dp[l][r]=num);
	}
	flag=false;
	string res="";
	if(str[l+1]=='?' || str[l+1]=='('){
		if(str[r-1]=='?' || str[r-1]==')'){
			for(int i=l+2;i<r-1;i++){
				if(str[i]==',' || str[i]=='?'){
					string left=memo(l+2,i);
					string right=memo(i+1,r-1);
					if(left=="invalid" || right=="invalid")continue;
					if(str[l]=='?' || str[l]=='L'){
						if(res.size()<left.size() || (res.size()==left.size() && res<left)){
							res=left;
							flag=true;
						}
					}
					if(str[l]=='?' || str[l]=='R'){
						if(res.size()<right.size() || (res.size()==right.size() && res<right)){
							res=right;
							flag=true;
						}
					}
				}
			}
		}
	}
	return flag?(dp[l][r]=res):"invalid";
}

int main(void){
	cin >> str;
	for(int i=0;i<=str.size();i++){
		for(int j=0;j<=str.size();j++){
			dp[i][j]="";
		}
	}
	cout << memo(0,str.size()) << endl;
	return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  char s;
  cin>>s;
  if(s=='a' || s=='i' || s=='u' || s=='e' || s=='o') cout<<"vowel"<<'\n';
  else cout<<"consonant"<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
const ll mod = (ll)1e9 + 7;
	
int main(){
	speed;
	int n; cin >> n;
	vector<ll> v(n);
	forn(n) {
		cin >> v[i];
	}
	sort(all(v));
	vector<ll> w {0, 0};
	int k = 0;
	for(int i = n - 2; i >= 0; i--) {
		if(v[i] == v[i + 1]) {
			w[k] = v[i];
			i--;
			k++;
			if(k == 2) break;
		}
	}
	ll res = w[0] * w[1];
	cout << res;
	return 0;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
int main() {

        
        string s;
        cin>>s;
        
        if((s.compare("SUN"))==0)
        {
            cout<<"7"<<endl;
        }
        if((s.compare("MON"))==0)cout<<"6"<<endl;
 if((s.compare("TUE"))==0)cout<<"5"<<endl;
      if((s.compare("WED"))==0)cout<<"4"<<endl;
           if((s.compare("THU"))==0)cout<<"3"<<endl;
                if((s.compare("FRI"))==0)cout<<"2"<<endl;
                     if((s.compare("SAT"))==0)cout<<"1"<<endl;
        
  
	return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
ll N,M;
ll tas=0;
ll ans=0;
cin>>N>>M;
vector<ll> A(M);
rep(i,M) cin>>A[i];
for(ll j=0;j<M;j++) tas=tas+A[j];
ans=N-tas;
if(ans>=0) cout<<ans<<endl;
else cout<<"-1"<<endl;

	return 0;
}


Measured memory_bytes: 3676
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2 + m*(m-1)/2;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++) {
        cin >> d[i];
    }
    
    sort(d.begin(), d.end());
    
    cout << d[n/2] - d[n/2 - 1]<< endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll money = 1000;
  rep(i,n-1){
    ll kabu=0;
    if(a[i] < a[i+1]){
      kabu = money/a[i];
      money %= a[i];
      money += kabu*a[i+1];
    }
  }
  cout << money << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	string s;
	cin >> s;

	map<char, int> mp;
	char a = 'a';
	while (a <= 'z')
		mp[a++] = 0;
	for (char c : s)
		mp[c]++;
	for (auto p : mp) {
		if (p.second == 0) {
			cout << p.first << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}


Measured memory_bytes: 512
#[allow(unused_imports)]
use proconio::{
    fastout, input,
};

#[fastout]
fn main() {
    input! {
        x: i32,
        y: i32,
    }
    println!("{}", if y % 2 == 0 && 2 * x <= y && y <= 4 * x { "Yes" } else { "No" });
}


Measured memory_bytes: 2124
import Control.Monad
import Data.List
main = do
  [n,c,k] <- map read . words <$> getLine
  (t:ts) <- sort <$> replicateM n (read <$> getLine) 
  let 
    f _ _ [] a = a
    f x y (z:zs) a
      | x==0 || z-y>k = f (c-1) z zs (a+1)
      | otherwise = f (x-1) y zs a
  print $ f (c-1) t ts 1

Measured memory_bytes: 64508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;
  string s;cin>>n>>s;
  ll ans=0;
  rep(i,0,n-2){
    if(s.substr(i,3)=="ABC")ans++;
  }
  cout<<ans<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;

    long long ans = -1;
    long long x = 0;
    for(int i=0; i<n; ++i){
        int d;
        long long c;
        cin >> d >> c;

        ans += c;
        x += d * c;
        if(x > 9){
            ans += (x - 1) / 9;
            x = (x - 1) % 9 + 1;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int n;
char s[101], t[101];

int main(){
	
	cin>>n>>s;
	
	int r = 0;
	for(int i = 0; i < n; i ++){
	    if(s[i] == '(')t[r ++] = '(';
		else if(s[i] == ')'){
			if(r > 0 && t[r - 1] == '(')r --;
			else t[r ++] = ')';
		}	
	}
	int x = 0;
	while(r > 0 && t[r - 1] == '(')r --, x ++;
	
	for(int i = 0; i < r; i ++)printf("(");
	printf("%s", s);
	for(int i = 0; i < x; i ++)printf(")");
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;


string s;
int k;
set<string> t;

int main(){
    cin>>s>>k;
    Rep(i,s.size()){
        Rep(j,5){
            t.insert(s.substr(i,j+1));
        }
    }
    auto itr=t.begin();
    Rep(i,k-1) itr++;
    cout<<*itr<<endl;

    return 0;
}

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

int main(){
  int x;
  cin >> x;
  int s;
  
  int y = x / 500;
  
  s = y * 1000;
  
  /*cout << y << endl; */  
  x = x - 500 * y;  
  /*cout << x << endl;*/
  
  y = x / 5;
  s = s + 5 * y;
  
  cout << s << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((ll)(1e18))

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<ll> a(3*N, 0LL);
	rep (i, 3*N) cin >> a[i];

	priority_queue<ll, vector<ll>, greater<ll> > p; // 前半分
	priority_queue<ll> q;	// 後ろ半分
	ll qsum = 0LL;
	ll psum = 0LL;
	rep (i, 3 * N){
		if (i < N){
			p.push(a[i]);
			psum += a[i];
		} // end if
		if (i >= 2 * N){
			q.push(a[i]);
			qsum += a[i];
		} // end if
	} // end for

	vector<ll> pm(N + 1, 0LL);
	pm[0] = psum;
	rep (i, N){
		p.push(a[N + i]); psum += a[N + i];
		psum -= p.top(); p.pop();
		pm[i + 1] = psum;
	} // end for

	vector<ll> qm(N + 1, 0LL);
	qm[0] = qsum;
	rep (i, N){
		q.push(a[2 * N - 1 - i]); qsum += a[2 * N - 1 - i];
		qsum -= q.top(); q.pop();
		qm[i + 1] = qsum;
	} // end for

	ll res = -INF;
	rep (i, N + 1){
//		cerr << pm[i] << ' ' << qm[i] << endl;
		ll curr = pm[i] - qm[N - i];
		res = max(res, curr);
	} // end rep
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 5876
import java.util.*;
import java.awt.Point;

public class Main {
	static int w,h,sx,sy;
	static int[] dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
	static String[] field;
	static boolean[][] visited;
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while(read()) {
			System.out.println(solve());
		}
	}
	
	static boolean read() {
		w = sc.nextInt(); h = sc.nextInt();
		if(w == 0 && h == 0) {
			return false;
		}
		field = new String[h];
		
		for(int i = 0; i < h; i++) {
			field[i] = sc.next();
			int tmp = field[i].indexOf('@');
			if(tmp != -1) {
				sy = i; sx = tmp;
			}
		}
		return true;
	}
	
	static int solve() {
		visited = new boolean[h][w];
		Queue<Point> que = new LinkedList<Point>();
		Point s = new Point(sx, sy);
		
		que.add(s);
		visited[sy][sx] = true;
		int ans = 1;
		while(!que.isEmpty()) {
			Point p = que.poll();
			for(int i = 0; i < 4; i++) {
				Point next = new Point(p.x + dx[i], p.y + dy[i]);
				if(!inField(next) || field[next.y].charAt(next.x) == '#' || visited[next.y][next.x] == true) {
					continue;
				} else {
					que.add(next);
					visited[next.y][next.x] = true;
					ans++;
				}
			}
		}
		return ans;
	}
	
	static boolean inField(Point p) {
		if(p.x >= 0 && p.x < w && p.y >= 0 && p.y < h) {
			return true;
		} else {
			return false;
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#define RANGE_1(e) (boost::irange(0,(e)))
#define RANGE_2(s,e) (boost::irange((s),(e)))
#define RANGE_3(s,e,step) (boost::irange((s), (e), (step)))
#define RANGE_SELECTER(_1,_2,_3,SELECT,...) SELECT
#define range(...) RANGE_SELECTER(__VA_ARGS__, RANGE_3, RANGE_2, RANGE_1) (__VA_ARGS__)
#define guard(x) if(x);
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define CALL(x) (x).cbegin(),(x).cend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define BIT(n) (1LL<<(n))

using namespace std;
using lint = long long;

// template<class T>class irange{private:struct I{T x;T operator*(){return x;}bool operator!=(I&lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;public:irange(T i,T n):i({i}),n({n}){}I&begin(){return i;}I&end(){return n;}};
// template<class T>class srange{private:struct I{T x,s;T operator*(){return x;}bool operator!=(I&lhs){if(s<(T)0)return x>lhs.x;return x<lhs.x;}void operator++(){x=x+s;}};I i,n;public:srange(T i,T n,T s):i({i,s}),n({n,s}){}I&begin(){return i;}I&end(){return n;}};
// template<class T>irange<T>range(T n){return irange(0,n);}template<class T>irange<T>range(T i,T n){return irange(i,n);}template<class T>srange<T>range(T i,T n,T s){return srange(i,n,s);}
template<class T>bool amax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool amin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

struct initialize{initialize(){cin.tie(nullptr);ios::sync_with_stdio(false);};}__ini__;

int main(){
    /* Code Area */
    int x, y;
    cin >> x >> y;
    guard (!(y & 1)) else {
        cout << "No" << endl;
        return 0;
    }
    int t = 2 * x - y / 2;
    cout << (t >= 0 && t <= x ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3632
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()

	a := make([]int, N)
	zero := false
	for i := 0; i < N; i++ {
		a[i] = getInt()
		if a[i] == 0 {
			zero = true
		}
	}
	if zero {
		out(0)
		return
	}
	ans := 1
	for i := 0; i < N; i++ {
		if ans*a[i]/a[i] != ans {
			out(-1)
			return
		}
		ans *= a[i]
	}
	if ans > int(1e18) {
		out(-1)
	} else {
		out(ans)
	}

}


Measured memory_bytes: 5860
# ABC061 D - Score Attack
import sys
N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

INF = 1 << 60
cost = [- INF] * (N + 1)
cost[1] = 0

for i in range(N):
    for n, nn, c in edge:
        if cost[nn] < cost[n] + c:
            # ベルマンフォード法の性質より、N回目に更新があるならinf
            if i == N - 1 and nn == N:
                print("inf")
                sys.exit()
            cost[nn] = cost[n] + c

print(cost[N])

Measured memory_bytes: 9196
#! /usr/bin/env python
# -*- coding: utf-8 -*-

raw_time = int(raw_input())

if 0 <= raw_time < 86400:
    hour = raw_time / 3600
    minute = (raw_time - hour * 3600) / 60
    second = (raw_time - hour * 3600 - minute * 60)
    print("%d:%d:%d") % (hour, minute, second)

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(ll i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    ll a,b,c,d;
    ll num[4];
    rep(i,4)cin >> num[i];
    ll ans = -1000000000000000000;
   
   rep(i,2){
       rep2(j,2,4){
           ll now = num[i]*num[j];
           ans=max(now,ans);
       }
   }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> d(K, 0), B(N, 0);
  vector<vector<int> > A(K, vector<int>(N, 0));
  int tmp, ans = 0;

  for (size_t i = 0; i < K; i++) {
    cin >> d.at(i);
    for (size_t j = 0; j < d.at(i); j++) {
      cin >> tmp;
      A.at(i).at(tmp - 1) = 1;
    }
  }

  for (size_t i = 0; i < N ; i++) {
    for (size_t j = 0; j < K; j++) {
      if (A.at(j).at(i) == 1) {
        B.at(i) = 1;
      }
    }
  }

  for (size_t i = 0; i < N; i++) {
    if (B.at(i) != 1) {
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3172
use std::cmp;

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let a = sc.value::<i64>();
    let b = sc.value::<i64>();
    let c = sc.value::<i64>();

    let x = cmp::min(a+b+1, c);
    let ans = b + x;

    println!("{}", ans);
}


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

constexpr int P = 1000000007;

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

    int n, x;
    cin >> n >> x;

    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());

    vector<int> p0(x + 1), p1(x + 1);
    for (int j = 0; j <= x; j++) {
        p0[j] = j % s[0];
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= x; j++) {
            p1[j] = (p0[j % s[i]] + p0[j] * (ll)i) % P;
        }
        swap(p0, p1);
    }

    cout << p0[x] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
//const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p,ll mod){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Div(ll n,ll m,ll mod){
	return n*Pow(m,mod-2,mod)%mod;
}

const ll mod[2]={1000000007,1000000009},base[2]={1009,17};
ll inv[2];

pll f(vl a,vl b){
	pll p=make_pair(Div(b[0],a[0],mod[0]),Div(b[1],a[1],mod[1]));
	return p;
}

ll n,res=0;
string s;
vvl a,b;
map<pll,ll> mp;

int main(){
	inv[0]=Div(1,base[0],mod[0]);
	inv[1]=Div(1,base[1],mod[1]);
	cin>>n>>s;
	a=b=vvl(n+1,vl(2));
	a[n][0]=a[n][1]=1;
	for(int i=n-1;i>=0;i--) for(int j=0;j<2;j++){
		if(s[i]=='+') a[i][j]=a[i+1][j],b[i][j]=b[i+1][j]+1;
		if(s[i]=='-') a[i][j]=a[i+1][j],b[i][j]=(b[i+1][j]-1+mod[j])%mod[j];
		if(s[i]=='>') a[i][j]=a[i+1][j]*base[j]%mod[j],b[i][j]=b[i+1][j]*base[j]%mod[j];
		if(s[i]=='<') a[i][j]=a[i+1][j]*inv[j]%mod[j],b[i][j]=b[i+1][j]*inv[j]%mod[j];
	}
	mp[f(a[n],b[n])]++;
	for(int i=n-1;i>=0;i--){
		pll p;
		p.first =Div((b[i][0]-b[0][0]+mod[0])%mod[0],a[i][0],mod[0]);
		p.second=Div((b[i][1]-b[0][1]+mod[1])%mod[1],a[i][1],mod[1]);
		res+=mp[p];
		mp[f(a[i],b[i])]++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 59140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int N;
	cin >> N;

	vector<int> a;
	inputVector(a, N);

	rep(i, N) a[i]--;

	int ret = 0;
	rep(i, N) {
		if (a[a[i]] == i) ret++;
	}

	cout << ret / 2 << endl;

    return 0;
}


Measured memory_bytes: 1400
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
   
N, M = LI()
mat = [[0] * N for _ in range(N)]
for _ in range(M):
    a, b = LI_()
    mat[a][b] = 1
    mat[b][a] = 1 
seen = [0 for _ in range(N)]
ans = 0

def dfs(i, count):
    global ans
    import pdb
    # pdb.set_trace()
    if count == N:
        return True

    for j, reachable in enumerate(mat[i]):
        if reachable and not seen[j]:
            seen[j] = 1
            if dfs(j, count + 1):
                ans += 1
            seen[j] = 0

    return False

def main():
    seen[0] = 1
    dfs(0, 1)
    print(ans)
main()



Measured memory_bytes: 9372
//ProblemE

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <memory>
#include <cstdio>
#include <cstring>

#define _MOD 1000000007
#define MAXN 100000
#define MAXM 200000
#define NOTSET 0x7FFFFFFFFFFFFFFFL

using namespace std;

//ProblemE

template<int MOD = _MOD>
class ModInt {
public:
	ModInt(int val = 0) : val(val) {
		if (val < 0) (val %= MOD) += MOD;
	}
	ModInt(long long val) : val(val %= MOD) {
		if (val < 0) val += MOD;
	}
	operator int() const { return val; }
	ModInt& operator+= (const ModInt& b) {
		val = (val + b.val) % MOD;
		return *this;
	}
	ModInt& operator-= (const ModInt& b) {
		val = (val - b.val + MOD) % MOD;
		return *this;
	}
	ModInt& operator*= (const ModInt& b) {
		val = ((long long)(val) * b.val) % MOD;
		return *this;
	}
	ModInt operator+ (const ModInt& b) const { return val + b.val; }
	ModInt operator- (const ModInt& b) const { return val - b.val; }
	ModInt operator* (const ModInt& b) const { return (long long)val * b.val; }
private:
	int val;
};


class Solve {
private:
	int n, m;
	int s, t;

	using MInt = ModInt<>;
	struct Edge {
		int to;
		long long time;
	};
	vector<Edge> edges[MAXM];

	struct {
		MInt cnt = 0;
		long long time = NOTSET;
	} FS[MAXN], FT[MAXN];

	bool flags[MAXN];

	void MinPath(decltype(FS) &F, int beg, int end) {
		set<int, std::function<bool(const int&, const int&)>> pq([&F](const int &a, const int &b) {
			if(F[a].time == F[b].time) return a < b;
			else return F[a].time < F[b].time;
		});

		F[beg] = { 1, 0 };
		for(int i = 0;i < n; i++) pq.insert(i);

		while (!pq.empty()) {
			int top = *pq.begin();
			pq.erase(pq.begin());

			for (auto& e : edges[top]) {
				if (F[top].time + e.time < F[e.to].time) {
					pq.erase(e.to);
					F[e.to] = { F[top].cnt, F[top].time + e.time };
					pq.insert(e.to);
				}
				else if (F[top].time + e.time == F[e.to].time) {
					F[e.to].cnt += F[top].cnt;
				}
			}
		}
	}

	void solve() {
		cin >> n >> m;
		cin >> s >> t;
		s--; t--;

		for (int i = 0; i < m; i++) {
			int l, r, d;
			cin >> l >> r >> d;
			l--; r--;
			edges[l].push_back({ r, d });
			edges[r].push_back({ l, d });
		}

		MinPath(FS, s, t);
		MinPath(FT, t, s);

		auto minTime = FS[t].time;
		if (FS[t].time != FT[s].time)
			throw;

		MInt total = FS[t].cnt * FT[s].cnt;

		if (minTime % 2 == 0) {
			for (int i = 0; i < n; i++) {
				if (minTime / 2 == FS[i].time) {
					total -= FS[i].cnt * FS[i].cnt * FT[i].cnt * FT[i].cnt;
				}
			}
		}

		for (int i = 0; i < n; i++) for (auto e : edges[i]) {
			if (FS[i].time * 2 < minTime && FS[e.to].time * 2 > minTime
				&& FS[i].time + e.time + FT[e.to].time == minTime) {
				total -= FS[i].cnt * FS[i].cnt * FT[e.to].cnt * FT[e.to].cnt;
			}
		}

		cout << total << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 24576
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		TreeMap<String,Integer> map=new TreeMap<>();
		int q=Integer.parseInt(in.next());
		for(int i=0;i<q;i++) {
			int odr=Integer.parseInt(in.next());
			
			switch(odr) {
			case 0:
				String key0=in.next();
				int x0=Integer.parseInt(in.next());
				map.put(key0,x0);
				break;
				
			case 1:
				String key1=in.next();
				Integer num1=map.get(key1);
				out.println((num1!=null)? num1:0);
				break;
				
			case 2:
				String key2=in.next();
				map.remove(key2);
				break;
				
			case 3:
				String L=in.next(),R=in.next();
				NavigableMap<String,Integer> sub=map.subMap(L, true, R, true);
				Iterator<NavigableMap.Entry<String,Integer>> itr=sub.entrySet().iterator();
				while(itr.hasNext()) {
					NavigableMap.Entry<String,Integer> entry=itr.next();
					out.println(entry.getKey()+" "+entry.getValue());
				}
			}
		}
		out.flush();
	}

}


Measured memory_bytes: 174792
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0)
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
	IOS;
    int test = 1; //cin>>test;
    for(int tt = 1; tt <= test; tt++){
    	string s; cin >> s;
    	int len = 0;
    	bool r = false;
    	int ans = 0;
    	for(int i = 0; i < 3; i++){
    		if(s[i] == 'S'){
    			if(r && len > 0) ans = max(ans, len);
    			len = 0;
    			r = false;
    		} else {
    			r = true;
    			len++;
    		}
    	}
    	if(r && len > 0) ans = max(ans, len);
    	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdbool.h>

int main() {
	int i, n, a[200], count = -1;
	bool flag = false;

	scanf("%d", &n);

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

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

	return 0;
}

Measured memory_bytes: 128
def fact(A): #fact(int)
    c0 = A
    r = 2
    lis = []
    count = 1
    while A != 1:
        if A%r == 0:
            A = A//r
            lis.append(r)
            r = 2
        else:
            r += 1
        if r > int(pow(c0,0.5))+1:
            lis.append(A)
            break
    return(lis)
n = int(input())
m = 10**9+7
lis = []
for i in range(2,n+1):
    L = fact(i)
    lis.extend(L)
import collections
c = collections.Counter(lis)
A = list(set(lis))
ans = 1
for a in A:
    ans *= c[a] + 1
    ans = ans%m
print(ans%m)

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





int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if (a+b==c+d){
    cout<<"Balanced"<<endl;
  }
  
  else if (a+b>c+d){
    cout<<"Left"<<endl;
  }
  
  else {
    cout<<"Right"<<endl;
  }
  
  
}

  













Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    int a[m], b[m];
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
    }
    int c[n];
    for (int i = 0; i < n; ++i) {
        c[i] = i + 1;
    }
    int cnt = 0;
    do {
        int flg = 0;
        /*
        for (int i = 0; i < n; ++i) {
            cout << c[i] << " ";
            if (i == n - 1) cout << endl;
        }*/
        for (int i = 1; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if ((c[i - 1] == a[j] && c[i] == b[j]) || (c[i - 1] == b[j] && c[i] == a[j])) {
                    break;
                }
                if (j == m - 1) {
                    flg++;
                }
            }
            if (flg) {
                break;
            }
            if (i == n - 1) {
                cnt++;
            }
        }
    } while (next_permutation(c, c + n) && c[0] == 1);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;

int main()
{
    ll N, K; cin >> N >> K;
    vector<ll> H(N);
    for (auto& h : H) {
        cin >> h;
    }
    sort(H.begin(), H.end());
    ll ans = INF;
    for (ll i = 0; i < N - (K - 1); i++) {
        ans = min(ans, H[i + K - 1] - H[i]);
    }
    cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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

int main(){
    ll s;
    cin>>s;
    ll x,y;
    x=((ll)1e9-s%((ll)1e9))%((ll)1e9);
    y=(x+s)/1e9;
    
    cout<<"0 0 "<<(ll)1e9<<" "<<1<<" "<<x<<" "<<y<<endl;
    return 0;
}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void chmax(int &x, int v) { if (x < v) x = v; }

int H, W;
int EX, EY;
char A[100][100];
int tate[100][100];
int yoko[100][100];
vector<vector<vector<vector<int> > > > dp;
inline int f_tate(int x, int l, int r) {
  l = max(l, 0);
  r = min(r, H-1);
  if (x<0||x>=W||l>r) return 0;
  return tate[x][r]-(l>0?tate[x][l-1]:0);
}
inline int f_yoko(int y, int l, int r) {
  l = max(l, 0);
  r = min(r, W-1);
  if (y<0||y>=H||l>r) return 0;
  return yoko[r][y]-(l>0?yoko[l-1][y]:0);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W;
  rep(i, H) rep(j, W) cin >> A[j][i];
  rep(x, W) rep(y, H) if (A[x][y] == 'E') EX = x, EY = y;
  rep(x, W) rep(y, H) tate[x][y] = yoko[x][y] = A[x][y] == 'o';
  rep(x, W-1) rep(y, H) yoko[x+1][y] += yoko[x][y];
  rep(x, W) rep(y, H-1) tate[x][y+1] += tate[x][y];

  dp.resize(W+1);
  rep(l, W+1) {
    dp[l].resize(W+1-l);
    rep(r, W+1-l) {
      dp[l][r].resize(H+1);
      rep(u, H+1) dp[l][r][u].resize(H+1-u, -INF);
    }
  }
  dp[0][0][0][0] = 0;
  rep(l, W) {
    rep(r, W-l) {
      rep(u, H) {
        rep(d, H-u) {
          if (dp[l][r][u][d] == -INF) continue;
          chmax(dp[l+1][r][u][d], dp[l][r][u][d] + ((EX-(l+1)<r)?0:f_tate(EX-(l+1), max(EY-u, d), min(EY+d, H-1-u))));
          chmax(dp[l][r+1][u][d], dp[l][r][u][d] + ((EX+(r+1)>=W-l)?0:f_tate(EX+(r+1), max(EY-u, d), min(EY+d, H-1-u))));
          chmax(dp[l][r][u+1][d], dp[l][r][u][d] + ((EY-(u+1)<d)?0:f_yoko(EY-(u+1), max(EX-l, r), min(EX+r, W-1-l))));
          chmax(dp[l][r][u][d+1], dp[l][r][u][d] + ((EY+(d+1)>=H-u)?0:f_yoko(EY+(d+1), max(EX-l, r), min(EX+r, W-1-l))));
        }
      }
    }
  }
  int m = 0;
  rep(l, W+1) rep(r, W+1-l) rep(u, H+1) rep(d, H+1-u) chmax(m, dp[l][r][u][d]);
  cout << m << "\n";
  return 0;
}


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

int main(){
    int n, m, k, i, j, s, bit, f, c = 0;
    cin >> n >> m;
    int l[m][n] = {}, p[m], q[m];
    for(i=0; i<m; i++){
        cin >> k;
        for(j=0; j<k; j++){
            cin >> s;
            l[i][s-1]++;
        }
    }
    for(i=0; i<m; i++){
        cin >> p[i];
    }
    for(i=0; i<pow(2,n); i++){
        bit = i;
        for(j=0; j<m; j++){
            q[j] = p[j];
        }
        for(j=0; j<n; j++){
            f = bit & 1;
            bit = bit >> 1;
            if(f == 0) continue;
            for(k=0; k<m; k++){
                if(l[k][j] == 1){
                    q[k] ^= 1;
                }
            }
        }
        for(j=0; j<m; j++){
            if(q[j] != 0){
                break;
            }
            if(j == m-1){
                c++;
            }
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define llu unsigned long long int
#define scll(x) scanf("%lld",&x)
#define scld(x) scanf("%lf",&x)
#define scull(x) scanf("%llu",&x)
#define scch(x) scanf(" %c",&x)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define ppb() pop_back()
#define ppf() pop_front()
#define Pi acos(-1.0)
#define INF 1e18
#define ff first
#define ss second
#define mpr make_pair
ll  _xor(ll a,ll b){return a^b;}
ll _and(ll a,ll b){return a&b;}
ll _or(ll a,ll b){return a|b;}
ll _not(ll a){ return ~a;}
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool comp(pair<ll,ll>p1,pair<ll,ll>p2)
{
	return p1.ff<p2.ff;
}
ll power[100005];
int main()
{
           #ifndef ONLINE_JUDGE 
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
         #endif
    ll b,c=0,d,e,f=0,g,h,i,j,k,l1,l2,n,t,mod=998244353,ans=0,l3,c1,c2;
        scll(c1);
        scll(c2);
        if(c2>=c1)
        	cout<<"unsafe";
        else
        	cout<<"safe";
       //or(i=0;i<=10;i++)
       	//cout<<power[i]<<'\n';

      
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


    
     int solve()
     {  
        int a,b,k;cin>>a>>b>>k;
        int z=min(a,k);
        a-=z;
        k-=z;
        z=min(b,k);
        b-=z;
        cout<<a<<" "<<b;

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256