akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#define int long long
using namespace std;
int mod=1e9+7;
int dx[]={1,0,0,-1},dy[]={0,1,-1,0},dx2[]={2,2,2,2,2,1,1,1,1,0,0,-1,-1,-1,-1,-2,-2,-2,-2,-2},dy2[]={2,1,0,-1,-2,2,1,-1,-2,2,-2,2,1,-1,-2,2,1,0,-1,-2};
int dist[1000][1000];
signed main(void){
    int h,w,ch,cw,dh,dw;
    string s[1000];
    cin>>h>>w>>ch>>cw>>dh>>dw;
    ch--,cw--,dh--,dw--;
    for(int i=0;i<h;i++)
        cin>>s[i];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            dist[i][j]=mod;
    dist[ch][cw]=0;
    deque<pair<int,int>>deq;
    deq.emplace_back(ch,cw);
    while(!deq.empty()){
        auto p=deq.front();
        deq.pop_front();
        int x=p.first,y=p.second;
        for(int i=0;i<4;i++){
            int xx=x+dx[i],yy=y+dy[i];
            if(xx<0||yy<0||xx>=h||yy>=w||s[xx][yy]=='#')
                continue;
            if(dist[xx][yy]>dist[x][y]){
                dist[xx][yy]=dist[x][y];
                deq.emplace_front(xx,yy);
            }
        }
        for(int i=0;i<20;i++){
            int xx=x+dx2[i],yy=y+dy2[i];
            if(xx<0||yy<0||xx>=h||yy>=w||s[xx][yy]=='#')
                continue;
            if(dist[xx][yy]>dist[x][y]+1){
                dist[xx][yy]=dist[x][y]+1;
                deq.emplace_back(xx,yy);
            }
        }
    }
    cout<<(dist[dh][dw]>=mod?-1:dist[dh][dw])<<endl;
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int cnt = 0, o = 0;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++)
    {
        o = a[o];
        cnt++;
        if(o == 1) {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 640
int main(void)
{
 int S = 0;
 int h = 0;
 int m = 0;
 int s = 0;
  
 scanf("%d",&S);
 h = S/3600;
 m = (S%3600)/60;
 s = ((S%3600)%60);
  
 printf("%d:%d:%d\n",h,m,s);
 return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
  ios::sync_with_stdio(0);cin.tie(0); 
  int n,t=0;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n-2;i++)
  {
  	if(s[i]=='A')
  	{
  		if(s[i+1]=='B'&&s[i+2]=='C')
  		t++;
	  }
  }
  cout<<t;
  
 
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String[] d = new String[k];
        for (int i = 0; i < k; i++) {
            d[i] = sc.next();
        }
        
        for (int i = n; i <= 100000 ; i++) {
            boolean find = false;
            for (int j = 0; j < k; j++) {
                if (Integer.toString(i).contains(d[j])) {
                    find = true;
                    break;
                }
            }
            if (find) {
                continue;
            }
            System.out.println(i);
            System.exit(0);
        } 
    }    
}


Measured memory_bytes: 17744
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b; cin >> a >> b;
    printf("%.10lf",(double)a/b);
}




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

robot_list = []

for i in range(n):
    x, l = list(map(int, input().split()))
    robot_list.append([x+l, x-l, l])

delete_robot = 0
robot_list.sort()
temp_robot = robot_list[0]

for i in range(n-1):
    if temp_robot[0] > robot_list[i+1][1]:
        delete_robot += 1
    else:
        temp_robot = robot_list[i+1]

print(n - delete_robot)


