akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y)
{
    return x / gcd(x, y) * y;
}

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

    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    bool f = true;
    h[0]--;
    for (int i = 1; i < n; i++)
    {
        if (h[i - 1] > h[i])
        {
            f = false;
            break;
        }
        if (h[i - 1] == h[i])
            continue;
        h[i]--;
    }
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

ll dp[110][5][2];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  ll K;
  cin >> K;
  ll n = SZ(s);
  dp[0][0][1] = 1;
  rep(i, n){
    rep(j, 10){
      if(j == s[i]-'0'){
        rep(k, 4){
          if(j == 0) dp[i+1][k][1] += dp[i][k][1];
          else dp[i+1][k+1][1] += dp[i][k][1];
        }
      }
      if(j < s[i]-'0'){
        rep(k, 4){
          if(j == 0) dp[i+1][k][0] += dp[i][k][1];
          else dp[i+1][k+1][0] += dp[i][k][1];
        }
      }
      rep(k, 4){
        if(j == 0) dp[i+1][k][0] += dp[i][k][0];
        else dp[i+1][k+1][0] += dp[i][k][0];
      }
    }
  }
  print(dp[n][K][0]+dp[n][K][1]);
}


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

int main(){
    ll N; cin >> N;
    ll ans = 0;
    ll b=0, a=0;
    ll cnt=0;
    vector<string> V(N);
    for(int i = 0; i < N; i++){
        string S; cin >> S;
        for(int j = 0; j < S.size()-1; j++){
            if(S[j] == 'A' && S[j+1] == 'B') ans++;
        }
        if(S[0] == 'B') b++;
        if(S[(int)S.size()-1] == 'A') a++;
        if(S[0] == 'B' && S[(int)S.size()-1] == 'A') cnt++;

    }
    if( cnt != 0 && cnt == a && cnt == b) cout << ans + min(a, b) -1 << endl;
    else if(cnt == 1 && a == 1 && b == 1) cout << 0 << endl;
    else if(cnt == N) cout << ans+min(a, b)-1 << endl;
    else cout << ans+min(a, b) << endl;

}

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

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

    int n, m;
    cin >> n >> m;

    int bucket[m] = {0};

    rep(i, n){
        int k;
        cin >> k;

        rep(j, k){
            int a;
            cin >> a;
            ++bucket[a-1];
        }
    }

    int res = 0;
    rep(i, m){
        if(bucket[i]==n) ++res;
    }
    cout << res << endl;
}

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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
bool vis[N];
ll f[N];

