akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;
#define ll long long

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################

int main() {
  string s,t;
  cin>>s>>t;
  int cnt=0;
  for(int i=0;s[i];i++){
      if(s[i]!=t[i])cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl


signed main(void){
    string S;
    cin >> S;
    int k=S.size();
    int y=0;
    REP(i,k){
        if(S[i]=='x')y++;
    }
    if(y>=8){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = -1;
		int maxix = 21;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int v = sc.nextInt();
			if (v > max) {
				max = v;
				maxix = a;
			} else if (v == max && maxix > a) {
				maxix = a;
			}
		}

		System.out.println(maxix + " " + max);
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int a,b,c; cin>>a>>b>>c;
  int d=a+b+c;
  
  if(d>=22){
    cout<<"bust"<<endl;
    
  }else{
    cout<<"win"<<endl;
  }
  
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define int long long

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

signed main()
{
  int n;
  cin >> n;
  vi a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  int bsum = 0;
  vi c(n);
  rep(i, n){
    bsum += b[i];
    c[i] = a[i] + b[i];
  }

  sort(all(c));
  reverse(all(c));

  int ans = 0;
  rep(i, n){
    if(i%2 == 0){
      ans += c[i];
    }
  }

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


Measured memory_bytes: 2560
#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;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<int> d(n-1);
  rep(i, n-1) d[i] = a[i+1] - a[i];
  ll ans = 0;
  int l = 1, r = n-1;
  rep(i, n-1) ans += (ll)d[i] * 2 * min(l++, r--);
  if (n % 2 == 1) ans -= min(d[(n-3)/2], d[(n-1)/2]);
  else ans -= d[(n-2)/2];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3972
#include <iostream>
#define INF (2 >> 28)
using namespace std;

int main() {
    int before, after, sum;
    while(cin >> before >> after >> sum, before) {
        int maxi = INF;
        for(int i = 1; i < sum; i++) {
            for(int j = 1; j < sum; j++) {
                if(i + j > sum) break;
                if(i * (100 + before) / 100 + j * (100 + before) / 100 == sum) {
                    maxi = max(maxi, i * (100 + after) / 100 + j * (100 + after) / 100);
                }
            }
        }
        cout << maxi << endl;
    }
}

Measured memory_bytes: 1160
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false INT_MAX INT_MIN insert erase clear pop push compare INT64_MAX INT64_MIN  reverse replace stringstream string::npos length substr front priority_queue
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 7 ;
const int inf =
 1e9 + 5 ;
 //1e18L + 5;
const int nax = 2e5 + 5;
void min_self(int&a , int b){a=min(a,b);}
void max_self(int&a , int b){a=max(a,b);}
void add_self(int&a , int b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int H , A ; 
cin >> H  >> A ; 
cout << (H/A) + int(H%A!=0) << endl;	

	
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
BC=[list(map(int,input().split())) for i in range(m)]
BC=sorted(BC,reverse=True,key=lambda x: x[1])
flag=0
t=0
for i in range(m):
  if flag==1:
    break
  for j in range(t,n):
    if BC[i][1]>A[j]:
      A[j]=BC[i][1]
      BC[i][0]-=1
      t=j+1
      if BC[i][0]==0:
        break
    else:
      flag=1
      break
print(sum(A))

Measured memory_bytes: 33868
use std::cmp;

fn main() {
    let q: usize = {
        let mut s = String::new(); // バッファを確保
        std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
        s.trim_right().to_owned().parse().unwrap() // 改行コードが末尾にくっついてくるので削る
    };
    let mut pairs: Vec<(String, String)> = vec![];
    for i in 0..q {
        let s = read_line_from_stdin();
        let t = read_line_from_stdin();
        pairs.push((s, t));
    }
    for pair in pairs {
        println!("{}", solve(&pair.0, &pair.1));
    }
}

fn read_line_from_stdin() -> String {
    let mut s = String::new(); // バッファを確保
    std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
    s.trim_right().to_owned() // 改行コードが末尾にくっついてくるので削る
}

fn solve(s: &str, t: &str) -> i32 {
    // initialize vec
    let mut dp = vec![];
    for _i in 0..s.len() + 1 {
        dp.push(vec![0; t.len() + 1])
    }
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();
    for i in 0..s.len() {
        for j in 0..t.len() {
            // ** 添字がややこしいので注意 **
            // s[i] と s[j] の比較結果は dp[i + 1][j + 1] に対応する
            // (dp は空文字の添字を 0 としているため)
            if s[i] == t[j] {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = cmp::max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    // println!("{:?}", dp);
    dp[s.len()][t.len()]
}


Measured memory_bytes: 9108
S = input()
l = ['A', 'C', 'G', 'T']

S2 = ''
for i in range(len(S)):
    if S[i] in l:
        S2 += S[i]
    else:
        S2 += '-'
S2 = S2.split('-')
ans = 0
for s in S2:
    if ans < len(s):
        ans = len(s)
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()

	ans := 0
	memo := map[int]int{}
	for i := k; i > 0; i-- {
		memo[i] = mpow(k/i, n)
		for j := 2; j*i <= k; j++ {
			memo[i] = sub(memo[i], memo[i*j])
		}
		ans = add(ans, i*memo[i]%MOD)
	}

	// debug(memo)
	fmt.Fprintln(wr, ans)
}

// MOD constant
const MOD = 1000000007

type pair struct {
	num int
	dep int
}

func add(b,c int) int { a := (b+c)%MOD; if a<0 { a += MOD }; return a }
func sub(b,c int) int { a := (b-c)%MOD; if a<0 { a += MOD }; return a }
func mul(b,c int) int { a := (b*c)%MOD; if a<0 { a += MOD }; return a }
func div(b,c int) int {
	a, p, x, u := c, MOD, 1, 0
	for p != 0 {
		t := a/p
		a, p = p, a-t*p
		x, u = u, x-t*u
	}
	res := b*x%MOD
	if res<0 { res+= MOD }
	return res
}
func mpow(a,n int) int {
	res := 1
	for n>0 {
		if n&1 == 1 { res = res*a%MOD }
		a = a*a%MOD
		n >>= 1
	}
	return res
}


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

using namespace std;

const int N_ = int(1.1e5);

int N;

vector<int> gph[N_];

int low[N_], high[N_];

void dfs (int u, int p = -1) {
  for(int v : gph[u]) if(v != p) {
    low[v] = max(low[v], low[u] - 1);
    high[v] = min(high[v], high[u] + 1);
    dfs(v, u);
    low[u] = max(low[u], low[v] - 1);
    high[u] = min(high[u], high[v] + 1);
  }
}

bool chk (int u, int p, int parity) {
  if(low[u] == high[u] && (low[u] - parity) % 2) {
    return false;
  }
  bool ret = true;
  for(int v : gph[u]) if(v != p) ret &= chk(v, u, !parity);
  return ret;
}

int ans[N_];

void go(int u, int p, int cur) {
  ans[u] = cur;
  for(int v : gph[u]) if(v != p) {
    go(v, u, low[v] <= cur - 1 ? cur - 1 : cur + 1);
  }
}

int main() {
#ifdef IN_MY_COMPUTER
  freopen("e.in", "r", stdin);
#endif
  scanf("%d", &N);
  for(int e = 0; e < N-1; e++) {
    int u, v; scanf("%d%d", &u, &v);
    gph[u].push_back(v);
    gph[v].push_back(u);
  }

  for(int i = 1; i <= N; i++) {
    low[i] = -10000000;
    high[i] = 10000000;
  }
  
  {
    int K; scanf("%d", &K);
    while(K--) {
      int v, p; scanf("%d%d", &v, &p);
      low[v] = high[v] = p;
    }
  }

  dfs(1, -1);
  for(int i = 1; i <= N; i++) {
    if(low[i] > high[i]) {
      puts("No");
      return 0;
    }
  }

  if(chk(1, -1, 0)) {
    // parity is 0
    go(1, -1, low[1] + (low[1] % 2));
  }else if(chk(1, -1, 1)) {
    // parity is 1
    go(1, -1, low[1] + (1 - low[1] % 2));
  }else {
    puts("No");
    return 0;
  }
  
  for(int u = 1; u <= N; u++) {
    for(int v : gph[u]) {
      assert(abs(ans[u] - ans[v]) == 1);
    }
  }
  
  puts("Yes");
  for(int i = 1; i <= N; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    int n,i=0,j=1;cin >> n;
    ll ans=0;

    while(n>i){
        if(j%5!=0 and j%3!=0){
            ans+=j;
        }
        i++;
        j++;
    }
    cout << ans << endl;
}





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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<lint> a(n);
    REP(i, n) { cin >> a[i];}
    vector<int> pos(2);//{y座標,x座標}
    //string s="";
    vector<int> v(w);

    REP(i,n){
        REP(j,a[i]){
            if(pos[1]==0){
                //s = "";
            }
            //s += to_string(i+1);
            v[pos[1]] = i+1;

            if(pos[1]==w-1){
                REP(ii,w){
                    int jj;
                    if (pos[0] % 2 == 0)
                    {
                        jj = ii;
                    }else{
                        jj = w - ii - 1;
                    }
                    cout << v[jj] << " ";
                    //if(ii!=w-1){cout << " ";                }
                }
                cout << "\n";
                pos[0] += 1;
                pos[1] = 0;
            }else{
                pos[1] += 1;
            }
        }
    }
    //lint ans;
    //cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
    int a[1000000];
    int n,m;
    int i,j,k;
    int max=0;
    int sum=0;
        
    scanf("%d %d",&n,&m);


    while(n != 0){
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                sum =a[i] + a[j];
                if (sum > max && sum <= m){
                    max = sum;
                }
            }
        }
    if(max == 0){
        printf("NONE\n");
    }else{
        printf("%d\n",max);
    }
    max = 0;
    scanf("%d %d",&n,&m);
    }
}


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

int main(){
  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin>>x1>>y1>>x2>>y2;
  x3=x2-y2+y1;
  y3=y2+x2-x1;
  x4=x1-y2+y1;
  y4=y1+x2-x1;
  cout << x3 <<" "<< y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    a*=10;
    b*=10;
    int x=(a+b)/2;
    int y=(a+b+3600)/2;
    if(x-a<y-b){
        cout<<x/10;
        if(x%10)cout<<".5";
        cout<<endl;   
    }
    else{
        y%=3600;
        cout<<y/10;
       if(y%10)cout<<".5";
        cout<<endl;   

    }
    return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
	int N = 0;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		ans += i;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def swap(A, i, j):
#    print("\tswap Aj:{} Ai:{}\n".format(A[j], A[i]))
    x = A[i]
    A[i] = A[j]
    A[j] = x

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            swap(A, i, j)
#        print("j:{} Aj:{} i:{} Ai:{} Ar:{}".format(j, i, A[j], A[i], A[r]))
#        print(A)
#        print(" ")
    A[r] = "[{}]".format(A[r])
    swap(A,i+1, r)
    i += 1
    return i

def main():
    """ ????????? """
    num = int(input().strip())
    A = list(map(int,input().split()))
    partition(A, 0, num-1)
    print(" ".join(map(str,A)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 18992
#include <bits/stdc++.h>
#define ll long long
using namespace std;
double dis[1005], eps = 1e-9;
int vis[1005];
vector<pair<double, pair<double, double>> > vec(1005);
double two(double one)
{
	return one * one;
}
double get_dist(int ind1, int ind2)
{
	return max(0.0,
			sqrt(
					two((vec[ind1].first - vec[ind2].first))
							+ two(
									vec[ind1].second.first
											- vec[ind2].second.first))
					- (vec[ind1].second.second + vec[ind2].second.second));
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	memset(vis, false, sizeof vis);
	for (int i = 0; i <= 1002; i++)
		dis[i] = 1e18;
	int n, x1, x2, x3, x4;
	cin >> x1 >> x2 >> x3 >> x4 >> n;
	for (int i = 1; i <= n; i++)
		cin >> vec[i].first >> vec[i].second.first >> vec[i].second.second;
	vec[0].first = x1;
	vec[0].second.first = x2;
	vec[n + 1].first = x3;
	vec[n + 1].second.first = x4;
	vec[0].second.second = vec[n + 1].second.second = 0;
	priority_queue<pair<double, int> > pq;
	dis[0] = 0;
	pq.push(make_pair(0.0, 0));
	while (pq.size())
	{
		int ind = pq.top().second;
		pq.pop();
		if (vis[ind])
			continue;
		vis[ind] = 1;
		for (int i = 0; i <= n + 1; i++)
		{
			if (i == ind)
				continue;
			double temp = get_dist(ind, i);
			if (dis[i] - (temp + dis[ind]) > eps)
			{
				dis[i] = temp + dis[ind];
				pq.push(make_pair(-dis[i], i));
			}
		}
	}
	cout << fixed << setprecision(9) << dis[n + 1];
	return 0;
}


Measured memory_bytes: 6512
#include <iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
	int u, minv;
	int d[MAX], p[MAX], color[MAX];
	
	for(int i=0;i < n;++i){
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	
	while(1){
		minv = INFTY;
		u = -1;
		for(int i=0;i < n;++i){
			if(minv > d[i] && color[i] != BLACK){
				u = i;
				minv = d[i];
			}
		}
		if(u == -1) break;
		color[u] = BLACK;
		for(int v=0;v < n;++v){
			if(color[v] != BLACK && M[u][v] != INFTY){
				if(d[v] > M[u][v]){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for(int i=0;i < n;++i){
		if(p[i] != -1) sum += M[i][p[i]];
	}
	return sum;
}

int main(){
	cin >> n;
	
	for(int i=0; i < n;++i){
		for(int j=0; j < n;++j){
			int e; cin >> e;
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}
	
	cout << prim() << endl;
	
	return 0;
}


Measured memory_bytes: 3136
X = input()
# X = 'SSTTST'
# X = 'TSSTTTSS'

# naive case
# len_prev = -1
# while len_prev != len(X):
#     len_prev = len(X)
#     X = X.replace('ST', '')
# print(len(X))


i = 0
cnt = []
X += " "
cur = 1
for i in range(len(X) - 1):
    if X[i] == X[i + 1]:
        cur += 1
    else:
        cnt.append((X[i], cur))
        cur = 1

total = 0
for i in range(len(cnt) - 1):
    if cnt[i][0] == 'S':
        if cnt[i][1] > cnt[i + 1][1]:
            if i + 2 < len(cnt):
                cnt[i + 2] = (cnt[i + 2][0], cnt[i + 2][1] + cnt[i][1] - cnt[i + 1][1])
        total += min(cnt[i][1], cnt[i + 1][1])
print(len(X) - 1 - 2 * total)


Measured memory_bytes: 10976
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n;
    ll a[200010];
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    if(n%2==0){
        for(int i=0;i<n;i+=2){
            cout<<a[n-1-i]<<' ';
        }
        for(int i=0;i<n;i+=2){
            cout<<a[i]<<' ';
        }
        printf("\n");
    }
    else{
     for(int i=0;i<n;i+=2){
            cout<<a[n-1-i]<<' ';
        }
        for(int i=1;i<n;i+=2){
            cout<<a[i]<<' ';
        }
        printf("\n");
    }


    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const ll mod = 1000000007;
int n,a[55],b[55];
int dp[20][1<<18];
int need[20][1<<18];
int main(){
	cin >> n;
	rep(i,n) cin >> a[i] ;
	rep(i,n) cin >> b[i];
	rep(i,20) rep(j,(1<<18)) dp[i][j] = INF;
	rep(i,n) rep(j,(1<<n)){
		if(((j>>i)&1)) continue;
		rep(k,n){
			if(((j>>k)&1)){
				need[i][j] += k > i;
			}
		}
	}
	rep(i,n){
		dp[i][1<<i] = need[i][0];
	}
	rep(mask,(1<<n)){
		rep(i,n){
			if(!((mask>>i)&1)) continue;
			int cur = (i%2) ^ (__builtin_popcount(mask)%2);
			int val;
			if(cur == 1) val = a[i];
			else val = b[i];
			
			rep(j,n){
				if(((mask>>j)&1)) continue;
				int curr = (j%2) ^ (1-__builtin_popcount(mask)%2);
				int vall;
				if(curr == 1) vall = a[j];
				else vall = b[j];
				
				if(val <= vall){
					dp[j][mask|(1<<j)] = min(dp[j][mask|(1<<j)],dp[i][mask]+need[j][mask]);
				}
			}
		}
	}
	int ans = INF;
	rep(i,n) ans = min(ans,dp[i][(1<<n)-1]);
	cout << (ans>5e8?-1:ans) << endl;
}

Measured memory_bytes: 39168
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<iomanip>
#define MOD 1000000007
#define ll long long 
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); i--)
const int MAX = 1000010;

using namespace std;
ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

ll comb(ll n, ll r) {
	return (fact[n] * fact_inv[r]) % MOD* fact_inv[n - r] % MOD;
}

int main() {
	int X, Y;
	cin >> X >> Y;


	ll a, b;
	if ((2 * X - Y) % 3 == 0 && (2 * X - Y) >= 0 ) {
		b = (2 * X - Y) / 3;

		if ((2 * Y - X) % 3 == 0 && (2 * Y - X) >= 0 ) {
			a = (2 * Y - X) / 3;
			int n = 1000008;
			fact[0] = 1;
			// 階乗の計算
			for (int i = 0; i < n; i++){
				fact[i + 1] =( fact[i] *static_cast<ll>(i+1)) % MOD; 
			}

			fact_inv[n] = power(fact[n], MOD - 2);
			// 逆元の計算
			for (int i = n-1; i >= 0; i--) {
				fact_inv[i] = (fact_inv[i + 1] * static_cast<ll>(i+ 1)) % MOD;
			}
			cout << comb(a+b,b) << endl;
		}
		else {
			cout << 0 << endl;
		}

	}
	else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 15872
#include <iostream>
#include <string>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x>=r&&x<=(W-r)&&y>=r&&y<=(H-r))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=10001;
char a[N][N];
int main()
{
 	int x,y,i,j;
 	cin>>x>>y;
 	for(i=1;i<=x;i++)
 	{
 		for(j=1;j<=y;j++)
 		{
 			cin>>a[i][j];
		 }
	 }
	 for(i=1;i<=y+2;i++)
	 {
	 	cout<<'#'; 
	 }
	 cout<<endl;
	 for(i=1;i<=x;i++)
	 {
	 	cout<<"#";
	 	for(j=1;j<=y;j++)
	 	{
	 		cout<<a[i][j];
		 }
		 cout<<"#";
		 cout<<endl;
	 }
	 for(i=1;i<=y+2;i++)
	 {
	 	cout<<'#'; 
	 }
	 return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,A;
    cin>>N>>A;
    cout<<N*N -A<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
double dp[3030][3030];
double p[3030];
int main(){
    int n; cin >> n;
    for(int i=0;i<n;++i) cin >> p[i];
    dp[0][0] = 1.0;
    for(int i=0;i<n;++i){
        for(int j=0;j<=i;++j){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1.0-p[i]);
        }
    }
    double res = 0.0;
    for(int j=(n+1)/2;j<=n;++j) res += dp[n][j];
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


Measured memory_bytes: 70272
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  int s=0;
  for(int i=0;i<n;i++) {cin>>a[i];s+=a[i];}
  long long ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++) ans+=a[i]*a[j];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
	typedef long long int lli;
	const int MaxN=55;
	#define fst first
	#define snd second
	int N,M,Q;
	pair <int,int> indi[MaxN];
	int c[MaxN];
	int valor[MaxN];
	int res;
	void dfs(int ind,int val,vector <int> arr){
		if(ind==N){
			int i,p,q,tot=0;
			for(i=0;i<Q;i++){
				//cout<<arr[i]<<" ";
				p=indi[i].fst,q=indi[i].snd;
				p-=1,q-=1;
				if(arr[q]-arr[p]==c[i]){
					tot+=valor[i];
				}
			}
			//cout<<"\n";
			res=max(res,tot);
			return;
		}
		if(val>M)return;
		arr.push_back(val);
		dfs(ind+1,val,arr);
		arr.pop_back();
		dfs(ind,val+1,arr);
	}
int main(){
	lli i,time=0;
	cin>>N>>M>>Q;
	for(i=0;i<Q;i++){
		cin>>indi[i].fst>>indi[i].snd>>c[i]>>valor[i];
	}
	vector <int> vacio;
	vacio.clear();
	dfs(0,1,vacio);
	cout<<res;
}

Measured memory_bytes: 3168
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
double pi=3.14159265;

int main(){
    ll n,mn=2000000,mx=-2000000,sum=0;
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
        mn=min(mn, a[i]);
        mx=max(mx, a[i]);
        sum += a[i];
    }
    cout << mn << ' ' << mx << ' ' << sum << endl;
}


Measured memory_bytes: 3164
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
ll a,b,c;
cin>>a>>b>>c;
for(int i=0;i<10;i++){
	c=a*c-b;
	cout<<c<<'\n';
}
}
	

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,c = map(int, input().split())
    print(max(a,b,c)*9+a+b+c)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	
	static int sum = 0; //print
	
	void search(char[][] board, int i) {
		out: for(int j = 0; j < board[i].length; j++) {//1??????????????¢?´¢
			if(board[i][j] == board[0][0]) {
				for(int k = j + 1; k < board[i].length; k++) {//2??????????????¢?´¢
					if(board[i][k] == board[0][1]) {
						int interval = k - j;//1???????????¨2??????????????????
						int cnt = 2;//?????????????????¢?´¢???????????????
						for(int m = k + interval; m < board[i].length; m = m + interval) {//3???????????\????????¢?´¢
							if(board[i][m] == board[0][cnt]) {
								cnt = cnt + 1;
								if(cnt == board[0].length) {
									sum = sum + 1;
									break out;
								}
							} else {
								break;
							}
						}
					}
				}
			}				
		}
	}

	
	
	void doIt() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[][] board = new char[n + 1][];
		board[0] = sc.next().toCharArray();
		for(int i = 1; i <= n; i++) {
			board[i] = sc.next().toCharArray();
			new Main().search(board, i);
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

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

    x -= a;
    while(x >= b) {
        x -= b;
    } 
    cout << x << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;
int n,h;
int a[114514],b[114514];

int main(){
    cin >> n >> h;
    REP(i, n)cin >> a[i] >> b[i];
    sort(a,a+n,greater<int>());
    sort(b,b+n,greater<int>());
    ll cnt = 0,sum = 0;
    ll ans = 0;
    while(sum < h){
        if(cnt < n && b[cnt] > a[0]){
            sum += b[cnt];
            cnt++;
        }
        else{
            sum += a[0];
        }
        ans++;
    }
    dump(ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  
  int count=0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)!=T.at(i))
    count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3836
n = int(input())
c = input().split()

cb = c[:]
for i in range(n):
	for j in range(n-1,i,-1):
		if cb[j][1] < cb[j-1][1]:
			cb[j-1],cb[j] = cb[j],cb[j-1]
print(*cb)
print('Stable')

cs = c[:]
for i in range(n):
	m = min(range(i,n), key=lambda j: cs[j][1])
	if i != m:
		cs[i],cs[m] = cs[m],cs[i]
print(*cs)
print('Stable' if cb == cs else 'Not stable')


Measured memory_bytes: 5608
b=[]
i=-1
while True:
    a=input()
    if a=="-":
        break
    else:
        b.append(a)
        i+=1
        c=int(input())
        for j in range(c):
            a=int(input())
            d=b[i][a:]
            b[i]=b[i][0:a]
            b[i]=d+b[i]
for i in b:
    print(i)


Measured memory_bytes: 5600
#ABC073-C
n,t = map(int,input().split())
time = list(map(int,input().split()))

cnt = t

for i in range(1,n):
    if time[i] - time[i-1] <= t:
        cnt += time[i] - time[i-1]
    else:
        cnt += t
        
print(cnt)

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

int main() {
  int n, k, d = 0; 
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x, kx;
    cin >> x;
    kx = k - x;
    d += (x < kx ? x : kx) * 2;
  }
  cout << d << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N, M;
        cin >> N >> M;

        vector<pair<ll, ll>> vp(N);
        rep(i, 0, N) {
            cin >> vp[i].first >> vp[i].second;
        }

        sort(all(vp));

        ll hon = 0;
        ll ans = 0;
        for (int i = 0; i < N; ++i) {
            if (hon + vp[i].second <= M) {
                ans += vp[i].first * vp[i].second;
                hon += vp[i].second;
            } else {
                ll val = max(0ll, M - hon);
                ans += vp[i].first * val;
                hon += val;
            }
        }

        cout << ans << endl;


    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...)
#define dump(x)
#define debug(x)
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

class ERoadwork {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, Q;
	    in >> N >> Q;
	    vector<int> S(N), T(N), X(N), D(Q);
	    REP(i,0,N) in >> S[i] >> T[i] >> X[i];
	    REP(i,0,Q) in >> D[i];

	    map<int, int> qMap; // <Di, i>
	    vector<pair<int, int>> xOrder(N); // <Xi, i>
	    vector<int> answer(Q, -1);

	    REP(i,0,Q) qMap[D[i]] = i;
	    REP(i,0,N) xOrder[i] = {X[i], i};
	    sort(all(xOrder));

	    for (const auto p : xOrder) {
	        const int x = p.first;
	        const int s = S[p.second];
	        const int t = T[p.second];
//	        out << "xst:" << x << s << t << "\n";

	        vector<int> removed;
	        auto itr = qMap.lower_bound(s-x);
	        while (itr != qMap.end() && itr->first < t-x) {
	            answer[itr->second] = x;
	            removed.emplace_back(itr->first);
	            itr++;
	        }
	        for (const int i : removed) {
//                out << "Di:" << i << "\n";
	            qMap.erase(i);
	        }
	    }

	    REP(i,0,Q) out << answer[i] << "\n";
	}
};


int main() {
	ERoadwork solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
#define INT long long
#define oo 6e18
using namespace std;
string s;
INT n, k, x[100010], ans = oo, p;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i = 0 ; i < n ; i++ )
        cin>>x[i];
    for(int i = 0 ; i <= n-k ; i++ )
    {
        if( x[i+k-1]*x[i] < 0 )
            ans = min(ans, (x[i+k-1]-x[i]+min(abs(x[i]), abs(x[i+k-1]))));
        else ans = min(ans, max( abs(x[i]), abs(x[i+k-1]) ) );
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (2e5);
    static List<Integer>[] edges;
  
	public static void main(String[] args) {
	   
	    	String s = sc.next();
	    	String t = sc.next();
	    	if(s.equals(t.substring(0,t.length()-1))) out.print("Yes");
	    	else out.print("No");
	    
		out.close();
   }
	
	
}



Measured memory_bytes: 32796
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int len;
char STR[5000000];
char str[5000000];
long long mod=1000000007;
pair<long long,int> state(int a){
	long long ret=0;
	int at=a;
	do{
		if('0'<=str[at]&&str[at]<='9'){
			int val=0;
			int v=at;
			while('0'<=str[v]&&str[v]<='9'){
				val*=10;
				val+=str[v]-'0';
				v++;
			}
			if(at==a){
				ret=val;
			}else{
				if(val>=31)ret=0LL;
				else{
					for(int i=0;i<val;i++)ret/=2;
				}
			}
			at=v+2;
		}else if(str[at]=='S'){
			pair<long long,int> dat=state(at+2);
			long long val=dat.first*dat.first%mod;
			if(at==a){
				ret=val;
			}else{
				if(val>=31LL)ret=0LL;
				else{
					for(int i=0;i<val;i++)ret/=2;
				}
			}
			at=dat.second+3;
		}
	}while(at<len&&str[at]!='>');
	//printf("%d %d: %lld\n",a,at-2,ret);
	return make_pair(ret,at-2);
}
int main(){
	while(1){
		gets(STR);
		if(STR[0]=='#')return 0;
		len=0;
		for(int i=0;STR[i];i++){
			if(STR[i]!=' '){
				if((i==0&&'0'<=STR[i]&&STR[i]<='9')||('0'<=STR[i]&&STR[i]<='9'&&!('0'<=STR[i-1]&&STR[i-1]<='9'))){
					str[len++]='0';
					str[len++]='0';
				}
				str[len++]=STR[i];
			}
		}
		str[len]=0;
		printf("%lld\n",state(0).first);
	}
}

Measured memory_bytes: 5756
s=input()
n=int(input())
cnt=0
l=[]
r=[]
for i in range(n):
    e=list(map(str,input().split()))
    q=int(e[0])
    if len(e)!=1:
        f=int(e[1])
        c=e[2]
    if q==2:
        if (f==1 and cnt%2==0) or (f==2 and cnt%2!=0):
            l.append(c)
        else:
            r.append(c)
    else:
        cnt+=1
if cnt%2==0:
    print(''.join(l[::-1])+s+''.join(r))
else:
    print(''.join(r[::-1])+s[::-1]+''.join(l))

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    reverse(S.begin(), S.end());
    S += '0';
    int N = S.length();
    int dp[N][2];
    rep(i, N) rep(j, 2) dp[i][j] = mod;
    dp[0][0] = S[0] - '0';
    dp[0][1] = 10 - (S[0] - '0');
    for(int i = 0; i < N-1; i++){
        dp[i+1][0] = min(dp[i][0] + (S[i+1]-'0'), dp[i][1] + (S[i+1]-'0') + 1);
        dp[i+1][1] = min(dp[i][0] + 10 - (S[i+1]-'0'), dp[i][1] + 9 - (S[i+1]-'0'));
    }
    cout << dp[N-1][0] << endl;
    return 0;
}

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

int main(){
  string X; cin >> X;
  int sz=X.size();
  int lS=0;
  for(int i=0;i<sz;i++){
    if(X.at(i)=='S'){
      lS++;
    }else if(lS!=0)
      lS--;
  }
  cout << lS*2;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

bool isPrime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int main()
{
    int Q;
    cin >> Q;
    vector<int> cnt(1e5 + 2, 0);
    repd(i, 3, 1e5 + 1) {
        if (i % 2) {
            if (isPrime(i) && isPrime((i + 1) / 2)) {
                cnt[i]++;
            }
        }
    }

    repd(i, 1, cnt.size()) {
        cnt[i] += cnt[i - 1];
    }

    rep(i, Q) {
        int l, r;
        cin >> l >> r;

        cout << cnt[r] - cnt[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))
ans = 0
s = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    s+=1
  else:
    ans = max(ans, s)
    s = 0
ans = max(ans, s)
  
print(ans)

Measured memory_bytes: 20328
# AtCoder Beginner Contest 150 : B (2020/01/10)
N = int(input())
S = str(input())
key = 'ABC'
cnt = 0
for i in range(N+1-len(key)):
    T = S[i]+S[i+1]+S[i+2]
    if T == key:
        cnt = cnt + 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n;  cin >> n;
    vector<int>a(n);
    rep(i, n)   cin >> a[i];
    bool ans = false;
    bool flag0 = true; //全部0ならtrue
    rep(i, n){
        if(a[i] != 0)   flag0 = false;
    }
    if(flag0){
        ans = true;
    }else{
        if(n%3){
            ans = false;
        }else{
            vector<pair<int, int> >dic(4, pair<int, int>(-1, 0));
            rep(i, n){
                rep(j, 4){
                    if(a[i] != dic[j].first){
                        if(dic[j].first == -1){
                            dic[j].first = a[i];
                            dic[j].second++;
                            break;
                        }
                    }else{
                        dic[j].second++;
                        break;
                    }
                }
            }
            if(dic[1].first == -1){
                ans = false;
            }else if(dic[2].first == -1){
                if(dic[0].first == 0 && dic[0].second == n/3)   ans = true;
                if(dic[1].first == 0 && dic[1].second == n/3)   ans = true;
            }else if(dic[3].first == -1){
                int tmp = 0;
                rep(i, 3)   tmp ^= dic[i].first;
                if(tmp){
                    ans = false;
                }else{
                    if(dic[0].second == n/3 && dic[1].second == n/3 && dic[2].second == n/3){
                        ans = true;
                    }else{
                        ans = false;
                    }
                }
            }else{
                ans = false;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

struct Node
{
    ll a;
    ll b;
};

int main()
{
    ll N, K;
    cin >> N >> K;

    vector<Node> nodes(N);

    for (int i = 0; i < N; ++i) {
        cin >> nodes[i].a >> nodes[i].b;
    }

    sort(begin(nodes), end(nodes), [](const auto& n1, const auto& n2) { return n1.a < n2.a; });

    ll c = 0;
    ll ans = 0;

    for (int i = 0; i < N; ++i) {
        if (c <= K-1 && K-1 < c + nodes[i].b) {
            ans = nodes[i].a;
            break;
        }

        c += nodes[i].b;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int n,m;
		while((((n=s.nextInt())&(m=s.nextInt()))!=0)) {
			place[] in = new place[m];
			for(int i=0;i<in.length;i++)
				in[i]=new place(i+1);
			for(int i=0;i<n;i++) {
				for(int j=0;j<in.length;j++)
					in[j].c+=Byte.parseByte(s.next());
			}
			Arrays.sort(in, (o1, o2) -> o2.c-o1.c);
			System.out.print(in[0].no);
			for(int i=1;i<in.length;i++)
				System.out.printf(" %d",in[i].no);
			System.out.println();
		}
	}
}
class place{
	int c=0,no;
	place(int no) {
		this.no=no;
	}
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int l = 0;
  int r = 0;
  int a;
  for(int i = 0; i < M; ++i) {
    cin >> a;
    if(a < X) {
      l++;
    } else if(X < a) {
      r++;
    }
  }
  cout << min(l, r) << endl;
  return 0;
}

Measured memory_bytes: 256