akhauriyash/Code-Regression huggingface dataset:
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
const int N = 5e5+10;
const double eps = 0.00000001;
const ll mod = 1e18 + 7 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int w[4][4];
int r[4],c[4];
int main(){
    rep(i,1,3)
        rep(j,1,3) 
            w[i][j] = read();
    int n = read();
    while(n--){
        int a = read();
        rep(i,1,3){
            rep(j,1,3){
                if(w[i][j] == a){
                    r[i]++;c[j]++;
                }
            }
        }
        rep(i,1,3){
            if(w[i][i]== a) r[0] ++;
            if(w[i][3-i+1] == a) c[0] ++;
        }
    }
    rep(i,0,3){
        if(r[i]==3||c[i]==3) return puts("Yes"),0;
    }
    puts("No");


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n, limit;
    cin >> n >> limit;
    vector<lint> w(n), v(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    // dp[i][j]:品物を[0,i)まで使って価値jを作るときの最小の重さ
    vector<vector<lint>> dp(n + 1, vector<lint>(1e+5 + 1, LLONG_MAX));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 1e+5; j++) {
            if (j - v[i - 1] < 0) {
                dp[i][j] = dp[i - 1][j];
            } else if (dp[i - 1][j - v[i - 1]] == LLONG_MAX) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] =
                    min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
            }
        }
    }
    for (int i = 1e+5; i >= 0; i--) {
        if (dp[n][i] <= limit) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 80256
class Node:
    def __init__(self, key=None, pri=None, left=None, right=None):
        self.key = key
        self.pri = pri
        self.left = left
        self.right = right
        self.parent = None

def rRotate(t):
    s = t.left
    t.left = s.right
    s.right = t
    return s

def lRotate(t):
    s = t.right
    t.right = s.left
    s.left = t
    return s

def insert(t, key, pri):
    if t == None:
        return Node(key, pri)
    if key == t.key:
        return t

    if key < t.key:
        t.left = insert(t.left, key, pri)
        if t.pri < t.left.pri:
            t = rRotate(t)
    else:
        t.right = insert(t.right, key, pri)
        if t.pri < t.right.pri:
            t = lRotate(t)

    return t

def find(x, k):
    while x != None and k != x.key:
        if x.key != None:
            if k < x.key:
                x = x.left
            else:
                x = x.right
    return x

def delete(t, key):
    if t == None:
        return None
    if key < t.key:
        t.left = delete(t.left, key)
    elif key > t.key:
        t.right = delete(t.right, key)
    else:
        if t.left == None and t.right == None:
            return None
        elif t.left == None:
            t = lRotate(t)
        elif t.right == None:
            t = rRotate(t)
        else:
            if t.left.pri > t.right.pri:
                t = rRotate(t)
            else:
                t = lRotate(t)
        return delete(t, key)
    return t

def inorder(u):
    if u == None:
        return
    inorder(u.left)
    print(' ' + str(u.key), end="")
    inorder(u.right)

def preorder(u):
    if u == None:
        return
    print(' ' + str(u.key), end="")
    preorder(u.left)
    preorder(u.right)

count = int(input())
t = None
for i in range(count):
    a = input().split()
    if a[0] == 'insert':
        t = insert(t, int(a[1]), int(a[2]))
    elif a[0] == 'find':
        if find(t, int(a[1])) == None:
            print('no')
        else:
            print('yes')
    elif a[0] == 'delete':
        t = delete(t, int(a[1]))
    else:
        inorder(t)
        print('\n', end="")
        preorder(t)
        print('\n', end="")



Measured memory_bytes: 52028
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int D,T,S;
  cin >> D >> T >> S;
  if (S * T >= D) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;

}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int c[3][3];

