akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890123456
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//

//
//initialization finish


// your function is here
//

//
// your function finished



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//
	ll n, l; cin >> n >> l;

	int pre;
	rep(i, n)
	{
		int a; cin >> a;
		if (i == 0)
		{
			pre = a;
			continue;
		}

		if (pre + a >= l)
		{
			Print("Possible");

		FOR(j,1,i)Print(j);
		FFOR(j, n - 1, i)Print(j);
		Print(i);
		return 0;
		}
		pre = a;
	}
	Print("Impossible");


	//
	// your code finished


	return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var S = ReadLine();

        var C = new List<char>();
        for (int i = 0; i < 26; i++)
        {
            C.Add((char)('a' + i));
        }
        foreach (var i in S)
        {
            C.Remove(i);
        }

        if (C.Count > 0)
        {
            WriteLine(S+C[0]);
        }
        else
        {
            if(S!="")
            WriteLine(next(S.ToCharArray()));
        }

    }
    static string next(char[] S)
    {
        
        
        var list = new List<char>();
        for (int i = S.Length - 1; i >= 0; i--)
        {
            foreach(var j in list)
            {
                if (j > S[i])
                {
                    string ans = string.Join("", S).Substring(0, i);
                    return ans + j;
                }
                
            }
            list.Add(S[i]);
        }
        return "-1";
    }
}


Measured memory_bytes: 26292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    ll k;
    cin>>k;
    string res = "";
    for(ll i=1;i<=k;i++)
    {
        res+= "ACL";
    }
    cout<<res<<"\n";
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
ll n,m,i,j,k,l,t,arr[sz],brr[sz],crr[sz];
vector<ll>v;
int main()
{
    scanf("%lld %lld",&n,&k);
    for(i=1;i<=n;i++)
        scanf("%lld",&arr[i]);
    for(i=k+1;i<=n;i++)
    {
        if(arr[i]>arr[i-k])
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 5320
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head
void recurse(int start, int p, int max, vector<vector<int>>& tree, vector<int>& a, vector<int>& l, vector<int>& ans) {
    // upper bound

    int ind = upper_bound(l.begin(), l.end(), a[start]-1) - l.begin();
    ind--;
    int prev = l[ind+1];
    l[ind+1] = min(l[ind+1], a[start]);
    max = std::max(max, ind+1);
    ans[start] = max;

    for (auto x : tree[start]) {
        if (x == p)
            continue;
        recurse(x, start, max, tree, a, l, ans);
    }
    l[ind+1] = prev;
}

int main() {
    int n, u, v;
    cin >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    vector<vector<int>> tree(n+1);
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    vector<int> l(n+1, INT_MAX);
    l[0] = INT_MIN;
    vector<int> ans(n+1);
    recurse(1, -1, 0, tree, a, l, ans);

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


Measured memory_bytes: 36608
#include <iostream>
#include <vector>

using namespace std;

int N;
int p[205];
vector<int> ans;

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> p[i];
	
	for(int i = 0; i < N; i++){
		ans.push_back(1);
		for(int j = 0; j < N-1; j++){
			if(p[j] > p[j+1]){
				ans.push_back(N-1);
				int t = p[j];
				p[j] = p[j+1];
				p[j+1] = t;
			}
			ans.push_back(1);
		}
	}
	
	cout << ans.size() << endl;
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}
	return 0;
}

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

li_h = list(map(int, input().split()))


li_cost = [float("inf")] * n

li_cost[0] = 0

# i = 現在の足場
for i in range(n):
    if i + 1 < n:
        li_cost[i + 1] = min(abs(li_h[i] - li_h[i + 1]) + li_cost[i], li_cost[i + 1])
    if i + 2 < n:
        li_cost[i + 2] = min(abs(li_h[i] - li_h[i + 2]) + li_cost[i], li_cost[i + 2])

print(li_cost[-1])



Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
const int MOD = 1e9+7;
const int INF = 1e5+10;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};