Measured memory_bytes: 89620
#include<bits/stdc++.h>
typedef long long i64;
const int P=924844033,M=2333;
int N,K;
int pw(int a,int n){
	if(n<0)n+=P-1;
	int v=1;
	for(;n;n>>=1,a=i64(a)*a%P)if(n&1)v=i64(v)*a%P;
	return v;
}
int A[M],B[M],r[M],E[M],fac[M],fiv[M];
int fix(int x){return x+(x>>31&P);}
void ntt(int*a,int t){
	for(int i=1;i<N;++i)if(i<r[i])std::swap(a[i],a[r[i]]);
	for(int i=1;i<N;i<<=1){
		i64 z=pw(5,(P-1)/(i<<1)*t);
		E[0]=1;
		for(int k=1;k<i;++k)E[k]=E[k-1]*z%P;
		for(int j=0;j<N;j+=i<<1){
			int*b=a+j,*c=b+i;
			for(int k=0;k<i;++k){
				int x=b[k],y=c[k]*i64(E[k])%P;
				b[k]=fix(x+y-P);
				c[k]=fix(x-y);
			}
		}
	}
	if(t==-1){
		i64 I=pw(N,-1);
		for(int i=0;i<N;++i)a[i]=a[i]*I%P;
	}
}
int n,k;
int C(int n,int k){
	if(n<k)return 0;
	return fac[n]*i64(fiv[k])%P*fiv[n-k]%P;
}
int main(){
	scanf("%d%d",&n,&k);
	for(N=2,K=0;N<n+5;N<<=1,++K);
	for(int i=1;i<N;++i)r[i]=r[i>>1]>>1|(i&1)<<K;
	for(int i=fac[0]=1;i<=n;++i)fac[i]=i64(i)*fac[i-1]%P;
	fiv[n]=pw(fac[n],-1);
	for(int i=n;i;--i)fiv[i-1]=i64(i)*fiv[i]%P;
	int an=n/k,bn=n/k+1,ac=(k-n%k)*2,bc=n%k*2;
	for(int i=0;i<=n;++i)A[i]=C(an-i,i);
	for(int i=0;i<=n;++i)B[i]=C(bn-i,i);
	ntt(A,1),ntt(B,1);
	for(int i=0;i<N;++i)A[i]=i64(pw(A[i],ac))*pw(B[i],bc)%P;
	ntt(A,-1);
	int ans=0;
	for(int i=0;i<=n;++i)ans=(ans+i64(i&1?-1:1)*fac[n-i]*A[i])%P;
	printf("%d\n",fix(ans));
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()


using namespace std;

int main()
{
	int N, i; cin >> N >> i;

	cout << N - i + 1;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の標準入力
		int n = sc.nextInt();
		String[] englishWord = new String[n];
		List<String> wordList = new ArrayList<String>();
		Set<String> checkHash = new HashSet<String>();
		// 整数値の数だけ文字列を標準入力
		for(int i = 0; i < n; i++) {
			englishWord[i] = sc.next();
			wordList.add(englishWord[i]);
			if(i >= 1) {
				// 文字列の先頭文字と1つ前の文字列の末尾文字を比較
				if(!(englishWord[i].substring(0, 1).equals(englishWord[i - 1].substring(englishWord[i - 1].length() - 1)))) {
					System.out.println("No");
					System.exit(0);
				}
			}
		}
		// 重複している文字列が存在するか
		for(String str : wordList) {
			if(checkHash.contains(str)) {
				System.out.println("No");
				System.exit(0);
			} else {
				checkHash.add(str);
			}
		}
		System.out.println("Yes");
		sc.close();
	}
}

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

namespace ConsoleApplication40
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) break;
                decimal b = decimal.Parse(a);
                if (b > 91) Console.WriteLine("heavy");
                else if (b > 81) Console.WriteLine("light heavy");
                else if (b > 75) Console.WriteLine("middle");
                else if (b > 69) Console.WriteLine("light middle");
                else if (b > 64) Console.WriteLine("welter");
                else if (b > 60) Console.WriteLine("light welter");
                else if (b > 57) Console.WriteLine("light");
                else if (b > 54) Console.WriteLine("feather");
                else if (b > 51) Console.WriteLine("bantam");
                else if (b > 48) Console.WriteLine("fly");
                else Console.WriteLine("light fly");

            }
        }
    }
}

Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll a,b; cin>>a>>b;
	if(abs(a-b)>1){
		cout<<0;
		return 0;
	}
	ll ans=1;
	while(a && b){
		ans*=a; ans%=MOD;
		ans*=b; ans%=MOD;
		--a; --b;
	}
	if(a==b)ans*=2;
	ans%=MOD;
	cout<<ans;
	
	return 0;
}

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

