akhauriyash/Code-Regression huggingface dataset:
V, E, r = map(int, input().split())
graph = {i:{} for i in range(V)}
visit = [False for _ in range(V)]
min_d = [(10**18, i) for i in range(V)]
distance = [10**18 for i in range(V)]
import heapq

for i in range(E):
    n1, n2, c = map(int, input().split())
    graph[n1][n2] = c

def dijkstra(s):
    distance[s] = 0
    min_d[s] = (0, s)
    heapq.heapify(min_d)
    while len(min_d):
        m, idx = heapq.heappop(min_d)
        if visit[idx]==True:
            continue
        distance[idx] = m
        visit[idx] = True
        for j in graph[idx].keys():
            heapq.heappush(min_d, (distance[idx]+graph[idx][j], j))
    return distance

min_d = dijkstra(r)
for m in min_d:
    if m==10**18:
        print('INF')
    else:
        print(m)

            

            



Measured memory_bytes: 120396
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef unsigned long long ull;

int main()
{
	ull N, A, B;
	cin >> N >> A >> B;

	ull sumA = 0;

	ull oneSet = A + B;

	sumA += (N / oneSet) * A;
	sumA += (N % oneSet < A) ? (N % oneSet) : A;

	cout << sumA << endl;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<long long> A(n);
	vector<long long> V(n + 1);
	for (int i = 0; i < A.size(); i++) {
		cin >> A[i];
	}
	V[0] = 0;
	for (int i = 0; i < A.size(); i++) {
		V[i + 1] = (A[i] + V[i])%m;
	}
	long long cnt = 0;
	map<long long,long long> M;
	for (int i = 0; i < V.size(); i++) {
		cnt += M[V[i]];
		M[V[i]]++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>

#define max(a, b)  a > b ? a : b
#define min(a, b)  a < b ? a : b

int main()
{
	int A[4], B[4], C[2][10], HIT, BLOW;

	while (scanf("%d %d %d %d %d %d %d %d", &A[0], &A[1], &A[2], &A[3], &B[0], &B[1], &B[2], &B[3]) != EOF)
	{
		memset(C, 0, sizeof(C));

		HIT  = 0;
		BLOW = 0;

		for (int i = 0; i < 4; i++)
		{
			if (A[i] == B[i])
			{
				HIT += 1;
			}

			C[0][A[i]] += 1;
			C[1][B[i]] += 1;
		}

		for (int i = 0; i < 10; i++)
		{
			BLOW += min(C[0][i], C[1][i]);
		}

		BLOW -= HIT;
		
		printf("%d %d\n", HIT, BLOW);
	}

	return 0;
}

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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,r,x,y,m,n;
    	ll h1,m11,h2,m22;
    	cin>>h1>>m11>>h2>>m22>>k;
    	x=h1*60+m11;
    	y=h2*60+m22;
    	if((y-x-k)<=0)
    	{
    		cout<<0<<endl;
    	}
    	else
    	{
    		cout<<y-x-k<<endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
const int MOD(1e9 + 7);
unordered_map<int, int> desc[10005], multiplu;
int n, x, d, res, add;
inline int Pow(int baza, int exponent) {
    int putere(1);
    while (exponent) {
        if (exponent % 2)
            putere = (1LL * putere * baza) % MOD;
        baza = (1LL * baza * baza) % MOD;
        exponent /= 2;
    }
    return putere;
}
int main() {
    DAU
    cin >> n;
    multiplu.reserve(50);
    multiplu.max_load_factor(2.5);
    for (int i = 1; i <= n; ++i) {
        desc[i].reserve(50);
        desc[i].max_load_factor(2.5);
        cin >> x;
        res += Pow(x, MOD - 2);
        if (res >= MOD)
            res -= MOD;
        d = 2;
        while (x != 1) {
            while (x % d == 0)
                ++desc[i][d], x /= d;
            if (d == 2)
                d = 3;
            else d += 2;
            if (d * d > x)
                d = x;
        }
        for (const auto& P : desc[i])
            multiplu[P.first] = max(multiplu[P.first], P.second);
    }
    for (const auto& P : multiplu)
        res = (1LL * res * Pow(P.first, P.second)) % MOD;
    cout << res;
    PLEC
}


Measured memory_bytes: 6656
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int X,Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
}

Measured memory_bytes: 256
import sys
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    R = int(input())
    print(R * 2 * 3.141592)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67540
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

int main(){
    string S,T;
    int res=0;
    cin >> S >> T;
    for(int i=0;i<S.size();i++){
        res+=(S[i]!=T[i])*1;
    }
    cout<<res;
}

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

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

    if(a + b == 15){
        cout << "+" << endl;
    } else if(a * b == 15){
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b-c>=0)out("No");
    else if(a*a+b*b+c*c+2*a*b-2*a*c-2*b*c>4*a*b)out("Yes");
    else out("No");

	return 0;
}


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


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

  int ans = 0;
  for (int i = 1; i <= N; i = i + 2) {
      int num_divisor = 0;
      for (int j = 1; j <= i; j++) {
          if (i % j == 0) num_divisor++;
      }
      if (num_divisor == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int c[6][6];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int h,w,k;
	scanf(" %d %d %d",&h,&w,&k);
	rep(i,0,h){
		rep(j,0,w){
			char ch;
			scanf(" %c",&ch);
			c[i][j] = ch == '#';
		}
	}
	int ans = 0;
	rep(msk, 0, 1 << (h + w)){
		int cnt = 0;	
		rep(i,0,h){
			rep(j,0,w){
				int col = ((msk >> i)&1) || ((msk >> (j + h))&1);
				if(!col && c[i][j]){
					++cnt;	
				}
			}
		}
		ans += cnt == k;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3676
# include <bits/stdc++.h>
 
//# define int long
 
using namespace std;
 
 
int32_t main()
{
	vector < int > a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if ( (a[0] == a[1] && a[2] != a[1]) || ( a[1] == a[2] && a[1] != a[0] ) ) {
		cout << "Yes";
	}  
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <climits>
#include <iostream>
#include <vector>

const int N = 26, D = 365;

using namespace std;
typedef long long ll;
vector<int> adj[N];
int main() {
    int d;
    cin >> d;
    vector<int> c(N);
    vector<vector<int>> s(D, vector<int>(N));
    int sum = 0;
    for (int i = 0; i < N; ++i)
        cin >> c[i];
    for (int i = 0; i < d; ++i)
        for (int j = 0; j < N; ++j)
            cin >> s[i][j];
    vector<int> ans;
    vector<int> last(N, 0);
    for (int i = 1; i <= d; ++i) {
        int maxt = 0, maxg = INT_MIN;
        for (int j = 0; j < N; ++j) {
            int gain = s[i - 1][j];
            for (int k = 0; k < N; ++k)
                if (k != j)
                    gain -= c[k] * (i - last[k]);
            if (gain > maxg) {
                maxg = gain;
                maxt = j;
            }
        }
        last[maxt] = i;
        ans.emplace_back(maxt + 1);
    }
    for (int i : ans)
        cout << i << endl;
}

Measured memory_bytes: 3700
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

void yesno(bool f) { cout << (f ? "Yes" : "No") << endl; }

//

int main()
{
	int n, m;
	cin >> n >> m;

	int map[30][30] = {0};

	rep(i, n)
	{
		int k;
		cin >> k;
		rep(j, k)
		{
			int a;
			cin >> a;
			map[i][a - 1] = 1;
		}
	}

	int cnt = 0;

	for ( int i = 0; i < 30; i++ )
	{
		bool all = true;

		rep(j, n)
		{
			if ( map[j][i] == 0 )
			{
				all = false;
			}
		}
		if ( all ) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            string s; cin >> s;
            if (s == "snuke") {
                cout << (char) ('A' + j) << (i + 1) << "\n";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        int a,b,c,d,e,f;
        cin>>a>>b>>c>>d>>e>>f;
        int water[31]={0};
        for(int i=0;i<=30;i++){
                for(int j=0;j<=30;j++){
                       if(a*i+b*j<=30){
                               water[a*i+b*j]=1;
                       }
                }
        }
        int x=0,y=214700;
        int Water,Salt;
        for(int k=1;k<=30;k++){
                for(int i=0;i<=3000;i++){
                        for(int j=0;j<=3000;j++){
                            if(water[k]==1){
                                        Water=k*100;
                                        Salt=c*i+d*j;
                                if(x*(Water+Salt)<=y*Salt){
if(Water+Salt<=f&&Salt<=k*e){
                                        x=Salt;
                                        y=Water+Salt;
}
                                }
                            }
                        }
                }
        }
        cout<<y<<" "<<x;
}

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

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h,w,n,i;
    cin>>h>>w>>n;
    int r=0,c=0,sum=0;
    if(h<=w)
    {
    	int x=n/w;
    	if(n%w==0)
    	cout<<x;
    	else
    	cout<<x+1;
	}
	else
	{
		int x=n/h;
		if(n%h==0)
		cout<<x;
		else
		cout<<x+1;
		
	}
    

}

Measured memory_bytes: 256
# include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,p=1,minj; cin>>n;
  vector <string> data1(n),data2(n);
  for(int i=0;i<n;i++){
    cin >>data1[i]; data2[i] = data1[i];
  }
  while(p!=0){
    p=0;
    for(int i=n-1;i>0;i--){
      if(data1[i][1]<data1[i-1][1]){
        swap(data1[i],data1[i-1]);
        p=1; 
      }
    }
  }
  for(int i=0;i<n;i++){
    minj =i;
    for(int j=i;j<n;j++){
      if(data2[j][1]<data2[minj][1]) minj =j;
    }
    if(i != minj){
      swap(data2[i],data2[minj]); 
    }
  }
  for(int i=0;i<n;i++)cout<<(i!=0?" ":"")<<data1[i];
  cout<<"\n"<<"Stable"<<"\n";
  for(int i=0;i<n;i++)cout<<(i!=0?" ":"")<<data2[i];
  if(data1 == data2) cout<<"\n"<<"Stable"<<"\n";
  else cout<<"\n"<<"Not stable"<<"\n";
  return 0;
}




Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        while ( a % 2 == 0 ) {
            ans++;
            a /= 2;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define strep(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<pair<ll,ll>,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
#define rs resize
int main()
{
   std::ios::sync_with_stdio(false);
   ll n,i;
   vi r,ev,odd;
   cin>>n;
   ll a[n];
   rep(i,0,n){
      cin>>a[i];
      if(a[i]%2 == 0 and a[i]%4 != 0)
       ev.pb(a[i]);
      else
      {
        if(a[i]%4 == 0)
         r.pb(a[i]);
      }
      if(a[i]&1)
       odd.pb(a[i]);
   }
   int c = r.size(), b = odd.size();
   if(ev.size() == 0)
   {
      if(c >= b - 1)
       cout<<"Yes";
      else
       cout<<"No";
   }
   else
   {
      if(c >= b)
       cout<<"Yes";
      else
       cout<<"No";
   }
   return 0;
}


Measured memory_bytes: 2296
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional> 
#include <vector>
#include <cstring>

using namespace std;

int main(){

    char s[101],t[101];
    cin >> s;
    cin >> t;

    int lent = strlen(t);
    sort(s,s+strlen(s));
    sort(t,t+lent);
    
    for(int i=0;i<lent/2;i++){
        swap(t[i],t[lent-1-i]);
    }

    string s2(s,strlen(s));
    string t2(t,lent);


    if(s2 < t2){
      cout << "Yes";
    }else{
      cout << "No";
    }
  
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = acos(-1.0);
const ll LINF = (ll)1e18 + 5;
const int INF = (int)1e9 + 5;

template<class T>
T sqr(T x) { return x * x; }

template<class T>
T abs(T x) { return x < 0 ? -x : x; }

template<class T>
ll round(T x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T>
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T>
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}


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

template<class T>
ostream & operator <<(ostream & os, const vector<T> & v) {
	bool was = false;
	os << "{";
	for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class T>
ostream & operator <<(ostream & os, const set<T> & v) {
	bool was = false;
	os << "{";
	for (typename set<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class T>
ostream & operator <<(ostream & os, const multiset<T> & v) {
	bool was = false;
	os << "{";
	for (typename multiset<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class P, class Q>
ostream & operator <<(ostream & os, const map<P, Q> & v) {
	bool was = false;
	os << "{";
	for (typename map<P, Q>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

#define all(x) (x).begin(), (x).end()

template<class T>
T nextInt() {
	ll x = 0;
	bool p = false;
	char c;
	do {
		c = getchar();
	} while (c <= 32);
	if (c == '-') {
		p = true;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return (p ? -x : x);
}

void solve() {
	string s;
	cin >> s;
	vector<char> res;
	for (char c : s) {
		res.push_back(c);
		if (res.size() >= 2 && res[(int)res.size() - 2] == 'S' && res.back() == 'T') res.pop_back(), res.pop_back();
	}
	s = string(all(res));
	cout << s.size() << endl;
}

int main() {
	srand(time(0));

#ifdef LOCAL
	//gen();
	freopen("input.txt", "r", stdin);
#else
	
#endif

	int t = 1;
	//scanf("%d", &t);
	while (t--) solve();
	
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 100
ll d[MAX_V][MAX_V];
int V;
void warshall_floyd() {
	rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

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

	int H, W;
	cin >> H >> W;
	V = 10;
	rep(i, 0, V) rep(j, 0, V) d[i][j] = INF;
	rep(i, 0, V) rep(j, 0, V) {
		int c;
		cin >> c;
		d[i][j] = c;
	}

	warshall_floyd();

	map<int, int> A;
	rep(i, 0, H) rep(j, 0, W) {
		int a;
		cin >> a;
		A[a]++;
	}

	ll rsl = 0;
	for(map<int, int>::iterator it = A.begin(); it != A.end(); it++) {
		if(it->first != -1 and it->first != 1) {
			rsl += (it->second * d[it->first][1]);
		}
	}

	cout << rsl << endl;

}


Measured memory_bytes: 256
'use strict';
function Main(inputs) {
 
 const input = inputs.split("\n");
 
 const a = Number(input[0].split(' ')[0]);
 const b = Number(input[0].split(' ')[1]);
 const k = Number(input[0].split(' ')[2]);

 console.log((a > k ? a - k : 0),(a > k ? b : a + b > k? a + b - k : 0));
}
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include <iostream>

int main(int argc, const char * argv[]) {
    
    int h, m, s;
    
    int in ;
    
    std::cin >> in ;
    
    h = in/60/60 ;
    m = (in/60)%60 ;
    s = in%60%60 ;
    
    
    std::cout << h << ":" << m << ":" << s << std::endl ; // 時間
    
    
    return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,ans=0;
	cin>>n>>x;
	int ans2=n;
	int a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0; i<n; i++){
		ans=ans+a[i];
	}
	x=x-ans;
	ans2=ans2+x/a[0];
	cout<<ans2<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

ll mofumofumofu() {
  int x;
  if (scanf("%d", &x) == EOF) exit(0);
  return (ll)x;
}

int main() {
  for (;;) {
    int N = mofumofumofu();
    ll L = mofumofumofu();
    vector<ll> v(N);
    for (int i : range(N)) {
      v[i] = mofumofumofu();
    }

    int t = -1;
    for (int i : range(N - 1)) {
      if (v[i] + v[i + 1] >= L) {
        t = i;
        break;
      }
    }

    if (t == -1) {
      puts("Impossible");
      continue;
    }
    puts("Possible");
    for (int i : range(t)) {
      printf("%d\n", i + 1);
    }
    for (int i = N - 2; i >= t; --i) {
      printf("%d\n", i + 1);
    }
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    string s;
    cin >> s;
    REP(i,s.length()) cout << "x";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define REPN(i,a,b) for(ll i = a; i <= b; ++i)
#define REPV(i,a,b) for(ll i = a; i >= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define with_tests int t; cin>>t; while(t--){ solve(); }
#define without_tests solve();
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 100000000
#define ff first
#define ss second
const int M=1e9+7;

void solve()
{
	int n;
	cin>>n;
	vector<pair<int, int>> A(n);
	REP(i,0,n)
	{
		cin>>A[i].ff>>A[i].ss;
	}
	int cnt = 0;
	bool ans = false;
	REP(i,0,n)
	{
		if(A[i].ff == A[i].ss)
		{
			++cnt;
			if(cnt > 2)
			{
				ans = true;
				break;
			}
		}
		if(A[i].ff != A[i].ss)
		cnt = 0;
	}
	if(ans)
	cout<<"Yes\n";
	else
	cout<<"No\n";
}
 
int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  //with_tests;
  without_tests;
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int ans=0;
string str,tmp;

int main(){
	while(cin>>str){
		tmp=str;
		reverse(tmp.begin(),tmp.end());
		if(str==tmp) ans++;
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int h[101];

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

  int ans = 0;

  for (int l = 0; l < n; l++) {
    while (h[l] > 0) {
      int r;
      for (r = l + 1; r < n; r++) {
        if (h[r] == 0) {
          break;
        }
      }
      for (int i = l; i < r; i++) h[i]--;
      ans++;
    }
  }
  cout << ans << endl; 
  return 0;
}

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

#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOD(i,b,a) for(i=a;i>=b;i--)
#define pa pair<long long , long long >
#define fi first
#define se second
#define task "x"
#define pb push_back

typedef long long ll;
const ll M=1e6+1;
const ll N=1e4+1;
using namespace std;

ll i, j, n, m,h, b[M], c[M],ans;
pa a[M];
ll co[M],ha[M];
map<pair<ll,ll>,ll > d;
vector< ll > ans1, ans2;
bool kt = true;

void input()
{
    cin >> n >> m >> h;
    FOR(i,1,h) {cin >>a[i].fi >> a[i].se;
       d[{a[i].fi,a[i].se}] = -1;
       ha[a[i].fi]++;
       co[a[i].se]++;
    }
}

void solve()
{
    ll lnh =0,lnc = 0;
    FOR(i,1,n){
        lnh = max(lnh,ha[i]);
    }
    FOR(i,1,m){
        lnc = max(lnc,co[i]);
    }
    FOR(i,1,n){
        if(ha[i] == lnh) ans1.pb(i);
    }
    FOR(i,1,m){
        if(co[i] == lnc) ans2.pb(i);
    }
    FOR(i,0,ans1.size()-1){
     FOR(j,0,ans2.size()-1)   {
         ll b1 = ans1[i],b2 = ans2[j];
         if(d[{b1,b2}]!=-1)
            {
                kt = false;
                break;
            }
     }
     if(kt == false) break;
    }
    ans =lnh + lnc;
    if(kt == false ) cout<<ans;
    else cout<<ans-1;
}

int main()
{
  	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	if(fopen(task".inp","r"))
        {
 	  freopen(task".inp","r",stdin);
 	  freopen(task".out","w",stdout);
	}
	input();
	solve();

   return 0;
}


Measured memory_bytes: 39728
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    int n;
    cin >> n;

    vector<int> d;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        d.push_back(tmp);
    }

    ll sum = 0;
    REP(i,n){
        FOR(j,i+1,n){
            if(i==j) continue;
            else{
                sum += d[i]*d[j];
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3568
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def get(self):
      return [self.members(r) for r in self.roots()][1:]

N,M,K = map(int,input().split())
f_arr = [0 for _ in range(N+1)]
uf = UnionFind(N+1)
for i in range(M):
  a,b = map(int,input().split())
  uf.union(a,b)
  f_arr[a] += 1
  f_arr[b] += 1
for j in range(K):
  a,b = map(int,input().split())
  if uf.same(a,b):
    f_arr[a] += 1
    f_arr[b] += 1

arr = []
for k in range(1,N+1):
  ans = uf.size(k)-f_arr[k] -1
  arr.append(ans)
print(*arr)


Measured memory_bytes: 14116
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
b_ls = [int(i) for i in sys.stdin.readline().split()]
plus_ls = []
minus_ls = []
for a, b in zip(a_ls, b_ls):
    if b > a:
        minus_ls.append(b - a)
    elif a > b:
        plus_ls.append(a - b)
    else:
        pass
plus_ls.sort(reverse=True)
sum_min = sum(minus_ls)

cnt = len(minus_ls)
for i in plus_ls:
    if sum_min <= 0:
        break
    sum_min -= i
    cnt += 1
if sum_min > 0:
    print(-1)
else:
    print(cnt)

Measured memory_bytes: 18644
x,k,d = map(int,input().split())

if x < 0:
    x *= -1
if x == 0:
    if k % 2 == 0:
        ans = 0
    else:
        ans = d
elif x >= d:
    if x // d >= k:
        ans = x - k*d
    else:
        if (k - (x // d)) % 2 == 0:
            ans = x % d
        else:
            ans = abs(x % d - d)
else:
    if k % 2 == 0:
        ans = x
    else:
        ans = abs(x - d)
print(ans)


Measured memory_bytes: 9084
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
const int MAX_K = 1e3;

int main(){ 
  int N; scanf("%d", &N);
  if(N == 1){
    cout << "Yes" << endl;
    cout << "2" << endl;
    cout << "1 1" << endl;
    cout << "1 1" << endl;
    return 0;
  }
  int k = 0;
  for(int res = 1; res <= MAX_K; res++){
    if((res*(res+1))/2 == N){  k = res; break;}
  }
  
  if( k == 0){ printf("%s\n", "No"); return 0;}
  
  vector<int> vec[k+1];
  int cnt = 0;
  
  for(int i = 2; i <= k-1; i++){ 
    //上から何段目スタートか
    for(int h = i*(i-1)/2 + 1; h <= i*(i+1)/2; h++){
      vec[cnt].push_back(h);
    }
      int w = i*(i+1)/2;
    for(int times = 0; i+times < k ; times++){
      w += i+times;
      vec[cnt].push_back(w);
     
    }
    cnt++;
  }
  
  for(int s = 0; s < k; s++){
    vec[cnt].push_back( ( (s*(s+1))/2 )+1 );
  }
  
  cnt++;
  
  for(int t = (k*(k-1))/2 + 1; t <= k*(k+1)/2; t++){
    vec[cnt].push_back( t );
  }
  
  cnt++;
  
  for(int u = 1; u <= k; u++){
    vec[cnt].push_back( (u*(u+1) )/2);
  }
  
  printf("%s\n", "Yes");
  printf("%d\n", k+1);
  
  for(int i = 0; i <= k; i++){
    printf("%d ", (int)vec[i].size());
    for(auto n : vec[i]){ printf("%d ", n);}
    printf("\n");
  }
  
  return 0;
}
    
  


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

int main(){
  map<ll,ll> mp;
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) mp[a[i]]++;
  for(auto m:mp){
    if(m.second!=1){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,x;cin>>n>>x;
    vector<ll> a(n);
    ll tot=0;
    ll maxi=0;
    int y=-1;
    rep(i,n){
        cin>>a[i];
        tot+=a[i];
    }
    rep(i,n-1){
        ll buf=a[i]+a[i+1];
        if(chmax(maxi,buf))y=i;
    }
    if(maxi<x){
        cout<<"Impossible"<<endl;
        return 0;
    }
    vector<int> t;
    rep(i,y){
        t.push_back(i+1);
    }
    for(int i=n-1;i>y;i--){
        t.push_back(i);
    }
    cout<<"Possible"<<endl;
    rep(i,n-1){
        cout<<t[i]<<endl;
    }
}

Measured memory_bytes: 4692
bingo = [1,1,1,1,1,1,1,1,1]
bingo[0] , bingo[1] , bingo[2] = map(int, input().split())
bingo[3] , bingo[4], bingo[5] = map(int, input().split())
bingo[6], bingo[7], bingo[8] = map(int, input().split())
n = int(input())
ls = []
counter = 0
for i in range(n):
  ls.append(int(input()))
 
for i in range(len(bingo)):
  for j in range(len(ls)):
    if ls[j] == bingo[i]:
      bingo[i] = 0
      break
for i in range(len(bingo)):
  if i == 0:
    if bingo[i] + bingo[i+1] + bingo[i+2] == 0:
      counter += 1
      break
    elif bingo[i] + bingo[i+3] + bingo[i+6] == 0:
      counter += 1
      break
    elif bingo[i] + bingo[i+4] + bingo[i+8] == 0:
      counter += 1
      break
  elif i == 1:
    if bingo[i] + bingo[i+3] + bingo[i+6] == 0:
      counter += 1
      break
  elif i == 2:
    if bingo[i] + bingo[i+3] + bingo[i+6] == 0:
      counter += 1
      break
    elif bingo[i] + bingo[i+2] + bingo[i+4] == 0:
      counter += 1
      break
  elif i == 3:
    if bingo[i] + bingo[i+1] + bingo[i+2] == 0:
      counter += 1
      break
  elif i == 6:
    if bingo[i] + bingo[i+1] + bingo[i+2] == 0:
      counter += 1
      break
if counter > 0:
  print("Yes")
else: 
  print("No")

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

#define ll long long

int main()
{
    std::string S;
    std::cin >> S;

    int size = S.size();
    if(S[size-1] == 's') {
        std::cout << S << "es" << std::endl;
    }
    else {
        std::cout << S << 's' << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;
static const double pi = 3.141592653589793;
 double DegreeToRadian(double degree){
  return degree * pi / 180.0;
 }

string S;

signed main(){
  
  double A,B,H,M;cin>>A>>B>>H>>M;
  double deg1,deg2;
  deg1=(H/12+(M/60)/12)*2*pi;
  deg2=(M/60)*2*pi;
  // print(deg1,deg2);
  double ans=A*A+B*B-2*A*B*cos(deg1-deg2);
  ans=sqrt(ans);
  print(ans);



}


Measured memory_bytes: 4276
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    int a[3][3], b[10];
    bool state[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
            state[i][j] = false;
        }
    }

    int n;  cin >> n;
    for(int i = 0; i < n; i++){
        cin >> b[i];
        for(int k = 0; k < 3; k++){
            for(int j = 0; j < 3; j++){
                if(a[k][j] == b[i]){
                    state[k][j] = true;
                }
            }
        }
    }

    bool ok = false;
    for(int i = 0; i < 3; i++){
        bool okTmp = true;
        for(int j = 0; j < 3; j++){
            if(!state[i][j]){
                okTmp = false;
            }
        }
        if(okTmp){
            ok = true;
        }
    }

    for(int i = 0; i < 3; i++){
        bool okTmp = true;
        for(int j = 0; j < 3; j++){
            if(!state[j][i]){
                okTmp = false;
            }
        }
        if(okTmp){
            ok = true;
        }
    }

    bool okTmp = true;
    for(int i = 0; i < 3; i++){
        if(!state[i][i]){
            okTmp = false;
        }
    }
    if(okTmp){
        ok = true;
    }

    okTmp = true;
    for(int i = 0; i < 3; i++){
        if(!state[2-i][i]){
            okTmp = false;
        }
    }
    if(okTmp){
        ok = true;
    }

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }




    return 0;
}


Measured memory_bytes: 256
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* Author :  lethuc_upcoder.hcmup.edu.vn
* Hà Lan
Có phải bao nhiêu lâu nay em không theo tôi về làng
Phố xá đông vui đã níu chân em ngày tháng
Khóm hoa vàng ươm thiên lý đong đưa nắng hắt bên nhà
Giữa nơi thật quen tôi kiếm xa xăm tuổi thơ
 
Có phải em đi là giấc mơ đi, ký ức riêng tôi ở lại
Áo trắng tôi thương những hôm chiều tà như vẫn bay qua
Chuyến xe thời gian bỗng nhiên một ngày đưa ta đến miền đất lạ
Vẫn nghe xao xuyến có hôm nhớ làng còn nguyên thiết tha
 
Bởi em từng ở nơi đó
Bởi em từng yêu nơi đó nên tôi về thấy cả một thời
Bởi tôi từng gửi trong gió
Vẫn vương người con gái có đôi mắt tựa sông xanh bầu trời
 
Những khi hái sim trên đồi
Và dưới trăng em là thiên sứ
Ngày ấy tôi thương em mất rồi
Để lớn khôn chỉ toàn nhung nhớ
_._._._._._._._._._._._._._._._._._._._._.*/
 
#include  <bits/stdc++.h>
#define ll long long
#define db(x) cerr << #x << " = " << (x) << " ";
#define ms(s, n) memset(s, n, sizeof(s))
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
using namespace std;
 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){ 
    return (a.second < b.second);
} 
 
bool cmpdec(int a,int b){
        return a>b;
}
 
ll q,n;
 
int main(){
  char c;
  cin >> c;
  cout << (char)((int)c+1);
 
  cerr << "\nTime elapsed: " << 1000*clock() / CLOCKS_PER_SEC << "ms\n";
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  bool guusuu = true;
  for(int i = 0;i <= n - 1;i++){
    int num = 0;
    cin >> num;
    if(num % 2 == 1)guusuu = false;
  }
  if(guusuu)cout << "second" << endl;
  else cout << "first" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
//#include<stdio.h>
using namespace std;
int main(){
  /*int a,b;
    cin>>a>>b;*/
   /* int c,d,e;
    c=a+b;
    d=a-b;
    e=a*b;
    if(c<d){
        c=d;
    }
    if(c<e){
        c=e;
    }
    cout<<c<<endl;*/
    int A, B; cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
    return 0;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
namespace IO
{
	template <typename T> inline void read(T &x)
	{
		int f = 1; x = 0; char c = getchar();
		for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
		for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
		x *= f;
	}

	template <typename T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }
	template <typename T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }

	template <typename T> inline void write(T x)
	{
		if (x < 0) putchar('-'), x = -x;
		if (x > 9) write(x / 10);
		putchar(x % 10 + '0');
	}
	template <typename T> inline void writesp(T x) { write(x); putchar(' '); }
	template <typename T> inline void writeln(T x) { write(x); putchar('\n'); }
}
using namespace IO;
const int N = 2e5 + 5;
int n, a[N];
ll sum;
int main(){
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1);
	
	int npos = 1, cnt = 1;
	for (int i = 2; i <= n; i++)
	{
		sum += a[npos];
		cnt++;
		if (cnt == 2) {
			npos++;
			cnt = 0;
		}
	}
	writeln(sum);
  return 0;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define MAX (ll)(5e3 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

ll mult (ll a, ll b) {
	return ((a % MOD) * 1LL * (b % MOD)) % MOD;
}

ll add (ll a, ll b) {
	return (a + b) % MOD;
}

int main () {
	ll n;
	cin >> n;
	ll a[n], ar[61][n];
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		for (ll j = 0; j <= 60; j++) {
			if ((a[i] >> j) & 1) {
				ar[j][i] = 1;
			}
			else {
				ar[j][i] = 0;
			}
		}	
	}
	for (ll i = n - 2; i >= 0; i--) {
		for (ll j = 0; j <= 60; j++) {
			ar[j][i] += ar[j][i + 1];
		}
	}
	ll ans = 0;
	for (ll i = 0; i < n - 1; i++) {
		ll x = n - i - 1;
		for (ll j = 0; j <= 60; j++) {
			if ((a[i] >> j) & 1) {
				ans = add (ans, mult (x - ar[j][i + 1], (1LL << j)));
			}
			else {
				ans = add (ans, mult (ar[j][i + 1], (1LL << j)));
			}
		}
	}
	cout << ans << "\n";
}
	
		
				


Measured memory_bytes: 145536
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index++];return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  list.sort(function(a,b){
  	return a - b;
  });
  myout(list[N / 2] - list[Math.floor(N / 2) - 1]);
}


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

using namespace std;
using ll = long long;

int main()
{
  int N,a;
  int res=0;
  cin >> N;
  rep(i,N){
  	cin >> a;
    if(a%2==1 && (i+1)%2==1) res++;
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int A1,A2,A3;
    cin>>A1>>A2>>A3;
    if((A1+A2+A3)>=22){cout<<"bust"<<endl;}
    else{cout<<"win"<<endl;}
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, M, cnt[100100], g[100100], odd[100100], ans;
vector<int> v[100100], n[100100];

int main () {
        scanf("%d %d", &N, &M);
        fo(i, 0, N) {
                int x;
                scanf("%d", &x);
                cnt[x%M]++;
                v[x%M].PB(x);
        }
        fo(i, 0, M) {
                sort(v[i].begin(), v[i].end());
                fo(j, 0, (int) v[i].size()) {
                        if (!j || v[i][j-1] != v[i][j]) {
                                int x = j; while (x+1 < (int) v[i].size() && v[i][x+1] == v[i][j]) x++;
                                n[i].PB(x-j+1);
                                if (n[i].back()&1) odd[i]++, g[i] += x-j;
                                else g[i] += x-j+1;
                        }
                }
        }

        ans = cnt[0]/2;
        if (M%2 == 0) ans += cnt[M/2]/2;

        for (int i = 1; i < M-i; i++) {
                int a = i, b = M-i;
                if (odd[a] > odd[b]) swap(a, b);
                ans += odd[a], odd[b] -= odd[a], odd[a] = 0;
                while (odd[b] >= 2 && g[a] >= 2) odd[b] -= 2, g[a] -= 2, ans += 2;
                ans += g[a]/2 + g[b]/2;
        }

        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 12416