akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

    ll sum = n*100 + m*1800;
    double x = 1 - pow(0.5, m);
    double ans = sum * pow(0.5, m) * pow(2, 2*m);
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

int main(void){
    ll N;
    cin >> N;
    vector<ll> a(N*3);
    for(int i = 0; i < N*3 ; i++){
        cin >> a[i];
    }
    
    sort(a.begin(),a.end(),greater<ll>());
    ll sum = 0;
    for(int i = 1; i < N*2 ; i+=2){
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

int main() {
    string l;
    cin >> l;
    int n = l.size();
    ll dp[2][n];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    dp[1][0] = 2;
    for (int i = 1; i < n; i++) {
        if (l[i] == '1') {
            dp[0][i] = (dp[0][i - 1] * 3 + dp[1][i - 1]) % MOD;
            dp[1][i] = dp[1][i - 1] * 2 % MOD;
        } else {
            dp[0][i] = dp[0][i - 1] * 3 % MOD;
            dp[1][i] = dp[1][i - 1];
        }
    }
    cout << (dp[0][n - 1] + dp[1][n - 1]) % MOD << endl;
    return 0;
}


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

ll n,m,a,b,num[100009],ans[100009];
vector<ll>e[100009];

int main(){
    cin>>n>>m;
    rep(i,n-1+m){
        cin>>a>>b;
        e[a].push_back(b);
        num[b]++;
    }
    queue<ll> que;
    FOR(i,1,n+1)if(num[i]==0)que.push(i);
    while(!que.empty()){
        ll now=que.front();
        que.pop();
        rep(i,e[now].size()){
            num[e[now][i]]--;
            if(num[e[now][i]]==0){
                ans[e[now][i]]=now;
                que.push(e[now][i]);
            }
        }
    }
    FOR(i,1,n+1)cout<<ans[i]<<endl;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; size_t(i) < s.size(); i++) {
		s[i] = '9' + '1' - s[i];
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int r,c;
    cin >> r >> c;
    int a[r + 1][c + 1] = {};
    for(int i = 0;i < r;i++)
    {
        for(int j = 0;j < c;j++)
        {
            cin >> a[i][j];
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
        }
    }
    for(int i = 0;i < r + 1;i++)
    {
        for(int j = 0;j < c + 1;j++)
        {
            cout << a[i][j];
            if(j != c)
            {
                cout << " ";
            }
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 3132
#include "bits/stdc++.h"
using namespace std;
const int INF = 1001001001;
int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;

	int res = 0;
	vector<vector<int> > dp(N + 1, vector<int>(N + 1, 0));
	for (int n = 0;n<N;++n) {
		for (int m = 0;m<N;++m) {
			if (S[n] == S[m]) {
				dp[n + 1][m + 1] = dp[n][m] + 1;
				res = max(res, min(dp[n + 1][m + 1],m-n)); 
				//abcabcxxxx
				//xxxabcabcx
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define print(x) cout << x << endl

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

ll MOD = 1000000007;


int main()
{
    ll n, m;
    cin >> n >> m;
    string A = "";
    string B = "";
    rep(i, n) {
        A += to_string(m);
    }
    rep(i, m) {
        B += to_string(n);
    }
    print(min(A, B));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int pivot(char c[][11], int b, int e)
{
    for(int i = b+1; i <= e; i++){
        int k = strcmp(c[b], c[i]);
        if(k != 0){
            return (k > 0 ? b : i);
        }
    }
    
    return -1;
}
int partition(char c[][11], int b, int e, int p)
{
    char piv[11];
    strcpy(piv, c[p]);
    while(1){
        while(strcmp(piv, c[b]) >  0) b++;
        while(strcmp(piv, c[e]) <= 0) e--;
        if(e < b) break;
        swap(c[b], c[e]);
    }
    return b;
}
void st_sort(char c[][11], int b, int e)
{
    int p;
    if((p = pivot(c, b, e)) == -1) return;
    int t = partition(c, b, e, p);
    st_sort(c, b, t-1);
    st_sort(c, t, e)  ;
}
int main()
{
    int n;
    long long ans = 0;
    cin >> n;
    char c[100000][11];
    for(int i = 0; i < n; i++){
        scanf("%s", c[i]);
        sort(c[i], c[i] + 10);
    }
    st_sort(c, 0, n-1);
    long long i = 0, j = 0;
    while(i < n){
        if(strcmp(c[i], c[j]) == 0){
            i++;
        }
        else{
            ans += (i - j) * (i - j - 1) / 2;
            j = i;
        }
    }
    ans += (i - j) * (i - j - 1) / 2;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int main(void){

    int n;
    cin >> n;
    vector<int> a(n);

    int count4 = 0;
    int count2 = 0;
    int count  = 0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(a[i]%4==0) count4++;
        else if(a[i]%2==0) count2++;
        else count++;
    }
    
    if(count == 2 && count4 >= 2) {
        cout << "Yes" << endl;
    }
    else if(count == 1 && count4 >= 1) {
        cout << "Yes" << endl;
    }
    else if(count == 0) {
        cout << "Yes" << endl;
    }
    else if(count-count4<=1 && count2 == 0) {
        cout << "Yes" << endl;
    }
    else if(count == count4) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;    

}


Measured memory_bytes: 640
from heapq import *

def main():
  n = int(input())
  ab = []
  for _ in range(n):
    a, b = map(int, input().split())
    ab.append((b, a))
  heapify(ab)
  total = 0
  is_done = True
  while ab:
    _ab = heappop(ab)
    if total + _ab[1] <= _ab[0]:
      total += _ab[1]
    else:
      is_done = False
  if is_done:
    print('Yes')
  else:
    print('No')


if __name__ == '__main__':
  main()


Measured memory_bytes: 92376
import sys
import subprocess
import re
import datetime
import os

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0

for i in range(N):
    if V[i]>C[i]:
        ans = ans + (V[i]-C[i])


print(ans)

Measured memory_bytes: 4436
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
string s;
int k;
signed main(){
    cin>>s>>k;
    int i=0;
    while(s[i]=='1')i++;
    if(i>=k)cout<<'1'<<endl;
    else cout<<s[i]<<endl;
    return 0;
}

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

int main() {
  int num1, num2;
  char op;
  cin >> num1 >> op >> num2;
  if(op == '+')
    cout << num1 + num2 << endl;
  else if(op == '-')
    cout << num1 - num2 << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	
	char ans[20];
	string str;
	cin >> str;
	REP(i, 20) {
		ans[i] = 'x';
	}
	int ptr = 0;
	REP(i, str.size()) {
		if (str[i] == '0') {
			ans[ptr] = '0';
			ptr++;
		}
		else if (str[i] == '1') {
			ans[ptr] = '1';
			ptr++;
		}
		else if (str[i] == 'B') {
			if (ptr != 0) {
				ptr--;
				ans[ptr] = 'x';
			}
		}
	}

	REP(i, 20) {
		if (ans[i] == 'x') {
			break;
		}
		else {
			cout << ans[i];
		}
	}
	cout << endl;

	
	
	




	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    map<long long,long long> m;
    for(auto p:A){
        m[p]++;
    }

    long long ans=0;
    for(auto p:m){
        ans+=p.second*(p.second-1)/2;
    }

    for(int i=0;i<N;i++){
        long long bns=ans;
        long long c=m[A[i]];
        bns-=c*(c-1)/2;
        bns+=(c-1)*(c-2)/2;
        cout<<bns<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 11892
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#include <bitset>

#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl

using namespace std;

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

template <class T>
ostream &operator<<(ostream &os, vector<T> const &vec) {
    if (vec.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream &operator<<(ostream &os, array<T, S> const &arr) {
    if (arr.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

template <class T, class U>
ostream &operator<<(ostream &os, pair<T, U> const &p) {
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

namespace math {
ll gcd(ll u, ll v) {
    while (v != 0) {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}
ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;

    return ((m / math::gcd(m, n)) * n);
}
}  // namespace math

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) {}
    bool unionSet(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) { return root(x) == root(y); }
    ll root(ll x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    ll size(ll x) { return -data[root(x)]; }
};

template <class T, class U>
pair<T, U> operator+(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first + b.first, a.second + b.second);
}

template <class T, class U>
pair<T, U> operator-(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first - b.first, a.second - b.second);
}

ll bound(function<bool(ll)> f, ll ng, ll ok) {
    while (abs(ng - ok) > 1) {
        ll mid = (ng + ok) / 2;
        if (f(mid))
            ok = mid;
        else
            ng = mid;
    }

    return ok;
}


int main(void) {
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    pv(y);
    pv(m);
    pv(d);

    array<int, 3> h = {2019, 4, 30}, i = {y, m, d};

    cout << (i <= h ? "Heisei" : "TBD") << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);

	if(A==B&&B==C)
	{
		printf("No");
	}
	else if(A==B||B==C||A==C)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

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

#define mod 1000000007
using ll = long long;

int main(){

  int n,k;
  cin >> n >> k;

  if(n==k){
    ll ans=1;
    ll num;
    for(int i=0;i<n;i++){
      cin >> num;
      ans=ans*num%mod;
    }
    cout << (ans+mod)%mod;
    return 0;
  }

  priority_queue<ll> pos;
  priority_queue<ll> neg;
  ll num;
  for(int i=0;i<n;i++){
    cin >> num;
    if(num>=0){
      pos.push(num);
    }else{
      neg.push(-num);
    }
  }

  if(k%2==1 && pos.size()==0){
    ll ans=1;
    ll num;
    for(int i=0;i<n;i++){
      num=-neg.top();
      neg.pop();
      if(i>=n-k){
        num=num%mod;
        ans=ans*num%mod;
      }
    }
    cout << (ans+mod)%mod << endl;
    return 0;
  }

  ll posnum=1;
  ll negnum=1;
  bool posErase=1;
  bool negErase=1;
  ll ans=1;
  int i=0;
  if(k%2==1){
    ans=pos.top();
    pos.pop();
    i++;
  }
  while(1){
    if(i==k){
      cout << (ans+mod)%mod << endl;
      return 0;
    }
    if(pos.size()>=2 && posErase==1){
      posnum=pos.top();
      pos.pop();
      posnum=posnum*pos.top();
      pos.pop();
      posErase=0;
    }

    if(neg.size()>=2 && negErase==1){
      negnum=neg.top();
      neg.pop();
      negnum=negnum*neg.top();
      neg.pop();
      negErase=0;
    }

    if(posnum>=negnum){
      posErase=1;
      posnum=posnum%mod;
      ans=ans%mod*posnum%mod;
      posnum=0;
    }else{
      negErase=1;
      negnum=negnum%mod;
      ans=ans%mod*negnum%mod;
      negnum=0;
    }
    i+=2;
  }

}

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

typedef long long ll;
int main(){
    int ac = 0, wa = 0, tle = 0, re = 0;
    int n;
    cin>>n;
    while(n --){
        string s;
        cin>>s;
        if(s == "AC")
            ac++;
        else if(s == "WA")
            wa++;
        else if(s == "TLE")
            tle++;
        else{
            re++;
        }
    }
    cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
}

Measured memory_bytes: 3628
S=int(input())
head=int(S/100)
tail=S-head*100
head_can_month = head<=12 and head>=1
tail_can_month = tail<=12 and tail>=1
if head_can_month:
    if tail_can_month:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if tail_can_month:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 38256
//#include "pch.h"
#include <iostream>
#include<string>
#include<algorithm>

using namespace std;

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


	bool judge1 =false;
	bool judge2 = false;
	int j;
	if (S[0]=='A') { 
		for (int i = 2; i < S.size() - 1; i++) {
			if (S[i] == 'C') { judge1 = true; 
			j = i; }
			
		}
		for (int i = 1; i < S.size(); i++) {
			if (i != j && isupper(S[i])) {
				 judge2 = true;
			}
		}
		if (judge1 == true && judge2 != true) {
			cout << "AC" << endl;
		}
		else cout << "WA" << endl;
	}
	else cout << "WA" << endl;
}



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

using namespace std;

typedef long long ll;

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

  string s;
  cin >> s;
 ll n=s.size();
 ll res=n; 
  rep(i,0,n-1) if(s[i]!=s[i+1]) res=min(res,max(i+1LL,n-i-1LL));
  
 cout << res << endl;
  
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		Console.WriteLine("{0}",s[1]*s[2]>=s[0]?"Yes":"No");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27512
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int k;
    vector<int>v(3);

    cin >> v[0] >> v[1] >> v[2] >> k;

    sort(v.begin(),v.end(),greater<int>());

    for(int i = 0;i < k;i++)
        v[0] *= 2;

    cout << accumulate(v.begin(),v.end(),0) << endl;

    return 0;
}

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

int main(){

  int N; cin >> N;
  vector<int> H(N);
  for(int i=0; i<N; i++)
    cin >> H.at(i);
  
  for(int i=0; i<N-1; i++){
    
    if(H.at(i+1) > H.at(i))
      H.at(i+1) -= 1;
    
    if(H.at(i+1) < H.at(i)){
      cout << "No" << endl;
      return 0;
    }
    
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
import sys
import math
import copy

def main():
    n = int(input())
    l = [int(t) for t in input().split()]

    # まずはLを昇順にソートする
    l.sort()
    
    count = 0
    # 1番短い棒(i)と2番目に短い棒(j)を決める
    for i in range(0, n):
        for j in range(i+1, n):
            lb, ub = j, n
            while ub - lb > 1:
                half = (lb + ub) // 2
                if l[half] < l[i] + l[j]:
                    lb = half
                else:
                    ub = half
            count += ub - (j + 1)

    print(count)

    return 0

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 43276
N, P = map(int, input().split())
xs = []
value = 0
for _ in range(N):
    w, b = map(int, input().split())
    xs.append((100-P)*w+P*b)
    value -= P*b

xs.sort(reverse=True)

for i, x in enumerate(xs, 1):
    value += x
    if value >= 0:
        print(i)
        break


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

int main(){
  int N,M,X,sum=0,plus=0;
  cin >> N >> M >> X;
  int A[M+1];
  for(int i=1; i<=M; i++){
    cin >> A[i];
    for(int j=X; j<=N; j++){
    if(A[i]==j){
      sum +=1;
    }
  }for(int a=1; a<=X; a++){
    if(A[i]==a){
      plus += 1;
    }
  }
  }if(sum <= plus){
    cout << sum << endl;
  }else{
    cout << plus << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;
#define write_to_file() freopen("output.txt" , "w" , stdout)
#define read_from_file() freopen("input.txt" , "r" , stdin)
#define GeoOutputFix(VV) cout<<fixed<<setprecision(VV)
#define MAX_V  1e9
#define MIN_V -1e9
template<class T>istream& operator>> (istream& is, complex<T>& p){T value;is >> value, p.real(value), is >> value, p.imag(value);return is;}
typedef long long lld;
typedef pair<lld, lld> dd;
typedef complex<double> point;
#define X real()
#define Y imag()
#define dist(a , b) sqrt(pow(a.X - b.X , 2) + pow(a.Y- b.Y , 2))
#define dist2(a , b) ((long double)hypot(a , b))
#define mid(a,b) (((a)+(b))/point(2,0))
#define compare(a , b) (fabs(a.X - b.X) < -1e9 && fabs(a.Y - b.Y) < -1e9)
#define all(c) c.begin() , c.end()
#define MOD (lld)(1e9+7)
#define EPS 1e-9
#define neighbours(u , e , v) for(int e = head[u] , v ; v = to[e] , ~e ; e = nxt[e])
#define watch1(x) cout<<(#x)<<" = "<<x<<"\n"
#define watch2(x , y) cout<<(#x)<<" = "<<x<<"  "<<(#y)<<" = "<<(y)<<"\n"
#define watch3(x , y , z) cout<<(#x)<<" = "<<x<<"  "<<(#y)<<" = "<<(y)<"  "<<(#z)<<" = "<<(z)<<"\n"
int dr[] = {1 , 1 , 1 , 0 , 0 , -1 , -1 , -1};
int dc[] = {-1 , 0 , 1 , -1 , 1 , -1 , 0 , 1};
int ddr[] = {1 , 0 , 0 , -1};
int ddc[] = {0 , -1 , 1 , 0};
inline int SD(){int i ;scanf("%d", &i);return i;}
inline lld SLL(){lld i;scanf("%lld", &i);return i;}
inline char SC(){char i;scanf(" %c", &i);return i;}
const int AKA = 1e6 + 6 , OO = 0x3f3f3f3f;
//----------------------------------------[TO_OO]--[To infinity and beyond]--------------------------------------------------------

int main()
{
    string s1 , s2;
    cin>>s1>>s2;
    int c = 0;
    for(int i = 0 ; s1[i] ; ++i)
        c+= (s1[i] == s2[i]);
    printf("%d" , c);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N,C,p[100],a;
    a=0;
    cin>>N>>C;
    for(int i=0; i<C; i++){
        cin>>p[i];
        a=a+p[i];
    }
    if(a%(N+1)==0){
        cout<<a/(N+1)<<endl;
    }
    else{
        cout<<a/(N+1)+1<<endl;
    }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool flg;
int expr(string s,int& p);
int term(string s,int& p);
int factor(string s,int& p);
int number(string s,int& p);
int expr(string s,int& p){
  int res=term(s,p);
  while(p<(int)s.size()){
    if(flg) return 0;
    if(s[p]=='+'){
      p++;
      res+=term(s,p);
      continue;
    }
    if(s[p]=='-'){
      p++;
      res-=term(s,p);
      continue;
    }
    break;
  }
  return res;
}
int term(string s,int& p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(flg) return 0;
    if(s[p]=='*'){
      p++;
      res*=factor(s,p);
      continue;
    }
    break;
  }
  return res;
}
int factor(string s,int& p){
  int res;
  if(s[p]=='-'){
    p++;
    res=-factor(s,p);
  }else if(s[p]=='('){
    p++;
    res=expr(s,p);
    if(p>=(int)s.size()||s[p]!=')'){
      flg=1;
      return 0;
    }
    p++;
  }else if(isdigit(s[p])){
    res=number(s,p);
  }else{
    flg=1;
    return 0;
  }
  return res;
}
int number(string s,int& p){
  if(s[p]=='0'){
    if(p+1<s.size()&&isdigit(s[p+1])){
      flg=1;
      return 0;
    }
    p++;
    return 0;
  }
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p])) res=res*2+s[p++]-'0';
  return res;
}
bool check(string s){
  if(s.size()==0) return 0;
  int op=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='(') op++;
    if(s[i]==')') op--;
    if(op<0) return 0;
  }
  if(op) return 0;
  return 1;
}
//set<string> ss;
int Q(string s){
  if(count(s.begin(),s.end(),'=')!=1) return 0;
  int k=s.find('=');
  string a=s.substr(0,k);
  string b=s.substr(k+1,s.size()-(k+1));
  if(!check(a)) return 0;
  if(!check(b)) return 0;
  //cout<<s<<endl;
  //cout<<a<<" "<<b<<endl;
  flg=0;
  int p=0;
  int x=expr(a,p);
  //cout<<flg<<" "<<p<<" "<<x<<endl;
  if(flg||p!=(int)a.size()) return 0;
  p=0;
  int y=expr(b,p);
  //cout<<flg<<" "<<p<<" "<<y<<endl;
  if(flg||p!=(int)b.size()) return 0;
  //cout<<a<<" "<<b<<endl;
  //cout<<x<<":"<<y<<endl;
  return x==y;
}
int ans=0;
string l="01+-*()=";
void dfs(string s,int b){
  bool f=1;
  for(int i=0;i<(int)s.size();i++){
    if(!isalpha(s[i])) continue;
    f=0;
    char c=s[i];
    for(int j=0;j<(int)l.size();j++){
      if((b>>j)&1) continue;
      string t=s;
      for(int k=0;k<(int)s.size();k++){
	if(t[k]==c) t[k]=l[j];
      }
      dfs(t,b+(1<<j));
    }
    break;
  }
  if(f) ans+=Q(s);
}
signed main(){
  string s;
  cin>>s;
  
  dfs(s,0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

  int ans = 0;
  FOR(i,1,k+1) FOR(j,1,k+1) FOR(l,1,k+1){
    int x = gcd(i,j);
    int y = gcd(x,l);
    ans += y;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
import copy

N, M = map(int, raw_input().split())
dic = {}

for i in range(M):
    tmp = map(int, raw_input().split())
    if tmp[0] not in dic:
        dic[tmp[0]] = []
        dic[tmp[0]].append(tmp[1])
    else:
        dic[tmp[0]].append(tmp[1])
    if tmp[1] not in dic:
        dic[tmp[1]] = []
        dic[tmp[1]].append(tmp[0])
    else:
        dic[tmp[1]].append(tmp[0])

flag = 0

key1 = copy.deepcopy(dic[1])
for i in key1:
    key2 = copy.deepcopy(dic[i])
    for i in key2:
        if i == N:
            flag = 1

if flag == 1:
    print "POSSIBLE"
else:
    print "IMPOSSIBLE"
    

Measured memory_bytes: 63504
ans' [] _ _ = "YES"

ans' (i:is) (a:as) (b:bs)
  | (i>a) && (a>b) = ans' is (i:a:as) (b:bs)
  | (a>i) && (i>b) = ans' is (a:as) (i:b:bs)
  | (a>b) && (b>i) = "NO"
  | otherwise      = ans' (i:is) (b:bs) (a:as)
  
ans i = ans' i [0] [-1] -- a /= b

main = do
  n <- getLine
  c <- getContents
  let n' = read n :: Int
      i = map (map read) $ map words $ take n' $ lines c :: [[Int]]
      o = map ans i
  mapM_ putStrLn o
  

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
string s;

int main(){
	cin >> s;
	vector<char> v;
	v.PB(s[0]);
	for(int i=1; i<s.length();i++){
		if (v.back()=='S' && s[i]=='T') v.pop_back();
		else v.PB(s[i]);
	}
	cout << v.size();	

	return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  int first = 0;
  int second = 0;
  int firstarg, secondarg;
  for (int i = 1; i <= N; i++) {
    int a; cin >> a;
    if (a >= first) {
      second = first;
      secondarg = firstarg;
      first = a;
      firstarg = i;
    }else if (a >= second) {
      second = a;
      secondarg = i;
    }
  }
  for (int j = 1; j <= N; j++) {
    if (j == firstarg) cout << second << "\n";
    else               cout << first << "\n";
  }

  return 0;
}



Measured memory_bytes: 1664
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: date_time
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    int a; cin >> a;
    cout << a + (a * a) + (a * a * a) << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long
 
string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) {
    const unsigned int pos = replacedStr.find(from);
    const int len = from.length();
 
    if (pos == std::string::npos || from.empty()) {
        return replacedStr;
    }
 
    return replacedStr.replace(pos, len, to);
}
 
int main() {
  	string S;
  	cin >> S;
  	
  	if(S=="ABC")replaceOtherStr(S, "BC", "RC");
	else replaceOtherStr(S, "RC", "BC");
  
	cout << S << endl;
}

Measured memory_bytes: 3632
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll a,b;
cin>>a>>b;
ll ans=a*b;
ll g=__gcd(a,b);
cout<<ans/g<<endl;
}

Measured memory_bytes: 3596
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int saveb = 0;
		int max = 0;
		int a = 0;
		int b = 0;
		for(int i = 0;i < n;i++){
			a = saori.saori_hayami();
			b = saori.saori_hayami();
			if(a > max){
				max = a;
				saveb = b;
			}
		}
		int ans = max + saveb;
		System.out.println(ans);


		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22280
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;
typedef long long int lli;


void solve(){
	int n,w;
	cin>>n>>w;
	int wt[n+1], val[n+1];
	for(int i=1; i<=n; i++){
		cin>>wt[i]>>val[i];
	}
	lli dp[n+1][w+1];
	for(int i=0; i<=n; i++){
		for(int j=0; j<=w; j++){
			if(i==0 || j==0){
				dp[i][j]=0;
				continue;
			}
			if(j-wt[i]>=0){
				dp[i][j]=max(dp[i-1][j], dp[i-1][j-wt[i]]+val[i]);
			}
			else{
				dp[i][j]=dp[i-1][j];
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	cout<<dp[n][w]<<endl;
}

signed main(){
	//#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    //#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


Measured memory_bytes: 79232
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)












int main(){
    ll n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    vector<bool> win(n, true);
    ll ans = 0;
    REP(i, n){
        if(i >= k){
            if(t[i] == t[i - k] && win[i - k]){
                win[i] = false;
                continue;
            }
        }
        if(t[i] == 'r'){
            ans += p;
        }
        if(t[i] == 's'){
            ans += r;
        }
        if(t[i] == 'p'){
            ans += s;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------

H,W = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

M = list( list(input()) for _ in range(H) )
#=> [['.', '.', '.', '.'], ['.', 'S', 'S', '.'], ['.', '.', 'S', '.'], ['.', '.', '.', '.']]

INF  = float("inf") # 正の無限大
L = [[[INF,-1] for _c in range(W)] for _r in range(H)]


if M[0][0]=='.':
	L[0][0]=[0,0]
else:
	L[0][0]=[1,1]

h=0
w=0

for h in range(1,H):
	l = [ L[h-1][0][0], 0]
	if M[h][0]=='#':
		l[0] += (0 if L[h-1][0][1] else 1)
		l[1] = 1
	L[h][0] = l

for w in range(1,W):
	l = [ L[0][w-1][0], 0]
	if M[0][w]=='#':
		l[0] += (0 if L[0][w-1][1] else 1)
		l[1] = 1
	L[0][w] = l

#p(M)
#p(L)


for h in range(1,H):
	for w in range(1,W):
		l = [ L[h][w-1][0], 0]
		t = [ L[h-1][w][0], 0]
		if M[h][w]=='#':
			l[0] += (0 if L[h][w-1][1] else 1)
			t[0] += (0 if L[h-1][w][1] else 1)
			l[1] = t[1] = 1
		
		L[h][w] = (l if l[0]<t[0] else t)



#p(M)
#p(L)
print(L[H-1][W-1][0])


Measured memory_bytes: 4084
#include <iostream>
#define ll long long int
#include<bits/stdc++.h>
#include<cmath>
#define MOD 1000000009
using namespace std;
int main()
{
	char x;
	cin>>x;
	if(int(x)>64&&int(x)<95)
	cout<<"A"<<endl;
	else
	cout<<"a"<<endl;
	return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef int Weight;
struct Edge{
  int src, dst;
  Weight cost;
  Edge(int f, int t, Weight c) : src(f), dst(t), cost(c) {}
  Edge(int f, int t) : src(f), dst(t) {}
};
typedef vector<Edge> Node;
typedef vector<Node> Graph;
bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color) {
  color[v] = 1;
  FORIT(e, g[v]) {
    if (color[e->dst] == 2) continue;
    if (color[e->dst] == 1) return false;
    if (!visit(g, e->dst, order, color)) return false;
  }
  order.push_back(v); color[v] = 2;
  return true;
}
bool topological_sort(const Graph &g, vector<int> &order) {
  int n = g.size();
  vector<int> color(n);
  REP(u, n) if (!color[u] && !visit(g, u, order, color))
    return false;
  reverse(order.begin(), order.end());
  return true;
}

int main(){
  int M, N;
  while(cin >> M >> N){
    Graph G(M);
    REP(i, M) if(i != 1) G[i].push_back(Edge(i, 1));
    REP(i, N){
      int a, b; cin >> a >> b;
      a--; b--;
      G[a].push_back(Edge(a, b));
    }
    vector<int> order;
    assert(topological_sort(G, order));
    REP(i, order.size()) cout << order[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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


int a[10000000] = {};

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;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[n];For(i,0,n) cin>>a[i];
	ll sum = a[0];
	bool toggle=1;
	For(i,1,n){
		if(toggle) sum+=a[i];
		else sum-=a[i];
		toggle = !toggle;
	}
	ll x1 = sum/2;
	vector<ll> ans;
	ans.pb(x1);
	ll prev = x1;
	For(i,1,n){
		ans.pb(a[i]-prev);
		prev = ans.back();
	}

	vector<ll> final;
	final.pb(ans.back());
	For(i,0,ans.size()-1){
		final.pb(ans[i]);
	}

	for(ll x:final){
		cout<<2*x<<" ";
	}
	cout<<endl;






























	
}

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int a[3];

int main(int argc, const char * argv[]) {
   
 
    
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    
    sort(a,a+3);
    
    int diff = a[2]-a[1];
    int ans = diff;
    a[0] += diff;
    
    diff = a[2]-a[0];
    
    if(diff&1) {
        printf("%d\n",ans+diff/2+2);
    }else{
        printf("%d\n",ans+diff/2);
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		long max = sc.nextLong();
		long ans = 0;
		for (int i=1; i<n; i++){

			long a = sc.nextLong();

			if (a > max) {
				max = a;
			} else {
				ans += (max - a);
			}
		}
		System.out.println(ans);
	}


}

Measured memory_bytes: 60092
h,w = map(int,input().split())
table = [["#"]*(w+2) for i in range(h+2)]
for i in range(1,h+1):
    a_list = list(input())
    for j in range(1,w+1):
        table[i][j] = a_list[j-1]
for i in range(h+2):
    print("".join(table[i]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
string s;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> s;
  if (s == "ABC") cout << "ARC";
  else if (s == "ARC") cout << "ABC";
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
 
int main() {
    int i = 1;
    int value;
    while( 1 ){
        cin >> value;
        if( value == 0)break;
            cout << "Case " << i << ": " << value << endl;
            ++i;

    }
    return 0;
}
 


Measured memory_bytes: 3088
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    // while(k>0)
    // {
    //     int max=a[0];
    //     int p=0;
    //     for(int i=0;i<n;i++)
    //     {
    //         if(max<a[i])
    //         {
    //             max=a[i];
    //             p=i;
    //         }
    //     }
    //     a[p]=0;
    //     k=k-1;
    // }
   long long int count=0;
    sort(a,a+n);
    for(int i=0;i<n-k;i++)
    count=count+a[i];
    cout<<count;
}

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

int main(){
  int n,s=0;cin>>n;
  // s=n/1000000000+n/100000000+n/10000000+n/1000000+n/100000+n/10000+n/1000+n/100+n/10+n%10;
  int temp=n;
  for(int i=0;i<10;i++){
    s+=temp%10;
    temp=(temp-temp%10)/10;
  }
  cout<<(n%s==0?"Yes":"No")<<endl;
}


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

int main()
{
  ll h,n;
  cin >> h >> n;
  rep(n)
  {
    ll tmp;
    cin >> tmp;
    h -= tmp;
  }
  if(h<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int x[200000];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
	}
	sort(x,x+n);
	int ans=0;
	for(int h=(1<<30);h>0;h>>=1)
	{
		for(int i=0,j=n-1;i<j;i++)
		{
			if(x[i]!=-1)
			{
				while(j>i and (x[j]==-1 or x[i]+x[j]>h))
				{
					j--;
				}
				if(j>i and x[j]!=-1 and x[i]+x[j]==h)
				{
					ans++;
					x[i]=x[j]=-1;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	double L;
	cin >> L;
	double ans = pow(L / 3, 3);
	printf("%.10f", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll L, R, D, cnt = 0; cin >> L >> R >> D;
    for(;L <= R; L++) if(L%D==0)cnt++;
    cout << cnt << endl;

} 

Measured memory_bytes: 3532