/*----------------------------------------------*/
string s[20];
int allD[20][20];
bool reached[20][20][20][20];
signed main(){
  int h,w;
  cin>>h>>w;
  rep(i,h) cin>>s[i];
  int ans=0;
  rep(i,h)rep(j,w){
    // bool reached[20][20];
    if(s[i][j]=='#') continue;
    int d_max=0;//max of distance(each i,j)
    int d[20][20];
    rep(k,20)rep(l,20) d[k][l]=INF;
    d[i][j]=0;
    queue<pair<int,int>> q;
    q.push(make_pair(i,j));
    while(!q.empty()){
      auto xy= q.front();q.pop();
      int x=xy.first,y=xy.second;
      if(x<0||x>h-1||y<0||y>w-1) continue;
      if(s[x][y]=='#') continue;
      // if(d[x][y]<INF) continue;
      if(reached[i][j][x][y]) continue;
      reached[i][j][x][y]=true;

      rep(k,4){
        if(x+dx[k]<0||x+dx[k]>h-1||y+dy[k]<0||y+dy[k]>w-1) continue;
        chmin(d[x][y],d[x+dx[k]][y+dy[k]]);
        q.push(make_pair(x+dx[k],y+dy[k]));  
      } 
      if(x!=i||y!=j) d[x][y]++;
    }
    rep(k,h)rep(l,w) if(d[k][l]<INF) chmax(d_max,d[k][l]);
    allD[i][j]=d_max;
    chmax(ans,d_max);
    /*rep(k,h){
      rep(l,w)cout<<d[k][l]<<" ";
      cout<<endl;
    }
    cout<<endl;
    */
  }
  /*
  rep(i,h){
    rep(j,w) cout<<allD[i][j];
    cout<<endl;
  }*/
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int n,d[101],ans;

int main()
{
    scanf("%d",&n);
    n+=1;
    for(int i=1;i<n;i++)
    {
        scanf("%d",&d[i]);
    }
    sort(d,d+n);
    for(int i=1;i<n;i++)
    {
        if(i%2) d[i] = 24-d[i];
    }
    sort(d,d+n);
    ans = 24-d[n-1];
    for(int i=1;i<n;i++)
    {
        //printf("%d %d\n",d[i],d[i-1]);
        ans = min(d[i]-d[i-1],ans);
    }
    
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<fstream>
#include<vector>
#include<string>
#include<iostream>
#include<math.h>

using namespace std;

int main(void) {

	int number;
	double money;
	double sum = 0;
	string currency;
	string JPY = "JPY";

	cin >> number;

	for (int i = 0; i < number; i++) {
		cin >> money >> currency;

		if (currency == JPY) {
			sum = sum + money;
		}
		else {
			sum = sum + money * 380000;
		}

	}

	cout << sum << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int cnt=0, ans=0;
    for(char c : s)
        if(c=='A' || c=='T' ||  c=='C' || c=='G')
            cnt++;
        else{
            if(cnt > ans)
                ans = cnt;
            cnt=0;
        }
    if(cnt > ans)
        ans = cnt;
    cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    return b if a%b==0 else gcd(b,a%b)
def lcm(x,y):
    return x*y//gcd(x,y)

N=int(input())
ans=1
for _ in range(N):
    ans=lcm(ans,int(input()))
print (ans)

Measured memory_bytes: 3060
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int vis[100007],tim[100007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    int sum=0,num=0;
    for(int i=1;i<=m;++i){
        int x;
        string s;
        cin>>x>>s;
        if(s[0]=='A'){
            if(!vis[x]){
                ++num;
                sum+=tim[x];
            }
            vis[x]=1;
        }
        else{
            if(!vis[x])
                ++tim[x];
        }
    }
    cout<<num<<" "<<sum;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000000000000

int main(void)
{
    string A, B;
    cin >> A >> B;
    if(A.length() > B.length()) cout << "GREATER";
    else if(A.length() < B.length()) cout << "LESS";
    else{
        rep(i, A.length()){
            if(A[i] > B[i]){
                cout << "GREATER";
                return 0;
            }else if( A[i] < B[i]){
                cout << "LESS";
                return 0;
            }
        }
        cout << "EQUAL";
    }

    return 0;
}

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

int main() {
  int N, a=0, b=0, i;
  cin >> N;
  vector<int> card(N);
  for(i=0; i<N; i++){
    cin >> card.at(i);
  }
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  for(i=0; i<N; i++){
    if(i==0 || i%2==0){
      a += card.at(i);
    }
    else b += card.at(i);
  }
  cout << a-b << endl;
}

Measured memory_bytes: 256
//in the name of allah
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
bool ans[N];
bool ask(int v , int u){
        cout << "? " << v << " " << u << endl;        
        fflush(stdout);
        char ans;
        cin >> ans;
        return (ans == 'Y');
}

int main(){
        int n , m;
        cin >> n >> m;
        if(n<=m){
                cout << "Impossible\n";
                return 0;
        }
        stack<int> st;
        for(int i=0 ; i<n+m ; i++){                
                if(!st.size()){
                        st.push(i);
                        continue;
                }              
                if(ask(st.top() , i))
                        st.push(i);
                else
                        st.pop();
        }
        int v = st.top();
        for(int i=0 ; i<n+m ; i++)
                ans[i] = ask(v , i);
        cout << "! ";
        for(int i=0 ; i<n+m ; i++)
                cout << ans[i];
        cout << endl;
        fflush(stdout);
}

Measured memory_bytes: 724
#include <iostream>
using namespace std;
long long p[65],a[100005];
void insert(long long x)
{
 for(int i=60;i>=0;i--)
 {
  if(!(x>>i))continue;
  if(!p[i])
  {
   p[i]=x;
   break;
  }
  x^=p[i];
 }
}
long long query()
{
 long long ans=0;
 for(int i=60;i>=0;i--)
  ans=max(ans,ans^p[i]);
 return ans;
}
int main()
{
 int n;
 cin>>n;
 long long sum=0,ans=0;
 for(int i=1;i<=n;i++)
 {
  cin>>a[i];
  sum^=a[i];
 }
 for(int i=1;i<=n;i++)
 {
  a[i]&=(~sum);
  insert(a[i]);
 }
 ans=query();
 cout<<ans*2+sum<<endl;
 return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> data(N,vector<int>(2));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> data.at(i).at(j);
        }
    }
    double sum;
    for (int i = 0; i < N-1; i++) {
        for (int j = i + 1; j < N; j++) {
            int x_length = (data.at(i).at(0) - data.at(j).at(0)) * (data.at(i).at(0) - data.at(j).at(0));
            int y_length = (data.at(i).at(1) - data.at(j).at(1)) * (data.at(i).at(1) - data.at(j).at(1));
            double length = sqrt(x_length + y_length);
            sum += 2 * length;
        }
    }
    sum /= N;
    printf("%.10f", sum);
}

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

using namespace std;

typedef long long ll;

using V = vector<int>;
using Q = queue<int>;
using Graph = vector<vector<int>>;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define YesNo(x) cout<<(x?"Yes":"No")<<endl
#define YESNO(x) cout<<(x?"YES":"NO")<<endl
#define yesno(x) cout<<(x?"yes":"no")<<endl
#define yay(x) cout<<(x?"yay":":(")<<endl

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
	ll a, b, c, d, ac, ad, bc, bd;
	cin >> a >> b >> c >> d;
	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;
	vector<long long> ans = {ac, ad, bc, bd};
	sort(ans.begin(), ans.end());
	out(ans[3]);
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

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

    std::string s;
    std::cin >> s;

    for(const auto& word : s)
    {
        size_t index = &word - &s[0];
        if(index % 2 == 0)
            std::cout << word;
    }
    putchar('\n');

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <numeric>
#include <cmath>
#include <set>
#include <functional>
#include <vector>
#include <queue>

using namespace std;

#define ll long long
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl;

int a[1000010];


int main() {
    int N;
    cin >> N;
    rep(i, N) cin >> a[i];

    set<int>st;
    rep(i, N) {
        if (st.find(a[i]) == st.end()) {
            st.insert(a[i]);
        }
        else st.erase(a[i]);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 5248
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll H, W, N;
    cin >> H >> W >> N;
    ll b = max(H, W);
    ll ans = 0;
    ll cur = 0;
    while (true) {
        cur += b;
        ans++;
        if (N <= cur) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool p = 1;
  if(a == b) {
    if(b != c) p = 0;
  }
  else if(b == c || a == c) p = 0;
  if(p) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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



int dfs(long long n,string s,bool f3,bool f5,bool f7){
    if (n < stoll(s)) return 0;
    int ans = 0;

    if (f3 && f5 && f7) {
        ans++;
    }
    ans += dfs(n,"3" + s , true,f5,f7);
    ans += dfs(n,"5" + s , f3,true,f7);
    ans += dfs(n,"7" + s , f3,f5,true);

    return ans;

}

int main(void)
{
    long long n;
    cin >> n;
    int count = 0;

    count += dfs(n,"3" , true,false,false);
    count += dfs(n,"5" , false,true,false);
    count += dfs(n,"7" , false,false,true);

    cout << count << endl;
}


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

using namespace std;

int main(){
 int N,v[1001];
 double x;
 cin>>N;
 for(int i=0;i<N;i++){
   cin>>v[i];
 }

 sort(v,v+N);
  x=v[0];
 for(int i=1;i<N;i++){
   x=(x+v[i])/2;
 }
 cout << x;
 return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val s = read()
    val notUpper = "[a-z]".toRegex()
    val upper = "[A-Z]".toRegex()
    val containC = "[a-z]*C[a-z]*".toRegex()
    
    var isSatisficated = s[0] == 'A' && notUpper.matches(s[1].toString())
    
    isSatisficated = isSatisficated && containC.matches(s.slice(2..s.length-2)) && notUpper.matches(s[s.length-1].toString())
    println(if(isSatisficated) "AC" else "WA")
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 31856
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll dp[45][2];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   ll K;
   cin >> n >> K;
   vector<ll> a(n);
   rep(i, 0, n) cin >> a[i];
   rep(i, 0, 45) dp[i][1] = -1;
   dp[41][0] = 0;
   rrep(d, 40, 0) {
      ll mask = 1LL << d;
      int cnt = 0;
      rep(i, 0, n) if (a[i] & mask) cnt++;
      if (dp[d + 1][1] >= 0)
         chmax(dp[d][1], dp[d + 1][1] + mask * max(cnt, n - cnt));
      if (dp[d + 1][0] >= 0) {
         if (K & mask) {
            chmax(dp[d][1], dp[d + 1][0] + mask * cnt);
            chmax(dp[d][0], dp[d + 1][0] + mask * (n - cnt));
         } else {
            chmax(dp[d][0], dp[d + 1][0] + mask * cnt);
         }
      }
   }
   cout << max(dp[0][0], dp[0][1]) << endl;
   return 0;
}

Measured memory_bytes: 1024
#pragma warning(disable:4996)
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<time.h>
#include<iomanip>
#include<vector>
using namespace std;
typedef unsigned long long ull;

int main() {
	char s[10000];
	int n;
	cin >> n >> s;
	for (int i = 0; s[i] != NULL && s[i] != '\n'; ++i) {
		s[i] += n;
		if (s[i] > 90) {
			s[i] -= 26;
		}
	}
	for (int i = 0; s[i] != NULL && s[i] != '\n'; ++i) {
		cout << s[i];
	}
}

/*

*/

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

const ll oo = 1e18;
const int MOD = 1000000007;
const int N = 500002;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define cpx complex<double>

string s;
int kp[N], ks[N];
bool same = true;

int main() {
	cin >> s;
	for(int i = 1; i < s.size();++i){
		same = same && (s[i-1]==s[i]);
	}
	if(same){
		printf("%d\n1\n", (int)s.size());
		return 0;
	}
	kp[0] = 0;
	int j = 0;
	for (int i = 1 ; i < s.size(); ++i) {
		while (j > 0 && s[i] != s[j])j = kp[j - 1];
		if (s[i] == s[j])j++;
		kp[i] = j;
	}
	ks[s.size() - 1] = s.size() - 1;
	j = s.size() - 1;
	for (int i = s.size() - 2; i >= 0 ; --i) {
		while (j < s.size() - 1 && s[i] != s[j])
			j = ks[j + 1];
		if(s[i]==s[j])--j;
		ks[i] = j;
	}
	if(kp[s.size()-1] == 0 || s.size()%(s.size()-kp[s.size()-1])!=0){
		printf("1\n1\n");
		return 0;
	}/*
	for (int i = 0; i < s.size(); ++i){
		cout << ks[i] << " ";
	}
	cout << endl;
*/
	int cnt = 0;
	for(int i = 0 ; i+1 < s.size();++i){
		if((kp[i]==0||(i+1)%(i-kp[i]+1)!=0)&&
			(ks[i+1]==s.size()-1 || (s.size()-(i+1))%(ks[i+1]-i) != 0)){
			cnt++;
		}
	}
	puts("2");
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4868
fun main(args: Array<String>) {

    val c = readLine()!!.split("").filterNot { it.isBlank() }.toTypedArray()

    if(c.distinct().size == 1){
        println("No")
        return
    }

    if(c[0] == c[1] && c[2] == c[3] || c[0] == c[2] && c[1] == c[3] || c[0] == c[3] && c[1] == c[2]){
        println("Yes")
    }else{
        println("No")
    }
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m;
    cin >> n >> m;
    vector<P> a(n);
    priority_queue<int> que;
    int ans = 0;
    for (int i = 0;i < n;++i) cin >> a[i].first >> a[i].second;
    sort(a.begin(),a.end());
    int j = 0;
    for (int i = 1;i <= m;++i) {
        while (j < n && a[j].first <= i) {
            que.push(a[j].second);
            j++;
        }
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include "bits/stdc++.h"
 
using namespace std;
 
typedef long long ll;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
    
 #define sz(x) (int)(x).size()
 #define mp make_pair
 #define pb push_back
 #define all(x) x.begin(), x.end()
 
 #define PI 3.14159265358979323846264338327950L
const int MOD = 1000000007;
 
int main() 
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int n,x,t;cin>>n>>x>>t;
    
    cout<<fixed<<(int)ceil((double)n/x)*t;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    char c; cin >> c;
    cout << ++c << endl;
}

Measured memory_bytes: 3552
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

bool xx[4010][16020];
bool yy[4010][16020];
vector<int> mv[2];

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    int mark = 0;
    int len = s.size();
    int num = 0;
    for (int i = 0; i < len; i++) {
        if (s[i] == 'F') {
            num++;
        } else {
            if (num > 0 || (mark == 0 && mv[0].size() == 0)) {
                mv[mark].push_back(num);
            }
            num = 0;
            mark = (mark + 1) % 2;
        }
    }
    mv[mark].push_back(num);
    for (int i = 0; i < 4010; i++) {
        fill(xx[i], xx[i] + 16020, false);
        fill(yy[i], yy[i] + 16020, false);
    }
    xx[0][mv[0][0] + 8010] = true;
    yy[0][8010] = true;
    int lenx = mv[0].size();
    for (int i = 1; i < lenx; i++) {
        for (int j = 0; j < 16020; j++) {
            if (xx[i - 1][j]) {
                xx[i][j + mv[0][i]] = true;
                xx[i][j - mv[0][i]] = true;
            }
        }
    }
    int leny = mv[1].size();
    for (int i = 0; i < leny; i++) {
        for (int j = 0; j < 16020; j++) {
            if (yy[i][j]) {
                yy[i + 1][j + mv[1][i]] = true;
                yy[i + 1][j - mv[1][i]] = true;
            }
        }
    }
    if (xx[lenx - 1][x + 8010] && yy[leny][y + 8010]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using P   = pair<int, int>;
using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int h, w;cin >> h >> w;
    char a[100][100];
    int count[ALPHABET];
    for(int i=0;i<ALPHABET;i++){
        count[i] = 0;
    }
    for(int i=0;i<h;i++){
        string s;cin >> s;
        for(int j=0;j<w;j++){
            a[i][j] = s[j];
            count[a[i][j]-'a']++;
        }
    }

    string ans = "Yes";

    int center;
    int cross;
    if(h%2 == 0 && w%2 == 0){
        center = 0;
        cross = 0;
    }
    if(h%2 == 0 && w%2 == 1){
        center = 0;
        cross = h;
    }
    if(h%2 == 1 && w%2 == 0){
        center = 0;
        cross = w;
    }
    if(h%2 == 1 && w%2 == 1){
        center = 1;
        cross = h+w-2;
    }

    int other = h*w - center - cross;
    for(int i=0;i<ALPHABET;i++){
        if(count[i]%2 == 0){
            cross -= count[i]%4;
            int toother = (count[i]/4)*4;
            if(other < toother){
                cross -= toother-other;
                other = 0;
            }else{
                other -= toother;
            }
        }else{
            if(h%2 == 0 || w%2 == 0) ans = "No";
            center--;
            cross -= (count[i]-1)%4;
            int toother = ((count[i]-1)/4)*4;
            if(other < toother){
                cross -= toother-other;
                other = 0;
            }else{
                other -= toother;
            }
        }
        if(center < 0 || cross < 0 || other < 0) ans = "No";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import Control.Arrow (second)
import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B

solve :: V.Vector Int -> Int
solve xs = V.sum xs - V.length xs

main = do
  Just n <- fmap fst . B.readInt <$> B.getLine
  xs <- V.unfoldrN n (fmap (second B.tail) . B.readInt) <$> B.getLine
  print $ solve xs



Measured memory_bytes: 1020
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Snack
{
    static void Main(string[] args)
    {

        var input = Console.ReadLine().Split(' ');

        var first = long.Parse(input[0]);
        var second = long.Parse(input[1]);

        long ans = Lcm(first, second);

        Console.WriteLine(ans);



    }

    static long Gcd(long a, long b)
    {
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    static long Lcm(long a, long b)
    {
        return (a * b) / Gcd(a, b);
    }
}

Measured memory_bytes: 13140
import bisect

def Toll_Gates(n , m , x , al):

    al.sort()
    ans = 0

    left = bisect.bisect_left(al, x)
    right = m - left

    ans = min(left , right)

    return ans

def main():
    n , m , x = map(int , input().split())
    al = list(map(int, input().split()))
    print(Toll_Gates(n , m , x , al))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <math.h>

using namespace std;

int ans;

void solve(int sum,int objNum,int cnt,int nowNum){
	if(sum>objNum || cnt>4)return ;

	else if(sum == objNum){
		ans++;
		return;
	}
	else if(cnt==4)return;

	else if(cnt==3){
		int tmp = objNum-sum;
		if(nowNum*nowNum>tmp)return;
		if((int)sqrt(tmp)*(int)sqrt(tmp)==tmp)ans++;
		
		return;
	}

	else{
		for(int i=nowNum;i*i<=objNum;i++){
			solve(sum+i*i,objNum,cnt+1,i);
		}
	}
}

int main(){

	int n;
	while(cin>>n){
		if(n==0)break;

		ans=0;
		solve(0,n,0,1);
		

		cout<<ans<<endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    int n,Ans = 0,k;  cin >> n >> k;
    for(int i = 0;i<n;i++){
        int a;  cin >> a;  if(a >= k)  Ans++;
    }
    cout << Ans;
    return 0;
}


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

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> h(n);
    for(ll i=0;i<n;++i){
        cin>>h[i];
    }
    ll ans = 0;
    ll flag = 0;
    for(ll i=1;i<n;++i){
        ll a = h[i-1] - h[i];
        if(a >= 0){
            flag++;
        }else{
            ans = max(ans, flag);
            flag = 0;
        }
    }
    ans = max(ans, flag);
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
import numpy as np
from scipy.sparse.csgraph import dijkstra

N, X, Y = list(map(int, input().split()))

# N = 2000
# X = 100
# Y = 1900


X -= 1
Y -= 1

# @profile


def main(N, X, Y):
    graph = np.zeros((N, N))
    # np.fill_diagonal(graph[1:, :], 1)
    np.fill_diagonal(graph[:, 1:], 1)
    graph[X, Y] = 1
    # graph[Y, X] = 1
    dist = dijkstra(graph, directed=False).astype(int).ravel()
    # print(dist_matrix)

    ans = np.bincount(dist, minlength=N)//2
    print(*ans[1:], sep="\n")


main(N, X, Y)


Measured memory_bytes: 138292
#include<stdio.h>

int main(void) {
  int n, x, t;
  scanf("%d %d %d", &n, &x, &t);
  if(n % x == 0) {
    printf("%d\n", (n / x) * t);
  } else {
    printf("%d\n", (n / x + 1) * t);
  }
  return 0;
}

Measured memory_bytes: 1736
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  vector<int> B(N+1);
  vector<int> C(N);
  rep(i,N) cin>>A.at(i);
  reps(i,N) cin>>B.at(i);
  reps(i,N-1) cin>>C.at(i);
  int sum=0;
  rep(i,N){
    int a=A.at(i);
    if(i>=1&&a==A.at(i-1)+1){
      sum+=(B.at(a)+C.at(A.at(i-1)));
    }
    else sum+=B.at(a);
  }   
  cout<<sum<<endl;


  
}

Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,a[1100][1100];
int tot,p[110000]; bool vis[110000];
void init(){
	vis[1]=true;
	for (int i=2;i<=10000;i++){
		if (!vis[i]) p[++tot]=i;
		if (tot==1000) break;
		for (int j=1;j<=tot&&(i*p[j]<=10000);j++){
			vis[i*p[j]]=true;
			if (i%p[j]==0) break;
		}
	}
}
inline int lcm(int x,int y){
	if (!x||!y) return x|y;
	return x/__gcd(x, y)*y;
}
signed main(){
	init();
	scanf("%lld",&n);
	if (n==2){
		puts("4 7\n23 10");
		return 0;
	}
	for (int i=1;i<=n;i++) 
		for (int j=1;j<=n;j++)
			if (((i+j)&1)==0)
				a[i][j]=p[(i+j)/2]*p[(i-j+n+1)/2+n];
	
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (!a[i][j]) 
				a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i][j+1],a[i+1][j]))+1;
	for (int i=1;i<=n;i++){
		for (int j=1;j<n;j++) printf("%lld ",a[i][j]);
		printf("%lld\n",a[i][n]);
	}
	return 0;	
}


Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<vector<int>> A(N,vector<int>(N-1));
    for(auto& vec:A) for(auto& in:vec){ cin >> in; in--; }

    for(int i = 0; i < N;i++){
        reverse(A[i].begin(),A[i].end());
    }
    
    vector<int> checked(N,-1);
    while(true){
        bool update = false;
        for(int i = 0; i < N;i++){
            if(checked[i] == res) continue;
            checked[i] = res;
            if(A[i].empty()) continue;
            
            int t = A[i].back();
            
            if(checked[t] == res) continue;
            if(A[t].empty()) return -1;
            
            if(A[t].back() == i){
                update = true;
                checked[t] = res;
                
                A[i].pop_back();
                A[t].pop_back();
            }
            
        }
        if(!update){
            for(int i = 0; i < N;i++){
                if(A[i].empty()) continue;
                return -1;
            }
            break;
        }
        res++;
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<int>() << endl;
    return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
#include<iostream>
#define ll long long
#define back return
using namespace std;
ll n,m,i,j,k,lsbl,sum,sumend;
ll gcd(ll a,ll b)
{
    if(!b)
        back a;
    back gcd(b,a%b);
}
ll maxx(ll a,ll b)
{
    if(a>=b)
        back a;
    back b;
}
int main()
{
    cin>>n>>m>>k;
    ll lsbl1=k;
    for(i=2;i<=n;i++)
    {
        cin>>lsbl;
        k=gcd(k,lsbl);
        lsbl1=maxx(lsbl,lsbl1);
    }
    if(lsbl1>=m&&!(m%k))
    {
        cout<<"POSSIBLE"<<endl;
        back 0;
    }
    cout<<"IMPOSSIBLE"<<endl;
    back 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int L, M, N, sum, num, i;
	
	while (scanf("%d", &L), L){
		num = 0;
		sum = 0;
		
		for (i = 0; i < 12; i++){
			scanf("%d %d", &M, &N);
			sum += M - N;
			
			if (num == 0 && sum >= L){
				num = i + 1;
			}
		}
		
		if (num == 0){
			printf("NA\n");
		}
		else {
			printf("%d\n", num);
		}
	}
	
	
	return (0);
}

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

int main() {
    int n,k; cin >> n >> k;
    vector<long> h(n);
    for(int i = 0; i < n; i ++) cin >> h[i];
    vector<long> dp(n);
    dp[0] = 0;
    for(int i = 1; i < n; i ++) {
        for(int j = 1; j <= min(i,k); j ++) {
            if(j==1) dp[i] = abs(h[i]-h[i-j]) + dp[i-j];
            else dp[i] = min(dp[i],abs(h[i]-h[i-j]) + dp[i-j]);
        }
    }
    cout << dp[n-1] << endl;
}

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

int main() {
  int h,w;
  int ans = 0;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> l(h,vector<int>(w,0));
  rep(i,h) {
    if(s[i][0] == '#') l[i][0] = 0;
    else l[i][0] = 1;
  }
  vector<vector<int>> r(h,vector<int>(w,0));
  rep(i,h) {
    if(s[i][w-1] == '#') r[i][w-1] = 0;
    else r[i][w-1] = 1;
  }
  vector<vector<int>> u(h,vector<int>(w,0));
  rep(j,w) {
    if(s[0][j] == '#') u[0][j] = 0;
    else u[0][j] = 1;
  }
  vector<vector<int>> d(h,vector<int>(w,0));
  rep(j,w) {
    if(s[h-1][j] == '#') d[h-1][j] = 0;
    else d[h-1][j] = 1;
  }

  for(int i = 0; i < h; i++) {
    for(int j = 1; j < w; j++) {
      if(s[i][j] == '#') {
        l[i][j] = 0;
        continue;
      }
      l[i][j] = l[i][j-1] + 1;
    }
  }
  for(int j = 0; j < w; j++) {
    for(int i = 1; i < h; i++) {
      if(s[i][j] == '#') {
        u[i][j] = 0;
        continue;
      }
      u[i][j] = u[i-1][j] + 1;
    }
  }
  for(int i = h-1; i >= 0; i--) {
    for(int j = w-2; j >= 0; j--) {
      if(s[i][j] == '#') {
        r[i][j] = 0;
        continue;
      }
      r[i][j] = r[i][j+1] + 1;
    }
  }
  for(int j = w-1; j >= 0; j--) {
    for(int i = h-2; i >= 0; i--) {
      if(s[i][j] == '#') {
        d[i][j] = 0;
        continue;
      }
      d[i][j] = d[i+1][j] + 1;
    }
  }

  rep(i,h)rep(j,w) {
    ans = max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 67200
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, ans;
    cin >> a >> b >> c;
    ans = max(a, max(b, c)) - min(a, min(b, c));
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    a += b
    c += d
    ans = ["Left", "Right"]
    if a == c:
        print("Balanced")
        return
    print(ans[a < c])
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39152