int main()
{
  int n; cin >> n;
  vector<pair<ll, ll>> v(n);
  rep(i, n){
    ll a, b; cin >> a >> b;
    v[i] = make_pair(b, a);
  }
  sort(v.begin(), v.end());
  int sum = 0;
  bool f = true;
  rep(i, n){
    sum += v[i].second;
    if(sum > v[i].first)f = false;
  }
  if(f)cout << "Yes" << endl;
  else cout << "No" << endl;
  system("pause");
}


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

typedef struct Dice {
	int north,south,east,west,top,bottom;
} Dice;

typedef void (*DiceCmd)(Dice* dp);

void turn_north(Dice* dp){
	int tmp;

	tmp = dp->top;
	dp->top = dp->south;
	dp->south = dp->bottom;
	dp->bottom = dp->north;
	dp->north = tmp;
}

void turn_south(Dice* dp){
	int tmp;

	tmp = dp->top;
	dp->top = dp->north;
	dp->north = dp->bottom;
	dp->bottom = dp->south;
	dp->south = tmp;
}

void turn_east(Dice* dp){
	int tmp;

	tmp = dp->top;
	dp->top = dp->west;
	dp->west = dp->bottom;
	dp->bottom = dp->east;
	dp->east = tmp;
}

void turn_west(Dice* dp){
	int tmp;

	tmp = dp->top;
	dp->top = dp->east;
	dp->east = dp->bottom;
	dp->bottom = dp->west;
	dp->west = tmp;
}

void clockwise(Dice* dp){
	int tmp;

	tmp = dp->south;
	dp->south = dp->east;
	dp->east = dp->north;
	dp->north = dp->west;
	dp->west = tmp;
}

void anticlockwise(Dice* dp){
	int tmp;

	tmp = dp->south;
	dp->south = dp->west;
	dp->west = dp->north;
	dp->north = dp->east;
	dp->east = tmp;
}

void input_dice(Dice *dp){
	scanf("%d",&dp->top);
	scanf("%d",&dp->south);
	scanf("%d",&dp->east);
	scanf("%d",&dp->west);
	scanf("%d",&dp->north);
	scanf("%d",&dp->bottom);
}

