akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
struct edge {
    ll from, to, cost;
};

pair<vector<ll>, vector<int>> bellman_ford(vector<edge> &g, int V, int s) {
    vector<ll> d(V, LINF);
    d[s] = 0;
    for (int i = 0; i < V - 1; i++) {
        for (int j = 0; j < g.size(); j++) {
            edge e = g[j];
            if (d[e.from] == LINF) {
                continue;
            }
            d[e.to] = min(d[e.to], d[e.from] + e.cost);
        }
    }
    vector<int> neg(V);
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < g.size(); j++) {
            edge e = g[j];
            if (d[e.from] == LINF) {
                continue;
            }
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                neg[e.to] = 1;
            }
            neg[e.to] |= neg[e.from];
        }
    }
    return make_pair(d, neg);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, p;
    cin >> n >> m >> p;
    vector<edge> g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        g.push_back({a, b, p - c});
    }
    pair<vector<ll>, vector<int>> v = bellman_ford(g, n, 0);
    if (v.second[n - 1]) {
        cout << -1 << endl;
    } else {
        cout << max(0LL, -v.first[n - 1]) << endl;
    }
}


Measured memory_bytes: 592
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
long long gatherLoop(long long pos, long long i){
    if(pos<0)return 0;
    auto halfLoop = 1LL<<i;
    if(i==0){
        // cout<<"gatherLoop("<<pos<<","<<i<<")="<<(pos%4 == 1 || pos %4 == 2)<<endl;
        return pos%4 == 1 || pos %4 == 2;
    }
    else{
        if(pos%(halfLoop*2)<halfLoop){
            // cout<<"gatherLoop("<<pos<<","<<i<<")="<<0<<endl;
            return 0;
        }else{
            // cout<<"gatherLoop("<<pos<<","<<i<<")="<<(pos%2^1)<<endl;
            return pos%2^1LL;
        }
    }
}
long long onedigit(long long A, long long B, long long i){
    return (gatherLoop(A-1,i)^gatherLoop(B,i))<<i;
}
int main(){
    long long A,B;
    cin>>A>>B;
    long long ans=0;
    for(long long i=0;i<40;i++){
        // cout<<i<<endl;
        ans^=onedigit(A,B,i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
#include<numeric>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;
	vector<int> a(100010);
	int even2 = 0, even4 = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0 && a[i] % 4 != 0) even2++;
		else if (a[i] % 4 == 0) even4++;
	}

	if (even2 == 0) {
		if (even4 >= n / 2) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}

	if (even4 >= ((n - even2) + ((n - even2) % 2)) / 2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
  int h,w;
  cin >>h>>w;
  
  vector<vector<char>> a(h, vector<char>(w));
  
  for (int i=0; i<h; ++i){
    for (int j=0; j<w; ++j){
      cin >> a.at(i).at(j);
    }
  }
  
  vector<bool> yokonoiro(h, false);
  vector<bool> tatenoiro(w, false);
  
  for (int i=0; i<h; ++i){
    for (int j=0; j<w; ++j){
      if (a.at(i).at(j) == '#') {
        yokonoiro.at(i) = true;
        tatenoiro.at(j) = true;
      }
    }
  }
  
  for (int i=0; i<h; ++i){
    if (yokonoiro.at(i)) {
      for (int j=0; j<w; ++j){
        if (tatenoiro.at(j)) {
          cout << a.at(i).at(j) ;
        }
      }
      cout << endl;
    }
  }
}

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

int main(void){
    int n, l;
    cin >> n >> l;
    
    string s[100];
    int i;
    for(i = 0; i < n; i++){
        cin >> s[i];
    }
    
    sort(s, s + n);
    
    for(i = 0; i < n; i++){
        cout << s[i];
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
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 REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll n, ll m){
    return n * (m / gcd(n, m));
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vi A(N);
    REP(i,N){
        cin >> A[i];
    }
    ll ans=0;
    REP(i,N){
        ans += A[i]-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<=i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int> sosu;
    int ord[100];
    reps(index, 2, N+10){
        bool divided=false;
        rep(j, sosu.size()){
            if(index%sosu[j]==0){
                divided=true;
                continue;
            }
        }
        if(divided==false) sosu.push_back(index);
        //cout<<index<<endl;
    }
    int count=0;
    rep1(I, N){
        if(I%2==0) continue;
        MEMSET(ord, 0);
        int ThisNum=I;
        rep(j, sosu.size()){
            while(ThisNum%sosu[j]==0){
                ord[j]++;
                ThisNum/=sosu[j];
            }
            if(ThisNum==1) break;
        }
        ll lp=1;
        rep(j, sosu.size()){
            lp*=(ord[j]+1);
            if(lp>8) break;
        }
        if(lp==8) count++/*, cout<<I<<endl*/;
    }
    cout<<count<<endl;
    return 0;
}


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

#include <bits/stdc++.h>


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;

class CAlchemist {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        multiset<double> ms;
        for (int i = 0; i < n; ++i) {
            double x;
            in >> x;
            ms.insert(x);
        }
        while (ms.size() != 1) {
            double a = *ms.begin();
            double b = *next(ms.begin());
            ms.erase(ms.find(a));
            ms.erase(ms.find(b));
            ms.insert((a + b) / 2);
        }
        out << fixed << setprecision(9);
        out << (*ms.begin());
    }
};


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


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  ++X;
  for(int i = 0; i < n; ++i) cin >> x[i];
  for(int i = 0; i < m; ++i) cin >> y[i];
  int mxx = *max_element(begin(x), end(x));
  ++mxx;
  int mny = *min_element(begin(y), end(y));
  int l = max(mxx, X);
  int r = min(mny, Y);
  if(l <= r) cout << "No War" << endl;
  else cout << "War" << endl;
}


Measured memory_bytes: 256
#https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r, mod):
   if ( r<0 or r>n ):
       return 0
   r = min(r, n-r)
   return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
   g1.append( ( g1[-1] * i ) % mod )
   inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
   g2.append( (g2[-1] * inverse[-1]) % mod )


x, y = map(int, input().split())

a = x+y
if a % 3 != 0:
    print(0)
    exit()

m = (2 * x - y) // 3

print(cmb(a // 3, m, mod))

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

int main() {
  int n;
  cin >> n;
  set<int> s;
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    s.insert(t);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main() {
	char sa[101];
	char sb[101];
	char sc[101];
	int a, b, c;
	int lena, lenb, lenc;
	int flag;

	scanf("%s", sa);
	scanf("%s", sb);
	scanf("%s", sc);

	lena = strlen(sa);
	lenb = strlen(sb);
	lenc = strlen(sc);

	a = b = c = -1;

	flag = 0;

	do {
		if (flag == 0) {
			a++;
			if (sa[a] == 'a') {

				flag = 0;
			}
			else if (sa[a] == 'b') {

				flag = 1;
			}
			else if (sa[a] == 'c') {

				flag = 2;
			}
		}
		else if (flag == 1) {
			b++;
			if (sb[b] == 'a') {

				flag = 0;
			}
			else if (sb[b] == 'b') {

				flag = 1;
			}
			else if (sb[b] == 'c') {

				flag = 2;
			}
		}
		else if (flag == 2) {
			c++;
			if (sc[c] == 'a') {

				flag = 0;
			}
			else if (sc[c] == 'b') {

				flag = 1;
			}
			else if (sc[c] == 'c') {

				flag = 2;
			}
		}
	} while (a < lena  && b < lenb  && c < lenc);

	if (a == lena)printf("A");
	else if (b == lenb)printf("B");
	else if (c = lenc)printf("C");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int w,h,n,w0=0,h0=0;
    cin>>w>>h>>n;
    int x,y,ai;
    rep(i,n){
        cin>>x>>y>>ai;
        if(ai==1) w0=max(w0,x);
        else if(ai==2) w=min(w,x);
        else if(ai==3) h0=max(h0,y);
        else if(ai==4) h=min(h,y);
    }
    if(w>w0&&h>h0) cout<<(w-w0)*(h-h0)<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi              acos(-1)
#define ll              long long
#define ld              long double
#define gcd             __gcd
#define bitscount       __builtin_popcount
#define ff              first
#define ss              second
#define MAXX            1e18
#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL)
//__builtin_popcount()  -->  counts how many 1 s are in a binary represented integer
//accumulate() --> finds sum of an array of integers
using namespace std;
int main()
{
    ll n, k, i, j;
    cin>>n>>k;
    vector<ll> v(n), dp(n);
    for(i=0; i<n; i++)
        cin>>v[i];
    for(i=0; i<n; i++){
        if(i == 0)
            dp[i] = v[i];
        else if(i>0 && i<=k)
            dp[i] = abs(v[i] - v[0]);
        else{
            dp[i] = MAXX;
            for(j=1; j<=k; j++){
                dp[i] = min(dp[i], dp[i-j]+abs(v[i]-v[i-j]));
            }
        }
    }
//    for(i=0; i<n; i++)
//        cout<<dp[i]<<" ";
    cout<<endl<<dp[n-1];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int m, d;
  cin >> m >> d;

  int ans = 0;
  FOR(i, 1, m + 1) {
    FOR(j, 10, d + 1) {
      if (j / 10 >= 2 && j % 10 >= 2 && (j / 10) * (j % 10) == i) ans++;
    }
  }
  cout << ans << '\n';
  

  
  return 0;
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())

xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))



xlist.sort()
ylist.sort()

xmax=xlist[N-1]
ymax=ylist[M-1]
xmin=xlist[0]
ymin=ylist[0]



if X+1<=Y and xmax<ymin and xmax<Y and ymin>X:
    print("No War")
else:
    print("War")
            

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int x = s.size();
	for (int i = 0; i < x; i++) {
		if (char(s[i]+n) > 'Z') {
			cout << char('A'- 'Z' - 1 + s[i] + n);
			continue;
		}
		cout << char(s[i] + n);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
def calc_pow(x, y):
    if y == 0:
        return 1

    else:
        ans = calc_pow(x, y//2)**2

        if y%2:
            ans *= x
        
        return ans % 1000000007

N = int(input())

k = calc_pow(8, N) + calc_pow(10, N) - 2*calc_pow(9, N)
print(k % 1000000007)

Measured memory_bytes: 9168
N = int(input())
A = list(map(int, input().split()))

#最大公約数
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

gcd_calc = A[0]
for a in A[1:]:
    gcd_calc = gcd(gcd_calc, a)

print(gcd_calc)


Measured memory_bytes: 14228
package main

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

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

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	N := nextInt()
	arr := make([]int, N+1)
	for i := 2; i <= N; i++ {
		Ai := nextInt()
		arr[Ai]++
	}
	for i := 1; i <= N; i++ {
		fmt.Println(arr[i])
	}

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

int main(){
	int d;
	cin >> d;
	if(d==25) cout << "Christmas" << endl;
	else if(d==24) cout << "Christmas Eve" << endl;
	else if(d==23) cout << "Christmas Eve Eve" << endl;
	else cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

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

def xyzsort(n, x, y, z):
	return [x + y + z, x + y - z, x - y + z, -x + y + z, x - y - z, -x + y - z, -x - y + z, -x - y - z][n]

max_score = 0
for n in range(8):
	xyz = sorted(XYZ, key=lambda x: xyzsort(n, x[0], x[1], x[2]))[::-1]
	#print(xyz)
	sx, sy, sz = 0, 0, 0
	for m in range(M):
		cx, cy, cz = xyz[m]
		sx, sy, sz = sx + cx, sy + cy, sz + cz
	#print(abs(sx) + abs(sy) + abs(sz))
	max_score = max(max_score, abs(sx) + abs(sy) + abs(sz))
print(max_score)


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	vi l(3);
	cin >> n;
	REP(i, 3)cin >> l[i];
	vi v(n);
	REP(i, n)cin >> v[i];
	ll p = 1;
	REP(i, n)p *= 4;
	ll ans = INF;
	REP(k, p) {
		vl sum(3, 0), cnt(3, 0);
		ll a = k;
		ll t = 0;
		REP(i, n) {
			if (a % 4 != 3) {
				sum[a % 4] += v[i];
				cnt[a % 4]++;
			}
			a /= 4;
		}
		
		bool ok = true;
		REP(i, 3) {
			if (cnt[i] == 0)ok = false;
			else t += 10 * (cnt[i] - 1);
		}

		if (ok) {
			REP(i, 3) {
				t += abs(l[i] - sum[i]);
			}
			chmin(ans, t);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# include"stdio.h"

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a==b)&&(b==c))printf("1\n");
    else if((a==b)||(b==c)||(a==c))printf("2\n");
    else printf("3\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    ll sum=0;
    rep(i,N) sum+=a[i];
    ll now=0,ans=IINF;
    rep(i,N){
        now+=a[i];
        chmin(ans,abs(sum-2*now));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力

vector<vector<ll> > G;
vector<bool> seen;
vector<ll> d;
vector<ll> f;
ll cnt=1;
//ll fcnt=1;
void dfs(ll v){
    seen[v] = 1;
    d[v] = cnt;
    cnt++;
    rep(i,G[v].size()){
        if(seen[G[v][i]] == 0){
            dfs(G[v][i]);
        }
    }
    f[v] = cnt;
    cnt++;
}

int main() {
    ll n;
    cin >> n;
    G.resize(n);
    seen.resize(n);
    d.resize(n);
    f.resize(n);

    rep(i,n){
        ll u,k;
        cin>>u>>k;
        rep(j,k){
            ll v;
            cin>>v;
            G[i].pb(v-1);
        }
    }
    rep(i,n){
        if(seen[i]==0)
            dfs(i);
    }

    rep(i,n){
        cout <<i+1<<" "<< d[i]<<" "<<f[i]<<endl;
    } 
    
   
    


    return 0;
    

}


Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    cin >> N;
    if(N % 2){
        cout << N * 2 << endl;
    }else{
        cout << N << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
   char a[2][3],b[2][3];
   char ch;
   int i,j;
   for(i=0;i<2;i++)
   {
   for(j=0;j<3;j++)
   scanf("%c",&a[i][j]);
   scanf("%c",&ch);
   }

   int r=1,c=2;
   for(i=0;i<2;i++)
   for(j=0;j<3;j++)
   b[r-i][c-j]=a[i][j];

    int flag=1;
   for(i=0;i<2;i++)
   {
   for(j=0;j<3;j++)
   if(a[i][j]!=b[i][j])
   {
       flag=0;
       printf("NO\n");
       break;
   }
   if(flag==0)
   break;
   }
   if(flag==1)
   printf("YES\n");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		System.out.println(str.toUpperCase());

	}
}

Measured memory_bytes: 15012
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define maxn 2000000
using namespace std;
int ladiv[maxn];
bool sl[maxn];
int n;
int a;
bool vis[maxn];
int main() {
    for(long long i=2;i<maxn;i++) {
        if(!sl[i]) {
            ladiv[i]=i;
            for(long long j=i*i;j<maxn;j+=i) {
                if(ladiv[j]==0) ladiv[j]=i;
                sl[j]=true;
            }
        }
    }
    scanf("%d",&n);
    int g=0;
    bool pw=true;
    for(int i=0;i<n;i++) {
        scanf("%d",&a);
        g=__gcd(a,g);
        int pr=-1;
        while(a!=1) {
            if(vis[ladiv[a]] && pr!=ladiv[a]) pw=false;
            pr=ladiv[a];
            vis[pr]=true;
            a/=ladiv[a];
        }
    }
    if(g!=1) printf("not coprime");
	else if(!pw) printf("setwise coprime");
	else printf("pairwise coprime");
	return 0;
}


Measured memory_bytes: 14568
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9

void increaseHeight(const vector<int> &H, vector<int> & H_c, const int l, const int r, int &count) {
  int min_h = INF;
  int min_h_idx = -1;
  for (int i = l; i <= r; i++) {
    int diff = H[i] - H_c[i];
    if(min_h > diff) {
      min_h = diff;
      min_h_idx = i;
    }
  }
  
  if (min_h != INF) {
    count += min_h;
    for (int i = l; i <= r; i++) {
      H_c[i] += min_h;
    }

    increaseHeight(H, H_c, l, min_h_idx-1, count);
    increaseHeight(H, H_c, min_h_idx+1, r, count);
  }
}

int main() {
  int N;
  cin >> N;
  
  vector<int> H, H_c(N, 0);
  H.reserve(N);
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    H.emplace_back(h);
  }
  
  int count = 0;
  increaseHeight(H, H_c, 0, N - 1, count);
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		for (int i = 1; i < s.length; i++) {
			if (s[i - 1] == s[i]) {
				System.out.println(i + " " + (i + 1));
				return;
			}
		}
		for (int i = 2; i < s.length; i++) {
			if (s[i - 2] == s[i]) {
				System.out.println((i - 1) + " " + (i + 1));
				return;
			}
		}
		System.out.println("-1 -1");
	}
}


Measured memory_bytes: 26196
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

using cat = long long;

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N;
	cin >> N;
	vector< vector<int> > dist(N, vector<int>(N, N+1));
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			dist[i][j] = min(min(i, N-1-i), min(j, N-1-j));
	vector< vector<char> > cost(N, vector<char>(N, 1));
	cat ans = 0;
	for(int i = 0; i < N*N; i++) {
		int a;
		cin >> a;
		a--;
		int x = a/N, y = a%N;
		cost[x][y] = 0;
		ans += dist[x][y];
		static queue< pair<int, int> > q;
		q.push({x, y});
		while(!q.empty()) {
			x = q.front().first, y = q.front().second;
			q.pop();
			int d = dist[x][y] + cost[x][y];
			static constexpr int dx[] = {1, -1, 0, 0};
			static constexpr int dy[] = {0, 0, 1, -1};
			for(int k = 0; k < 4; k++) {
				if(dx[k]+x < 0 || dy[k]+y < 0 || dx[k]+x == N || dy[k]+y == N) continue;
				int xn = x + dx[k], yn = y + dy[k];
				if(d >= dist[xn][yn]) continue;
				dist[xn][yn] = d;
				q.push({xn, yn});
			}
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 4908
def myAnswer(N:int,X:list) -> None:
   tmp = sorted(X)
   r1 = tmp[N//2-1]
   r2 = tmp[N//2]
   for x in X:
      if(x <=r1):
         print(r2)
      else:
         print(r1)




def modelAnswer():
   return
def main():
   N = int(input())
   X = list(map(int,input().split()))
   myAnswer(N,X)
if __name__ == '__main__':
   main()

Measured memory_bytes: 25624
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    while(1){
        int n,l,r;
        cin >> n >> l >> r;
        if(n==0 && l==0 && r==0) break;
        vector<int> v(n);
        rep(i,n) cin >> v[i];
        int cnt = 0;
        for(int i=l; i<=r; i++){
            bool ok = 0;
            for(int j=0;j < n;j++){
                if(i%v[j] == 0){
                    ok = 1;
                    if((j+1) % 2 != 0){
                        cnt++;
                    } 
                    break;
                }
            }
            if(ok == 0 && n%2 == 0) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll dp[2][100000]; //0 -> w, 1 -> b
vector<int> G[100000];
bool used[100000];

void dfs(int v){
    used[v] = true;
    ll b = 1, w = 1;
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]){
            dfs(G[v][i]);
            b *= dp[0][G[v][i]];
            b %= MOD;
            w *= (dp[1][G[v][i]]+dp[0][G[v][i]]);
            w %= MOD;
        }
    }
    dp[0][v] = w;
    dp[1][v] = b;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(0);
    cout << (dp[0][0]+dp[1][0])%MOD << endl;
}

Measured memory_bytes: 12928
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll R,C; cin >> R >> C;
    vector<string> S(R);
    for(auto& in:S) cin >> in;
    vector<int> bitcnt(1<<C);
    for(int i = 0; i < (1<<C);i++){
        bitcnt[i] = __builtin_popcount(i);
    }
    vector<vector<int>> dp(2,vector<int>(1<<C,-1));
    int cur = 0, next = 1;
    dp[cur][0] = 0;
    for(int i = 0; i < R;i++){
        for(int j = 0; j < C;j++){
            for(int k = 0; k < (1<<C);k++) dp[next][k] = -1;
            for(int k = 0; k < (1<<C);k++){
                if(dp[cur][k] == -1) continue;
                int cur_cnt = bitcnt[k&(1<<j) - 1];
                if(cur_cnt < S[i].length()){
                    int tmp = dp[cur][k];
                    if(cur_cnt > 0 && (k & 1<<(j-1))){
                        if(S[i][cur_cnt-1] == S[i][cur_cnt]) tmp++;
                    }
                    if(i > 0 && (k & (1<<j))){
                        if(S[i][cur_cnt] == S[i-1][S[i-1].length() - bitcnt[k >> j]]) tmp++;
                    }
                    dp[next][k|1<<j] = max(dp[next][k|1<<j],tmp);
                }
                if(C - j > S[i].length() - cur_cnt){
                    dp[next][k & ~(1<<j)] = max(dp[next][k & ~(1<<j)],dp[cur][k]);
                }
            }
            cur = (cur == 0)? 1:0;
            next = (next == 0)?1:0;
        }
    }
    cout <<2 * (*max_element(dp[cur].begin(), dp[cur].end())) << endl;
    return 0;
}

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

int main(){
  int N;

  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);

  for(int i=0;i<N;i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }

  for(int i=0;i<N;i++){
    int aa, bb, cc;

    aa = a.at(i) * a.at(i);
    bb = b.at(i) * b.at(i);
    cc = c.at(i) * c.at(i);

    // cout << aa << endl;
    // cout << bb << endl;
    // cout << cc  << endl;

    if(aa == bb + cc || bb == aa + cc || cc == aa + bb){
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}



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

using namespace std;

typedef long long ll;

const int N = 21;
const ll mod = 1e9 + 7;

ll dp[N][1 << N];
ll a[N][N];
int sz, n;

ll solve(int k, int mask)
{
	if(k < 0)
		return mask == sz;

	ll &ans = dp[k][mask];

	if(ans != -1)
		return ans;

	ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(a[k][i] && (mask & (1 << i)) == 0)
			ans += solve(k - 1, mask | (1 << i));
	}

	// cout << endl;

	return ans % mod;	
}

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

	memset(dp, -1, sizeof(dp));

	cin >> n;

	sz = (1 << n) - 1;

	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];

	// dp[0][0] = 1;

	// for(int i = 0; i < n; i++)
	// {
	// 	// cout << "db: " << i << endl;
	// 	for(int mask = 0; mask < (1 << n); mask++)
	// 	{
	// 		for(int j = 0; j < n; j++)
	// 		{
	// 			if(!a[i][j] || ((1 << j) & mask == (1 << j)))
	// 				continue;

	// 			dp[i + 1][mask | (1 << j)] = (dp[i + 1][mask | (1 << j)] + dp[i][mask]) % mod;
	// 		}
	// 	}
	// }

	cout << solve(n - 1, 0) << endl;

	return 0;
}

Measured memory_bytes: 344448
n, k = map(int, input().split())
p =[int(s) for s in input().split()]
s = 0
key = 0
pred = 0
acc = {}
for h in range(n):
    if h == 0:
        acc[0] = p[0]
    else:
        acc[h] = acc[h-1]+p[h]
for r in range(n-k+1):
    if r == 0:
        s2 = acc[k-1]
    else:
        s2 = acc[k+r-1]-acc[r-1]
    if s2>s:
        s = s2
        key = r
print(0.5*(s+k))

Measured memory_bytes: 43548
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        1000005
#define mod         1000000007  
#define pi          3.1415926535897932384626433
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d,x;
    cin>>a>>b>>c>>d;
    x=max({a*1ll*c,a*1ll*d,b*1ll*c,b*1ll*d});
    cout<<x;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

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


Measured memory_bytes: 3572
import sys


def solve():
    readline = sys.stdin.readline
    N, W = map(int, readline().split())
    WV = (map(int, readline().split()) for _ in range(N))
    INF = 10 ** 15
    MAX_V = 100 * 10**3 + 10
    dp = [INF] * MAX_V
    dp[0] = 0
    for w, v in WV:
        for i in range(MAX_V-1, v-1, -1):
            tmp_dp = dp[i-v] + w
            if dp[i] > tmp_dp:
                dp[i] = tmp_dp
    for v, w in enumerate(dp):
        if w <= W:
            ans = v
    return ans


if __name__ == "__main__":
    answer = solve()
    print(answer)


Measured memory_bytes: 5740
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
    string a[10000];
    int c,d,e;
    while(true){
        cin>>a[0];
        if(a[0]=="-"){
            break;
        }
        cin>>c;
        e=a[0].size();
        for(int i=1;i<=c;i++){
            cin>>d;
            a[i]=a[i-1].substr(d,e-d)+a[i-1].substr(0,d);
        }
        cout<<a[c]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;

void solve(){
    string s;cin>>s;
    int n=s.size();
    int ans = n,a=0;
    fol(i,n){
        if (s[i]=='S') a++;
        else{
            if (a!=0){
                ans-=2;
                a--;
            }
        }
    }
    cout << ans <<endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int d[5001];

int main()
{
	int n;
	int i,j;
	int max;
	int sum;
	for(i=0;i<5001;i++){
		d[i]=0;
	}
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d",&d[i]);
			if(i!=0) d[i]+=d[i-1];
		}
		sum=d[0];
		for(i=0;i<n;i++){
			if(d[i]>sum) sum=d[i];
			for(j=0;j<i;j++){
				if((d[i]-d[j])>sum) sum=d[i]-d[j];
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}

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

int main() {
	vector<int> vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;
	cout << vec.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>


using namespace std;

#define Max INT_MAX
#define Inf (INT_MAX/2)
#define Min INT_MIN


#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
// s <= x < g ?
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
// 0 <= x < w && 0 <= y < h ?
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

typedef pair<int, int> P;

int main()
{
    int N;
    cin >> N;
    rep(i,N){
        int a,b,c;
        int d[3];
        cin >> a >> b >> c;
        d[0] = a;
        d[1] = b;
        d[2] = c;
        sort(d, d+3);
        if( pow(d[0],2) + pow(d[1],2) == pow(d[2],2) ){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

int main(){
  long double a,b,c;
  cin >> a >> b >> c;
  long double left = a+b+2*sqrt(a*b);
  long double right = c;
  if(left < right) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n,m,l = (int(x) for x in input().split())
a = []
b = []
c = [[] for i in range(n)]

for i in range(n):
        a.append(list(int(x) for x in input().split()))
for i in range(m):
        b.append(list(int(x) for x in input().split()))
for i in range(n):
    for j in range(l):
        w = 0
        for k in range(m):
            w += a[i][k] * b[k][j]
        else:
            c[i].append(w)

for i in range(n):
    for j in range(l):
        print(c[i][j] ,end = "")
        if j == l-1:
            print()
        else:
            print(end = " ")


Measured memory_bytes: 6964
#!/usr/bin/env python3
t = int(input())

count = 0
speed = 1
margin = 0
while t > 0:
    t -= speed
    count += 1
    if margin + speed * 3 <= t:
        speed *= 3
        margin += speed
    elif t < margin:
        margin -= speed
        speed /= 3
print(count)



Measured memory_bytes: 5596
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    ll t = 0;
    cin >> t;
    vector<ll> time(n);
    for (int i=0; i<n; i++) {
        cin >> time.at(i);
    }
    sort(time.begin(), time.end());
    ll ans = 0;
    for (int i=1; i<n; i++) {
        ans += min(t, time.at(i)-time.at(i-1));
    }
    cout << ans + t << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cctype>
#include <string>
using namespace std;

int main()
{
    string str;
    int num, num1;
    cin >> num1  >> num >> str;

    transform(str.begin()+num-1,str.begin()+num,str.begin()+num-1,::tolower);
    cout <<  str << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int x;
	cin>>x;
	if(x>=400&&x<=599){
		cout<<"8";
	}
	else if(x>=600&&x<=799){
		cout<<"7";
	}
	else if(x>=800&&x<=999){
		cout<<"6";
	}
	else if(x>=1000&&x<=1199){
		cout<<"5";
	}
	else if(x>=1200&&x<=1399){
		cout<<"4";
	}
	else if(x>=1400&&x<=1599){
		cout<<"3";
	}
	else if(x>=1600&&x<=1799){
		cout<<"2";
	}
	else if(x>=1800&&x<=1999){
		cout<<"1";
	}
	return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args){	
		int i , j , k , l;
		Scanner sc = new Scanner(System.in);	
		int N = sc.nextInt();
		int allcount = 0;
		int [] interval = new int[N];
		int [] nameArrayIndex = new int[N];
//-------------??????????????\???----------------------------------------------		
	    String name = sc.next();
		char[] nameArray = new char[name.length()];
		for(i = 0 ; i < name.length() ; i++){
			nameArray[i] = name.charAt(i);
		}		
//-------------??????????????\???----------------------------------------------
	    String[] board = new String[N];
		for(i = 0 ; i < N ; i++){
			board[i] = sc.next();
		}
		char[][] boardArray = new char[N][100];
		for(i = 0 ; i < N ; i++){
			for(j = 0 ; j < board[i].length() ; j++){
				boardArray[i][j] = board[i].charAt(j);
			}
		}
//------------------------------------------------------------
		for(i = 0 ; i < N ; i++){
out1:		for(j = 0 ; j < board[i].length() ; j++){
				if(boardArray[i][j] == nameArray[0]){
					for(k = j + 1 ; k < board[i].length() ; k++){
						if(boardArray[i][k] == nameArray[1]){
							interval[i] = k - j ;
							nameArrayIndex[i] = 2;
							for(l = k + interval[i] ; l < board[i].length() ; l = l + interval[i]){
								if(boardArray[i][l] == nameArray[nameArrayIndex[i]]){
									if(nameArrayIndex[i] == name.length() - 1){
										allcount++;
										break out1;
									}
									nameArrayIndex[i]++;
								}else{
									break;
								}
							}
						}
					}
				}
			}
		}
		System.out.println(allcount);
	}
}

Measured memory_bytes: 27792
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
// #include <map>
#include <iomanip>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 

const LL inf = 1e18;
LL d[444][444], a[444];
LL vis[444][444], s[444];

LL dp(int L, int R){
	if(vis[L][R]) return d[L][R];
	vis[L][R] = 1;
	if(L == R) return d[L][R] = 0;
	d[L][R] = inf;
	for(int i = L + 1; i <= R; ++i){
		d[L][R] = min(d[L][R], dp(L, i - 1) + dp(i, R) + s[R] - s[L - 1]); 
	}
	return d[L][R];
}

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;

	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		s[i] = s[i - 1] + a[i];
	}
	cout << dp(1, n) << endl;
	return 0;
}

Measured memory_bytes: 3072