akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;
/*
vector<ll> G[500005];
vector<P> tree[500010];

//big priority queue
priority_queue <ll> pql;
priority_queue <P> pqp;

//small priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
*/
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj,n,m;
ll a,b,c,d,e,g,h,r,l,num;
ll x[500005],y[500005],z[500005];
bool dame;
char s[500005];
ll dp[500005];

int main(){
    
    cin >> n;  
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	dp[0] = 0;
	dp[1] = abs(x[1] - x[0]);
	for(i=2;i<n;i++){
		dp[i] = min(dp[i-2] + abs(x[i-2] - x[i]),dp[i-1] + abs(x[i-1] - x[i]));
	}
	p(dp[n-1]);
    return 0;
}

Measured memory_bytes: 5120
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
route=["","","",""]
route[0]='U'*dy+'R'*dx
route[1]='D'*dy+'L'*dx
route[2]='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
route[3]='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print("".join(route))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int ct=0;
vector<vector<int> >  adj;
vector<int>  visited;
void dfs(int s)
{
    visited[s]=1;
    ct++;
    for(auto it:adj[s])
    {
        if(!visited[it])
        dfs(it);
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    visited.resize(n+1);
    int maxi=0;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            dfs(i);
            maxi=max(maxi,ct);
            ct=0;
        }
    }
    cout<<maxi<<endl;
    
}

Measured memory_bytes: 21160
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const i64 N = read_item();
	const i64 X = read_item();
	const i64 M = read_item();

	vector<pair<i64, i64>> first_steps(M, (pair<i64,i64>){-1LL, 0LL});

	i64 v = X;
	i64 sum = v;

	for(i64 i = 2; i <= N; i++) {

		v = v * v % M;
		sum += v;

		i64 j = first_steps[v].first;
		i64 s = first_steps[v].second;

		if(j == -1) {
			first_steps[v] = {i, sum};
		} else {
			i64 step_diff = i - j;
			i64 sum_diff = sum - s;
			i64 cycle_count = (N - i) / step_diff;
			i += cycle_count * step_diff;
			sum += cycle_count * sum_diff;
		}
	}

	printf("%lld\n", sum);

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 4848
from sys import stdin

n = int(stdin.readline().rstrip())
h = [int(x) for x in stdin.readline().rstrip().split()]

m = 0
count = 0
for i in range(n):
    if i == n - 1:
        if m < count:
            m = count
    else:
        if h[i] >= h[i + 1]:
            count += 1
        else:
            if m < count:
                m = count
            count = 0

print(m)

Measured memory_bytes: 14252
#include<stdio.h>

int main(){
	int x,y,count,t;
	while(0<=scanf("%d%d",&x,&y)){
		if(x==0 && y==0)break;
		if(x<y){
			count=x;
			x=y;
			y=count;
		}
		count=0;
		while(y!=0){
			x=x%y;
			t=x;
			x=y;
			y=t;
			++count;
		}
		printf("%d %d\n",x,count);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "Sunny")
        cout << "Cloudy" << endl;
    if (s == "Cloudy")
        cout << "Rainy" << endl;
    if (s == "Rainy")
        cout << "Sunny" << endl;
}


Measured memory_bytes: 760
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>

using namespace std;

typedef pair<int, int> P;

const int N = 20000;

int n, data[N];
char d[N];
vector<P> points;
map<P, P> id;
bool ans, used[N];
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

void dfs(int pos, int c){
  if(!ans) return;
  used[pos] = true;
  data[pos] = c;
  P p[2];
  p[0] = p[1] = points[pos];
  if(d[pos] == 'x') p[1].second++;
  else p[1].first++;
  for(int i=0;i<2;i++){
    for(int j=0;j<4;j++){
      P np = P(p[i].first + dy[j], p[i].second + dx[j]);
      if(np == p[1-i]) continue;
      if(id.count(np)){
        if(used[id[np].first]){
          if(i^id[np].second && data[id[np].first] == data[pos]) ans = false;
          if(!(i^id[np].second) && data[id[np].first] != data[pos]) ans = false;
        }
        if(!used[id[np].first]) dfs(id[np].first, i^id[np].second^c);
      }
    }
  }
}

