akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define MOD 1000000007
long long pw[115], dp[2][40005], ans; 
int x[115], y[115], in[40005], have[40005]; 
int main()
{
	// freopen("CF17-TR-I.in", "r", stdin); 
	int n, m; 
	scanf("%d%d", &n, &m);
	pw[0] = 1; 
	for (int i = 1; i <= 110; i++)
		pw[i] = (pw[i - 1] + pw[i - 1]) % MOD; 
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d", x + i, y + i); 
		x[i]--;
		y[i]--; 
	}
	for (int i = 0; i < 1 << n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			in[i] += (i & (1 << x[j])) && (i & (1 << y[j]));
			have[i] += (i & (1 << x[j])) || (i & (1 << y[j]));
		}
	}
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 1 << n; j++)
		{
			if (!(j & (1 << i)))
				continue; 
			dp[i][j] = pw[in[j]];
			for (int k = j; k; k = k - 1 & j)
				(dp[i][j] -= dp[i][j ^ k] * pw[in[k]]) %= MOD; 
		}
	}
	for (int i = 0; i < 1 << n; i++)
	{
		int t = (1 << n) - 1 ^ i; 
		for (int j = t; ; j = j - 1 & t)
		{
			if (in[i] + in[j] == in[i | j])
				(ans += dp[0][i] * dp[1][j] % MOD * pw[m - have[i | j]]) %= MOD; 
			if (!j)
				break; 
		}
	}
	printf("%lld\n", (pw[m] - ans + MOD) % MOD);
	return 0; 
}


Measured memory_bytes: 896
n,m=map(int,input().split())
l_max=0
r_min=10**5+1
for i in range(m):
    l,r=map(int,input().split())
    l_max=max(l,l_max)
    r_min=min(r,r_min)
print(max(r_min-l_max+1,0))

Measured memory_bytes: 9128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;

vector<vector<int>> dp;

