akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; (i) < (int) (n); (i) ++)
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        long long s = 0;
        map<int, int> cnt;
        rep(i, n) {
                scanf("%d", &a[i]);
                s += a[i];
                cnt[a[i]] ++;
        }
        int q;
        scanf("%d", &q);
        while (q --) {
                int b, c;
                scanf("%d%d", &b, &c);
                int v = cnt[b];
                s += (long long) (c - b) * v;
                cnt[b] = 0;
                cnt[c] += v;
                printf("%lld\n", s);
        }
        return 0;
}


Measured memory_bytes: 8156
def gcd(a, b): 
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

def main():
    n=int(input())
    a=1
    b=1
    for _ in range(n):
        x,y = map(int,input().split())
        n=a//x
        m=b//y
        if a%x!=0:
            n+=1
        if b%y!=0:
            m+=1
        a=max(n,m)*x
        b=max(n,m)*y
    print(a+b)
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 38768
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;

    constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
        if (b <= 0) return 1; if (b == 1) return a % mod; if (b == 2) return (a * a) % mod;
        return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
    }
    constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
        return (a * mpow(b, mod - 2, mod)) % mod;
    }
}

int main() {
    int n; cin >> n;
    vec<int> a(n);
    for (auto &e : a) cin >> e;
    sort(a.begin(), a.end());
    int sum = 0, p = a[0];
    for (int i = 1; i < n; ++i) {
        sum += a[i] - p;
        p = a[i];
    }
    cout << sum << endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    FOR(i, 1, 50000 + 1) {
        if ((int)(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}


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

namespace ABC128
{
    class C
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int[] k = new int[M];
            int[,] s = new int[M, 20];

            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split(' ');
                k[i] = int.Parse(input[0]);

                for (int j = 1; j <= k[i]; j++)
                {
                    s[i, j] = int.Parse(input[j]);
                    //Console.WriteLine("---");
                    //Console.WriteLine(s[i, j]);
                }
            }

            input = Console.ReadLine().Split(' ');
            int[] p = new int[M];
            for (int i = 0; i < M; i++)
            {
                p[i] = int.Parse(input[i]);
            }

            int[] a = new int[N];
            CalcSw(N, a, M, k, s, p);

            Console.WriteLine(count);

        }

        static int count = 0;
        static void CalcSw(int N, int[] a, int M, int[] k, int[,] s, int[] p)
        {
            if (N == 0)
            {
                // foreach (var x in a) { Console.Write(x); }
                // Console.WriteLine();

                // 一番下まできたら、Mとｋでループして、
                // 電気がついているかどうかを確認する
                // 計算したらメモ化再帰のでカウントする
                int c = 0;
                for (int i = 0; i < M; i++)
                {
                    c = 0;
                    //Console.WriteLine("------");
                    for (int j = 1; j <= k[i]; j++)
                    {
                        //Console.WriteLine(s[i, j]);
                        if (a[s[i, j] - 1] == 1) { c++; }
                    }
                    //Console.WriteLine();
                    //Console.WriteLine("------");
                    if ((c % 2) != p[i]) { return; }
                }
                count++;
                return;
            }

            //ここでスイッチの状態を固定する処理を書く
            N--;
            a[N] = 0;
            CalcSw(N, a, M, k, s, p);
            a[N] = 1;
            CalcSw(N, a, M, k, s, p);
        }
    }
}


Measured memory_bytes: 13140
as=(65..90).to_a.map{|e|e.chr}
N=gets.to_i
s=gets.chomp.codepoints.map{|e|e.chr}
ans=Array.new{s.size}
(s.size).times do |i|
    idx=as.index(s[i])
    ans[i]=as[(idx+N)%26]
end
puts ans.join


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