int main() {
	int n = read(), m = read();
	while (m--) {
		int x = read();
		vis[x] = 1;
	}
	f[0] = 1;
	if (!vis[1]) f[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (vis[i]) continue;
		f[i] = (f[i - 1] + f[i - 2]) % mod;
	}
	printf("%lld\n", f[n]);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n;
int b[112];
int sum;
int p;

int main(){
	cin >> n;
	
	REP(i,n-1) cin >> b[i];
	
	sum = b[0];
	
	FOR(i,1,n-1){
		sum += min(b[i], b[i-1]);
	}
	
	sum += b[n-2];
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
X,Y = map(int,input().split())
if X+Y == 2:
    print(1000000)
elif X+Y == 3:
    print(500000)
elif X+Y == 4:
    print(400000)
elif X == 3 or Y == 3:
    if X == 2 or Y == 2:
        print(300000)
    elif X == 3 and Y == 3:
        print(200000)
    else:
        print(100000)
elif X == 2 or Y ==2:
    print(200000)
elif X == 1 or Y == 1:
    print(300000)
else:
    print(0)

Measured memory_bytes: 67180
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
   
int L[MAX/2+2], R[MAX/2+2];
int count = 0;
   
void merge(int [], int, int, int);
void mergeSort(int [], int, int);
   
int main(){
  int A[MAX], n, i;
   
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  mergeSort(A, 0, n);
  for(i = 0;i < n;i++){
    if(i != 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}
   
void merge(int A[], int left, int mid, int right){
  int n1, n2, i, j, k;
   
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++){
    L[i] = A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid+i];
  }
  L[n1] = R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else A[k] = R[j++];
  }
}
   
void mergeSort(int A[], int left, int right){
  int mid;
   
  if(left+1 < right){
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

int tt;

void dfs(vector<int> &visited, vector<set<int>> &adj, int i, int n) {
	visited[i] = n;
	for (auto v: adj[i])
	{
		if (!visited[v]) {
			tt++;
			dfs(visited, adj, v, n);
		}
	}
}

int main(int argc, char const *argv[])
{
	int V, E;
	cin >> V >> E;
	vector<set<int>> adj(V);
	int u, v;
	for (int i = 0; i < E; ++i)
	{
		cin >> u >> v;
		u--;
		v--;
		adj[u].insert(v);
		adj[v].insert(u);
	}
	int ans = 0;
	int count = 0;
	vector<int> visited(V, 0);
	for (int i = 0; i < V; ++i)
	{
		tt=0;
		if (!visited[i]) {
			count++;
			tt++;
			dfs(visited, adj, i, count);
		}
		ans = max(ans, tt);
	}
	cout << ans << "\n";
}

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

const string v="Vacant";

int main(){
    int n;
    cin>>n;
    cout<<0<<endl;
    string msg0;
    cin>>msg0;
    if(msg0==v) return 0;
    cout<<n/2<<endl;
    string msg1;
    cin>>msg1;
    if(msg1==v) return 0;
    string lstr,rstr;
    int lb,ub;
    if((n/2)%2==0 && msg0!=msg1 || (n/2)%2==1 && msg1==msg0){
        lb=0,ub=n/2;
        lstr=msg0;
    }
    else{
        lb=n/2,ub=n;
        lstr=msg1;
    }
    while(ub-lb>0){
        int mid=(lb+ub)/2;
        cout<<mid<<endl;
        string msg;
        cin>>msg;
        if(msg==v) return 0;
        if((mid-lb)%2==0 && msg==lstr || (mid-lb)%2==1 && msg!=lstr){
            lb=mid;
            lstr=msg;
        }
        else{
            ub=mid;
        }
    }
    
    return 1;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h,w,m;
    cin >> h >> w >> m;
    vector<int> hs(h), ws(w);
    set<pint> s;
    rep(i, m){
        int r,c;
        cin >> r >> c;
        --r; --c;
        hs[r]++;
        ws[c]++;
        s.emplace(r, c);
    }
    int mh = 0, mw = 0;
    rep(i, h) chmax(mh, hs[i]);
    rep(j, w) chmax(mw, ws[j]);
    vector<int> is, js;
    rep(i, h) if(mh == hs[i]) is.push_back(i);
    rep(j, w) if(mw == ws[j]) js.push_back(j);
    int ans = mh + mw;
    for(int i : is) for (int j : js){
        if(s.count(pint(i, j))) continue;
        print(ans);
        return 0;
    }
    print(ans - 1);



}


Measured memory_bytes: 23836
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100000010;

int main(){
    int n;
    scanf("%d", &n);
    int ans = 0;
    rep(i, n){
        int a;
        scanf("%d", &a);
        ans += __builtin_ctz(a);
    }
    printf("%d\n", ans);
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	int n, l;
	std::cin >> n >> l;
	vector<string> strs(n);
	rep(i, n) std::cin >> strs[i];
	sort(rng(strs));
	rep(i, n) {
		std::cout << strs[i];
	}
	std::cout << "\n";
}


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

using namespace std;

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

    int ans = 0;

    ans += (x/500) * 1000;
    x = x - ((x/500) * 500);
    ans += (x/5) * 5;

    cout << ans <<'\n';

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
struct interval
{
	int l,r;
	bool operator < (const interval &i) const
	{
		return r<i.r;
	}
}a[200010];
int n,m;
int main()
{
	int now,ans;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+m+1);
	now=a[1].r;
	ans=1;
	for (int i=2;i<=m;i++)
		if (a[i].l>=now)
		{
			ans++;
			now=a[i].r;
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
def nyu():
    H,W = map(int,input().split())
    S = [list(map(str,input())) for _ in range(H)]

    return H,W,S

def kansu(LH,LW,LS):
    success_flg  = True

    for h in range (LH):
        for w in range(LW):
            if LS[h][w] == '#':
                if h != 0:
                    if LS[h-1][w] == '#':
                        continue
                if h != LH-1:
                    if LS[h+1][w] == '#':
                        continue
                if w != 0:
                    if LS[h][w-1] == '#':
                        continue
                if W != LW-1:
                    if LS[h][w+1] == '#':
                        continue
                success_flg = False
                break
            

    
    if success_flg == True:
        print("Yes")
    else:
        print("No")




H,W,S = nyu()
kansu(H,W,S)

Measured memory_bytes: 3064
N, X = map(int,input().split())
a = [1]
p = [1]
def solve():
    for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    print(getAns(N,X))

def getAns(L,x):
    if L == 0:
        if x <= 0:
            return 0
        else:
            return 1
    elif x <= 1 + a[L-1]:
        return getAns(L-1, x-1)
    else:
        return p[L-1] + 1 + getAns(L-1, x-2-a[L-1])

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
#bfs
def bfs(s,sx,sy,gx,gy):
    from collections import deque
    inf = float("inf")
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    d = [[inf for _ in  range(w)] for _ in  range(h)]
    que = deque()
    que.append([sx,sy])
    d[sx][sy] = 1
    while que:
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] == '.' and d[nx][ny] == inf:
                que.append([nx,ny])
                d[nx][ny] = d[p[0]][p[1]] + 1
    return d[gx][gy]

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]

cnt = 0
for i in s:
    for j in i:
        if j == ".":
            cnt+=1

ans = bfs(s,0,0,h - 1,w - 1)
if ans==float("inf"):
    print(-1)
else:
    print(cnt - ans)


Measured memory_bytes: 40816
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n;
    cin >> n;

    vi p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];

    vi g(n);
    rep(i, n) g[i] = i+1;

    int pn, qn;
    int cnt = 0;
    do {
        cnt++;
        bool f = true;
        rep(i, n) {
            if(g[i] != p[i]) f = false;
        }
        if(f) {
            pn = cnt;
            break;
        }
    } while(next_permutation(ALL(g)));

    SORT(g);
    cnt = 0;
    do {
        cnt++;
        bool f = true;
        rep(i, n) {
            if(g[i] != q[i]) f = false;
        }
        if(f) {
            qn = cnt;
            break;
        }
    } while(next_permutation(ALL(g)));

    cout << abs(pn-qn) << endl;


    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
const int MAX_V = 201;

int t[51][51];
pii edge[3000];
int n, m;
bool use[51];
bool vis[51];
void rec(int s,int p) {

	for (size_t i = 1; i <= n; i++)
	{
		if (edge[p].first == s && edge[p].second == i) continue;
		if (edge[p].second == s && edge[p].first == i) continue;

		if (t[s][i] == 1 && !use[i]) {
			use[i] = true;
			vis[i] = true;
			rec(i, p);
			use[i] = false;
		}
	}
}
void Bridge() {
	cin >> n >> m;
	for (size_t i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		t[a][b] = 1;
		t[b][a] = 1;
		edge[i] = pii(a, b);

	}
	int count = 0;
	use[1] = true;
	for (size_t i = 0; i < m; i++)
	{
		vis[1] = true;
		rec(1, i);
		bool c = false;
		for (size_t j = 1; j <= n; j++)
		{
			if (!vis[j]) {
				c = true;
			}
			vis[j] = false;
		}
		count += c;
	}
	cout << count << endl;
}

int main() {
	Bridge();
	return 0;
}



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

const int N = 1e5 + 10;

int n, m, q;
int a[N];

struct node {
    int sum;
    int len, lazy;
} t[N << 2];

#define lson rt << 1
#define rson rt << 1 | 1

template<class T>inline void read(T &x) {
    x = 0; int f = 0; char ch = getchar();
    for ( ; !isdigit(ch); ch = getchar()) f |= (ch == '-');
    for ( ; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
    x = f ? -x : x;
    return;
}

inline void pushup(int rt) {
    t[rt].sum = t[lson].sum + t[rson].sum;
}

void build(int l, int r, int rt) {
    t[rt].len = r - l + 1;
    if (l == r) {
        t[rt].sum = m;
        return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, lson), build(mid + 1, r, rson);
    pushup(rt);
}

inline void pushdown(int rt) {
    if (t[rt].lazy) {
        t[lson].lazy += t[rt].lazy;
        t[rson].lazy += t[rt].lazy;
        t[lson].sum += t[rt].lazy * t[lson].len;
        t[rson].sum += t[rt].lazy * t[rson].len;
        t[rt].lazy = 0;
    }
}

void update(int L, int R, int c, int l, int r, int rt) {
    if (L <= l && r <= R) {
        t[rt].sum += c * t[rt].len;
        t[rt].lazy += c;
        return;
    }
    pushdown(rt);
    int mid = (l + r) >> 1;
    if (L <= mid) update(L, R, c, l, mid, lson);
    if (R > mid) update(L, R, c, mid + 1, r, rson);
    pushup(rt);
}

int QuerySum(int L, int R, int l, int r, int rt) {
    if (L <= l && r <= R) return t[rt].sum;
    pushdown(rt);
    int mid = (l + r) >> 1, ans = 0;
    if (L <= mid) ans += QuerySum(L, R, l, mid, lson);
    if (R > mid) ans += QuerySum(L, R, mid + 1, r, rson);
    return ans;
}

signed main() {
    read(n), read(m), read(q);
    build(1, n, 1);
    for (int i = 1, opt; i <= q; ++i) {
        read(opt);
        if (opt == n) update(1, n - 1, -1, 1, n, 1);
        else if (opt == 1) update(2, n, -1, 1, n, 1);
        else update(1, opt - 1, -1, 1, n, 1), update(opt + 1, n, -1, 1, n, 1);
    }
    for (int i = 1; i <= n; ++i) if (QuerySum(i, i, 1, n, 1) <= 0) puts("No");
        else puts("Yes");
    return 0;
}

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

int main()
{
  long long n;
  cin >> n;
  long long res = LLONG_MAX;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i != 0) {
      continue;
    }
    res = min(res, i + n / i - 2);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
n, x, y = map(int,input().split())

cnt = [0] * (n - 1)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        temp1 = j - i
        temp2 = abs(i - x) + abs(j - y) + 1
        dis = min(temp1, temp2)
        cnt[dis - 1] += 1

print(*cnt, sep='\n')

Measured memory_bytes: 9296
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	
	ll pow5(ll i) {
		return i * i * i * i * i;
	}
	void solve() {
		IOS;
		ll x;
		cin >> x;
		map<ll,ll> st;
		ll m = 1e11;
		for (ll i = 0; pow5(i) < m; ++i) {
			//st.insert(pow5(i));
			//st.insert(-pow5(i));
			st[pow5(i)] = i;
			st[pow5(-i)] = -i;
		}
		P res;
		for (auto v : st) {
			ll tmp = v.first - x;
			auto itr = st.find(tmp);
			if (itr != st.end()) {
				res.first = v.second;
				res.second = (*itr).second;
			}
		}
 		put(res.first, res.second);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


Measured memory_bytes: 3676
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, m; cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    int check = (sum + 4 * m - 1) / (4 * m);
    int cnt = 0;
    rep(i, n) {
        if(a[i] >= check) ++ cnt;
    }
    if(cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 2010;
long long mod = 1e9+7;
long long cache[N];
long long s;

long long dp(long long num)
{
    if(num > s)
        return 0;
    if(num == s)
        return 1;

    long long &ans = cache[num];
    if(ans != -1)
        return ans;

    ans = 0;
    for(long long nnum = 3; nnum<=s; nnum++)
    {
        if(nnum + num <= s)
            ans =(ans + dp(num + nnum))%mod;
        else
            break;
    }

    return ans%mod;
}

int main()
{  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>s;
    memset(cache, -1, sizeof(cache));

    long long ans = dp(0);
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3652
n = int(input())
vals = list(map(int, input().split()))
dp = [0] * n

dp[0] = 0 
dp[1] = abs(vals[0] - vals[1])

for i in range(2,n):
    dp[i] = min( dp[i-1] + abs(vals[i] - vals[i-1]), \
            dp[i-2] + abs(vals[i] - vals[i-2]))

print(dp[n-1])


Measured memory_bytes: 13980
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let v: Vec<u32> = read_vec();
    let x = v[0];
    let y = v[1];
    let g1: Vec<u32> = vec![1, 3, 5, 7, 8, 10, 12];
    let g2: Vec<u32> = vec![4, 6, 9, 11];
    let g3: Vec<u32> = vec![2];
    if g1.contains(&x) && g1.contains(&y)
        || g2.contains(&x) && g2.contains(&y)
        || g3.contains(&x) && g3.contains(&y)
    {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define LL long long
#define pow10 sndaslkknsda
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
int X[3];
void add(int &a , int b)
{
	a = a + b < mod ? a + b : a + b - mod;
}
bool good(int mask)
{
	int ptr = 2;
	int start = 16;
	for(int i = 16; i >= 0; i--)
	{
		if((mask & (1 << i)) && (start - i + 1) == X[ptr])
		{
			ptr--;
			if(ptr == -1)	
				return true;
			start = i - 1;
		}
	}
	return false;
}
int n;
int Good[1 << 17];
int dpT[1 << 17][41][2];
int dp(int mask , int N , int p)
{
	if(N == n)
		return p;
	if(dpT[mask][N][p] != -1)
		return dpT[mask][N][p];
	int ans = 0;
	for(int digit = 1; digit <= 10; digit++)
	{
		int Mask = mask;
		Mask >>= digit;
		Mask |= 1 << (17 - digit);
		add(ans , dp(Mask , N + 1 , p | Good[Mask]));
	}
	return dpT[mask][N][p] = ans;
}
int main()
{
	memset(dpT , -1 , sizeof dpT);
	cin >> n >> X[0] >> X[1] >> X[2];
	for(int i = 0; i < (1 << 17); i++)
		Good[i] = good(i);
	cout << dp(0 , 0 , 0);
	
	
	return 0;
}


Measured memory_bytes: 42752
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    vector<int> v(5);
    for(int i=0; 5>i; i++){
        cin >> v[i];
        if(v[i] ==0){
            cout << i + 1 << endl;
        }
    }
}






Measured memory_bytes: 3572
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(void)
{
	int a, b,s;
	cin >> a >> b;
	s = a + b;
	if (a % 3 == 0 || b % 3 == 0 || s % 3 == 0)
	{
		cout << "Possible";
	}
	else
	{
		cout << "Impossible";
	}
	return 0;
}

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

typedef long long ll;

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

    int a,b;
    cin >> a >> b;
    if((a*b)%2==0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

p1 = 2*c * max(x, y)
p2 = a*x + b*y
p3 = 2*c * min(x, y) + a*(x-min(x, y)) + b*(y-min(x, y))

print(min(p1, p2, p3))

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.at(a.length() - 1) == b.at(0) && b.at(b.length() - 1) == c.at(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.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 lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
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() {
  int N;
  string S;
  cin >>N>>S;
  vector<int> vec(N);
  int x=0;
  rep(i,N) {
if(S.at(i)=='I') {
  x++;
  vec.at(i)=x;
}
    else {
      x--;
      vec.at(i)=x;
    }
  }
  
  sort(all(vec));
  cout<<max(0,vec.at(N-1))<< endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next();
		String s2 = scan.next();
		char c1 = s1.charAt(0);
		char c2 = s1.charAt(1);
		char c3 = s1.charAt(2);
		char d1 = s2.charAt(0);
		char d2 = s2.charAt(1);
		char d3 = s2.charAt(2);
		if (c1 == d3 && c2 == d2 && c3 == d1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

int main(){
  string S,ans;
  ans = "Yes";
  cin>>S;
  if(S.size()%2==1)ans = "No";
  else{
    for(int i = 0;i<S.size();i+=2){
      if(S.at(i)!='h'||S.at(i+1)!='i'){
        ans = "No";
        break;
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
# for _ in range(int(input())):
#     arr = list(map(int,input().split()))
n = int(input())
arr = [[400,599],[600,799],[800,999],[1000,1199],[1200,1399],[1400,1599],[1600,1799],[1800,1999]]
arr = arr[-1::-1]
for i in range(len(arr)):
    if n>=arr[i][0] and n<=arr[i][1]:
        print(i+1)
        exit()

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

class Program
{
    static void Main()
    {
        int num = ReadInts()[0];
        var words = new Words[num];

        for (int i = 0; i < words.Length; i++)
        {
            var word = new Words();
            var count = ReadInts()[0];
            for (int j = 0; j < count; j++)
            {
                var datas = ReadInts();
                var mask = (1 << (datas[0] - 1));
                word.HasWord |= mask;
                if (datas[1] != 0) word.Word |= mask;
            }
            words[i] = word;
        }

        var res = Honests(words).Select(p => GetBitStands(p).Count()).Max();

        Console.WriteLine(res);
    }

    static IEnumerable<int> Honests(Words[] words )
    {
        var max = (1 << words.Length);
        for (int i = 0; i < max; i++)
        {
            if (GetBitStands(i).All(p => words[p].IsHonest(i)))
                yield return i;
        }
    }
    static IEnumerable<int> GetBitStands(int val)
    {
        for (int i = 0; val > 0; i++, val >>= 1)
            if ((val & 1) != 0) yield return i;
    }

    struct Words
    {
        public int HasWord { get; set; }
        public int Word { get; set; }

        public bool IsHonest(int v)
        {
            return ((v ^ Word) & HasWord) == 0;
        }
    }

    #region Utils
    static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    #endregion
}


Measured memory_bytes: 17488
s = input()
t = input()

list_s = list(s)
list_s.sort()

list_t = list(t)
list_t.sort(reverse=True)

yes = False
if len(list_s) < len(list_t):
    yes = True

for i in range(len(list_s)):
    if len(list_t)-1 < i:
        break
    if list_s[i] < list_t[i]:
        yes = True
        break
    elif list_s[i] > list_t[i]:
        yes = False
        break

if yes:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;
int main(){
  int n;cin >> n;
  vector<int> p(n),q(n),base(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  rep(i,n)base[i] = i+1;
  int a = 1,b = 1;
  int aans,bans;
  do{
    // rep(i,n) printf("%d ",base[i]);
    // cout << endl;
    // printf("%d %d\n",a,b);
    bool pflag = true;
    bool qflag = true;
    rep(i,n) if(base[i]!=p[i]) pflag = false;
    rep(i,n) if(base[i]!=q[i]) qflag = false;
    if(!pflag) a++;
    else aans = a;
    if(!qflag) b++;
    else bans = b;
  }while(next_permutation(base.begin(),base.end()));
  cout << abs(aans-bans) << endl;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll N;
string S;

int main() {
    cin >> S;
    int s = 0, t = 0;
    REP(i, S.size()) {
        if (S[i] == 'S')s++;

        if (S[i] == 'T') {
            if (s > 0)s--;
            else t++;
        }

    }
    cout << s + t << endl;
    return 0;
}


Measured memory_bytes: 640
using System.Text;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[m];
        var b = new int[m];
        var p1 = 0L;
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            a[i] = int.Parse(line[0]);
            b[i] = int.Parse(line[1]);
            p1 += (a[i] + 1) % b[i];
        }
        var c = getAns(a, b, n, m);
        print(c, p1, n, m);
    }
    static void print(long[] c, long p1, int n, int m)
    {
        var sb = new StringBuilder();
        var w1 = p1 + c[1];
        sb.Append(string.Format("{0}\n", w1));
        for (int i = 2; i <= n; i++)
        {
            c[i] += c[i - 1];
            var w = p1 + c[i] + m * (long)(i - 1);
            sb.Append(string.Format("{0}\n", w));
        }
        Console.Write(sb);
    }
    static long[] getAns(int[] a, int[] b, int n, int m)
    {
        var c = new long[n + 1];
        for (int i = 0; i < m; i++)
        {
            var bi = b[i];
            var p = bi - a[i];
            while (p <= n)
            {
                if (p != 1) c[p] -= bi;
                p += bi;
            }
        }
        return c;
    }
}



Measured memory_bytes: 28516
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A > B) {
		swap(A, B);
	}
	if (B > C) {
		swap(B, C);
	}
	if (A > B) {
		swap(A, B);
	}

	int ans = 0;
	int a = (C - A) / 2;
	A += 2*a;
	ans += a;

	int b = (C - B) / 2;
	B += 2*b;
	ans += b;

	if (A == B && B == C) {

	}
	else if (A == C - 1 && B == C - 1) {
		ans++;
	}
	else if (A == C - 1 || B == C - 1) {
		ans += 2;
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll s[100100];

ll solve() {
    ll res = 0;
    for (int d = 1; d < n; d++) {
        ll v = 0, v_max = 0;
        int l = 0, r = n-1;
        while (r > d) {
            if (l >= r && r % d == 0) break;
            v += s[l] + s[r];
            v_max = max(v_max, v);
            l += d;
            r -= d;
        }
        res = max(res, v_max);
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
}

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

    input();
    cout << solve() << endl;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


int main() {
  int a,b,ans=0;
  cin >> a >> b;
  
  ans += a;
  
  if(a>b)ans--;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    ll ans = 0;
    rep(i, n) {
        rep(j, i) {
            int p = upper_bound(l.begin(), l.begin() + j, l[i] - l[j]) - l.begin();
            ans += j - p;
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256