void solve()
{
	string s, t;
	cin >> s >> t;

	int n = (int)s.length();
	int m = (int)t.length();

	dp.assign(n + 1, vector<int>(m + 1, 0));

	for (int i = 1; i <= n; i++)
	{
		for (int k = 1; k <= m; k++)
		{
			if (s[i - 1] == t[k - 1])
			{
				dp[i][k] = dp[i - 1][k - 1] + 1;
			}
			else
			{
				dp[i][k] = max(dp[i - 1][k], dp[i][k - 1]);
			}
		}
	}


	int i = n, k = m;
	string ans = "";
	while (i > 0 && k > 0)
	{
		if (s[i - 1] == t[k - 1])
		{
			ans.push_back(s[i - 1]);
			i--;
			k--;
		}
		else if (dp[i - 1][k] == dp[i][k])
		{
			i--;
		}
		else
		{
			k--;
		}
	}

	int l = (int)ans.length();
	for (int i = 0; i < l; i++)
	{
		cout << ans[l - i - 1];
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}


int main() {
  int H, W, K;
  int ans = 0;
  cin >> H >> W >> K;

  vector< string > s(H);
  rep(i, H) cin >> s[i];

  rep(i, 1 << H) {
    rep(j, 1 << W) {
      int count = 0;
      rep(x, H) rep(y, W) {
        if ((i >> x & 1) || (j >> y & 1)) continue;
        if (s[x][y] == '#') count++;
      }

      if (count == K) ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
   int  n,k,d;
    cin >> n>>k;
    vector<int> a(n),sunuke(n);
    rep(i, k) {
        cin >> d;
        rep(i, d) {
            cin >> a[i];
            sunuke[a[i]-1]++;
        }
       
    }
    int c = 0;
    rep(i, n) {
        if (sunuke[i] == 0)c++;
    }
    cout << c << endl;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
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 ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll H;cin>>H;
    ll count=1,ans=0;
    while(H){
        ans+=count;
        count*=2;
        H/=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX];
int parent[MAX];
int lowest[MAX];
int timer;
void dfs(int current,int prev){
  //ノードcurrentを訪問した直後の処理
  prenum[current]=lowest[current]=timer;
  timer++;
  visited[current]=true;
  int next;
  for(int i=0;i<G[current].size();i++){
    next=G[current][i];
    if(!visited[next]){
      //ノードcurrentからノードnextへ訪問する直前の処理
      parent[next]=current;
      dfs(next,current);
      //ノードnextの探索が終了した直後の処理
      lowest[current]=min(lowest[current],lowest[next]);
    }else if(next!=prev){
      //エッジcurrent->nextがBack-edgeの場合の処理
      lowest[current]=min(lowest[current],prenum[next]);
    }
  }
  //ノードcurrentの探索が終了した直後の処理
}
void art_points(){
  for(int i=0;i<N;i++) visited[i]=false;
  timer=1;
  //lowestの計算
  dfs(0,-1); //0==root
  set<int>ap;
  int np=0;
  for(int i=1;i<N;i++){
    int p=parent[i];
    if(p==0) np++;
    else if(prenum[p]<=lowest[i]) ap.insert(p);
  }
  if(np>1)ap.insert(0);
  for(set<int>::iterator it=ap.begin();it!=ap.end();it++)
    cout<<*it<<endl;
}
int main(){
  int m;
  cin>>N>>m;
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  art_points();
  return(0);
}



Measured memory_bytes: 6896
#include <stdio.h>

int main() {
  int i,n,j,k;
  int b,f,r,v;
  int p[4][3][10]={0};



  scanf("%d",&n);

  for(i =0; i <n; i++) {
    scanf("%d %d %d %d",&b,&f,&r,&v);
    p[b-1][f-1][r-1] += v;
  }

  for(k=0; k<4; k++) {
    for(j=0; j<3; j++) {
      for(i=0; i<10;i++) {
	printf(" %d",p[k][j][i]);
      }
      printf("\n");
    }
    if(k == 3){
      break;
    }
    printf("####################\n");

  }
  return 0;
}

Measured memory_bytes: 612
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def main():
    N, M = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = A.copy()

    while not any(b % 2 for b in B):
        B = [b // 2 for b in B]

    if not all(b % 2 for b in B):
        print(0)
        return

    semi_lcm = 1
    for a in A:
        semi_lcm = lcm(semi_lcm, a // 2)

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 16804
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    REP(i, n) {
        int x;
        cin >> x;
        if (x != i+1) cnt++;
    }

    if (cnt == 0 || cnt == 2) {
        std::cout << "YES" << '\n';
    } else {
        std::cout << "NO" << '\n';
    }

    return 0;
}


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

int main()
{
    //freopen("in.txt","r",stdin);
    ll N,x,y,sum;
    cin >> N;
    for(ll i=(int)(sqrt(N));i>1;i--){
        if(N%i==0){
            x = i;
            y = N/i;
            sum = x + y - 2;
            cout << sum << endl;
            return 0;
        }
    }
    cout << N-1 << endl;//primes
}


Measured memory_bytes: 256
MOD = 10 **9 + 7
INF = 10 ** 10
def main():
    H,W = map(int,input().split())
    grid = [list(input()) for _ in range(H)]
    for i in range(H - 1,-1,-1):
        flag = True
        for j in range(W):
            if grid[i][j] == '#':
                flag = False
                break
        if flag:
            grid = grid[:i] + grid[i + 1:]
            H -= 1

    for i in range(W - 1,-1,-1):
        flag = True
        for j in range(H):
            if grid[j][i] == '#':
                flag = False
                break
        if flag:
            for j in range(H):
                grid[j] = grid[j][:i] + grid[j][i + 1:]
    for i in range(H):
        print(''.join(grid[i]))
if __name__ == '__main__':
    main()

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

int insertionSort(int a[], int n, int g){
  int cnt = 0;
  for(int i=g; i < n; i++){
    int key = a[i];
    int j = i-g;
    while (j >= 0 && a[j] > key){
      a[j+g] = a[j];
      j -= g;
      cnt++;
    }
    a[j+g] = key;
  }
  return cnt;
}


void shellSort(int a[], int n){
  int count= 0;
  int m;
  int *G;
  G = new int[n];
  int h = 1;
  int j = 0;
  G[0] = 1;
  while(h < n){
    G[j++] = h;
    h = h * 3 + 1;
  }
  if(h == 1) m = 1;
  else m = j;
  cout << m << endl;
  cout << G[m-1];

  for(int i = m-2; i >= 0 ; i--){
    cout << " " << G[i];
  }
  cout << endl;
  for(int i = 0; i < m; i++){
    count += insertionSort(a, n, G[m-1-i]);
  }
  cout << count << endl;
  for(int i = 0; i < n; i++){
    cout << a[i] << endl;
  }
  return ;
}

int main(){
  int n;
  int a[1000000];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  shellSort(a, n);
  return 0;
}

Measured memory_bytes: 6988
import sys

while True:
	a, op, b = sys.stdin.readline().split( " " )
	if "?" == op:
		break
	a, b = int( a ), int( b )
	if "+" == op:
		print( "{:d}".format( a+b ) )
	elif "-" == op:
		print( "{:d}".format( a-b ) )
	elif "*" == op:
		print( "{:d}".format( a*b ) )
	elif "/" == op:
		print( "{:d}".format( a//b ) )

Measured memory_bytes: 4224
#define mod 1000000007
#define PI 3.14159265358979323846
#define inf 100000000000000000
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<
#define forn(i, n) for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;

map< ii ,int > mp;
vector<int >v[5005];
signed main() {
    SPEED;
  //	freopen("test.txt","r",stdin);
    int n;cin>>n;
    int a[n],b[n],c[n];

    forn(i,n)cin>>a[i];
    forn(i,n)cin>>b[i];
    forn(i,n)cin>>c[i];


    ll ans = 0;

    ans += b[a[0] - 1];
    for(int i=1;i<n;i++)
    {
    	ans += b[a[i] - 1];
    	//cout<<ans<<endl;
    	if(a[i] == a[i-1] + 1)ans+=c[a[i-1] - 1]; 
    }
cout<<ans;



}	
 
 

Measured memory_bytes: 384
import sys
import heapq

input = sys.stdin.readline


def solve(N, M, A):
    A = [-a for a in A]
    heapq.heapify(A)
    for _ in range(M):
        max_a = heapq.heappop(A)
        max_a /= 2
        heapq.heappush(A, max_a)
    result = 0
    for a in A:
        result += int(-a)
    return result


if __name__ == '__main__':
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    answer = solve(N, M, A)
    print(answer)


Measured memory_bytes: 14204
#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++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    string s = to_string(n);

    int sn = 0;
    REP(i, s.size())
    {
        sn += s[i] - '0';
    }

    if(n % sn == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
signed main(){
    int x,y;
    cin>>x>>y;
    int ans=1;
    while(x*2<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 764
package main

import (
  "fmt"
)

func main() {
  var n int 
  fmt.Scan(&n)
  res := make(map[string]bool)
  for i := 0; i < n; i++ {
    var s string 
    fmt.Scan(&s)
    res[s] = true
  }
  ans := "Three"
  if len(res) == 4 {
    ans = "Four"
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
//20/07/2019
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_freopen  freopen("in.txt", "r", stdin);
#define out_freopen freopen("out.txt", "w", stdout);




int main(){
    ll n,d;

    cin>>n>>d;

    d=2*d+1;

    ll ans=n/d;

    if(n%d>0)
        ans++;

    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a1,a2,a3;
	scan(a1>>a2>>a3);
	if(a1+a2+a3>=22) prin("bust");
	else prin("win");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
using PPI = pair<P, int>;
//ll const mod=998244353;
ll const mod = 1e9 + 7;
const ll MAX = 300000;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vd = vector<double>;
using vs = vector<string>;
using vp = vector<P>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvd = vector<vector<double>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
using vvb = vector<vector<bool>>;
template <typename T>
bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }


//////////////////////////////////////



int main() {
    int n, m;
    cin >> n >> m;
    vi a(m), c(m);
    rep(i, m) {
        int b;
        cin >> a[i] >> b;
        rep(j, b) {
            int t;
            cin >> t;
            t--;
            c[i] += (1 << t);
        }
    }
    vvi dp(1 << n, vi(m + 1, INF));
    dp[0][0] = 0;
    rep(i, 1 << n) {
        rep(j, m) {
            chmin(dp[i | c[j]][j + 1], dp[i][j] + a[j]);
            chmin(dp[i][j + 1], dp[i][j]);
        }
    }
    int ans = dp[(1 << n) - 1][m];
    if (ans == INF)cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp11
{
    class Class40
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = I[0];
            var K = I[1];
            
            SortedDictionary<long, long> Table = new SortedDictionary<long, long>();
            for(int i = 0; i < N; i++)
            {
                var read = Console.ReadLine().Split().Select(long.Parse).ToArray();
                if (Table.Keys.Contains(read[0]))
                {
                    Table[read[0]] += read[1];
                }
                else
                {
                    Table[read[0]] = read[1];
                }
            }
            long sum = 0;
            foreach(long L in Table.Keys)
            {
                sum += Table[L];
                if (sum >= K)
                {
                    Console.WriteLine(L);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 21288
s = input()

while len(s) >= 5:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        print("NO")
        exit()
        
if len(s) == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include <cstdio>

using namespace std;

int main() {
    int sx, sy, tx, ty;
    scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
    for (int i = 0; i < tx - sx; ++i) printf("R");
    for (int i = 0; i < ty - sy; ++i) printf("U");
    for (int i = 0; i < tx - sx; ++i) printf("L");
    for (int i = 0; i < ty - sy; ++i) printf("D");
    printf("D");
    for (int i = 0; i <= tx - sx; ++i) printf("R");
    for (int i = 0; i <= ty - sy; ++i) printf("U");
    printf("LU");
    for (int i = 0; i <= tx - sx; ++i) printf("L");
    for (int i = 0; i <= ty - sy; ++i) printf("D");
    printf("R\n");
    return 0;
}


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

using namespace std;

int main()
{
    int n,ans,tem;
    scanf("%d%d",&n,&ans);
    for(int i=1;i<n;i++)
    {
        scanf("%d",&tem);
        ans=__gcd(ans,tem);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int hon = N % 10;

	if (hon == 0 || hon == 1 || hon == 6 || hon == 8)
	{
		cout << "pon" << endl;
	}
	else if (hon == 3)
	{
		cout << "bon" << endl;
	}
	else
	{
		cout << "hon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
def main(str)
  s, t = str.split("\n")
  s.length.times.count { |i| s[i] != t[i] }
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(4, main("cupofcoffee
cupofhottea"))
  end
end




Measured memory_bytes: 15224
package main

// https://atcoder.jp/contests/abc076/tasks/abc076_b
// https://img.atcoder.jp/abc076/editorial.pdf

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	c := 1
	for i := 0; i < n; i++ {
		// x+k, 2*x のうち小さい方を常に選ぶ
		c = min(c*2, c+k)
	}
	fmt.Println(c)
}

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


Measured memory_bytes: 512
N,K = list(map(int,input().strip().split()))
ans = int(10e10)

hlist = [int(input()) for i in range(N)] 

hlist.sort()

for i in range(N-K+1):
    low = hlist[i]
    high = hlist[i+K-1]
    ans = min(ans,(high-low))

print(ans)

Measured memory_bytes: 7488
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) {
		a_powered *= a;
	}
	return a_powered;
}

int main(int argc, char *argv[]){
    int AB, BC;
    cin >> AB >> BC;

    cout << AB * BC / 2;
}


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

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

	for(int i=0; i<s.length(); i++){
		s[i] = 'A' + ((s[i]-'A'+n)%26);
	}

	cout << s << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    set<char> s;
    rep(i,3){
        char ch; cin>>ch;
        s.insert(ch);
    }
    if(s.size()==3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
def main():
    n = input()
    len_n = len(n)
    semi_753_list = ["3", "5", "7"]
    cnt = 1
    while cnt < len_n + 1:
        addition_list_3 = [str753 + "3" for str753 in semi_753_list if len(str753) == cnt]
        addition_list_5 = [str753 + "5" for str753 in semi_753_list if len(str753) == cnt]
        addition_list_7 = [str753 + "7" for str753 in semi_753_list if len(str753) == cnt]
        semi_753_list += addition_list_3 + addition_list_5 + addition_list_7
        cnt += 1

    ans = 0
    for semi_753_num in semi_753_list:
        if "3" in semi_753_num and "5" in semi_753_num and "7" in semi_753_num and int(semi_753_num) <= int(n):
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

ll d, l, r, res = 0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> l >> r >> d;
    for(int i = 0; i < 1000; ++i){
        if(d * i >= l && d * i <= r) res++;
    }
    cout << res;
    return 0;
}

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

int main(){
    int sum[1001] = {}, cnt[1001] = {};
    for(int i = 1; i <= 1000; i++)  sum[i] = sum[i-1] + i;

    for(int i = 0; i <= 1000; i++){
        for(int j = i+2; j <= 1000; j++){
            if(sum[j]-sum[i] > 1000)    continue;
            cnt[sum[j]-sum[i]]++;
        }
    }

    int n;
    while(cin >> n, n)  cout << cnt[n] << endl;

    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>

int main(void){
	int n,x,i,j,k,a;

	a=0;
	n=1;
	x=1;

	while(n!=0 || x!=0){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0){
			break;
		}
		for(i=1;i<=n-2;i++){
			for(j=2;j<=n-1;j++){
				for(k=3;k<=n;k++){
					if((i+j+k)==x && i!=j && j!=k && k!=i && i<j && j<k){
						a++;
					}
				}
			}
		}
		printf("%d\n",a);
		a=0;
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 998244353
#define N 100005
int dp[N];
int n,k;
int h[N];
int solve(int i)
{
    if(i==n-1) return 0;
    if(dp[i]!=-1) return dp[i];
    int ans[k+5];
    int res=INT_MAX;
    for(int j=1;j<=k;j++)
    {
        ans[j]=INT_MAX;
        if(i+j<=n-1) ans[j]=abs(h[i]-h[i+j])+solve(i+j);
        res=min(res,ans[j]);
    }
    return dp[i]=res;

}
int main()
{
    fastio;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>h[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(0);
}



Measured memory_bytes: 52608
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        k:i64,x:i64
    }

    let l = x - (k - 1);
    let r = x + (k - 1);
    for i in l..r + 1 {
        print!("{} ", i);
    }
    println!("");
}


Measured memory_bytes: 4352
N, Q = map(int, input().strip().split())

A = []
D = {}
for l in range(N):
    n, t = input().strip().split()
    A.append([n, int(t)])

T = 0
while A:
    l = A.pop(0)
    if l[1] > Q:
        l[1] -= Q
        T += Q
        A.append(l)
    else:
        T += l[1]
        print(l[0], T)

Measured memory_bytes: 15844
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#define ll long long
using namespace std;
int pos(int n)
{
    if(n<0)
        return 0;
    else
        return n;
}
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<100<<" "<<100<<endl;
    int s[102][102]={0};//0为黑1为白.
    for(int i=51;i<=100;i++){
        for(int j=1;j<=100;j++){
            s[i][j]=1;
        }
    }
    a--,b--;
    for(int i=1;i<=50;i+=2){
        int j=1;
        for( ;j<=100;j+=2){
            if(a>0){
                s[i][j]=1;
                a--;
            }else{
                break;
            }
        }
    }
    for(int i=100;i>=51;i-=2){
        for(int j=1;j<=100;j+=2){
            if(b>0){
                s[i][j]=0;
                b--;
            }else{
                break;
            }
        }
    }
    for(int i=1;i<=100;i++){
        int j=1;
        for ( ;j<=100;j++){
            if(s[i][j]==1)
                cout<<".";
            else
                cout<<"#";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
from operator import itemgetter
from collections import Counter
N,M = map(int,input().split())
ab = {tuple(map(int,input().split())) for _ in range(M)}
if M == 1:
    print('IMPOSSIBLE')
    exit()
ab = [i[1] if i[0] == 1 else i[0] for i in ab if i[0] == 1 or i[1] == N]
c = Counter(ab)
if c.most_common(1)[0][1] == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 51684
import sys

N = int(sys.stdin.readline().strip())
ans = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for _ in range(N):
    s = sys.stdin.readline().strip()
    ans[s] += 1

for key, value in ans.items():
    print(key + " x " + str(value))

Measured memory_bytes: 9188
n = int(input())
a = list(map(int, input().split()))

x = 0
y = 0
z = 0
for i in a:
  if i%4 == 0: x += 1
  elif i%2 == 0: y += 1
  else: z += 1

if y%2+z-1 <= x: print("Yes")
else: print("No")

Measured memory_bytes: 20012
#include <stdio.h>

int main(void)
{
    int N;
 
    scanf("%d", &N);

    if (1<=N && N<= 999)
    {
        printf("ABC");
    }
    else if (1000<= N && N<=1998)
    {
        printf("ABD");
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
const int MOD = 1000000007;


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    ll n; cin >> n;
    vector<ll> so(1e3);
    for(ll i = 1;i <= n;i++){
        ll I = i;
        for(ll j=2;j*j<=i;j++){
            while(I % j == 0){
                so[j]++;
                I /= j;
            }
            so[j] %= MOD;
        }
        if(I != 1) so[I]++;
    }
    ll ans = 1;
    for(int i=0;i<1e3;i++){
        if(so[i] > 0){
            ans *= (so[i]+1);
            ans %= MOD;
    }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int W = Integer.parseInt(arr[0]);
        int H = Integer.parseInt(arr[1]);
        String[] arr2 = br.readLine().split(" ");
        int w = Integer.parseInt(arr2[0]);
        int h = Integer.parseInt(arr2[1]);
        out.println((H - h) * ( W - w));
        out.close();
    }
}


Measured memory_bytes: 21332
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    def modinv(a, mod):
        b,u,v = mod,1,0
        while b:
            t=a//b
            a-=t*b
            a,b=b,a
            u-=t*v
            u,v=v,u
        u%=mod
        if u < 0:
            u+=mod
        return u
    
    
    N=int(input())
    A=list(map(int,input().split()))
    l=A[0]
    for x in A[1:]:
        l=l*x//gcd(l,x)
    l%=MOD
    ans=0
    for x in A:
        ans+=l*modinv(x,MOD)
        ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69092
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		char[] n=sc.next().toCharArray();
		boolean flag=true;
		int s=0;
		int t=n.length-1;
		while(t-s>0) {
			flag&=n[s]==n[t];
			++s;
			--t;
		}
		System.out.println(flag?"Yes":"No");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
	int a[31];
	int w,n,i,an,bn,nazo;
	scanf("%d",&w);
	for(i=1;i<=w;i++)a[i]=i;
	scanf("%d",&n);
	while(n--){
	scanf("%d,%d",&an,&bn);
	nazo=a[an];a[an]=a[bn];a[bn]=nazo;
	}
	i=0;
	while(i++!=w)printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 596
<?php

fscanf(STDIN, "%d", $n);
for ($i = 0; $i < 3; $i++) {
    fscanf(STDIN, "%s", $a[$i]);
}
$res = 0;
for ($j = 0; $j < $n; $j++) {
    $res += cmp_at_pos_trio($a[0], $a[1], $a[2], $j);
}

echo $res;

function cmp_at_pos($a, $b, $pos)
{
    return substr($a, $pos, 1) == substr($b, $pos, 1) ? 0 : 1;
}

function cmp_at_pos_trio($a, $b, $c, $pos)
{
    return max(0, cmp_at_pos($a, $b, $pos) + cmp_at_pos($a, $c, $pos) + cmp_at_pos($c, $b, $pos) - 1);
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;

lli c[60][60];

int main() {
    int n, p, a[2] = {0, 0};
    scanf("%d%d", &n, &p);
    int i;
    for (i=0; i<n; ++i) {
        int t;
        scanf("%d", &t);
        a[t & 1]++;
    }
    c[0][0] = 1;
    for (i=1; i<60; ++i) {
        int j;
        c[i][0] = 1;
        for (j=1; j<=i; ++j) {
            c[i][j] = c[i-1][j] + c[i-1][j-1];
        }
    }
    lli s = 0;
    for (i=p; i<=n; i+=2) {
        s += (1LL << a[0]) * c[a[1]][i];
    }
    printf("%lld\n", s);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 200000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int n,m;
int mintime[100][100],mincost[100][100];
void warshall_floyd()
{
	for(int k=0;k<m;k++)
	{
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<m;j++)
			{
				mincost[i][j]=min(mincost[i][j],mincost[i][k]+mincost[k][j]);
				mintime[i][j]=min(mintime[i][j],mintime[i][k]+mintime[k][j]);
			}
		}
	}
	return;
}
int main()
{
	while(1)
	{
		cin >> n >> m;
		if(n==0&&m==0)break;
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(i==j)
				{
					mintime[i][j]=0;
					mincost[i][j]=0;
				}
				else
				{
					mintime[i][j]=INF;
					mincost[i][j]=INF;
				}
			}
		}
		for(int i=0;i<n;i++)
		{
			int a,b,cost,time;
			cin >> a >> b >> cost >> time;
			mincost[a-1][b-1]=cost;
			mincost[b-1][a-1]=cost;
			mintime[a-1][b-1]=time;
			mintime[b-1][a-1]=time;
		}
		warshall_floyd();
		/*
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<m;j++)
			{
				cout << mincost[i][j] << ' ';
			}
			cout << endl;
		}
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<m;j++)
			{
				cout << mintime[i][j] << ' ';
			}
			cout << endl;
		}
		*/
		int k1;
		cin >> k1;
		for(int i=0;i<k1;i++)
		{
			int p,q,r;
			cin >> p >> q >> r;
			if(r==0)
			{
				cout << mincost[p-1][q-1] << endl;
			}
			else
			{
				cout << mintime[p-1][q-1] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

string a;
stack<char> s;

int main(void) {
  cin >> a;
  int n = (int)a.size();
  REP(i, n) {
    if (a[i] == 'T') {
      if (!s.empty() && s.top() == 'S')
	s.pop();
      else
	s.push(a[i]);
    } else {
      s.push(a[i]);
    }
  }

  int sol = 0;
  for (; !s.empty(); s.pop(), ++sol);

  printf("%d\n",sol);

  return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_div(ll n){
	vector<ll> ret;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	return ret;

}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();

	int sum=0;
	for(int i=1;i<=N;i++){
		auto D=enum_div(i);
		if(i%2 && D.size()==8) sum++;
	}
	out(sum);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>

int main()
{
	unsigned long long N;
	std::cin >> N;

	std::vector<unsigned long long> X(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i];
	}



	const long long a = N;
	long long b = 0;
	long long c = 0;
	for (auto x : X) {
		b += x;
		c += x * x;
	}
	b *= -2;

	const unsigned long long P = -1.0 * (double)b / (2.0 * (double)a) + 0.5;

	//const unsigned long long anss = (-1 * b * b + 4 * a * c) / (4 * a);
	unsigned long long ans = 0;
	for (auto x : X) {
		ans += (P - x) * (P - x);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

string s[100];
int h, w;

int main(){
	cin>>h>>w;
	rep(i, h) cin>>s[i];
	rep(i, h) rep(j, w){
		if(s[i][j]=='#') continue;
		int cnt = 0;
		rep(i2, 3) rep(j2, 3){
			int ii = i+i2-1, jj = j+j2-1;
			if(ii<0||ii>=h||jj<0||jj>=w) continue;
			cnt += s[ii][jj]=='#';
		}
		s[i][j] = '0'+cnt;
	}
	rep(i, h) cout<<s[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	ll n,a,b;
	cin>>n>>a;
	b=a;
	for(int i=1;i<100000;i++)
	{
		if(n<b)
		{
			cout<<i<<endl;
			return 0;
		}
		else if(n==b)
		{
			cout<<i+1<<endl;
			return 0;
		}
		else b=b*a;
	}
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    int a,b,c;
    cin>>a>>b;

    if((a>=1&&a<=9) && (b>=1&&b<=9))
    {
        c=a*b;
        cout<<c<<endl;
    }
    else
    {
        cout<<"-1"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a,b;
int main() {
	cin>>a>>b;
	if((a == 1) && (b>1)) {
		cout<<"Alice"<<endl;
	} else if ((a>1) && (b==1)) {
		cout<<"Bob"<<endl;
	} else if((a == 1) && (b==1)) {
		cout<<"Draw"<<endl;
	} else if((a > 1) && (b>1) && (a>b)) {
		cout<<"Alice"<<endl;
	} else if((a>1) && (b>1) && (a<b)) {
		cout<<"Bob"<<endl;
	} else if((a>1) && (b>1) && (a == b)) {
		cout<<"Draw"<<endl;
	}
}

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

typedef long long ll;
vector<ll>v[MAX];

int main()
{

    ll a,b,i,l,r,q,n,m,j,pos,res,cal;
    vector<ll>v1;
    v1.push_back(4);
    v1.push_back(4);
    v1.push_back(5);
    v1.push_back(6);
    pos=lower_bound(v1.begin(),v1.end(),6)-v1.begin();
    //cout << pos << "\n";
    scanf("%lld%lld%lld",&n,&m,&q);
    for(i=0; i<m; i++)
    {
        scanf("%lld%lld",&l,&r);
        v[r].push_back(l);
    }
    for(i=1; i<=n; i++)
    {
        if(v[i].size()>0)
        {
            sort(v[i].begin(),v[i].end());
        }
    }
    for(i=0; i<q; i++)
    {
        scanf("%lld%lld",&l,&r);
        res=0;
        for(j=l; j<=r; j++)
        {
            if(v[j].size()==0)continue;
            pos=lower_bound(v[j].begin(),v[j].end(),l)-v[j].begin();
            cal=(v[j].size()-pos);
            res+=cal;
        }
        printf("%lld\n",res);
    }



    return 0;
}




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

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a >= 3200) cout << s;
    else cout << "red";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a, b, c;
int main()
{
	scanf("%d%d%d", &a, &b, &c);
	if(b >= a && b >= c)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

  int N, H; cin >> N >> H;
  vector<int> B(N);
  int a, b;
  int M = 0;
  rep(i, N) {
    cin >> a >> b;
    B[i] = b;
    M = max(M, a);
  }
  vector<int> C(1, M);
  rep(i, N) {
    if (B[i] > M) {
      C.push_back(B[i]);
    }
  }
  sort(C.begin(), C.end());
  int j=C.size() - 1;
  int ans = 0;
  while (H > 0) {
    if (j) {
      H -= C[j];
      j--;
      ans++;
    }
    else {
      ans += (H-1) / M + 1;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

typedef long long int64;

int main(void) {
  int64 n;
  std::cin >> n;
  std::vector<std::pair<int64, int64> > ps;
  int64 sq_n = std::sqrt(n);
  for (int64 i = 1; i <= sq_n; i++) {
    if (n % i == 0) {
      std::pair<int64, int64> p(i, n / i);
      ps.push_back(p);
    }
  }

  int64 min = std::numeric_limits<int64>::max();

  for (auto p : ps) {
    int64 val = p.first + p.second - 2;
    min = std::min(min, val);
  }

  std::cout << min << std::endl;

  return 0;
}


Measured memory_bytes: 384