int main(int argc, char** argv){
	Dice d0,d[2];
	int q_cnt,q_top,q_south;
	DiceCmd dice_cmd[6][3] = {
		{ turn_north, NULL, NULL }, // South -> Top
		{ turn_south,  NULL, NULL }, // North -> Top
		{ turn_east, NULL, NULL }, // West -> Top
		{ turn_west, NULL, NULL }, // Eas  -> Top
		{ NULL, NULL, NULL }, // Top -> Top
		{ turn_north, turn_north,  NULL }, // Bottom -> Top
	};
	int i,j;
	int yes;

	// Input
	for(i=0;i<=1;i++){
		input_dice(&d[i]);
	}

	// Solve
	yes = 0;
	for(i=0;i<=5;i++){
		// Reset
		memcpy( &d0, &d[0], sizeof(Dice) );
		// Turn
		for(j=0; dice_cmd[i][j]!=NULL; j++){
			dice_cmd[i][j](&d0);
		}

		// Turn & Check
		j=1;
		for(;;){
			if( memcmp(&d0, &d[1], sizeof(Dice)) == 0 ){
				yes = 1;
				break;
			} else if( j<4 ){
				clockwise(&d0);
				j++;
			} else {
				break;
			}
		}

		if( yes ) {
			break;
		}
	}

	// Output
	if( yes ){
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

int main(void) {
    int r;
    cin >> r;

    if (r < 1200)
        cout << "ABC";
    else if (r < 2800)
        cout << "ARC";
    else
        cout << "AGC";

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, u: int, v: int, A: "List[int]", B: "List[int]"):
    u -= 1
    v -= 1
    conns = [[] for _ in range(N)]
    for j in range(N - 1):
        conns[A[j] - 1].append(B[j] - 1)
        conns[B[j] - 1].append(A[j] - 1)

    can = [True] * N
    def find_v(idx, dis, visited):
        visited[idx] = True
        if idx == v:
            can[idx] = False
            return (dis, -1)
        ret = 0
        target = -1
        for conn in conns[idx]:
            if not visited[conn]:
                ret, target = find_v(conn, dis + 1, visited)
                if ret > 0:
                    if dis >= ret / 2:
                        can[idx] = False
                    if dis < ret / 2 and target == -1:
                        target = idx
                    break
        return ret, target
    visited = [False] * N
    uv, node = find_v(u, 0, visited)
    #print(can)
    #print('uv: ', uv)
    #print('node: ', node)
    #print(' ---- ' )
    def dfs(idx, dis, visited):
        visited[idx] = True
        ret = dis
        for conn in conns[idx]:
            if not visited[conn] and can[conn]:
                tmp = dfs(conn, dis + 1, visited)
                ret = max(ret, tmp)
        return ret
    visited = [False] * N
    ret = dfs(node, 0, visited)
    #print('ret:', ret)
    ret += uv // 2
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = int(next(tokens))  # type: int
    v = int(next(tokens))  # type: int
    A = [int()] * (N - 1)  # type: "List[int]"
    B = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, u, v, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 115076
// ------------------------------------
// Date:2018/ 3/24
// Problem:Good Sequence _ d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

int main()
{
  CIN(N);
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }
  sort(ALL(a));

  ll ans = 0;
  ll last = a[0];
  ll cnt = 0;
  REP(i, N) {
    // debug(a[i]);
    // debug(last);
    // debug(cnt);
    // debug(ans);
    if (last != a[i]) {
      if (cnt < last) ans += cnt;
      else if (cnt > last) ans += abs(cnt - last);
      last = a[i];
      cnt = 0;
    }
    cnt++;
  }
  if (cnt < last) ans += cnt;
  else if (cnt > last) ans += abs(cnt - last);
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 640
def examD(mod):
    N = I(); A = LI()
    d = defaultdict(int)
    for i in range(N):
        cur = A[i]
        j = 1
        while(cur>0):
            if cur&1==1:
                d[j] +=1
            j +=1
            cur >>=1
    ans = 0
    for i,j in d.items():
        ans += j*(N-j) * 2**(i-1)
        ans %=mod
    print(ans)
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD(mod)


Measured memory_bytes: 122120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
   int a;string s;
   cin>>a>>s;
   if (a>=3200)
   {
      /* code */
      cout<<s<<endl;
   }
   else
   {
      cout<<"red"<<endl;
   }
   
   
   
   
   }
   

Measured memory_bytes: 256
// ref. https://qiita.com/drken/items/03c7db44ccd27820ea0d

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll MAX_N = 305;

ll n;
// i..1, j..2, k..3
// dp[i][j][k] = dp[i][j][k]*(n-i-j-k)/n + dp[i-1][j][k]*i/n + dp[i+1][j-1][k]*j/n + dp[i][j+1][k-1]*k/n + 1
// dp[i][j][k] = (dp[i−1][j][k]*i + dp[i+1][j−1][k]*j + dp[i][j+1][k−1]*k + n)/(i+j+k)
double dp[MAX_N][MAX_N][MAX_N];

double rec(ll i, ll j, ll k) {
  if (dp[i][j][k] >= 0) { return dp[i][j][k]; }
  double res = 0;
  if (i>0) { res += rec(i-1,j,k)*i; }
  if (j>0) { res += rec(i+1,j-1,k)*j; }
  if (k>0) { res += rec(i,j+1,k-1)*k; }
  res += n;
  res /= i+j+k;
  return dp[i][j][k] = res;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cout << setprecision(10) << fixed;

  cin >> n;
  vector<ll> cnt(4);
  rep(i, n) {
    ll a;
    cin >> a;
    ++cnt[a];
  }
  // initialization
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0.0;

  cout << rec(cnt[1], cnt[2], cnt[3]) << endl;
}


Measured memory_bytes: 221952
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA solver = new TaskA();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskA {    
    String x;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      x = in.next();
      int ans = x.length(), sc = 0;
      for (int i = 0; i < x.length(); ++i)
        if (x.charAt(i) == 'S')
          ++sc;
        else
          if (sc > 0) {
            ans -= 2;
            --sc;
          }
      out.println(ans);
    }
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }
    
    public String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 12144
import itertools
from fractions import gcd