int main() {
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    rep(a1, 101) {
        rep(a2, 101) {
            rep(a3, 101) {
                int b1 = c[0][0] - a1;
                if (b1 != c[1][0] - a2 || b1 != c[2][0] - a3) continue;

                int b2 = c[0][1] - a1;
                if (b2 != c[1][1] - a2 || b2 != c[2][1] - a3) continue;

                int b3 = c[0][2] - a1;
                if (b3 != c[1][2] - a2 || b3 != c[2][2] - a3) continue;

                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

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

    static class StudyScheduling {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int H1 = in.nextInt();
            int M1 = in.nextInt();
            int H2 = in.nextInt();
            int M2 = in.nextInt();
            int K = in.nextInt();
            int time = (H2 - H1) * 60 + (M2 - M1);
            out.println(Math.max(0, time - K));
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 32916
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long ll;
const ll N=1e5+5;
const double eps=1e-6;
const int mod=1e9+7;
ll a[90];
void init()
{
    a[0]=2,a[1]=1;
    for(int i=2;i<=86;i++)
        a[i]=a[i-1]+a[i-2];
}
int main()
{
    ll n;
    init();
    while(cin>>n)
    {
        cout<<a[n]<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int N=2e5+5;
using namespace std;

int main()
{
    int d,t,s;cin>>d>>t>>s;
    if(d>t*s)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {

	var S string
	fmt.Scanf("%s", &S)

	switch S {

	case "SUN":
		fmt.Println("7")
	case "MON":
		fmt.Println("6")
	case "TUE":
		fmt.Println("5")
	case "WED":
		fmt.Println("4")
	case "THU":
		fmt.Println("3")
	case "FRI":
		fmt.Println("2")
	case "SAT":
		fmt.Println("1")
	}
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    lli h, w;
    cin >> h >> w;
    vector<string> s(100010);

    for(lli i=0; i<h; i++){
        cin >> s.at(i);
    }
    for(lli i=0; i<w+2; i++){
        cout << "#";
    }cout << endl;
    for(lli i=0; i<h; i++){
        cout << "#" << s[i] << "#" << endl;
    }
    for(lli i=0; i<w+2; i++){
        cout << "#";
    }cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main() {

	string s;
	cin >> s;

	string kk = "+-";

	int a[4] = { 0 };
	for (int i = 0; i < 4; i++) {
		a[i] = s[i] - '0';
	}
	if (a[0] + a[1] + a[2] + a[3] == 7) {
		cout << s[0] << '+' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
	}
	else if (a[0] + a[1] + a[2] - a[3] == 7) {
		cout << s[0] << '+' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
	}
	else if (a[0] + a[1] - a[2] + a[3] == 7) {
		cout << s[0] << '+' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
	}
	else if (a[0] + a[1] - a[2] - a[3] == 7) {
		cout << s[0] << '+' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
	}
	else if (a[0] - a[1] + a[2] + a[3] == 7) {
		cout << s[0] << '-' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
	}
	else if (a[0] - a[1] + a[2] - a[3] == 7) {
		cout << s[0] << '-' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
	}
	else if (a[0] - a[1] - a[2] + a[3] == 7) {
		cout << s[0] << '-' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
	}
	else if (a[0] - a[1] - a[2] - a[3] == 7) {
		cout << s[0] << '-' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
	}

	return 0;
}

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

using namespace std;

const int Nmax = 3005, Mod = 1e9 + 7;
typedef long long ll;

void add_to(int &x, int y) { x+=y; if(x>=Mod) x-=Mod; }
int inm(int x, int y) { return (ll)x*y%Mod; }

int N, K, i, j, ans = 0, dp[Nmax];
vector<int> v, v2;

int power(int x, int y)
{
    int ans = 1;
    while(y)
    {
        if(y&1) ans = inm(ans, x);
        x = inm(x, x); y >>= 1;
    }
    return ans;
}

int main()
{
///    freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> N >> K;
    for(i=1; i*i<=N; ++i)
        if(N % i == 0)
        {
            v.push_back(i);
            if(i*i < N) v2.push_back(N/i);
        }

    reverse(v2.begin(), v2.end());
    for(auto it : v2) v.push_back(it);

    for(i=0; i<v.size(); ++i)
    {
        dp[i] = power( K, (v[i]+1)/2 );

        for(j=0; j<i; ++j)
            if(v[i] % v[j] == 0)
                add_to(dp[i], Mod - dp[j]);

        add_to(ans, inm( dp[i], v[i] / (1<<(v[i]%2==0)) ) );
    }

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


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

using namespace std;

int main()
{

  unsigned long long dp[4001][5];
  for(int i=0;i<5;i++)
    for(int j=0;j<4001;j++)
      dp[j][i] = i==1&&j<=1000?1:0;

  for(int i=2;i<=4;i++)
    for(int j=0;j<=4000;j++)
      for(int k=0;k<=j && k<=1000;k++)
	dp[j][i] += dp[j-k][i-1];

  int n;
  while(cin >> n)
    cout << dp[n][4] << endl;
    
  return 0;
}

Measured memory_bytes: 1308
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    while (true)
    {
        bool isPrime = true;
        for (int i = 2; i * i <= x; i++)
        {
            isPrime = isPrime && (x % i != 0);
        }
        if (isPrime)
        {
            cout << x << endl;
            return 0;
        }
        x++;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())

A = []
for i in range(100):
  if sum(A) >= 10e12:
    break
  A.append(pow(2,i))
if N == 1:
  print(1)
else:
  for i in range(50):
    N = N//2
    if N <= 0:
      print(sum(A[:i+1]))
      break

Measured memory_bytes: 38384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: i32,
        a: [i32; n],
    }

    let mut ans = 0;
    for i in 1..(n - 1){
        if &a[(i-1) as usize] < &a[i as usize] && &a[i as usize] < &a[(i+1) as usize] || &a[(i-1) as usize] > &a[i as usize] && &a[i as usize] > &a[(i+1) as usize]{ans += 1;}
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

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

Measured memory_bytes: 3628
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
#include <map>
#include <math.h>

using ll = long long;
using namespace std;

int main(){
    int n; cin >> n;
    map<ll, int> a;
    rep(i, n){
        int a_i; cin >> a_i;
        a[a_i]++;
    }

    int count=0;
    // rep(i, n) if(a[i]==1) count++;
    for(auto itr = a.begin(); itr != a.end(); ++itr){
        if((itr->second)%2!=0) count++;
    }

    out(count);
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
typedef char str105[112345];

str105 S;

void Solve()
{
  int count = 0;
  char currentChar = S[0];
  for (int i = 1; S[i] != '\0'; ++i){
    if (S[i] != currentChar){
      currentChar = S[i];
      ++count;
    }
  }
  cout << count << endl;
}

void Init()
{
  cin >> S;
}

void Clean(){}

int main(){ Init(); Solve(); Clean(); return 0; }


Measured memory_bytes: 384
<?php
list($a, $b, $c) = ints();
if(min($a,$b,$c)!=max($a,$b,$c) && ($a==$b || $b==$c || $c==$a)){
    echo "Yes";
}else{
    echo "No";
}
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}

Measured memory_bytes: 4856
n = int(raw_input())

i = 0
s = []
h = []
c = []
d = []

def order_list(list):
  l = len(list)
  for i in xrange(l):
    j = i + 1
    while j < l:
      if list[i] > list[j]:
        temp = list[i]
        list[i] = list[j]
        list[j] = temp
      j += 1

  return list

def not_enough_cards(mark, list):
  list = order_list(list)
  # line = "########################################"
  # print line
  # print mark + ":"
  # print list
  # print line
  i = 0
  for x in xrange(1, 14):
    # print "x = " + str(x) + ", i = " + str(i)
    if i >= len(list):
      print mark + " " + str(x)
    elif x != list[i]:
      print mark + " " + str(x)
    else:
      i += 1

while i < n:
  line = raw_input().split(" ")
  line[1] = int(line[1])
  if line[0] == "S":
    s.append(line[1])
  elif line[0] == "H":
    h.append(line[1])
  elif line[0] == "C":
    c.append(line[1])
  elif line[0] == "D":
    d.append(line[1])
  i += 1

not_enough_cards("S", s)
not_enough_cards("H", h)
not_enough_cards("C", c)
not_enough_cards("D", d)

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)
int N;
vvi solver(vi arr) {
    vvi ansList(0);

    if (arr.size() == 1) {
        if (arr[0] == 1) {
            vi a(0);
            a.push_back(1);
            ansList.push_back(a);
        }
        return ansList;
    }

    for (int i = 0; i < arr.size(); i++) {
        if (arr[i] > i + 1) return ansList;
    }

    for (int i = 0; i < arr.size(); i++) {
        if (arr[i] != i + 1) continue;
        vi a(0);

        for (int j = 0; j < arr.size(); j++) {
            a.push_back(arr[j]);
        }
        a.erase(a.begin() + i);
        vvi ret = solver(a);
        if (ret.size() == 0) continue;

        for (int j = 0; j < ret.size(); j++) {
            ret[j].push_back(i + 1);
            ansList.push_back(ret[j]);
        }
    }
    return ansList;
}

int main() {
    cin >> N;

    vi A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vvi ans = solver(A);
    for (int i = 0; i < ans.size(); i++) {
        if (ans[i].size() == N) {
            for (int j = 0; j < N; j++) {
                cout << ans[i][j] << endl;
            }
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] section = new int[n];
		int[] happy_B = new int[n];
		int[] happy_C = new int[n - 1];
		int goukei = 0;
		for (int i = 0; i < n; i++) {
			section[i] = scan.nextInt();
		}
		for (int i = 0; i < n; i++) {
			happy_B[i] = scan.nextInt();
		}
		for (int i = 0; i < n - 1; i++) {
			happy_C[i] = scan.nextInt();
		}
		goukei += happy_B[section[0] - 1];
		for (int i = 1; i < n; i++) {
			if (section[i] == section[i - 1] + 1) {
				goukei += happy_B[section[i] - 1] + happy_C[section[i - 1] - 1];
			} else {
				goukei += happy_B[section[i] - 1];
			}
		}
		System.out.println(goukei);

	}
}

Measured memory_bytes: 21460
N=int(input())
*A,=map(int,input().split())

count=[min(i//400,8)for i in A]
c8=count.count(8)

if c8>0:
    print(max(len(set(count))-1,1),len(set(count))+c8-1)
else:
    print(len(set(count)),len(set(count)))

Measured memory_bytes: 3060
n, aa = input(), list(map(int, input().split()))
s = sum(aa)
m = s / 2
i = 0
min = float("inf")
ans = 0
aa.pop()
for a in aa:
    s -= a
    i += a  
    dif = abs(s - m)
    if dif < min:
        min = dif
        ans = abs(s-i)
print(ans)


Measured memory_bytes: 23796
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def solve():
    N = int(input())
    
    c = 0
    for i in range(1, N+1, 2):
        f = factorize(i)
        b = 1
        for j in f:
            b += b * j[1]
        if b == 8:
            c += 1

    return c

print(solve())

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#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 PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(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 pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  vsort(a);
  ll d=INF;
  rep(i,n-k+1){
    chmin(d,a[i+k-1]-a[i]);
  }
  cout<<d<<endl;
}

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

int main(){
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  
  for(int i=0; i<N; i++){
    cout << S[i] << T[i];
  }
  cout << endl;
  
  return 0;
}

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

int lcm(int n, int m) {
    if (n < m) swap(n, m);
    if (m == 0)
        return n;
    else
        return lcm(m, n % m);
}

int main() {
    int a, b;
    while (cin >> a >> b) {
        cout << lcm(a, b) << " " << a / lcm(a, b) * b << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){
    // Your code here!
    int N, W;
    cin >> N >> W;
    int dp[N+1][W+1];
    int v[N], w[N];
    
    
    
    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }
    
    dp[0][0] = 0;
    for(int i = 0; i <= W; i++) dp[0][i] = 0;
    for(int i = 1; i <= N; i++) dp[i][0] = 0;
    
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= W; j++){
            if(j- w[i] >= 0){
                dp[i+1][j] = max(dp[i][j], dp[i+1][j - w[i]] + v[i]);
            } else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7016
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());

        List<String> list = new ArrayList<>();

        IntStream.range(0, n).forEach(i -> list.add(sc.next()));

        int[] alpha = new int[26];
        Arrays.fill(alpha, 50);

        list.forEach(s -> {
            IntStream.rangeClosed('a', 'z').forEach(i ->
                alpha[i - 'a'] = (int) Math.min(alpha[i - 'a'], s.chars().filter(j -> j == i).count())
            );
        });

        for (char i = 'a'; i <= 'z'; i++) {
            for (int j = 0; j < alpha[i - 'a']; j++) {
                System.out.print(i);
            }
        }
    }
}

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

int main() {
  long long N ,M ,K;
  cin >> N >> M >> K;
  
  vector<long long>A(N);
  vector<long long>B(M);
  
  vector<long long>A_sum(N+1);
  vector<long long>B_sum(M+1);
  
  A_sum.at(0) = 0;
  B_sum.at(0) = 0;
  
  for(long long i = 0 ; i < N ; i++){
  	cin >> A.at(i);
    A_sum.at(i+1) = A_sum.at(i) + A.at(i); 
    //cout << A_sum.at(i+1) << endl;
  }
  for(long long i = 0 ; i < M ; i++){
  	cin >> B.at(i);
    B_sum.at(i+1) = B_sum.at(i) + B.at(i);    
  }

  long long sum = 0;
  long long sum_max = -1;
  long long last_j = 0;
  
  
  for(long long i = 0 ; i <= N ; i++){
  	for(long long j = last_j ; j <= M ; j++){
    	if(A_sum.at(N-i)+B_sum.at(j)<=K){
        	sum = A_sum.at(N-i)+B_sum.at(j);
          last_j = j;
              if(sum_max < N - i + j){
    			sum_max = N - i + j;
    		  }
        }else{
        	break;
        }
    }
  }
  
  cout << sum_max << endl;
  
}	


Measured memory_bytes: 9560
#include<bits/stdc++.h>
using namespace std;
int ans,n;
int main()
{
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)
	{
		int x=i,len=0;
		while(x)
		{
			x/=10;
			len++;
		}
		if(len&1)
			ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let mut x: Vec<i32> = (0..m).map(|_| input()).collect();
    x.sort();

    let mut diff: Vec<i32> = x.windows(2).map(|d| d[1] - d[0]).collect();
    diff.sort();
    let ans: i64 = diff
        .iter()
        .map(|&d| d as i64)
        .take(std::cmp::max(0, m as i32 - n as i32) as usize)
        .sum();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include "cstdio"
#include <string>
#include <vector>

#define NMAX 100
using namespace std;

int main(){
	int N,K,ans,D[10] = {};
	cin >> N >> K;
	for (int i = 0; i < K; ++i)
	{
		int a;
		cin >> a;
		D[a]++;
	}
	ans = N;
	while(true){
		int s = 1,ss = ans;
		while(ss){
			if(D[ss%10] == 1){
				s = 0;
				break;
			}
			ss /= 10;
		}
		if(s == 1){
			cout << ans <<"\n";
			break;
		}
		ans++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>                          
#include <iostream>
using namespace std;
int main(){
    int A,B; cin >>  A >> B;
    if(A==B) cout << "Draw";
    else if(A == 1){
        cout << "Alice";
    }else if(B == 1){
        cout << "Bob";
    }else{
        if(A>B) cout << "Alice";
        else cout << "Bob";
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
x = "abcdefghijklmnopqrstuvwxyz"
if len(s)!=26:
	for i in x:
		 if i not in s:
		 	letter = i
		 	break
	print(s+letter)
elif s=="zyxwvutsrqponmlkjihgfedcba":
	print(-1)
else:
	for i in range(24,-1,-1):
		if x.find(s[i])<x.find(s[i+1]):
			s,s2,y = s[:i],s[i:],s[i]
			break
	s3 = []
	for i in s2: s3.append(i)
	s3.sort()
	letter = s3[s3.index(y)+1]
	print(s+letter)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	bool check1 = true;
	bool check2 = true;

	for (int i = 0; i < S.size(); i++)
	{
		if ((i + 1) % 2 == 0)
		{
			if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D')
			{
				check1 = false;
			}
		}
		else
		{
			if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D')
			{
				check2 = false;
			}
		}
	}

	if (check1 && check2)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),count(1e6+1,0);
  int ma=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    ma=max(ma,A.at(i));
    count.at(A.at(i))++;
  }
  sort(A.begin(),A.end());
  vector<bool> flag(ma+1,false);
  int ans=0;
  for(int i=0;i<N;i++){
    if(!flag.at(A.at(i))){
      if(count.at(A.at(i))==1){
        ans++;
      }
      for(int x=A.at(i);x<=ma;x+=A.at(i)){
        flag.at(x)=true;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7920
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int a[M],pre[M];
inline int rsum(int l,int r)
{
    return (pre[r]-pre[l-1]);
}
inline int maxi(int a,int b,int c,int d)
{
    return max(max(a,b),max(c,d));
}
inline int mini(int a,int b,int c,int d)
{
    return min(min(a,b),min(c,d));
}
 main()

{
    fast
    int n,sum=0;
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
        sum+=a[i];
        pre[i]=sum;
    }
    int l=1,r=3,ses=inf;
    f(i,2,n)
    {
        while(l+2<=i && abs(rsum(1,l)-rsum(l+1,i)) > abs(rsum(1,l+1)-rsum(l+2,i)))l++;
        while(r+2<=n && abs(rsum(i+1,r)-rsum(r+1,n)) > abs(rsum(i+1,r+1)-rsum(r+2,n)))r++;
        int a=rsum(1,l),b=rsum(l+1,i),c=rsum(i+1,r),d=rsum(r+1,n);
        ses=min(ses,maxi(a,b,c,d)-mini(a,b,c,d));
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 6788
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));


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

	int N;
	string S;
	cin >> N >> S;
	int A = 0, B = 0;
	REP(i, N) {
		if (S[i] == '(') {
			A++;
			//if (B > 0)B--;
		}
		else {
			if (A > 0)A--;
			else if (A == 0)B++;
		}
		//cout << B << endl;
	}
	//cout << A << " " << B << endl;
	REP(i, B)cout << "(";
	cout << S;
	REP(i, A)cout << ")";
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char s[257],t[257];
    int i,j,k,n;
    for(scanf("%d\n",&n);n--;)
    {
        gets(s);
        for(i=1;i<=26;i+=2)
            for(j=0;j<=26;j++)
            {
                for(k=0,strcpy(t,s);s[k];k++)
                    if(s[k]>='a'&&s[k]<='z')
                        t[k]=((s[k]-'a')*i+j)%26+'a';
                if(strstr(t,"this")||strstr(t,"that"))
                    goto e;
            }
e:      puts(t);
    }
    return 0;
}

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


int main(){

	string s;
	cin >> s;

	bool even = true;

	for(int i = 0; i < s.size(); i++){
		if(even){
			even = false;
			if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
				continue;
			}
			else{
				cout << "No" << endl;
				return 0;
			}
		}else{// 偶数
			even = true;
			if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
				continue;
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
program test
implicit none

integer(8) :: n,a,b,i,j
integer(8) :: x(200000),ans=0

read(*,*) n,a,b
read(*,*) (x(i),i=1,n)

do i=1,n-1
	ans = ans + min(b,a * (x(i+1) - x(i)))
enddo

write(*,*) ans

end program

Measured memory_bytes: 1536
//******* It's LEVI_17 ***************

#include <bits/stdc++.h>

#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ff first
#define ss second
#define MP make_pair
#define mset(x,a) memset(x,a,sizeof(x))
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define vvll vector<vector<ll>>  
#define vll vector<ll> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define cases ll t;cin >> t;while(t--)
#define rr return 0
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define deb(a)			std::cerr<<#a<<"="<<(a)<<"\n"
#define deb2(a,b)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define deb3(a,b,c)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
const int MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1e18L + 5;
//syntax for priority queue
// max queue -> priority_queue<ll>
// min queue -> priority_queue<ll,vector<ll>,greater<ll>>

//##############################################################################################

ll countbits(int mask)
{
    ll count = 0;
    while (mask)
    {
        count += 1 & (mask);
        mask = mask >> 1;
    }

    return count;
}

void solve()
{
    ll n;
    cin >> n;
    ll arr[21][21];
    f(i, n)
        f(j, n)
        cin >> arr[i][j];



    vector<ll> dp((1 << n));

    dp[0] = 1;

    for (ll mask = 0; mask < (1 << n) - 1; ++mask)
    {
        ll a = countbits(mask);
        for (ll b = 0; b < n; b++)
        {
            if (arr[a][b] && !(mask & (1 << b)))
            {
                ll m2 = mask ^ (1 << b);
                (dp[m2] += dp[mask]%MOD)%=MOD;
            }
        }
    }

    cout << dp[(1 << n) - 1] << "\n";
}

//###############################################################################################

int main()
{
    fast;
    ll t = 1;
   // cin >> t;
    while (t--)
    {
        solve();
    }
    rr;
}


//Watashi wa tsuyoku modotte kimasu


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


typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<int, int> mi;
typedef map<ll, ll> ml;
#define fr(i, n) for (int i = 0; i < n; i++)
#define frn(i, k, n) for (int i = k; i < n; i++)
#define rf(i, n) for (int i = n-1; i >= 0; i--)
#define rfn(i, k, n) for (int i = n-1; i >= k; i--)

const int N = 5e5 + 5;
const int M = 998244353;
ll fact[N], inv[N];
vector<bool> prime;
vector<int> drow4{1, -1,  0,  0};
vector<int> dcol4{0,  0, -1,  1};
vector<int> drow8{0,  1,  1,  1,  0, -1, -1, -1};
vector<int> dcol8{1,  1,  0, -1, -1, -1,  0,  1};


ll powerModM(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res=(res * x)%M; 
        y = y >> 1; 
        x = (x *x) % M;
    } 
    return res % M; 
}

ll power(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x*x;
    } 
    return res; 
}
 
void preCalcFactorial(int n){
    fact[0] = inv[0] = 1;
    for(ll i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % M;
        inv[i] = powerModM(fact[i], M - 2);
    }
}
 
ll nCr(ll n,ll r){
    ll ans = ((fact[n] * inv[r]) % M + M) % M;
    ans = ((ans * inv[n-r]) % M + M) % M;
    return ans;
}

void sieve(int n) { 
    prime.resize(n+1, true);
    prime[1] = false;
    for (int p = 2; p * p <= n; p++){ 
        if (prime[p] == true) {
            for (int i = p*p; i <= n; i += p) 
                prime[i] = false; 
        } 
    }
} 

class BIT{
public:
    int size;
    vector<int> v;
    BIT(int s){
        size = s;
        v.resize(s, 0);
    }
    void update(int i, int delta){
        while(i < size){
            v[i] += delta;
            i += i & (-i);
        }
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= i & (-i);
        }
        return s;
    }
};

void testCase(){
	int n, M = 1e4 + 5;
	cin >> n;
	vi v(M);
	for(int i = 1; i <= 105; i++) {
		for(int j = 1; j <= 105; j++) {
			for(int k = 1; k <= 105; k++) {
				int val = i * i + j * j + k * k + i * j + j * k + k * i;
				if(val < M) v[val]++;
			}
		}
	}
	for(int i = 1; i <= n; i++) cout << v[i] << endl;
}

int main(){
    int t = 1;
    // cin >> t;
    while(t--){
        testCase();
    }
}


Measured memory_bytes: 3532
import collections

def show():
    for h in range(H):
        print("".join(map(str, ans[h])))

H, W, A, B = list(map(int, input().split()))

ans = collections.Counter()
for h in range(H):
    ans[h] = [0 for w in range(W)]

row = [0 for w in range(W)]
reverse_row = [1 for w in range(W)]
for a in range(A):
    row[a] = 1
    reverse_row[a] = 0
    
for h in range(H):
    if(h < B):
        ans[h] = row
    else:
        ans[h] = reverse_row
        
show()

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
string s;

bool read() {
    if (!(cin >> s))
        return false;

    return true;
}

void solve() {
    n = sz(s);
    int bal = 0, mbal = 0;

    forn (i, n)
        mbal = min(mbal, bal += (s[i] == 'S') - (s[i] == 'T'));

    cout << -2 * mbal << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 720
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d[] = new int[n];
    int a,total = 0;

    for(int i=0 ; i<n ; i++){
      d[i] = sc.nextInt();
    }

    for(int i=0 ; i<n ; i++){
      for(int j=i+1 ; j<n ; j++){
        a = d[i] * d[j];
        total = total + a;
      }
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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;
}

int main() {
  vector<int> P(5);
  rep(i, 5) cin >> P[i];
  int last_ind;
  int min_one = 10;
  rep(i, 5) {
    if (chmin(min_one, (P[i] + 9) % 10)) last_ind = i;
  }
  int ans = 0;
  rep(i, 5) {
    if (i != last_ind) ans += ((P[i] + 9) / 10) * 10;
  }
  ans += P[last_ind];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define vi vector<int>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 100002

map<int,int> dp[MAX_N];
vector<edge> G1[MAX_N],G2[MAX_N],G3[1000002];
int dp1[MAX_N];
priority_queue<P2,vector<P2>,greater<P2>> que;

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;

	rep(i,n){
		if(a+b>0){
			if(s[i]=='a'){
				cout<<"Yes"<<endl;
				if(a>0)a--;
				else b--;
			}else if(s[i]=='b'&&b>0){
				cout<<"Yes"<<endl;
				b--;
			}else{
				cout<<"No"<<endl;
			}

		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 33664
s = int(input())
lst = []
lst.append(s)
flag = True
cnt = 1
while flag:
    if lst[-1] % 2 == 0:
        tmp = lst[-1] / 2
        cnt += 1
    elif lst[-1] % 2 != 0:
        tmp = 3 * lst[-1] + 1
        cnt += 1
    if tmp in lst:
        flag = False
    else:
        lst.append(tmp)

print(cnt)

Measured memory_bytes: 3064
import os
import sys
from collections import defaultdict, deque
from functools import lru_cache

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

graph = [[] for _ in range(N ** 2)]
ins = [0] * (N ** 2)
for i in range(N):
    for j in range(N - 2):
        a, b = i, A[i][j] - 1
        c, d = i, A[i][j + 1] - 1

        if a > b:
            a, b = b, a
        if c > d:
            c, d = d, c

        graph[a * N + b].append(c * N + d)
        ins[c * N + d] += 1

zeros = []
seen = []
for v, cnt in enumerate(ins):
    if cnt == 0:
        zeros.append(v)
        seen.append(v)

ans = 0
while zeros:
    nz = []
    for v in zeros:
        for u in graph[v]:
            ins[u] -= 1
            if ins[u] == 0:
                nz.append(u)
                seen.append(u)
    zeros = nz
    ans += 1
if len(seen) == len(graph):
    print(ans)
else:
    print(-1)


Measured memory_bytes: 194492
/*
  kadai3_4 81
  unomi
*/
#include <stdio.h>

int main(void){
  int N=0, i=0, j=0;

  // N の入力を取得
  scanf("%d",&N);

  // 9*9の範囲を総当たり
  // →一致するものがあればyes、なければNoを出力
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      if(i*j == N){
        puts("Yes");
        return 0;
      }
    } 
  }
  puts("No");

  return 0;
}


Measured memory_bytes: 128