akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;

signed main(){
  int n;
  cin>>n;
  map<int,int> mp;
  int ans=0;
  REP(i,n){
    int a;
    cin>>a;
    mp[a]++;
  }
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    int f=itr->first,s=itr->second;
    if(f==s)continue;
    else{
      if(f<s)ans+=(s-f);
      else ans+=s;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6272
//Written by smartphone
#include <vector>
#include <algorithm>
#include <iostream>

#define int long long
using namespace std;
signed main(){
  int a, b, q;
  cin>>a>>b>>q;
  vector<int> s(a), t(b), x(q);
  for(int i=0; i<a; i++)cin>>s[i];
  for(int i=0; i<b; i++)cin>>t[i];
  for(int i=0; i<q; i++)cin>>x[i];
  s.push_back(-1LL<<60);
  s.push_back(1LL<<60);
  t.push_back(-1LL<<60);
  t.push_back(1LL<<60);
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  for(int i=0; i<q; i++){
    int ans=1LL<<60;
    int su = *upper_bound(s.begin(), s.end(), x[i]);
    int sl = *prev(upper_bound(s.begin(), s.end(), x[i]));
    int tu = *upper_bound(t.begin(), t.end(), x[i]);
    int tl = *prev(upper_bound(t.begin(), t.end(), x[i]));
    ans = min(ans, max(su, tu)-x[i]);
    ans = min(ans, x[i]-min(sl, tl));
    ans = min(ans, 2*su-x[i]-tl);
    ans = min(ans, 2*tu-x[i]-sl);
    ans = min(ans, x[i]+tu-2*sl);
    ans = min(ans, x[i]+su-2*tl);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3680
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 2e5 + 1;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, w, mn = OO, cnt[5];
llong ans;
pair<int, int> p[101];
vector<int> v[5];

int main () {
    cin >> n >> w;
    for(int i = 1; i <= n; i++){
        cin >> p[i].F >> p[i].S;
    }
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; i++){
        v[p[i].F - p[1].F].pb(p[i].S);
        cnt[p[i].F - p[1].F] = p[i].F;
    }
    for(int i = 0; i < 4; i++){
        v[i].pb(0);
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin() + 1, v[i].end());
    }
    llong sum = 0;
    for(int a = 0; a < v[0].size(); a++){
        sum += v[0][a];
        llong sum1 = sum;
        for(int b = 0; b < v[1].size(); b++){
            sum1 += v[1][b];
            llong sum2 = sum1;
            for(int c = 0; c < v[2].size(); c++){
                sum2 += v[2][c];
                llong sum3 = sum2;
                for(int d = 0; d < v[3].size(); d++){
                    sum3 += v[3][d];
                    if(cnt[0] * a + cnt[1] * b + cnt[2] * c + cnt[3] * d <= w){
                        ans = max(ans, sum3);
                    }else{
                        break;
                    }
                }
            }
        }
    }
    cout << ans;
    return 0;
    
}


Measured memory_bytes: 256
n,d = map(int,input().split())
x = [[int(i) for i in input().split()] for _ in range(n) ]
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        dis = 0
        for k in range(d):
            dis += (x[i][k]-x[j][k]) ** 2
        if (dis ** 0.5 == int(dis ** 0.5)):
            cnt += 1
print(cnt)


Measured memory_bytes: 3060
import java.io.*;
 
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            String[] nums = kb.readLine().split( " " );
            int a = Integer.parseInt( nums[0] );
            int b = Integer.parseInt( nums[1] );
            
            System.out.println( gcd( Math.max( a, b ), Math.min( a, b ) )  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
    
	public static int gcd( int x, int y )
	{
		if( 0 == y ) {
			return x;
		} else {
			return gcd( y, x%y );
		}
	}
}

Measured memory_bytes: 17096
program ABC114B
    implicit none
    integer(8)::i,N
    integer(8)::X
    integer(8)::diff_min
    character(10)::S

    read(5,*)S
    N=len_trim(S)

    do i=1,N-2
        read(S(i:i+2),*)X
        if(i==1 .or. abs(X-753)<diff_min)then
            diff_min=abs(X-753)
        end if
    end do

    print'(i0)',diff_min
end program ABC114B

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
#define MOD 1000000007
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;
}

//全点対最短路問題
#define MAX_V 400
long long d[MAX_V][MAX_V];
long long V;
void warshall_floyd() {
    for(int k = 0; k < V; k++) {
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int H, W;
    cin >> H >> W;
    V = 10;
    REP(i, V) {
        REP(j, V) {
            if(i != j) {
                d[i][j] = INF;
            } else {
                d[i][j] = 0;
            }
        }
    }
    REP(i, 10) {
        REP(j, 10) { cin >> d[i][j]; }
    }
    warshall_floyd();
    long long res = 0;
    REP(i, H) {
        REP(j, W) {
            int tmp;
            cin >> tmp;
            if(tmp != -1) {
                res += d[tmp][1];
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N + 1);
  for (int i = 1; i <= N; i++) cin >> h[i];

  vector<int> dp(N + 1, 1000000000);
  dp[0] = dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for (int i = 2; i <= N; i++) {
    for (int j = 1; j <= K; j++) {
      if (i - j <= 0) break;
      dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }

  cout << dp[N] << endl;
}

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

int main() {
    double a,b,x,r,t;
    cin >> a >> b >> x;

    if(x < (a*a*b)/2) {
        r = (2*x)/(a*b);
        t = 90-(atan(r/b)*180)/M_PI;
    } else {
        r = 2*b-(2*x)/(a*a);
        t = (atan(r/a)*180)/M_PI;
    }

    cout << setprecision(12) << t << endl;
}

Measured memory_bytes: 256
function main(arg){

	var A = ['z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','p','q','r','s','t','u','v','w','x','y','z'];
	arg = arg.trim("");
	var a = A.indexOf(arg);

    console.log(A[a+1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21192
n,a,b = gets.split.map(&:to_i)
v = gets.split.map(&:to_i).sort.reverse

t = [*a..b].map{|i|
  x = v[0...i]
  y = x.count(x[i-1])
  z = v.count(x[i-1])
  pe = 1
  y.times{|j|
    pe *= z-j
  }
  y.times{|j|
    pe /= j+1
  }
  val = x.inject(:+)
  val = val/i + (val%i).to_f/i
  [val, pe]
}.sort{|a,b| b[0]<=>a[0]}

ansval = t[0][0]
anscnt = 0
t.each{|e|
  if ansval == e[0]
    anscnt += e[1]
  end
}

puts sprintf("%.8f", ansval)
puts anscnt


Measured memory_bytes: 1788
s = list(input())
k = int(input())

if len(set(s)) == 1:
  print((len(s)*k)//2)
  exit()

def n_change(sss):
  s = sss.copy()
  x = 0
  for i in range(1, len(s)):
    if s[i] == s[i-1]:
      s[i] = "X"
      x += 1
  return x

print(n_change(s) + (k-1) * (n_change(2*s) - n_change(s)))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  vector<pair<int,int> > vp;
  int N;cin>>N;
  int MAXL = 0;
  int MINR = INF;
  int res = 0;
  for (int i = 0; i < N; i++)
  {
    int X,Y;
    cin>>X>>Y;
    Y++;
    chmax(res,max(Y - X,0LL));
    chmax(MAXL,X);
    chmin(MINR,Y);

    vp.emplace_back(make_pair(X,Y));
  }

  res += max(0LL,MINR - MAXL);
  // DEBUG(res,MINR,MAXL);
  vector<pair<int,int> > vp2;
  for (int i = 0; i < N; i++)
  {
    int A = max(0LL,(vp[i].second - MAXL));
    int B = max(0LL, MINR - vp[i].first);
    vp2.emplace_back(make_pair(A,-1*B));
  }
  sort(ALL(vp2));
  for (int i = 0; i < N; i++)
  {
    vp2[i].second *= -1;
  }
  int w = INF;
  for (int i = 0; i < N; i++)
  {
    // DEBUG(res,vp2[i].first,vp2[i].second);
    if(i) chmax(res,w + vp2[i].first);
    chmin(w,vp2[i].second);

  }
  cout<<res<<endl;
  
  
  


  
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var s = Input().ToInt();
		
		if(Math.Abs(s[0] - s[1]) < Math.Abs(s[0]-s[2]))
		{
			Console.WriteLine("A");
		}
		else
		{
			Console.WriteLine("B");
		
		}
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

#define REP(i, n) for(ull i = 0; i != n; ++i)
#define RREP(i, n) for(ull i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for(auto i = a; i != b; ++i)
#define ALL(v) (v).begin(), (v).end()
#define IN std::cin
#define OUT std::cout

using ll = long long;
using ull = unsigned long long;
template<typename V1, typename V2>
using pair = std::pair<V1, V2>;
using str = std::string;
template<typename Val, std::size_t Size>
using arr = std::array<Val, Size>;
template<typename Val>
using vec = std::vector<Val>;
template<typename Val>
using list = std::list<Val>;
template<typename Val>
using stack = std::stack<Val>;
template<typename Val>
using queue = std::queue<Val>;
template<typename Val>
using pqueue = std::priority_queue<Val>;
template<typename Val>
using deque = std::deque<Val>;
template<typename Key, typename Val>
using map = std::map<Key, Val>;
template<typename Key, typename Val>
using mmap = std::multimap<Key, Val>;
template<typename Key, typename Val>
using umap = std::unordered_map<Key, Val>;
template<typename Key, typename Val>
using ummap = std::unordered_multimap<Key, Val>;
template<typename Key, typename Val>
using set = std::set<Key, Val>;
template<typename Key, typename Val>
using mset = std::multiset<Key, Val>;
template<typename Key, typename Val>
using uset = std::unordered_set<Key, Val>;
template<typename Key, typename Val>
using umset = std::unordered_multiset<Key, Val>;

const str ln = "\n";

int main() {
    ull N, all = 0;
    IN >> N;
    vec<ull> A(N), memo(N);
    REP(i, N) {
        IN >> A[i];
        memo[A[i] - 1]++;
    }
    REP(i, N) {
        all += (memo[i] < 2) ? 0 : memo[i] * (memo[i] - 1) / 2;
    }
    REP(i, N) {
        memo[A[i] - 1]--;
        OUT << (ull)(all - memo[A[i] - 1]) << ln;
        memo[A[i] - 1]++;
    }
}

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

int main() {
   int n;
   cin >> n;
   int i=1;
   while(n>111*i)
   i++;
   cout << 111*i << endl;
}

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

int main()
{
    int d, t, s;

    cin >> d >> t >> s;

    int dist = s * t;

    if (dist >= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)cin>>i;
  sort(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<N-2;i++)
    for(int j=i+1;j<N-1;j++)
      for(int k=j+1;k<N;k++)
        if(A[i]!=A[j] && A[i]!=A[k] && A[j]!=A[k] && A[i]+A[j]>A[k])ans++;
  cout<<ans<<endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ios();
    int h, w, n;
    cin >> h >> w >> n;
    /*
    vector<pair<ll,ll>> v(n);
    for(auto& i : v) cin >> i.first >> i.second;
    sort(all(v));
    */
    
    map<pair<int,int>,int> mp;
    vector<ll> ans(10, 0);

    REP(loop, n){
        int a, b;
        cin >> a >> b;
        a--; b--;
        FOR(i, -2, 1){
            FOR(j, -2, 1){
                if(a + i < 0 || a + i >= h-2 || b + j < 0 || b + j >= w-2) continue;
                mp[make_pair(a+i, b+j)]++;
            }
        }
    }

    for(auto i : mp){
        ans[i.second]++;
    }
    ans[0] = (ll) (h-2)*(w-2) - accumulate(ans.begin()+1, ans.end(), 0LL);

    for(auto i : ans) cout << i << endl;
    
    return 0;
}


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

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

  if(a>b) cout << a+a-1 << endl;
  else if(a<b) cout << b+b-1 << endl;
  else if(a==b) cout << a+b << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static long MOD = (long) 1e9 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] s = new int[m];
		int[] c = new int[m];
		for (int i = 0; i < m; i++) {
			s[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		sc.close();
		int[] ans = new int[n];
		for (int i = 0; i < n; i++) {
			ans[i] = 10;
		}
		boolean can = true;
		for (int i = 0; i < m; i++) {
			if (ans[s[i] - 1] == 10) {
				ans[s[i] - 1] = c[i];
				if (s[i] - 1 == 0 && c[i] == 0 && n != 1) {
					can = false;
					break;
				}
			} else if (ans[s[i] - 1] != c[i]) {
				can = false;
				break;
			}
		}
		if (!can) {
			System.out.println(-1);
		} else {
			for (int i = 0; i < n; i++) {
				if (ans[i] != 10) {
					System.out.print(ans[i]);
				} else {
					if (i == 0 && n != 1) {
						System.out.print(1);
					} else {
						System.out.print(0);
					}
				}
			}
		}
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static Integer[] arrayInteger(Scanner sc, int n) {
		Integer[] array = new Integer[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 22736
#include <iostream>
#include <string.h>
using namespace std;
void call(int n){
    for(int i=1;i<=n;i++){
        if(i%3==0){
            cout<<" "<<i;
        }else{
            string s0=to_string(i);
            const char* s1=s0.data();
            const char* s2="3";
            if(strstr(s1,s2)!=NULL){
                cout<<" "<<i;
            }
        }
    }
    cout<<endl;
}
int main(){
    int v;
    cin>>v;
    call(v);
    return 0;
}

Measured memory_bytes: 3264
#include<stdio.h>
#include<string.h>
int main(void){
    int weeks;
    int account = 100000;
    int surplus;
    int i;
    scanf("%d", &weeks);
    for(i = 0; i < weeks; i++){
        account *= 1.05;   
    
        if((surplus = account % 1000) != 0){
            account -= surplus;
            account += 1000;
        }
    }
    
    printf("%d", account);
    putchar('\n');
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
  int count = 0;
  string S;
  string T;
  cin >> S;
  cin >> T;
  for (int i = 0; i < S.length();i++)
  {
    if(S[i] != T[i])
    {
      count++;
    }
  }
  if(count == 0)
  {cout << "Yes" << endl;}
  else
  {cout << "No" << endl;}
}


Measured memory_bytes: 3084
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	var ab = parseInt(input[0], 10) + parseInt(input[1], 10);
	var cd = parseInt(input[2], 10) + parseInt(input[3], 10);

	var result = "";
	if(ab == cd) result = "Balanced"
	else if(ab > cd) result = "Left"
	else result = "Right"

	console.log(result);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef int64_t ll;
typedef long double ld;
using namespace std;
const ll mod=1000000007;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();
    ll H,A;
    cin>>H>>A;
    cout<<(H+A-1)/A<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        boolean[] sCards = new boolean[13];
        boolean[] hCards = new boolean[13];
        boolean[] cCards = new boolean[13];
        boolean[] dCards = new boolean[13];
        StringBuilder sb = new StringBuilder();

        int restCardCnt = in.nextInt();
        while (in.hasNext()) {
            char suit = in.next().charAt(0);
            int number = in.nextInt();

            for (int i = 0; i < restCardCnt; i++) {
                switch (suit) {
                case 'S': sCards[number - 1] = true;    break;
                case 'H': hCards[number - 1] = true;    break;
                case 'C': cCards[number - 1] = true;    break;
                case 'D': dCards[number - 1] = true;    break;

                default:
                    break;
                }
            }
        }

        printRestCards("S", sCards, sb);
        printRestCards("H", hCards, sb);
        printRestCards("C", cCards, sb);
        printRestCards("D", dCards, sb);

        System.out.print(sb.toString());
    }

    private static void printRestCards(String suit, boolean[] rest, StringBuilder sb) {
        for (int i = 0; i < rest.length; i++) {
            sb.append(rest[i] ? "" : suit + " " + (i + 1) + "\n");
        }
        return;
    }
}

Measured memory_bytes: 18092
import sys
X,K,D= map(int, input().split())
if X>0 and X-K*D>0:
    print(X-K*D)
    sys.exit()
if X<0 and X+K*D<0:
    print(-X-K*D)
    sys.exit()
if X<0:
    X=-X
n=int(X/D)
if (K-n)%2==0:
    print(X-n*D)
else:
    print((n+1)*D-X)

Measured memory_bytes: 9184
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String, Integer> m = new HashMap<>();
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			if (m.containsKey(s)) {
				m.put(s, m.get(s) + 1);
			} else {
				m.put(s, 1);
			}
		}
		int max = 0;
		for (Integer i : m.values()) {
			max = Math.max(max, i);
		}
		
		List<String> list = new ArrayList<>();
		for (Map.Entry<String, Integer> e : m.entrySet()) {
			if (e.getValue() == max) {
				list.add(e.getKey());
			}
		}
		
		Collections.sort(list);
		for (String string : list) {
			System.out.println(string);
		}
	}
}


Measured memory_bytes: 85048
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int comp(const void *a, const void *b){
	return strcmp(*(char**)a, *(char**)b);
}

int main(void){
	int n, i;
	int l;
	char s[100][101];
	char *k[100];
	scanf("%d %d", &n, &l);
	for(i=0; i<n; i++){
		scanf("%s", s+i);
		k[i]=s[i];
	}
	qsort(k, n, sizeof(char*), comp);
	for(i=0; i<n; i++){
		printf("%s", k[i]);
	}
	putchar(10);
}


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

int n, m, c;
int ans;
int ansans;

int main() {
    cin >> n >> m >> c;
    int a[n][m];
    int b[m];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    
    for (int i = 0; i < n; i++) {
        ans = 0;
        for (int j = 0; j < m; j++){
            ans += a[i][j] * b[j];
        }
        ans += c;
        if (ans > 0) {
            ansans++;
        }
    }
    
    cout << ansans << endl;
    return 0;
}


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

int main() {
  int ab, bc, ca;
  cin >> ab >> bc >> ca;
  cout << (ab*bc) / 2 << endl;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  map<string, int> mp;
  cin >> n;
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    mp[s]++;
  }
  int m;
  cin >> m;
  for(int i=0; i<m; i++){
    string s;
    cin >> s;
    mp[s]--;
  }
  int ans = 0;
  for(auto x : mp) ans = max(ans, x.second);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

lli inv_fac[200001] = {};
lli fac[200001] = {};


//a^x mod mod197
lli pow_mod(lli a, lli x) {

	lli answer = 1;
	while (x != 0) {
		if (x % 2 == 1) answer = (answer * a) % mod197;
		a *= a;
		a %= mod197;
		x >>= 1;
	}

	return answer;
}

lli comb_mod(lli n, lli r) {
	if (fac[0] == 0) {
		fac[0] = 1;
		inv_fac[0] = 1;
		for (lli i = 1; i <= 200000; i++) {
			fac[i] = (fac[i - 1] * i) % mod197;
			inv_fac[i] = (inv_fac[i - 1] * pow_mod(i, mod197 - 2)) % mod197;
		}
	}
	if (n == 0 && r == 0) return 1;
	lli tmp = (inv_fac[n - r] * inv_fac[r]) % mod197;
	return (tmp * fac[n]) % mod197;
}

lli min_r_comb_mod(lli n, lli r) {
	if (n == 0 && r == 0) return 1;

	lli x = 1;
	lli y = 1;

	for (lli i = 1; i <= r; i++) {
		y *= i;
		y %= mod197;
		x *= (n - i + 1);
		x %= mod197;
	}

	return (pow_mod(y, mod197 - 2) * x) % mod197;
}


int main(void) {

	lli n, a, b;
	cin >> n >> a >> b;



	lli answer = pow_mod(2, n) - min_r_comb_mod(n, a) - min_r_comb_mod(n, b);
	answer %= mod197;
	answer += mod197;
	answer %= mod197;
	cout << answer - 1 << endl;


	return 0;
}

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define FASTIO cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); cout.tie(0);

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

#define DEBUG 1
#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, __VA_ARGS__)

int main() {
    ll a, b, k, temp;
    cin >> a >> b >> k;
    temp = min(a, k);
    a -= temp, k -= temp;
    b -= min(b, k);
    cout << a << ' ' << b << '\n';
    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())	
n = int(input())
a = list(map(int,input().split()))
ass = []

for i in range(n):
    for j in range(a[i]):
        ass.append(i+1)

#print(ass)

k = 1
l = 1
ans = ''

for i in range(h):
    ans = ''
    for j in range(w):
        if l == 1:
            if i == h-1 and j == w-1:
                ans += str(ass[i*w+j])
            else:
                ans += str(ass[i*w+j]) + ' '
        else:
            if i == h-1 and j == w-1:
                ans += str(ass[(i+1)*w-j-1])
            else:
                
                ans += str(ass[(i+1)*w-j-1]) + ' '
    l = l * (-1)
    print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
   
   int  ct=0;
   sort(l.begin(), l.end());
   for(int i=0;i<n-2;i++){
       for( int j=i+1;j<n-1;j++){
           for(int k=j+1;k<n;k++){
               if(l[i]!=l[j] && l[j]!=l[k] && l[i] != l[k]){
                   
                   if(l[k] < l[i]+l[j]) ct++;
               }
           }
       }
   }
   
   cout<<ct<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll dp[1005][1005];

int main()
{
    ll h,w;
    cin>>h>>w;
    char a[h+5][w+5];
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
    dp[0][0]=1;
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            if(a[i][j]=='.')
            {
                if(i>=1)
                    dp[i][j]+=dp[i-1][j];
                dp[i][j]%=mod;
                if(j>=1)
                    dp[i][j]+=dp[i][j-1];
                dp[i][j]%=mod;

            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 12404
#include <stdio.h>

int main(void){
	int w,h,i,j;
	do{
		scanf("%d %d",&h,&w);
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				putchar('#');
			}
			putchar('\n');
		}
		if(w!=0 || h!=0)
			putchar('\n');
	}while(w!=0 && h!=0);
		
		
	return 0;
}

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

int main(){
    int width,height,x,y,radius;
    cin >> width >> height >> x >> y >> radius;
    if(x + radius > width || x - radius < 0 || y + radius > height || y - radius < 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1160
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [n, k] <- map strToInt . words <$> getLine
    -- スペース区切り整数の入力
    l <- reverse . sort <$> map strToInt . words <$> getLine
    -- 出力
    putStrLn . show . sum $ take k l


Measured memory_bytes: 764
import itertools
n,m,q = map(int, input().split())
a,b,c,d = [0]*q,[0]*q,[0]*q,[0]*q

for i in range(q):
    a[i],b[i],c[i],d[i] = map(int, input().split())

ans = 0

for C in itertools.combinations_with_replacement(range(1,m+1),n):
    x = 0
    for i in range(q):
        if C[b[i]-1] - C[a[i]-1] == c[i]:
            x += d[i]

    ans = max(ans,x)

print(ans)

Measured memory_bytes: 9168
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        k: u32,
        n: u32,
        a: [u32; n],
    }

    let mut vd: Vec<u32> = vec!();
    for i in 0.. n - 1 {
        vd.push(a[(i + 1) as usize] - a[i as usize]);
    }
    vd.push(k + a[0] - a[(n - 1) as usize]);
    vd.sort();
    let ans = k - vd.last().unwrap();
    println!("{}", ans);
}


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

int main(){
int m,n,p,used;
cin >> m >> n;
while (m!=0 || n!=0){
  vector<bool> flag(7368792);
  used=0;
  for (int i=m; i<7368792; i++){
    if (flag[i]) continue;
    if (used==n){
      cout << i << endl;
      break;
    }else{
      used++;
      for (int j=i; j<=7368792; j+=i){
          flag[j]=true;
      }
    }
  }
  cin >> m >> n;
}
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	int ok = true;
	if(n % 2 == 1){
		if(a.at(0) != 0) ok = false;
		for(int i = 1; i < n; i += 2){
			if(a.at(i) != a.at(i + 1) || a.at(i) != i + 1) ok = false;
		}
	}
	else{
		for(int i = 0; i < n; i += 2){
			if(a.at(i) != a.at(i + 1) || a.at(i) != i + 1) ok = false;
		}
	}
	if(ok){
		ll ans = 1;
		rep(i,n / 2) ans = ans * 2 % mod;
		cout << ans << endl;
	}
	else{
		cout << 0 << endl;
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const int N = 1e5 + 18;



int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {

      
        int n;
        cin >> n;
        int sum = n * n * n + n * n + n;
        cout << sum << endl;
    }
    return 0;

}



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

int main(){

    string s;
    cin >> s;

    int b = 0;

    for(int i=0; i<s.length(); i++){
        b += (int)(s[i] - '0');
    }

    int s_int = atoi(s.c_str());

    if(s_int % b == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(x,to) for(x=0;x<(to);x++)

int main()
{
    int n,i;cin>>n;
    int l[2*n];
    FOR(i,2*n){
        cin>>l[i];
    }
    sort(l,l+2*n);
    int ans=0;
    FOR(i,n){
        ans+=l[2*i];
    }
    cout<<ans;
}


Measured memory_bytes: 256
while True:
	l=input().split()
	if l[1]=='?':
		break
	elif l[1]=='+':
		print(int(l[0])+int(l[2]))
	elif l[1]=='-':
		print(int(l[0])-int(l[2]))
	elif l[1]=='*':
		print(int(l[0])*int(l[2]))
	elif l[1]=='/':
		print(int(l[0])//int(l[2]))
		


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
#define ll long long 
int sumdigital(int n){
  int sum = 0;
  while(n>0){
    sum += n % 10;
    n /= 10;
  }
  return sum;  
}
using namespace std;
int main(){
  ll n;
  cin >> n;
  ll ans = 1000000000000000;
  for(int i = 1; i <= n/2+1; i++){
    int j = n-i;
    int sum = sumdigital(i)+sumdigital(j);
    if(sum < ans) ans = sum;
  }
  cout << ans << endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var input = ReadArrayInt();
            var T = input[0];
            var A = input[1];
            var H = ReadArrayInt();
            var dif = double.MaxValue;
            var ans = 1;
            for (int i = 0; i < N; i++)
            {
                var tmp = Math.Abs(A - (T - H[i] * 0.006));
                if (tmp < dif)
                {
                    ans = i + 1;
                    dif = tmp;
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


Measured memory_bytes: 13332
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        for (char c : arr) {
            if (c == '7') {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 35724
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int k,s;
    scanf("%d%d",&k,&s);
    int c=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int l=s-i-j;
            if(0<=l&&l<=k) c++;
        }
    }
    printf("%d\n",c);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
	string ss, tt;
	cin >> ss >> tt;

	int size = ss.size();
	bool ans;

	for (int i = 0; i < size; i++)
	{
		int num = 0;
		ans = true;

		for (int j = 0; j < size ; j++)
		{
			int t = i + j;
			if (t > size - 1)
			{
				t -= size;
			}

			if (ss[j] != tt[t])
			{
				ans = false;
				break;
			}
		}

		if (ans == true)
		{
			break;
		}
	}

	if (ans == true)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = input()
if n == 'SUN':
    print(7)
elif n== "MON":
    print(6)
elif n == "TUE":
    print(5)
elif n == "WED":
    print(4)
elif n== "THU":
    print(3)
elif n == "FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10 ;
int c[N] , b[N] ;
struct node
{
  int a , b ;
  node() {}
  node(int a ,int b) : a(a) , b(b) {}
  bool operator<(const node &A) const
  {
    return a < A.a ;
  }
}v[N];
int main()
{
  int n , d , a ;
  ios::sync_with_stdio(false) ;
  cin.tie(0) , cout.tie(0) ;
  cin >> n >> d >> a ;
  for(int i = 1 ; i <= n ;i ++)
   {
     int x , y ;
     cin >> x >> y ;
     y = y / a + (y % a == 0 ? 0 : 1) ;
     v[i] = {x , y} ;
   }
   sort(v + 1 , v + n + 1 ) ;
   for(int i = 1 ; i <= n ;i ++)
    b[i] = v[i].a ;
   long long ans = 0 ;
   for(int i = 1 ; i <= n ;i ++)
    {
      c[i] += c[i - 1] ;
      if(c[i] + v[i].b <= 0) continue ;
      int x = c[i] + v[i].b ;
      c[i] -= x ;
      ans += x ;
      int t = upper_bound(b + 1 , b + n + 1 , v[i].a + 2 * d) - b ;
      c[t] += x ;
    }
    cout << ans << endl ;
  return 0 ;
}


Measured memory_bytes: 3328
import java.io.*;
public class Main{
        public static void main(String[] args) throws IOException {
                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                String is; 
                while((is = in.readLine()) != null){
                        int n = Integer.parseInt(is);
                        if(n == 0){
                                System.out.println(0);
                                continue;
                        } else if(n == 1){
                                System.out.println(1);
                                continue;
                        } else if(n == 2){
                                System.out.println(2);
                                continue;
                        }
                        int c = 2;
                        int d = 0;
                        for(int i = 2;i < n; ++i){
                                if(i % 2 == 0){
                                        d = d * 3 + 1;
                                }
                                c += d * 2 + 1;
                        }
                        System.out.println(c);
                }   
        }   
}

Measured memory_bytes: 8872
def run(N, a):
    ans = -1
    cnt = 0
    idx = 0
    i = 1
    match = False
    while idx < N:
        ai = a[idx]
        idx += 1
        if ai == i:
            # print('match', i, ai, idx)
            match = True
            i += 1
        else:
            # print('break', i, ai, idx)
            cnt += 1
    if match:
        ans = cnt
    return ans


def main():
    N = int(input())
    a = list(map(int, input().split()))
    print(run(N, a))


if __name__ == '__main__':
    main()


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

using namespace std;

// 多次元 mul_array<int, 1, 2, 3> a
template <typename T, std::size_t... Ns>
struct index_reverse_for_array;
template <typename T, std::size_t N, std::size_t... Ns>
struct index_reverse_for_array<T, N, Ns...> { using type = std::array< typename index_reverse_for_array<T, Ns...>::type, N>; };
template <typename T, std::size_t N>
struct index_reverse_for_array<T, N> { using type = std::array<T, N>; };
template <class T, std::size_t... Ns> using mul_array = typename index_reverse_for_array<T, Ns...>::type;

// デバッグ用 dump マクロ
template <int N, int S> constexpr void temp_dump_split(const char *s, int i) { }
template <int N, int S, class V, class... Vs> constexpr void temp_dump_split(const char *s, int i, V v, Vs... vs) {
    if (i == S || s[i] == ',') { std::cerr << " = " << v << std::endl; temp_dump_split<N, S, Vs...>(s, i+1, vs...); return; }
    else if (s[i] != ' ') { cerr << s[i]; temp_dump_split<N, S, V, Vs...>(s, i+1, v, vs...); }
    else temp_dump_split<N, S, V, Vs...>(s, i+1, v, vs...);
}
template <std::size_t S, class... Ts>
static constexpr void temp_dump(const char (&s)[S], Ts... vs) { temp_dump_split<sizeof...(Ts), S, Ts...>(s, 0, vs...); }
#define dump(...) temp_dump(#__VA_ARGS__, __VA_ARGS__)

int main() {
    //cout << fixed << setprecision(10);

    //cout.setf(ios::right, ios::adjustfield);
    //cout.fill('0');
    //cout << setw(2) << "" << endl;

    string a, b;
    while (cin >> a >> b) {
        vector<vector<uint64_t>> dp(a.size());
        for (int i = 0; i < dp.size(); i++) {
            dp[i].resize(b.size());
            for (int j = 0; j < dp[i].size(); j++) {
                dp[i][j] = 0;
            }
        }
        uint64_t max = 0;
        for (int i = 0; i < dp.size(); i++) {
            for (int j = 0; j < dp[i].size(); j++) {
                if (a[i] == b[j]) {
                    if (i == 0 || j == 0)
                        dp[i][j] = 1;
                    else
                        dp[i][j] = dp[i-1][j-1] + 1;

                    if (max < dp[i][j])
                        max = dp[i][j];
                }
            }
        }

        cout << max << endl;
    }


    return 0;
}

//cout << 1["hello"] << endl;




Measured memory_bytes: 127984
/*
CF ID: Ankit717
PROG: Vacation
LANG: C++
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200005
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb push_back
#define pf push_front
#define nl cout << "\n";

const ll INF=1e18L+5;
 
struct Data{
	ll p;
	ll h;
};

void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pll &a,pll &b){
	// if(a.first==b.first){
	// 	return a.second<b.second;
	// }else{
		return a.first>b.first;
	//}
}

// vector<pll> adj[maxn];
// vector<ll> par;
// vector<bool> vis;

ll gcd(ll a,ll b){
    while(a!=0){
        ll temp=a;
        a = b % a;
        b = temp;
    }

    return b;
}

// bool prime[maxn],near[maxn];
// void sieve(){
// 	f(i,0,maxn+1){
// 		prime[i]=true;
// 	}
// 	prime[0]=falsrime[1]=false;
// 	for(ll i=2;i*i<=maxn;i++){
// 		if(prime[i]){
// 			for(j=i*i;j<=maxn;j+=i){
// 				prime[j]=false;
// 			}
// 		}
// 	}
// }

void solve(){
	ll n;
	cin >> n;
	ll a[n],b[n],c[n];
	f(i,0,n){
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<ll> swim(n,INF),bugs(n,INF),home(n,INF);
	swim[0]=a[0];
	bugs[0]=b[0];
	home[0]=c[0];

	f(i,1,n){
		swim[i]=max(bugs[i-1]+a[i],home[i-1]+a[i]);
		bugs[i]=max(swim[i-1]+b[i],home[i-1]+b[i]);
		home[i]=max(bugs[i-1]+c[i],swim[i-1]+c[i]);
	}

	cout << max(swim[n-1],max(bugs[n-1],home[n-1]));
}

int main(){
	ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    
	// ll t;
	// cin >> t;
	// f(i,0,t){
		solve();
	//}
}


Measured memory_bytes: 7920
#include"bits/stdc++.h"
using namespace std;

int main()
{
  int n;
  cin>>n;
  int a[n+5],b[n+5];


  for(int i=1;i<=n+1;i++)cin>>a[i];
  for(int i=1;i<=n;i++)cin>>b[i];

  long long  sum=0;
  for(int i=1;i<=n;i++){
  if(b[i]>=a[i])
  {
  sum+=a[i];
  b[i]-=a[i];
    a[i]=0;

  }
  else{
  //int p=a[i]-b[i];
  sum+=b[i];
  a[i]-=b[i];
    b[i]=0;


  }
    if(b[i]>=a[i+1])
  {
  sum+=a[i+1];
  b[i]-=a[i+1];
    a[i+1]=0;

  }
  else{
 // int p=a[i+1]-b[i];
  sum+=b[i];
  a[i+1]-=b[i];
    b[i]=0;


  }




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


Measured memory_bytes: 1024
<?php
  fscanf(STDIN,"%d",$n);
 $max = 0;
 $sum = 0;
 for($i=0;$i<$n;$i++){
   $p = trim(fgets(STDIN));
   $sum += $p;
   $max = max($p,$max);
 }

echo ($sum-$max/2);

Measured memory_bytes: 16200
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll m=1e9+7;
ll lev=0;
ll n,k;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
vector<ll> v[1000000+1];
ll vis[1000000+1]={0};
void dfs(ll u,ll p,ll lev)
{
    vis[u]=lev;
for(auto x: v[u])
{
if(x!=p)
{
dfs(x,u,lev+1);
}
}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
  
ll n;
cin>>n;
ll a[n+1];
map<ll,ll> m;
for(i=2;i<=n;i++)
{
cin>>a[i];
m[a[i]]++;
}
for(i=1;i<=n;i++)
{
cout<<m[i];
     cout<<"\n";
 } 
 } 
}


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

string insert_char(string s, int n, char c){
    s += ' ';
    for(int i=s.size() - 1; i>n; i--) s.at(i) = s.at(i-1);
    s.at(n) = c;
    return s;
}

vector<string> split(string s, char c){
    int first=0;
    vector<string> ss;
    while(first < s.size()){
        int last = s.find_first_of(c, first);
        if(last == string::npos) last = s.size();
        string s1 = s.substr(first, last - first);
        ss.push_back(s1);
        first = last + 1;
    }
    return ss;
}

int main() {
    string s;
    cin >> s;
    int64_t sum=0;
    for(int i=0; i < (1 << s.size() - 1); i++){
        bitset<9> b(i);
        string s1 = s;
        vector<string> ss;
        for(int j=s.size()-2; j>=0; j--){
            if(b.test(j)) {
                s1 = insert_char(s1, j+1, '+');
            }
        }
        ss = split(s1, '+');
        for(int i=0; i<ss.size(); i++){
            int64_t n = stoll(ss.at(i));
            sum += n;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256