def main():
    N = int(input())
    a = [list(map(str, input().split())) for i in range(N)]
    song = input()
        
    count = 0
    for i in range(N-1,0,-1):
        if a[i][0] == song:
            print(count)
            return
        else:
            count+= int(a[i][1])
    print(count)
main()

Measured memory_bytes: 5688
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 202020;
map<int, ll> f[nax];
const ll inf = 1e18L + 5;

ll get(int nn, int kk) {
	if (nn < 0) {
		return -inf;
	}
	if (f[nn].count(kk)) {
		return f[nn][kk];
	}
	return -inf;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vi a(n + 1);
	FOR(i, 1, n) cin >> a[i];
	f[0][0] = 0;
	f[1][0] = 0;
	f[1][1] = a[1];
	FOR(i, 2, n) {
		for (int k = (i - 1)/2; k <= (i + 1) / 2; ++k) {
			// chce policzy f[n][k]
			f[i][k] = get(i - 1, k);
			f[i][k] = max(f[i][k], get(i - 2, k - 1) + a[i]);
			f[i][k] = max(f[i][k], get(i - 3, k - 1) + a[i]);
		}
	}
	cout << get(n, n / 2) << endl;
}

Measured memory_bytes: 38552
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String temp = S.substring(0, 1);
		int cnt = 0;
		for(int i = 1; i < S.length(); i++) {
			if(!S.substring(i, i + 1).equals(temp)) {
				cnt++;
				temp = S.substring(i, i + 1);
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 33868
n = int(input())
nums = list(map(int, input().split()))

mod = 10**9 + 7

summm = sum(nums) % mod
sum_square = sum([num ** 2 for num in nums]) % mod

ans = (summm ** 2 - sum_square) % mod
ans *= (mod + 1) // 2
ans %= mod
print(ans)



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, ma, mb, a[40], b[40], c[40];
int dp[401][401];
const int INF = 5000;

int main() {
	cin >> n >> ma >> mb;
	inc(i, n) { cin >> a[i] >> b[i] >> c[i]; }
	
	inc(i, 401) {
	inc(j, 401) {
		dp[i][j] = INF;
	}
	}
	
	dp[0][0] = 0;
	inc(k, n) {
		dec(i, 401) {
		dec(j, 401) {
			if(dp[i][j] != INF) {
				setmin(dp[i + a[k]][j + b[k]], dp[i][j] + c[k]);
			}
		}
		}
	}
	
	int ans = INF;
	inc1(k, 400) {
		if(ma * k <= 400 && mb * k <= 400) { } else { break; }
		
		setmin(ans, dp[ma * k][mb * k]);
	}
	
	cout << (ans == INF ? -1 : ans) << endl;
	
	return 0;
}


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

vector<int>prime(999999,0);
//vector<int>prime1(1000001,0);
vector<int>mark(9999999,0);
int nprime;

void sieve(int n)///FINDING PRIME
{
    int limit=sqrt(n*1.0)+1,s=0;nprime=0;
    mark[1]=1;///1 if not prime.
    mark[2]=0;prime[nprime++]=2;//cout<<2<<endl;
    //for(int i=4;i<=n;i+=2)mark[i]=1;
    for(int i=3;i<=n;i+=2){
        if(!mark[i]){prime[nprime++]=i;//cout<<i<<endl;
        if(i<=limit){///karon limit er upor theke n porjonto not prime gula already cuta hoise.
            for(int j=i*i;j<=n;j+=i*2){
                mark[j]=1;
            }
        }}
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,s=0;
    cin>>n>>k;
    ll l1[n+1];
    for(int i=1;i<=n;i++)cin>>l1[i];
    sort(l1+1,l1+n+1);
    for(int i=1;i<=k;i++)s+=l1[i];
    cout<<s<<endl;
}


Measured memory_bytes: 46168
#include <stdio.h>
#include <string.h>
 
int main(void) {
    int n, i;
    int ayaneru = 0, asumisu = 0;
    char tomatu[128], sumipe[128];
    if (scanf("%d", &n) != 1) return 1;
    for (i = 0; i < n; i++) {
        int mareitaso;
        if (scanf("%127s%127s", tomatu, sumipe) != 2) return 1;
        mareitaso = strcmp(tomatu, sumipe);
        if (mareitaso > 0) ayaneru += 3;
        else if (mareitaso < 0) asumisu += 3;
        else ayaneru++, asumisu++;
    }
    printf("%d %d\n", ayaneru, asumisu);
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  string S,T;
  cin>>S>>T;
  VVI dp(S.size()+1,VI(T.size()+1));
  rep(i,S.size()) rep(j,T.size()){
    dp[i+1][j+1]=max({dp[i][j]+(S[i]==T[j]),dp[i+1][j],dp[i][j+1]});
  }
  int cnt=dp[S.size()][T.size()];
  string ans="";
  int X=S.size();
  int Y=T.size();
  while(cnt){
    while(dp[X-1][Y]==cnt) X--;
    while(dp[X][Y-1]==cnt) Y--;
    ans+=S[X-1];
    cnt--;
    X--;
    Y--;
  }
  reverse(all(ans));
  cout<<ans<<endl;
}

Measured memory_bytes: 35584
maxNum, brokenCount= map(int, input().split())

brokenIndexSet= set([int(input()) for i in range(brokenCount)])

ans = [0]*(maxNum + 1)
ans[0] = 1

#print(ans[-1])

for i in range(1, maxNum + 1):
    if i in brokenIndexSet:
        ans[i] = 0
    else:
        ans[i] = (ans[i - 1] + ans[i - 2]) % 1000000007 

print(ans[maxNum])


Measured memory_bytes: 13192
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
using namespace std;

#define TEST 0
#if TEST
FILE *in = freopen("./q", "r", stdin);
FILE *out = freopen("./ans", "w", stdout);
#endif

int main(){
	int n; cin >> n;
	while (n--){
		int balls[10];
		for (int i = 0; i < 10; i++){
			cin >> balls[i];
		}

		int left = 0, right = 0;
		bool ok = true;
		for (int i = 0; i < 10; i++){
			int dleft = balls[i] - left;
			int dright = balls[i] - right;

			if (dleft <= 0 && dright <= 0){
				ok = false;
				break;
			}

			if (dleft <= 0){
				right = balls[i];
			}
			else if (dright <= 0){
				left = balls[i];
			}
			else if (dleft < dright){
				left = balls[i];
			}
			else{
				right = balls[i];
			}
		}

		cout << (ok ? "YES": "NO") << endl;

	}
	

#if TEST
	fclose(in);
	fclose(out);
#endif
}

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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 

int main () {
    int K ,X;
    cin >> K >> X;

    if(K*500 >= X)cout << "Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    set<string> s;
    ll n;
    cin >> n;
    REP(i, n){
        string si;
        cin >> si;
        s.insert(si);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19220
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define mp     make_pair
#define cont   continue
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 1e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll a[MAXN],b[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
int n,m,k,cnt,sum,ans,mx,mn=INF;
bool y;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}


void solve(){
	string s,t;
	cin>>s>>t;
	vector<vector<pair<int,pii > > >dp(s.sz+1,vector<pair<int,pii> >(t.sz+1,{0,{-1,-1}}));
	for(int i=0;i<s.sz;i++){
        for(int j=0;j<t.sz;j++){
            if(s[i]==t[j]){
                if(dp[i][j].f+1>dp[i+1][j+1].f){
                    dp[i+1][j+1].f=dp[i][j].f+1;
                    dp[i+1][j+1].s.f=i;
                    dp[i+1][j+1].s.s=j;
                }
            }
            if(dp[i][j].f>dp[i+1][j].f){
                dp[i+1][j].f=dp[i][j].f;
                dp[i+1][j].s.f=i;
                dp[i+1][j].s.s=j;
            }
            if(dp[i][j].f>dp[i][j+1].f){
                dp[i][j+1].f=dp[i][j].f;
                dp[i][j+1].s.f=i;
                dp[i][j+1].s.s=j;
            }
        }
	}
	for(int i=0;i<=s.sz;i++){
        for(int j=0;j<=t.sz;j++){
            mx=max(mx,dp[i][j].f);
        }
	}
	string ans="";
	for(int i=0;i<=s.sz;i++){
        for(int j=0;j<=t.sz;j++){
            if(dp[i][j].f==mx){
                //cout<<i<<" "<<j<<" "<<mx<<endl;
                int i1=i,j1=j,p=-1;
                while(dp[i1][j1].s.f!=-1){
                    int i11=dp[i1][j1].s.f;
                    int j11=dp[i1][j1].s.s;
                    i1=i11;
                    j1=j11;
                   // cout<<i1<<" "<<j1<<endl;
                    if(dp[i1][j1].f!=p){
                        ans+=s[i1];
                    }
                    p=dp[i1][j1].f;
                }
                reverse(all(ans));
                cout<<ans;
                exit(0);
            }
        }
	}

}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




Measured memory_bytes: 108288
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 200002
#define mod 1000000007

ll add(ll x, ll y) {
	x += y;
	if(x >= mod) return x - mod;
	return x;
}

ll mul(ll x, ll y) {
	x *= y;
	if(x >= mod) return x % mod;
	return x;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll p = power(x, y/2);
	p = mul(p, p);
	if(y&1) return mul(p, x);
	return p;
}

ll get(int a, int n) {
	int res = 1;
	for(int i=1; i<=a; i++) {
		res = mul(res, n+1-i);
		res = mul(res, power(i, mod-2));
	}
	return res;
}

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

	ll n, a, b;
	cin >> n >> a >> b;
	ll all = add(power(2, n), mod-1);
	all = add(all, mod - get(a, n));
	all = add(all, mod - get(b, n));
	cout << all << endl;
	
	return 0;
}

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

int main(){
  char s[20];
  char t[21];
  int i;
  
  scanf("%s",s);
  scanf("%s",t);
  
  
  t[strlen(s)]='\0';
  
  
  if(strcmp(s,t)==0){
   printf("Yes\n");
    return 0;
  }
  printf("No\n");
  
  
 return 0; 
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int n;
vector<vector<pair<int,int>>> G(100000,vector<pair<int,int>>());
vector<int> ans(100000);

void dfs(int x,int y,int d){
  //cout << x << ' ' << y << ' ' << d << endl;
  ans.at(x)=d;
  
  for(auto p:G.at(x)){
    if(p.first==y);
    else{
      dfs(p.first,x,(d+p.second)%2);
    }
  }
  return;
}

int main(){
  cin >> n;
  int u,v,w;
  rep(i,n-1){
    cin >> u >> v >> w;
    u--;v--;
    w %= 2;
    G.at(u).push_back(make_pair(v,w));
    G.at(v).push_back(make_pair(u,w));
  }
  
  dfs(0,0,0);
  
  rep(i,n) cout << ans.at(i) << endl;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<int>seg;
vector<int>lazy;
int S;
void build(){
      S=(1<<(int)ceil(log2(seg.size())));
      int l=S-seg.size();
      for(int i=0;i<l;i++)seg.pb(0);
      reverse(all(seg));
      for(int i=1;i<seg.size();i+=2)seg.pb(max(seg[i],seg[i-1]));
      seg.pb(0);
      reverse(all(seg));
      lazy=vector<int>(seg.size()*4,0);
}
void push(int j){
      if(j>=seg.size())return;
      seg[j]+=lazy[j];
      lazy[j*2]+=lazy[j];
      lazy[j*2+1]+=lazy[j];
      lazy[j]=0;
}
void update(int j){
      while(j>0){
            push(j);
            push(j*2);
            push(j*2+1);
            if(j*2+1<seg.size())
            seg[j]=max(seg[j*2],seg[j*2+1]);
            j/=2;
      }
}
void rangeupdate(int j,int a,int b,int x,int y,int key){
      push(j);
      if(y<a||b<x)return;
      if(a<=x&&y<=b){
            lazy[j]+=key;
            push(j);
            update(j);
      }
      else{
            rangeupdate(j*2,a,b,x,(x+y)/2,key);
            rangeupdate(j*2+1,a,b,(x+y)/2+1,y,key);
      }
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,m;
      cin>>n>>m;
      seg.resize(n+1,0);
      build();
      map<int,vector<int> > X;
      vector<pair<ii,int> >arr(m+1);
      for(int i=1;i<=m;i++){
            int x,y,z;
            cin>>x>>y>>z;
            arr[i]={{x,y},z};
            X[x].pb(i);
            X[y].pb(-i);
      }
      int sum=0,ans=0;
      for(int x=1;x<=n;x++){
            if(X.count(x)){
                  vector<int>&Q=X[x];
                  for(int i=0;i<Q.size();i++){
                        if(Q[i]>0){
                              sum+=arr[Q[i]].second;
                        }
                  }
            }
            ans=max(ans,sum+seg[1]);
            rangeupdate(1,x,x,0,S-1,seg[1]);
            if(X.count(x)){
                  vector<int>&Q=X[x];
                  for(int i=0;i<Q.size();i++){
                        if(Q[i]<0){
                              pair<ii,int>& p=arr[-Q[i]];
                              rangeupdate(1,p.first.first,x,0,S-1,p.second);
                              sum-=p.second;
                        }
                  }
            }
      }
      cout<<ans;
}


Measured memory_bytes: 48432
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll a, b;
	cin >> a >> b;
	cout << (a * 3 + b)  /2;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n = int(input())
    #n, k = map(int, input().split())
    a, b, c, d = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()
    print(max(b*c, b*d, a*c, a*d))

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

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

using namespace std;
using graph=vector<vector<int>>;

graph T;
int x[1000];

int other[1000]; // other[u] := ( u を根とする部分木について, u と異なる色で塗られた頂点の重みの和の最小値 )

bool dfs(int u,int p){
	vector<pair<int,int>> Ch;
	int sum1=0,sum2=0;
	for(int v:T[u]) if(v!=p) {
		if(!dfs(v,u)) return false;
		Ch.emplace_back(x[v],other[v]);
		sum1+=min(x[v],other[v]);
		sum2+=max(x[v],other[v]);
	}
	if(sum1>x[u]) return false;

	int W=x[u]-sum1;
	static bool dp[5001];
	rep(w,W+1) dp[w]=false;
	dp[0]=true;
	for(auto p:Ch){
		int a=max(p.first,p.second)-min(p.first,p.second);
		for(int w=W;w>=a;w--) dp[w]|=dp[w-a];
	}
	int pos;
	rep(w,W+1) if(dp[w]) pos=w;
	other[u]=sum2-pos; // (sum1+sum2)-(sum1+pos)

	return true;
}

int main(){
	int n; scanf("%d",&n);
	T.resize(n);
	rep(i,n-1){
		int p; scanf("%d",&p); p--;
		T[i+1].emplace_back(p);
		T[p].emplace_back(i+1);
	}
	rep(u,n) scanf("%d",&x[u]);

	puts(dfs(0,-1)?"POSSIBLE":"IMPOSSIBLE");

	return 0;
}


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

const int maxn = 310;
int n, a[maxn][maxn];
vector<pair<int, int>> E;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            scanf("%d", &a[i][j]);
            if (i ^ j && i < j) E.push_back(make_pair(i, j));
        }
    }
    sort(E.begin(), E.end(), [&](pair<int, int> p1, pair<int, int> p2) {
        return a[p1.first][p1.second] < a[p2.first][p2.second];
    });
    long long ans = 0;
    for (auto p : E) {
        int u = p.first, v = p.second, mn = 2e9;
        for (int i = 1; i <= n; i++) if (i ^ u && i ^ v) {
            mn = min(mn, a[u][i] + a[i][v]);
        }
        if (mn > a[u][v]) ans += a[u][v];
        else if (mn < a[u][v]) printf("-1\n"), exit(0);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1144
// 2_abc143_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n){
        cin >> d[i];
    }
    ll ans = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void twoNumbers() {
		Scanner scan = new Scanner(System.in);
		int x = 0;
		int y = 0;
		
		while(true) {
			x = scan.nextInt();
			y = scan.nextInt();
			if((x == 0) && (y == 0)) break;
			if(x < y){
				System.out.println(x + " " + y);
			} else {
				System.out.println(y + " " + x);
			}
		}
	}
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		twoNumbers();
	}

}



Measured memory_bytes: 36468
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;
int main(){
    char s;
    scanf("%c", &s);
    cout << (char)(s+1);

}

Measured memory_bytes: 256