int main(){

    int n;
    string str1,str2;

    int cnt1 = 0;
    int cnt2 = 0;

    cin >> n;
    for (int i = 0; i < n; i++){

        cin >> str1 >> str2;
        if (str1 > str2){
            cnt1 += 3;
        } else if (str1 == str2){
            cnt1 += 1;
            cnt2 += 1; 
        } else {
            cnt2 += 3;
        }

    }

    cout << cnt1 << " " << cnt2 << endl;

    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

int main()
{
  int a, b;
  while (cin >> a >> b) {
    cout << a + b << endl;
  }
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

Measured memory_bytes: 256
L = int(input())
N = L.bit_length()
C = []
for i in range(N-1):
    C.append((N-i-1, N-i, 1 << i))
    C.append((N-i-1, N-i, 0))
v = 1
for i in range(N-1):
    if v & L:
        L ^= v
        C.append((1, N-i, L))
    v <<= 1
print(N, len(C))
for x, y, z in C:
    print(x, y, z)


Measured memory_bytes: 3064
import sys
v, e, r = map(int, input().split( ))
E = [[] for _ in range(v)]
inf = 10**12
for _ in range(e):
    s,t,d = map(int, input().split( ))
    E[s].append([t,d])


D = [inf for _ in range(v)]
D[r] = 0
"""
間違い
for ve in range(v):
    for ed in E[ve]:
        D[ed[0]] = min(D[ed[0]], D[ve] + ed[1])
    print(*D)
"""
for _ in range(v):
    for ve in range(v):
        for ed in E[ve]:
            D[ed[0]] = min(D[ed[0]], D[ve] + ed[1])

for i in range(v):
    if E[i]:
        for ed in E[i]:
            if D[i] + ed[1] < D[ed[0]] and D[ed[0]]<inf//10:
                print("NEGATIVE CYCLE")
                sys.exit()

for i in range(v):
    if D[i]<inf//100:
        print(D[i])
    else:
        print("INF")





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

main() {
  int n, sum;
  cin >>n;
  int a[101];
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  for(int i=0;i<n;i++) {
    sum += a[i]*(i%2?-1:1);
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    while True:
        s = input().split()
        if s[1] == '+':
            print(int(s[0]) + int(s[2]))
        
        elif s[1] == '-':
            print(int(s[0]) - int(s[2]))
        
        elif s[1] == '*':
            print(int(s[0]) * int(s[2]))
        
        elif s[1] == '/':
            print(int(int(s[0]) / int(s[2])))
        
        else:
            sys.exit()
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, d;
    cin >> n >> d;
    cout << (n + 2 * d) / (2 * d + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
function selectionSort(lgh, arr) {
  var count = 0;
  for(let i = 0; i < lgh-1; i++) {
    var tmp = i;
    for(let j = i; j < lgh; j++) {
      if(Number(arr[j]) < Number(arr[tmp])) {
        tmp = j;
      }
    }
    if(i != tmp) {
      [arr[i], arr[tmp]] = [arr[tmp], arr[i]];
      count++;
    }
  }
  console.log(arr.join(" "));
  return count;
}
function Main(input) {
  var [a, b] = input.split("\n");
  console.log(selectionSort(a, b.split(" ")));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

struct Shop {
	long long int price;
	int count;
};

int main() {
  int N, M;
	std::cin >> N >> M;
	std::vector<Shop> shops(N);
	for (int i=0; i<N; i++) {
	  std::cin >> shops[i].price >> shops[i].count;
	}

	std::sort(
	  shops.begin(), shops.end(),
		[](const Shop& lhs, const Shop& rhs) {
			return lhs.price < rhs.price;
		}
	);
	long long int cost = 0;
	int count = 0;
	for (int i=0; i<N; i++) {
		if (count + shops[i].count < M) {
		  cost += shops[i].count * shops[i].price;
			count += shops[i].count;
		} else {
		  int n_remain = M - count;
			cost += shops[i].price * n_remain;
			break;
		}
	}

	std::cout << cost << std::endl;
	return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>

int main()
{

    int a[5],flag=0, i;

    for(i=0;i<5;i++){
        scanf("%d",&a[i]);
    }

    for(i=0;i<5;i++){
        if(a[i]==0){
           flag=i;
           break;
        }
    }

    printf("%d",flag+1);
    return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h> 
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
int f[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    string a,b;
    int aa,bb;
    cin>>a>>b>>aa>>bb;
    string c;
    cin>>c;
    if(c==a) aa--;
    if(c==b) bb--;
    cout<<aa<<' '<<bb<<endl;
    return 0;
}

Measured memory_bytes: 256
N,X = map(int,input().split())
L = list(map(int,input().split()))

ruiseki = [0 for _ in range(N+1)]
for i in range(N):
    ruiseki[i+1] += ruiseki[i] + L[i]

ruiseki = list(filter(lambda x: x <= X,ruiseki))
print(len(ruiseki))

Measured memory_bytes: 38384
#include "cstdio"
using namespace std;
typedef long long ll;
int a[200005],d[200005],ans[200005],f[200005];
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        d[a[i]]=i;
    }
    for(i=n-1;i>=1;i--)
    {
        if(ans[i+1]==0)
        {
            if(d[i]>d[i+1])
            {
                ans[i]=1;
                f[i]=i+1;
            }
        }
        else
        {
            int aa=d[i],bb=d[i+1],cc=d[f[i+1]];
            if((aa<bb&&bb<cc)||(cc<aa&&aa<bb)||(bb<cc&&cc<aa))
            {
                ans[i]=ans[i+1];
                f[i]=f[i+1];
            }
            else
            {
                ans[i]=ans[i+1]+1;
                f[i]=i+1;
            }
        }
    }
    printf("%d\n",ans[1]);
    return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a = ivec(n);
    vec b = a;

    sort(all(b));
    if (b[0] != 1) {
        print(-1);
        return 0;
    }

    int nex = 1;
    rep (i, n)
        if (a[i] == nex) nex++;

    print(n - (nex - 1));

    return 0;
}


Measured memory_bytes: 3328
s = int(input())


N = 1000000

a = [0]*N
a[0] = s
for i in range(0,N):
	if a[i]%2 == 0:
		a[i+1] = a[i]/2
	if a[i]%2 == 1:
		a[i+1] = 3*a[i]+1
	
	for j in range(0,i):
		if a[j] == a[i]:
			print(i+1)
			exit()


Measured memory_bytes: 10868
#include <stdio.h>         //█████████████████████████████
#include <stdlib.h>        //█                           █
#include <math.h>          //█        ▄▀▄     ▄▀▄        █
#include <string.h>        //█       ▄█░░▀▀▀▀▀░░█▄       █
#include <ctype.h>         //█   ▄▄  █░░░░░░░░░░░█  ▄▄   █
#include <iostream>        //█  █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█  █
#include <algorithm>       //█████████████████████████████
#include <string>
#include <vector>

using namespace std;

#define U unsigned
#define S short
#define L long
#define LL long long 
#define LLU long long unsigned

#define rd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%d", &arr[aab]);}
#define pd(arr, n) for(int aab = 0; aab < n; aab++){printf("%d ", arr[aab]);}
#define rlld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lld", &arr[aab]);}
#define plld(arr, n) for(int aab = 0; aab < n; aab++){printf("%lld ", arr[aab]);}
#define rllu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%llu", &arr[aab]);}
#define pllu(arr, n) for(int aab = 0; aab < n; aab++){printf("%llu ", arr[aab]);}
#define rlf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lf", &arr[aab]);}
#define plf(arr, n) for(int aab = 0; aab < n; aab++){printf("%lf ", arr[aab]);}
#define rc(arr, n) for(int aab = 0; aab < n; aab++){scanf("%c", &arr[aab]);}
#define pc(arr, n) for(int aab = 0; aab < n; aab++){printf("%c", arr[aab]);}
#define rs(arr) scanf("%s", arr);
#define ps(arr) puts(arr);

#define swap(a, b) {int temp = a;a = b;b = temp;}
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

int min(int a, int b){	return a <= b ? a : b;}
int max(int a, int b){	return a >= b ? a : b;}
int findmin(int arr[], int n){int min = 0;for(int i = 1; i < n;min = arr[i] < arr[min] ? i : min, i++);return min;}
int findmax(int arr[], int n){int max = 0;for(int i = 1; i < n;max = arr[i] > arr[max] ? i : max, i++);return max;}
int arrsum(int arr[], int n){int sum = 0;for(int i = 0; i < n; sum += arr[i], i++);return sum;}
	
int main(){
	int n, m;

	scanf("%d %d", &n, &m);

	int arr[n];

	for(int i = 0; i < n; i++){
		scanf("%d", &arr[i]);
	}

	sort(arr, arr + n, greater<int>());

	double needed = (arrsum(arr, n) / (4.0 * m));

	for(int i = 0; i < m; i++){
		if(arr[i] < needed){
			printf("No");
			return 0;
		}
	}

	printf("Yes");

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a;
    string s;
    cin >> a >> s;
    if (a < 3200) cout << "red\n";
    else cout << s << '\n';
    return 0;
}


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

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


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

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

    bool ans = (N >= 30);
    cout << YesNo(ans) << BR;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

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

    for (int i=x-k+1; i<k+x; i++){
        if (i != x-k+1) cout << " ";
        if (i < 1000001 && i > -1000001) cout << i; 
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, S.size() - T.size() + 1) {
    int temp = 0;
    rep(j, T.size()) {
      if(S[i+j] == T[j]) temp++;
    }
    ans = max(ans, temp);
  }
  cout << T.size() - ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>

#define ll long long
using namespace std;

vector<ll> layer;
vector<ll> pati;

ll eat_pati(int n, ll x){

    if(n == 1){
        if(x == 5) return 3;
        if(x == 0) return 0;
        return x - 1;
    }

    if(layer[n - 1] + 1 >= x){
        return eat_pati(n - 1, x - 1);
    }else if(layer[n - 1] + 2 == x){
        return eat_pati(n - 1, x - 2) + 1;
    }else if(layer[n - 1] * 2 + 2 >= x){
        return pati[n - 1] + 1 + eat_pati(n - 1, x - 2 - layer[n - 1]);
    }else return pati[n - 1] * 2 + 1;
}

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

    layer.push_back(1);
    pati.push_back(1);

    for(int i = 1; i <= n; i++){
        layer.push_back(layer[i - 1] * 2 + 3);
        pati.push_back(pati[i - 1] * 2 + 1);
    }

    cout << eat_pati(n, x) << endl;

    return 0;
}

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

int main(){
  int e[15];
  int result=0;
  for(int i=0;i<12;i++)
    cin>>e[i];
  for(int i=0;i<12;i++){
    int a=e[i];
    int ege=0;
    for(int j=0;j<12;j++){
      if(e[j]==a){
	ege++;
      }
    }
  if(ege%4==0)
    result++;
  if(ege/4==3)
    result=12;
  }
  if(result==12)
    cout<<"yes\n";
  else
    cout<<"no\n";
  return 0;
}



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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> a[n];
    for (int i = 0; i < n; i++) a[i] = vector<int>(m, 0);
    for (int i = 0; i < n; i++) for (int k = 0; k < m; k++) cin >> a[i][k];
    int ans = -1;
    vector<int> play(m+1, 1);
    for (int i = 0; i < m-1; i++) {
        vector<int> tops(n);
        for (int k = 0; k < n; k++) {
            int t;
            for (int l = 0; l < n; l++) {
                if (play[a[k][l]]) {
                    t = a[k][l];
                    break;
                }
            }
            tops[k] = t;
        }
        sort(tops.begin(), tops.end());
        int cur = 1;
        int maxCon = 0;
        vector<int> maxVals;
        for (int k = 1; k < n; k++) {
            if (k == n-1) {
                if (tops[k] == tops[k-1]) {
                    cur++;
                    if (maxCon < cur) {
                        maxCon = cur;
                        maxVals.clear();
                        maxVals.push_back(tops[k]);
                    } else if (maxCon == cur) {
                        maxVals.push_back(tops[k]);
                    }
                } else {
                    if (maxCon < cur) {
                        maxCon = cur;
                        maxVals.clear();
                        maxVals.push_back(tops[k-1]);
                    } else if (maxCon == cur) {
                        maxVals.push_back(tops[k-1]);
                        if (maxCon == 1) maxVals.push_back(tops[k]);
                    }
                }
            }
            if (tops[k] == tops[k-1]) {
                cur++;
            } else {
                if (maxCon < cur) {
                    maxCon = cur;
                    maxVals.clear();
                    maxVals.push_back(tops[k-1]);
                } else if (maxCon == cur) {
                    maxVals.push_back(tops[k-1]);
                }
                cur = 1;
            }
        }
        for (int k = 0; k < n; k++) {
            for (auto &mv : maxVals) {
                play[mv] = 0;
            }
        }
        if (ans < 0) ans = maxCon;
        else ans = min(ans, maxCon);
    }
    if (ans < 0) cout << n << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
#include <limits>
#include <string>

#define INT_MAX 2147483647
#define INT_MIN -2147483647
using namespace std;

void bubble_sort(vector<pair<char, int> > &data)
{
	for (int i = 1; i < data.size(); ++i)
	{
		for (int j = data.size() - 1; j>=i; --j)
		{
			if (data[j].second < data[j - 1].second)
				swap(data[j], data[j - 1]);
		}
	}
}

void select_sort(vector<pair<char, int> > &data)
{
	for (int i = 0; i < data.size(); ++i)
	{
		int idx = i;
		for (int j = i + 1; j < data.size(); ++j)
		{
			if (data[j].second < data[idx].second)
			{
				idx = j;
			}
		}
		swap(data[i], data[idx]);
	}
}

void print(vector<pair<char, int> > &data)
{
	for (int i = 0; i < data.size() - 1; ++i)
		cout << data[i].first << data[i].second << " ";

	cout << data.back().first << data.back().second << endl;
}

bool equal(vector<pair<char, int> > &data1, vector<pair<char, int> > &data2)
{
	for (int i = 0; i < data1.size() -1; ++i)
	{
		if (data1[i] != data2[i])
			return false;
	}
	return true;
}

int main()
{
	vector<pair<char, int> > data1, data2;

	int num = 0;
	cin >> num;

	string s;
	while (cin >> s)
		data1.push_back(make_pair(s[0], s[1] - '0'));
	data2.assign(data1.begin(), data1.end());

	bubble_sort(data1);
	select_sort(data2);

	print(data1);
	cout << "Stable" << endl;
	print(data2);
	cout << (equal(data1, data2) ? "Stable" : "Not stable") << endl;

	return 0;
}

Measured memory_bytes: 3136
#include <iostream>

int main(int argc, char const* argv[])
{
    int x, a, b;
    std::cin >> x >> a >> b;

    x -= a;
    while(true)
    {
        x -= b;
        if(x < 0)
        {
            x += b;
            break;
        }
    }
    std::cout << x << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int m,d;
cin>>m>>d;
int ans=0;

rep(i,1,d)
{
	int x=i/10,y=i%10;
	if(x<2||y<2)continue;
	if(x*y>=1&&x*y<=m)ans++;
}
ol(ans);

return 0;
}



Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#define ll long long
using namespace std;



int main(){
  ll H,A;
  cin>>H>>A;
  if(H%A!=0)
  cout<<H/A+1<<endl;
  if(H%A==0)
    cout<<H/A<<endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = 510;
char s[maxn][maxn];
int n, m;

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  return 1;
}

char ans[maxn];

void solve() {
  for (int iter = 0; iter < 2; ++iter) {
    for (int i = 0; i < n; ++i) {
      ans[m] = 0;
      for (int j = 0; j < m; ++j) {
        ans[j] = s[i][j];
        if ((!iter && !i) || (iter && i == n - 1)) {
          ans[j] = '#';
        }
        if ((!iter && !(j & 1) && i < n - 1) || (iter && (j & 1) && i)) {
          ans[j] = '#';
        }
      }
      printf("%s\n", ans);
    }
    if (!iter) {
      printf("\n");
    }
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

//Programming Contest
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		int r = 0;
		for(int i=0;i<m;i++){
			int c = 0;
			for(int j=0;j<n;j++)c+=sc.nextInt()==1?1:0;
			r = Math.max(r, c);
		}
		System.out.println(r);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int n, m, x;
vector<int> c;
vector<vector<int>> a;

template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    cin >> n >> m >> x;
    c.resize(n);
    a.resize(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = INT_MAX;
    for (int i = 0; i < (1 << n); i++) {
        bitset<12> b(i);
        vector<int> rikai(m, 0);
        int sum_c = 0;
        for (int j = 0; j < n; j++) {
            if (b[j]) {
                sum_c += c[j];
                for (int k = 0; k < m; k++) {
                    rikai[k] += a[j][k];
                }
            }
        }
        bool flag = true;
        for (int j = 0; j < m; j++) {
            if (rikai[j] < x) {
                flag = false;
                break;
            }
        }
        if (flag) {
            chmin(ans, sum_c);
        }
    }
    if (ans != INT_MAX) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v(0) {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<TEN(9) + 7>;

const int MF = TEN(6) + TEN(5);
V<Mint> fact(MF + 1), iFac(MF + 1);
void first() {
    fact[0] = 1;
    for (int i = 1; i <= MF; i++) fact[i] = fact[i-1] * Mint(i);
    iFac[MF] = fact[MF].inv();
    for (int i = MF; i >= 1; i--) iFac[i-1] = iFac[i] * Mint(i);
    assert((fact[114] * iFac[114]).v == 1);
}

Mint C(int n, int k) {
    if (n < k || n < 0) return Mint(0);
    return fact[n] * iFac[k] * iFac[n - k];
}

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

    int h, w;
    cin >> h >> w;
    VV<Mint> dp(h, V<Mint>(w)); dp[0][0] = Mint(1);
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == '#') continue;
            if (i) dp[i][j] += dp[i-1][j];
            if (j) dp[i][j] += dp[i][j-1];
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
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); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    if(N < B) cout << ((A*N)/B) - A*(N/B) << endl;
    else cout << (A*(B-1)/B) << endl;
    return 0;
}


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

int main(){
    i64 n,m,sum=0,a;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a;
        sum+=a;
    }
    cout<<(sum>n?-1:n-sum)<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

ll modpow(ll n,ll r){
  ll res = 1;
  while(r){
    if(r & 1)res = res*n%MOD;
    n = n*n%MOD;
    r >>= 1;
  }
  return res;
}

vector<ll> f(2000100,1),rf(2000100,1);
void init(){
  rep(i,2000000)f[i+1] = f[i]*(i+1)%MOD;
  rf[2000000] = modpow(f[2000000],MOD-2);
  for(int i = 2000000;i > 0;i--)rf[i-1] = rf[i]*i%MOD;
}
ll comb(ll n,ll r){
  ll res = f[n]*rf[r]%MOD;
  res = res*rf[n-r]%MOD;
  return res;
}

int main(){
  
  init();
  int k;
  string s;
  cin >> k >> s;
  int size = s.size();
  ll res = 0;
  for(int i = 0;i <= k;i++){
    ll m = modpow(26,i)*modpow(25,k-i)%MOD;
    m = m*comb(size+k-i-1,size-1)%MOD;
    res = (res+m)%MOD;
  }
  cout << res << "\n";
  

  return 0;
}

Measured memory_bytes: 36584
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl "\n"
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fb(i, a, b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector <int>
#define vl vector <long long>
#define pi pair <int, int>
#define sz(x) (int) x.size()
#define M 100005
#define mod 1000000007
using namespace std;

void solve()
{
	ll n, W, ans = 0;
	cin>>n>>W;
	ll w[n+1], v[n+1], dp[W+1][n+1] = {};
	f(i, 1, n+1) cin>>w[i]>>v[i];
	f(i, 0, W+1) dp[i][0] = 0;
	f(i, 0, n) dp[0][i] = 0;
	f(i, 1, W+1)
	{
		f(j, 1, n+1)
		{
			ll x = 0, y = 0;
			if(i-w[j] >= 0) x = dp[i-w[j]][j-1] + v[j];
			y = dp[i][j-1];
			dp[i][j] = max(x, y);
		}
	}
	f(i, 0, W+1) ans = max(ans, dp[i][n]);
	cout<<ans;
}

int main()
{
    IOS
    int t = 1;
    //cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

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

int main(void) {
  int n; cin >> n;
  bool flag = false;
  
  for (int i=0; i<25; i++) {
    for (int j=0; j<15; j++) {
      if (4 * i + 7 * j == n) {
        flag = true;
      }
    }
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(s.nextInt()<1200?"ABC":"ARC");

    }



}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25368
#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <cassert>
#include <complex>
#include <time.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<"="<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;


int main()
{

	//freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin >> s;
	stack<char> st;
	FOR(i, 0, SZ(s))
	{
		if (st.empty()) st.push(s[i]);
		else
		{
			if (s[i] == 'T' && st.top() == 'S') st.pop();
			else st.push(s[i]);
		}
	}
	cout << SZ(st) << endl;

	return 0;
}



Measured memory_bytes: 720
N, Y = map(int, input().split())
flg = False
for i in range(N+1):
    for j in range(N+1):
        if N - i - j < 0:
            continue
        if (i*10000 + j*5000 + (N-i-j)*1000) == Y:
            flg = True
            break
    if flg:
        break
if flg:
    print(i, j, N-i-j)
else:
    print("-1 -1 -1")



Measured memory_bytes: 9076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		while(true){
		int a = sc.nextInt();
		String p = sc.next();
		int b = sc.nextInt();

		if(p.equals("+")) {
			System.out.println(a + b);
		}
		else if(p.equals("-")) {
			System.out.println(a - b);
		}
		else if(p.equals("*"))
			System.out.println(a * b);
		else if(p.equals("/"))
			System.out.println(a / b);
		else if(p.equals("?"))
			break;
		}



	}

}


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


int main(){
    map<int,int> m;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    int count=0;
    for(auto i=m.begin();i!=m.end();i++){
        if(i->first!=i->second){
          //  count=count+ min(abs(i->first - i->second),i->second);
          if(i->first > i->second){
              //count+= abs(i->first - i->second);
              count+= i->second;
          }
          else{
              //count+= i->second;
               count+= abs(i->first - i->second);
          }
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define INF 100000000
#define uint unsigned int
#define MOD 1e9+7
using namespace std;

bool judge(char &s) {
	if (s == 'A' || s == 'T' || s == 'G' || s == 'C') {
		return 1;
	}
	else {
		return 0;
	}
}
int main() {
	string s;
	cin >> s;
	int count = 0;
	int answer = 0;
	rep(i, s.size()) {
		if (judge(s.at(i))) {
			count++;
			if (count > answer) {
				answer = count;
			}
		}
		else {
			count = 0;
		}
	}

	cout << answer;
}

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll a,b;
    cin>>a>>b;
    if(a+b==(a+b)/2*2)
    cout<<(a+b)/2;
    else 
    cout<<"IMPOSSIBLE";
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3604
# Https://atcoder.jp/contests/abc151/tasks/abc151_d

from collections import deque

H, W = map(int, input().split())
maze = [list(input()) for i in range(H)]


def bfs(sx, sy):
    result = 0
    count = [[-1] * W for i in range(H)]
    count[sx][sy] = 0
    d = deque()
    d.append((sx, sy))
    while d:
        x, y = d.popleft()
        result = count[x][y]
        for i, j in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            tx, ty = x + i, y + j
            if (
                not (0 <= tx < H)
                or not (0 <= ty < W)
                or maze[tx][ty] == "#"
                or count[tx][ty] != -1
            ):
                continue
            else:
                count[tx][ty] = count[x][y] + 1
                d.append((tx, ty))
    return result


ans = 0
for i in range(W):
    for j in range(H):
        if maze[j][i] == ".":
            ans = max(ans, bfs(j, i))
print(ans)


Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll a,b,c,x=0,i=0;
    cin>>a>>b>>c;
    
    while(x<c){
        x+=a;
        i++;
        if(i%7==0){
            x+=b;
        }
    }
    cout<<i<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 200010
inline int read(){
	char ch=getchar(); int x=0;
	for (;ch>'9'||ch<'0';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}
int n,X,x[N],S[N],P[N];
signed main(){
	n=read(); X=read();
	for (int i=1;i<=n;i++) x[i]=read(),S[i]=S[i-1]+x[i];
	P[1]=5; for (int i=2;i<=n;i++) P[i]=2*i+1;
	int ans=9e18;
	for (int k=1;k<=n;k++){
		int tmp=0,p=n;
		for (int i=1;p>0;p-=k,i++){
			tmp+=(S[p]-S[max(p-k,0LL)])*P[i];
			if (tmp>ans) break;
		}
		tmp+=X*k;
		if (tmp<ans) ans=tmp;
	}
	printf("%lld\n",ans+n*X);
	return 0;			
}

Measured memory_bytes: 4992
H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    a.append(s)

isUseRow = [True] * H
isUseCol = [True] * W

for i in range(H):
    isDelete = True
    for j in range(W):
        if(a[i][j] == '#'):
            isDelete = False
    if(isDelete == False):
        isUseRow[i] = False
for i in range(W):
    isDelete = True
    for j in range(H):
        if(a[j][i] == '#'):
            isDelete = False
    if(isDelete == False):
        isUseCol[i] = False

for i in range(H):
    s = ''
    for j in range(W):
        if(isUseRow[i] == False and isUseCol[j] == False):
            s += a[i][j]
    if(s != ''):
        print(s)

Measured memory_bytes: 3064