void init(){
  ans = true;
  id.clear();
  points.clear();
  for(int i=0;i<N;i++){
    used[i] = false;
    data[i] = -1;
  }
}

main(){
  while(cin >> n && n){
    init();
    for(int i=0;i<n;i++){
      P in;
      cin >> in.second >> in.first >> d[i];
      points.push_back(in);
      id[in] = P(i, 0);
      if(d[i] == 'x') in.second++;
      else in.first++;
      id[in] = P(i, 1);      
    }
    for(int i=0;i<n;i++) if(!used[i]) dfs(i, 0);
    cout << (ans ? "Yes" : "No") << endl;
  }
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    map<int, int> sticks;
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        sticks[a]++;
    }
    priority_queue<int> q;
    for(auto p : sticks){
        rep(i,min<int>(p.second/2, 2)) q.push(p.first);
    }
    
    if(q.size() <= 1){
        cout << 0 << endl;
    }else{
        int ans = q.top();
        q.pop();
        ans *= q.top();
        cout << ans << endl;
    }
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for (int i = 22; i <= d; i++) {
		if (i % 10 >= 2 && (i % 10)*(i / 10) <= m && (i % 10)*(i / 10) != 0)
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a <= 0 && b >= 0 {
		fmt.Println("Zero")
	} else if a > 0 && b > 0 {
		fmt.Println("Positive")
	} else {
		if ((-a)-(-b)+1)%2 == 0 {
			fmt.Println("Positive")
		} else {
			fmt.Println("Negative")
		}
	}

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll dp[4020][4020];

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

    string S;
    cin >> S;
    ll N = S.size();

    dp[0][0] = 1;

    ll R=0, B=0;
    REP(i, 2*N){
    	if(i<N){
    		if(S[i] == '0') R += 2;
    		else if(S[i] == '2') B += 2;
    		else R++, B++;
    	}


    	REP(j, i+1){
    		ll idx = j;
    		ll jdx = i-j;
    		if(idx<R) dp[idx+1][jdx] += dp[idx][jdx]; 
    		dp[idx+1][jdx] %= mod;
    		if(jdx<B) dp[idx][jdx+1] += dp[idx][jdx]; 
    		dp[idx][jdx+1] %= mod;	
    	}
    }

    ll res = 0;
    REP(i, 2*N+1){
    	res += dp[i][2*N-i];
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 125312
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

for i in range(10**N):
    scstr = str(i)

    if len(scstr) == N and all(scstr[s-1] == str(c) for s,c in sc):
        print(i)
        break
else:
    print(-1)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

vector<pair<char, int>> runLengthEncoding(string s) {
    int n = s.size();

    vector<pair<char, int>> res;
    char pre = s[0];
    int cnt = 1;
    for(int i=1;i<n;i++) {
        if (pre != s[i]) {
            res.push_back({ pre, cnt });
            pre = s[i];
            cnt = 1;
        }
        else cnt++;
    }

    res.push_back({ pre, cnt });
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >>  S;
    auto res = runLengthEncoding(S);
    cout << res.size() << endl;
}


Measured memory_bytes: 1608
def main():
    N = int(input())
    dp = [0] * N
    rt = int(pow(N, 0.5)) + 1
    for i in range(1, rt):
        ii = i * i
        for j in range(1, i + 1):
            iji = ii + j * j + i * j
            if iji + 1 + i + j > N:
                break
            for k in range(1, j + 1):
                c = iji + k * k + (i + j) * k
                if c <= N:
                    if i == j or j == k:
                        l = 3
                        if i == k:
                            l = 1
                    else:
                        l = 6
                    dp[c - 1] += l
                else:
                    break
    print("\n".join(map(str,dp)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9536
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 1<<21, mod = 1e9 + 7;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	ll sm = 0;
	vi a(n); for(auto &i : a) cin >> i, sm +=i;
	sm = (sm + 4*m - 1) / (4*m);
	sort(all(a));
	int cnt = 0;
	for(auto &i : a) cnt += i>=sm;
	cout << (cnt<m?"No":"Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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 vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll d(n);
    rep(i, n){
        cin >> d[i];
    }
    sort(ALL(d));
    cout << d[n/2]-d[n/2-1] << endl;
    return 0;
}

Measured memory_bytes: 1152
S=input()

LIST_W=['Sunny','Cloudy','Rainy','Sunny']

#リスト中で x と等しい値を持つ最初の要素の位置をゼロから始まる添字で返します。 該当する要素がなければ ValueError が送出されます
index=LIST_W.index(S) 
print(LIST_W[index+1])

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010
char s[N];
int n, st[N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int ans = 0, top = 0;
	for(int i = 1; i <= n; ++i) s[i] -= '0';
	for(int i = 1; i <= n; ++i) {
		if(top && s[top] ^ s[i]) {++ans, --top; continue;}
		s[++top] = s[i];
	}
	printf("%d\n", ans * 2);
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(){
    char S[2000000];
    int n;
    long int i,ans=0;
    int w=0;
    scanf("%s",S);
    while(S[w]=='W') w++;
    for (i = 0;S[i] != '\0';i++);
    for(n=w;n<i;n++){
        if(S[n]=='W'){
            ans+=n-w;
            w++;
        }
    }


    printf("%ld\n",ans);

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int h; cin >> h;
  map<int, int> mp;
  int t = 1;
  while(h > 0){
    mp[h] = t;
    h /= 2;
    t *= 2;
  }

  int ans = 0, res = 1;
  for(auto p : mp){
    ans += p.second;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;


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

	int n, m, i, j, k, a, b, ans;
	cin >> n >> m;
	vector<vector<int>> adj(n + 1);
	vector<int> inbound(n + 1, 0);

	for (i = 0; i < m; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
		inbound[b]++;
	}

	vector<int> plist;
	queue<int> q;
	for (i = 1; i <= n; i++) {
		if (inbound[i] == 0) {
			plist.push_back(i);
			q.push(i);
		}
	}

	vector<int> dist(n + 1, 0);
	while (!q.empty()) {
		int id = q.front();
		q.pop();

		for (auto p : adj[id]) {
			dist[p] = max(dist[p], dist[id] + 1);
			inbound[p]--;
			if (inbound[p] == 0) q.push(p);
		}
	}

	ans = *max_element(dist.begin(), dist.end());
	cout << ans << "\n";


	return 0;
}




Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
namespace mint {
  constexpr int md = 1e9 + 7;
  inline void add (int &a, int b) {
    a += b; if (a >= md) a -= md;
  }
  inline void sub (int &a, int b) {
    a -= b; if (a < 0) a += md;
  }
  inline int sum (int a, int b) {
    add(a, b); return a;
  }
  inline int dif (int a, int b) {
    sub(a, b); return a;
  }
  template<class... A>
  inline int prod (A... args) {
    long long ret = 1;
    for (int a : initializer_list<int>{args...}) {
      assert(a >= 0);
      ret *= a;
      ret %= md;
    }
    return (int)(ret % md);
  }
  inline void mul (int &a, int b) {
    a = prod(a, b);
  }
  inline int inv (int a) {
    a %= md;
    if(a < 0) a += md;
    int b = md, u = 0, v = 1;
    while (a) {
      int t = b / a;
      b -= a * t; swap(a, b);
      u -= v * t; swap(u, v);
    }
    assert(b == 1);
    if(u < 0) u += md;
    return u;
  }
  inline int quot (int a, int b) {
    return prod(a, inv(b));
  }
  inline void div (int& a, int b) {
    a = quot(a, b);
  }
  inline int pow (int a, long long b) {
    int res = 1;
    for (; b; b >>= 1) {
      if (b & 1) mul(res, a);
      mul(a, a);
    }
    return res;
  }
  namespace factorials {
    int sz;
    vector<int> fact, finv;
    void init (int n) {
      sz = n;
      fact.resize(n); finv.resize(n);
      fact[0] = 1;
      for (int i = 1; i < n; i++) fact[i] = prod(fact[i - 1], i);
      finv[n - 1] = inv(fact[n - 1]);
      for (int i = n - 2; i >= 0; i--) finv[i] = prod(finv[i + 1], i + 1);
    }
  }
  inline int fct (int i) {
    using namespace factorials;
    assert(0 <= i && i < sz);
    return fact[i];
  }
  inline int fnv (int i) {
    using namespace factorials;
    assert(0 <= i && i < sz);
    return finv[i];
  }
  inline int binom (int n, int k) {
    using namespace factorials;
    assert(0 <= n && n < sz);
    if (0 < k || n < k) return 0;
    return prod(fact[n], finv[k], finv[n - k]);
  }
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> dp(n + 1, 0);
  vector<bool> a(n + 1, false);
  for (int j = 0; j < m; j++) {
    int x;
    cin >> x;
    a[x] = true;
  }
  dp[0] = 1;
  dp[1] = !a[1];
  for (int i = 2; i <= n; i++) {
    if (!a[i]) mint::add(dp[i], mint::sum(dp[i - 1], dp[i - 2]));
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 640
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int h, w;
    scan(h, w);

    long ans = min(solve(h, w), solve(w, h));
    writeln(ans);
}

long solve(int h, int w) {
    long ans = inf6;

    foreach (x ; 0 .. w + 1) {
        long b = 1L * h * x;
        long a = 1L * (h / 2) * (w - x);
        long c = 1L * ((h + 1) / 2) * (w - x);
        auto m = max(abs(a - b), abs(a - c), abs(b - c));
        ans = min(ans, m);

        a = 1L * h * ((w - x) / 2);
        c = 1L * h * ((w - x + 1) / 2);
        m = max(abs(a - b), abs(a - c), abs(b - c));
        ans = min(ans, m);
    }

    return ans;
}








void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main() {
	
	int n, k;
	cin >> n >> k;
	
	int x = 0;
	for (int i=0; i<n; i++) {
		int a;
		cin >> a;
		if (a >= k) x++;
	}
	
	cout << x << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<ll> a(N, 0LL), b(N, 0LL);
	rep (i, N){
		cin >> a[i];
	} // end rep
	rep (i, N){
		cin >> b[i];
	} // end rep

	ll cnt = 0LL;
	rep (i, N){
		if (a[i] > b[i]){
			ll k = a[i] - b[i];
			b[i] += k;
			cnt += k;
		} // end if
	} // end rep

	rep (i, N){
		if (a[i] < b[i]){
			ll k = (b[i] - a[i]) / 2LL;
			cnt -= k;
		} // end if
	} // end rep

	bool ok = (cnt <= 0LL);
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
N = max(a)

if N % 2 == 0:
    ans = N // 2
    dis = 10**18
    ans_ = N
    for i in a:
        if abs(i - ans) <= dis:
            dis = abs(i - ans)
            ans_ = i
    print(N, ans_)

else:
    ans1 = N // 2
    ans2 = ans1 + 1
    ans_ = N
    dis = 10**18
    for i in a:
        if abs(i -ans1) <= dis:
            dis = abs(i - ans1)
            ans_ = i
        if abs(i - ans2) <= dis:
            dis = abs(i - ans2)
            ans_ = i
    print(N, ans_)


Measured memory_bytes: 58864
uw = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lw = "abcdefghijklmnopqrstuvwxyz"

S = list(input())
for i,a in enumerate(S):
    try:
        index = uw.index(a)
        S[i] = lw[index]
    except:
        try:
            index = lw.index(a)
            S[i] = uw[index]
        except:
            continue
print("".join(S))


Measured memory_bytes: 5572
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>
#include <complex>
#include <numeric>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define gcd(x,y) __builtin_gcd(x,y)
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek = 998244353;

int main() {
	mipletsplay;
	string s;
	cin >> s;
	bool ok = false;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == s[i + 1])
			ok = true;
	}
	if (ok)
		cout << "Bad";
	else
		cout << "Good";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    struct Dice{
        int dice1;
        int dice2;
        int dice3;
        int dice4;
        int dice5;
        int dice6;
    };
    
    int a[6],i;
    for(i=0; i<6; i++){
        scanf("%d",&a[i]);
    }
    struct Dice Dice_1 = {a[0], a[1], a[2], a[3], a[4], a[5]};
    struct Dice Dice_2;
    
    char w;
    w = getchar();
    while(1){
        w = getchar();
        if(w == '\n')break;
        Dice_2 = Dice_1;
        if(w == 'E'){
            Dice_1.dice1 = Dice_2.dice4;
            Dice_1.dice3 = Dice_2.dice1;
            Dice_1.dice4 = Dice_2.dice6;
            Dice_1.dice6 = Dice_2.dice3;
        }else if(w == 'N'){
            Dice_1.dice1 = Dice_2.dice2;
            Dice_1.dice2 = Dice_2.dice6;
            Dice_1.dice5 = Dice_2.dice1;
            Dice_1.dice6 = Dice_2.dice5;
        }else if(w == 'S'){
            Dice_1.dice1 = Dice_2.dice5;
            Dice_1.dice2 = Dice_2.dice1;
            Dice_1.dice5 = Dice_2.dice6;
            Dice_1.dice6 = Dice_2.dice2;
        }else if(w == 'W'){
            Dice_1.dice1 = Dice_2.dice3;
            Dice_1.dice3 = Dice_2.dice6;
            Dice_1.dice4 = Dice_2.dice1;
            Dice_1.dice6 = Dice_2.dice4;
        }
    }
    printf("%d\n",Dice_1.dice1);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  V a;
  ll k;
  for(ll i=0; i<5; i++) {
    ll temp;
    cin >> temp;
    a.push_back(temp);
  }
  cin >> k;

  for(ll i=0; i<4; i++) {
    for(ll j=i+1; j<5; j++) {
      if(llabs(a[i]-a[j]) > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
  string s;
  cin>>s;
  int n=s.length(),l=0,k=0;
  fr(i,n){
    if(s[i]-'0'!=(i%2)) l++;
    else k++;
  }
  cout<<min(l,k)<<endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> w(n);
  vector<ll> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> w[i] >> v[i];
  }
  vector<vector<ll> > dp(n + 1, vector<ll>(W + 10));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= W; ++j) {
      if (0 <= j - w[i]) {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}

Measured memory_bytes: 83168
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
typedef long long ll;

void ans(bool qus)
{
    if (qus == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool qust)
{
    if (qust == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

using namespace std;

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    cout << x % b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <cmath>
#include <string>
using namespace std;
string s;
int T;
bool f=true;
int main(){
  cin >> s;
  int len=s.length();
  T=len;
  //cout << len << endl;
  for(int i=0;i<len-1;i++){
    if(s[i]=='0')f=false;
    if(s[i]!=s[i+1])T=min(max(i+1,len-(i+1)),T);
  }
  /*
  if(T==len){
    if(f)cout << len << endl;
    else cout << "0" << endl;
  }
  else
  */
    cout << T << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int sum = 0;
    string text;
    cin >> text;
    for (int i = 0; i < text.size(); i++) {
        sum += text[i] - '0';
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3720
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args) {
            var line1 = Console.ReadLine().Split(' ');
            int N = int.Parse(line1[0]);
            int K = int.Parse(line1[1]);

            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int count = 0;
            int pick = 0;
            while(true) {
                pick += K;
                count++;
                if (pick >= N) break;
                pick--;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 18016
#include<iostream>
using namespace std;
int main(void)
{
	char a;
	cin>>a;
	if(a=='a') cout<<"b"<<endl;
	if(a=='b') cout<<"c"<<endl;
	if(a=='c') cout<<"d"<<endl;
	if(a=='d') cout<<"e"<<endl;
	if(a=='e') cout<<"f"<<endl;
	if(a=='f') cout<<"g"<<endl;
	if(a=='g') cout<<"h"<<endl;
	if(a=='h') cout<<"i"<<endl;
	if(a=='i') cout<<"j"<<endl;
	if(a=='j') cout<<"k"<<endl;
	if(a=='k') cout<<"l"<<endl;
	if(a=='l') cout<<"m"<<endl;
	if(a=='m') cout<<"n"<<endl;
	if(a=='n') cout<<"o"<<endl;
	if(a=='o') cout<<"p"<<endl;
	if(a=='p') cout<<"q"<<endl;
	if(a=='q') cout<<"r"<<endl;
	if(a=='r') cout<<"s"<<endl;
	if(a=='s') cout<<"t"<<endl;
	if(a=='t') cout<<"u"<<endl;
	if(a=='u') cout<<"v"<<endl;
	if(a=='v') cout<<"w"<<endl;
	if(a=='w') cout<<"x"<<endl;
	if(a=='x') cout<<"y"<<endl;
	if(a=='y') cout<<"z"<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, cnt, num int
	fmt.Scan(&n)
	for i := 1; i <= n; i += 2 {
		cnt = 0
		for j := 1; j <= n; j++ {
			if i%j == 0 {
				cnt++
			}
		}
		if cnt == 8 {
			num++
		}
	}
	fmt.Println(num)
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
# input
n = int(input())
list = [int(a) for a in input().split()]

counter = 1
for ii in range(1, n):
    flag = 0
    for jj in range(0, ii):
        if list[ii] < list[jj]:
            flag = 1
            break
    if flag == 0:
        counter += 1

print(counter)


Measured memory_bytes: 2940
#include <stdio.h>

int main ()
{
	int K,A,B;
	scanf("%d%d%d",&K,&A,&B);
	if((B/K)*K<A){
		printf("NG\n");
	}
	else{
		printf("OK\n");
	
	}
	
	return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=1;i<=3500;++i)
        for(int j=1;j<=i;++j)
        {
            ll x=i*j,y=i+j;
            if(4*x>N*y)
            {
                if((N*x)%(4*x-N*y)==0)
                {
                    printf("%d %d %I64d\n",i,j,(N*x)/(4*x-N*y));
                    exit(0);
                }
            }
        }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	string s;
	cin >> s;
	int p = 700;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o') p += 100;
	}
	cout << p;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	zep(i, 0, s.size()){
		s[i] = 'x';
	}
	print(s)
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collection;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Deque;
import java.util.ArrayDeque;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CUnification solver = new CUnification();
        solver.solve(1, in, out);
        out.close();
    }

    static class CUnification {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int n = s.length;

            Deque<Boolean> stack = new ArrayDeque<>();

            for (int i = 0; i < n; i++) {
                boolean cur = s[i] == '1';
                if (stack.isEmpty() || stack.peekLast() == cur) {
                    stack.addLast(cur);
                } else {
                    stack.pollLast();
                }
            }

            int answer = n - stack.size();

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

    }
}



Measured memory_bytes: 25172
import itertools

N, M = map(int, input().split(" "))
path = [[False for j in range(N)] for i in range(N)]

for i in range(M):
    a, b = map(int, input().split(" "))
    path[a-1][b-1] = True
    path[b-1][a-1] = True

count = 0
for order in itertools.permutations(range(1, N)):
    before = 0
    for nextNode in order:
        if not path[before][nextNode]:
            break
        before = nextNode
    if before == order[-1]:
        count += 1
print(count)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, x;
bool b[1010000];
vector<int>prime;
signed main() {
	prime.push_back(2);
	for (int i = 3; i < 999999; i += 2) {
		bool b00l = 0;
		for (int p : prime) {
			if (i % p == 0) { b00l = 1; break; }
			if (p > sqrt(i))break;
		}
		if (!b00l)prime.push_back(i);
	}
	while (cin >> n >> x, n) {
		for1(i, x)b[i] = 0;
		b[0] = 1;
		for1(gr4cv, n) {
			int p; cin >> p;
			for0(i, x)if (i + p > x)break; else if (b[i])b[i + p] = 1;
		}
		int ans = -1;
		for (int p : prime)if (p > x)break; else if (b[p])ans = p;
		if (ans < 0)cout << "NA\n";
		else cout << ans << endl;
	}
}


Measured memory_bytes: 4612
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h; cin >> h;
	int n; cin >> n;
	vector<int> a(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	cout << (sum>=h?"Yes":"No") << endl;
}

Measured memory_bytes: 640
N=int(input())
S=input()

#Tに含まれた文字の種類を数える
def countletter(T):
    S=[]
    for t in T:
        if t not in S:
            S.append(t)
    return len(S)

ans=0

for i in range(1,N):
    A=S[:i]
    B=S[i:]
    
    ans=max(ans,countletter(A)+countletter(B)-countletter(S))
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ulli unsigned long long int
#define ld long double  
using namespace std; 

void solve() {
    int n;
    cin >> n;

    vector<int> v;
    make_heap(v.begin(), v.end());

    int temp;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        v.push_back(temp);
        push_heap(v.begin(), v.end());
    }

    int a_points = 0;
    int b_points = 0;
    for (int i = 0; i < n; i++) {
        (i & 1) ? b_points += v.front() : a_points += v.front();
        pop_heap(v.begin(), v.end());
        v.pop_back();
    }

    cout << a_points - b_points << "\n";
}

int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    //cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans = INT64_MAX;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<pair<int, int> > XY(N);
    set<int> XS, YS;
    for (auto &xy : XY) {
        cin >> xy.first >> xy.second;
        XS.insert(xy.first);
        YS.insert(xy.second);
    }
    vector<int> X(XS.begin(), XS.end()), Y(YS.begin(), YS.end());
    int Xsize = X.size(), Ysize = Y.size();
    for (int i = 0; i < Xsize; i++) for (int j = i; j < Xsize; j++) for (int k = 0; k < Ysize; k++) for (int l = 0; l < Ysize; l++) {
        int count = 0;
        for (auto &xy : XY) {
            if (X[i] <= xy.first && X[j] >= xy.first && Y[k] <= xy.second && Y[l] >= xy.second) count++;
        }
        if (count >= K) ans = min(ans, ((long long)X[j]-X[i])*((long long)Y[l]-Y[k]));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stack>
const int maxn=2e5+5;
using namespace std;
int main()
{
	string s;
	cin>>s;
	stack<char> q;
	for(int i=0;i<s.size();i++)
	{
		if(q.size()==0)
		{
			q.push(s[i]);
			continue;
		}
		char temp=q.top();
		if(temp=='S'&& s[i]=='T')
		{
			q.pop();
		}
else
{
q.push(s[i]);
}
	
	}
	cout<<q.size()<<endl;
	return 0;
} 

Measured memory_bytes: 644
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <functional>
#include "math.h"
using namespace std;
int main(){

	long double N, A, B, C, D, E;
	cin >> N;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> E;
	long double minhuman = A;
	if(B < minhuman){minhuman = B;}
	if(C < minhuman){minhuman = C;}
	if(D < minhuman){minhuman = D;}
	if(E < minhuman){minhuman = E;}
	long int x = ceil(N / minhuman);
	long int ans = x + 4;
	cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        long num = long.Parse(ReadLine());
        double root = Sqrt(num);
        int ans = 100;
        for(int i=1;i<=root;i++){
            if(num % i == 0){
                long a = i;
                long b = num/i;
                int count = 1;
                while(a>=10 || b>=10){
                    a/=10;
                    b/=10;
                    count++;
                }
                if(count < ans){
                    ans = count;
                }
            }
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(){
  int n,a[10000],i,j,flag,ans=0;
  scanf("%d",&n);
 
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    if(a[i]<=1)continue;
    else{
      flag=0;
      for(j=2;j*j<=a[i];j++){
	if(a[i]%j==0){flag=1;break;
	}

      }
      if(flag==0)ans++;
    }
    }
    printf("%d\n",ans);
    return 0;
  }

Measured memory_bytes: 628
a, b, c = input().split()        
a, b, c = int(a), int(b), int(c) 
fl = False                       
ab = a+b                         
ac = a+c                         
bc = b+c                         
while(1):                        
    if ab == c:                  
        fl = True                
        break                    
    if bc == a:                  
        fl = True                
        break                    
    if ac == b:                  
        fl = True                
        break                    
    break                        
if fl:                           
    print('Yes')                 
else:                            
    print('No')                  
                                 


Measured memory_bytes: 3192
import java.util.Scanner;
public class Main {

	static long Factrial(int num) {
		if(num == 1)
			return(1);
		else {
			return(num * Factrial(num - 1));
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		
		int num = stdIn.nextInt();
		
		System.out.println(Factrial(num));
	}

}

Measured memory_bytes: 15312
#include<stdio.h>
int main(){
    int a,b,T;

    
    scanf("%d%d",&a,&b);
    
    
    T=a-1;

    

    

    if (b >= a) T=T+1;
            
            
    printf("%d\n",T);
  
    
    return 0;
    
}


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

int main() {
  int N;
  cin >> N;
  vector<int> S(N);
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }
  ll result = accumulate(S.begin(), S.end(), 0);
  bool flg = false;
  if (result % 10 == 0) {
    sort(S.begin(), S.end());
    for (int i = 0; i < N; ++i) {
      ll buf = result;
      buf -= S[i];
      if (buf % 10 != 0) {
        result = buf;
        break;
      }
      if (i == N - 1) {
        flg = true;
      }
    }
  }
  
  if (flg) {
    cout << 0 << endl;
  } else {
    cout << result << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef pair<uint64_t, uint64_t> P;

int main(int argc, char** argv) {
  uint64_t N, H;
  cin >> N >> H;
  vector<uint64_t> a(N), b(N);
  rep(i, N) {
    cin >> a[i] >> b[i];
  }

  // For Debug
  // rep(i, N) {
  //   cout << a[i] << endl;
  // }
  // rep(i, N) {
  //   cout << b[i] << endl;
  // }

  vector<P> pairs;
  rep(i, N) {
    pairs.push_back(P(a[i], 0));
    pairs.push_back(P(b[i], 1));
  }

  sort(all(pairs));
  reverse(all(pairs));

  // For Debug
  // rep(i, 2 * N) {
  //   cout << pairs[i].first << ", " << pairs[i].second << endl;
  // }
  vector<P> candidates;
  rep(i, 2 * N) {
    if (pairs[i].second == 0) { // pairs[i] is A[i]
      candidates.push_back(pairs[i]);
      break;
    }
    candidates.push_back(pairs[i]);
  }
  // Now, the last element of candidates is type-A.
  uint64_t cnt = 0;
  uint64_t sum = 0;
  rep(i, candidates.size() - 1) {
    sum += candidates[i].first;
    ++cnt;
    if (sum >= H) { break; }
  }
  if (sum >= H) { // Passed only by B.
    cout << cnt << endl;
    return 0;
  }

  // Now, we use candidates[-1] as repeatable A.
  uint64_t a_score = candidates[candidates.size() - 1].first;
  uint64_t rest = H - sum;
  if ((rest % a_score) == 0) {
    cnt += (rest / a_score);
  } else {
    cnt += (rest / a_score) + 1;
  }

  cout << cnt << endl;
}


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

using namespace std;

int main() {

	int n,m,xx,yy;
	cin >> n >> m >> xx >> yy;

	vector<int> x(n, 0);
	vector<int> y(m, 0);

	int maxx = -100;
	int miny = 100;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (x[i] > maxx) { maxx = x[i]; }
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
		if (y[i] < miny) { miny = y[i]; }
	}

	maxx = max(xx, maxx);
	miny = min(yy, miny);
	if (miny - maxx < 1) {
		cout << "War" << endl;
	}
	else {
		cout << "No War" << endl;
	}
}

Measured memory_bytes: 256
n,W = map(int,input().split())
a = {}
for i in range(n):
    w,v = map(int,input().split())
    a.setdefault(w, []).append(v)

we = [0]*4
va = []
num = [0]*4
for i,[k,v] in enumerate(a.items()):
    we[i] = k
    va.append(sorted(v,reverse=True))
    num[i] = len(v)
for i in range(4-len(va)):
    va.append([0])

ans = -float('inf')
for i in range(max(1,num[0]+1)):
    for j in range(max(1,num[1]+1)):
        for k in range(max(1,num[2]+1)):
            for l in range(max(1,num[3]+1)):
                if we[0]*i + we[1]*j + we[2]*k + we[3]*l <= W:
                    total = 0
                    for im,m in enumerate([i,j,k,l]):
                        total += sum(va[im][:m])
                    ans = max(ans, total)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    int n;
    ll k;
    cin >> n >> k;
    vector<int> p(n);
    vector<ll> c(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i, n) cin >> c[i];

    ll ans = -inf;

    rep(i, n) {
        int v = i;
        ll sum = 0;
        int cnt = 0;
        while(true) {
            cnt++;
            sum += c[v];
            v = p[v];
            if(v == i) break;
        }
        ll path = 0;
        int now = 0;
        while(true) {
            now++;
            path += c[v];
            if(now > k) break;
            int x = (k - now) / cnt;
            chmax(ans, path + max(0LL, sum) * x);
            v = p[v];
            if(v == i) break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3704