akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())

switch = []
for i in range(M):
  ks = input().split()
  k = int(ks[0])
  for j in range(k):
    if j == 0:
      switch.append([int(ks[j + 1]) - 1])
    else:
      switch[-1].append(int(ks[j + 1]) - 1)

p = list(map(int, input().split()))

com = 2 ** N
ans = 0
for i in range(com):
  cnt = 0
  for j in range(M):
    sw_cnt = 0
    for s in switch[j]:
      sw_cnt += int((i % (2 ** (s + 1))) / (2 ** s))
    if sw_cnt % 2 == p[j]:
      cnt += 1
  if cnt == M:
    ans += 1

print(ans)

Measured memory_bytes: 3064
s = list(str(input()))
ans = 0
l = []
p = 0
m = 0
n = len(s)
if n == 1:
  if s[0] == "<":
    l = [1]
  else:
    l = [-1]
for i in range(n):
  if i == 0:
    if s[i] == "<":
      p += 1
    else:
      m -= 1
  else:
    if s[i] == s[i-1]:
      if s[i] == "<":
        p += 1
        if i == n-1:
          l.append(p)
      else:
        m -= 1
        if i == n-1:
          l.append(m)
    else:
      if s[i] == "<":
        l.append(m)
        m = 0
        p = 1
        if i == n-1:
          l.append(p)
      else:
        l.append(p)
        p = 0
        m = -1
        if i == n-1:
          l.append(m)

l.append(0)
for i in range(len(l)-1):
  if l[i] > 0:
    ans += l[i]*(l[i]-1)//2
    ans += max(l[i],-(l[i+1]))
  else:
    ans += (l[i])*(l[i]+1)//2
    if i == 0:
      ans += -(l[i])
print(ans)

Measured memory_bytes: 9776
'use strict'

function main(s) {
  s = s.split('\n')[0].split(' ').map(n => Number(n));

  const A = s[0];
  const B = s[1];
  const C = s[2];
  const X = s[3];
  const Y = s[4];
  const min = Math.min(X, Y);

  // AとBをそれぞれ買う
  const case1 = A * X + B * Y

  // ABセットで可能な限り組み替えて、残りをそれぞれ買う
  const case2 = (2 * C * min) + ((X - min) * A) + ((Y - min) * B)

  // 全てABセットで組み替える
  const case3 = 2 * C * Math.max(X, Y);

  const answer = Math.min(...[case1, case2, case3]);
  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
N=gets.to_i
N.times do
  length_list =  gets().split().map(&:to_i).to_a

  hypotenuse = length_list.max

  cathetus_list = length_list - [hypotenuse]
  cathetus_list_size = cathetus_list.size
  if cathetus_list_size != 2 || !cathetus_list.kind_of?(Array)
    puts "NO"
  elsif (hypotenuse**2) == (cathetus_list[0]**2 + cathetus_list[1]**2)
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 8708
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    val b = (0 until n).map { sc.next().toLong() }
    println(problem2019c(n, a, b))
}

fun problem2019c(n: Int, a: List<Long>, b: List<Long>): Int {
    val diff = LongArray(n)
    var plusList = mutableListOf<Long>()
    val minusList = mutableListOf<Long>()
    for (i in 0 until n) {
        val diffI = a[i] - b[i]
        diff[i] = diffI
        if (diffI > 0) {
            plusList.add(diffI)
        } else if (diffI < 0) {
            minusList.add(diffI)
        }
    }
    if (minusList.isEmpty()) return 0
    if (plusList.sum() < Math.abs(minusList.sum())) return -1
    plusList = plusList.sortedDescending().toMutableList()
    val minusSum = Math.abs(minusList.sum())
    var count = 0
    var p = 0L
    for (i in 0 until plusList.size) {
        p += plusList[i]
        count++
        if (p >= minusSum) break
    }
    return minusList.count() + count
}

Measured memory_bytes: 66116
#include <cstdio>
#include <cmath>

#define PI 3.1416

using namespace std;

int main(){
  int d;
  float mt=90.0*PI/180;
  float t,x,y;
  x=y=0.0;
  while(1){
    scanf("%d,%f",&d,&t);
    if(d==0&&t==0) break;
    x+=d*cos(mt);
    y+=d*sin(mt);
    mt+=-t*PI/180;
  }
  if(x<0) x+=1;
  if(y<0) y+=1;
  printf("%.0f\n%.0f\n",floor(x),floor(y));
  return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    bool update = true;

    while (update) {
        update = false;
        rep(i, N) {
            if (A[i] >= N) {
                update = true;
                ll need = ((A[i] - (N - 1)) + N - 1) / N;
                A[i] -= need * N;
                rep(j, N) if (i != j) A[j] += need;
                ans += need;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


# inputs
A, B, C = 0, 0, 0


def set_inputs():
    global A, B, C
    A, B, C = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    if A == B and B == C:
        print("Yes")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int N; cin >> N;
	vector<int> V1, V2;
	int cnt1=1, cnt2=1;
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp; V1.push_back(tmp);
	}
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp; V2.push_back(tmp);
	}

	vector<int> V3;
	for (int i = 1; i <= N; i++) V3.push_back(i);
	while (V1 != V3)
	{
		cnt1++;
		next_permutation(V3.begin(), V3.end());
	}
	for (int i = 0; i < N; i++) V3[i] = i+1;
	while (V2 != V3)
	{
		cnt2++;
		next_permutation(V3.begin(), V3.end());
	}

	cout << abs(cnt1 - cnt2) << endl;

	return 0;
}

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

using namespace std;

const int MAX_N=100001;

// iツ嘉アツ姪堋づ泳ツ古つ連ツ堕アツつオツづ偲ヲツづェツづゥツ確ツ猟ヲツづーツ格ツ納
double dp[MAX_N][51];
double ret[MAX_N];

int main(){
	fill(ret,ret+MAX_N,0.0);
	for(int i = 0; i < MAX_N; i++)
		fill(dp[i],dp[i]+51,0);

	dp[1][1]=1.0;
	ret[1]=1.0;
	for(int i = 2; i < MAX_N; i++){
		double ss=0;
		// iツ嘉アツ姪堋づ泳ツ古つ連ツ堕アツつオツづ偲ヲツづェツづゥツ確ツ猟ヲツづーツ計ツ算
		for(int j = 0; j <= min(i,50); j++){
			// ツ債。ツ嘉アツミツス
			if(j==0){
				for(int k = 1; k <= min(i-1,50); k++)
					dp[i][j]+=dp[i-1][k]*(1-pow(0.5,k));
			}
			// ツ連ツ堕アツ偲ヲツ督セ
			else{
				dp[i][j]=dp[i-1][j-1]*(pow(0.5,j-1));
				ss+=dp[i][j];
			}
		}
		ret[i]=ss+ret[i-1];
	}

	int n;
	while(cin>>n&&n!=0){
		printf("%.3lf\n",ret[n]);
	}

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

using pii = pair<int64_t, int64_t>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;

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

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

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, M, Q; cin >> N >> M >> Q;

    vector<vector<size_t>> idx(N + 1);
    for (size_t i = 0; i < M; ++i) {
        size_t L, R; cin >> L >> R;
        idx[L].emplace_back(R);
    }

    for (size_t i = 1; i <= N; ++i) {
        if (!idx[i].empty()) {
            sort(idx[i].begin(), idx[i].end());
        }
    }

    while (Q--) {
        size_t p, q; cin >> p >> q;
        size_t res = 0;
        for (size_t i = p; i <= q; ++i) {
            if (!idx[i].empty()) {
                auto bad = upper_bound(idx[i].begin(), idx[i].end(), q);
                size_t dist = bad - idx[i].begin();
                res += dist;
            }
        }
        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 3456
K = $stdin.gets.to_i
A, B = $stdin.gets.split.map {|i| i.to_i }
a = A / K
am = A % K
b = B / K
bm = B % K
if (a >=1 && am == 0) || (b >= 1 && bm == 0)
  puts 'OK'
elsif a < b
  puts 'OK'
else
  puts 'NG'
end


Measured memory_bytes: 14404
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n, k;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> k;
  vll h(n);
  rep(i, 0, n) cin >> h[i];
  sort(ALL(h));
  ll ans = INF;
  rep(i, 0, n-k+1) {
    ans = min(ans, h[i+k-1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
a, b = map(str, input().split())
a = int(a)
cm = 0
for i in range(len(b)):
    if b[i] == '.':
        cm = len(b[i+1:])
        b = b[:i] + b[i+1:]
        break

b = int(b)

c = str(a * b)
ans = c[:-cm]
if not ans:
    print(0)
else:
    print(ans)


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
    int n;
    cin>>n;
    vin a(n),asum(n),ami(n);
    rep(i,n){
        cin>>a[i];
        asum[i]=i+a[i];
        ami[i]=i-a[i];
    }
    
    ll ans=0;
    Graph ascnt(n),amcnt(n);
    map<int ,int> asac,amac;
    set<int> st;
    rep(i,n){
        if(asac.count(asum[i])){
            ascnt[asac[asum[i]]].pb(i);
        }
        else{
            asac[asum[i]]=i;
            ascnt[i].pb(i);
            st.insert(i);
        }
        if(amac.count(ami[i])){
            amcnt[amac[ami[i]]].pb(i);
        }
        else{
            amac[ami[i]]=i;
            amcnt[i].pb(i);
        }
    }
    
    for(int i:st){
        int j=asum[i];
        
        if(!amac.count(j)) continue;
        int h=ascnt[i].size();
        vin mio(h,0);
        for(int x: amcnt[amac[j]]){
            int ng=-1,ok=h;
            while(ok-ng>1){
                int mid=(ok+ng)/2;
                if(ascnt[i][mid]<x) ok=mid;
                else ng=mid;
            }
            if(ok==h) continue;
            ans+=(h-ok);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 52472
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool graph[101][101];
int first_time[101],last_time[101];
int visited[101];
int tt=0;
int v[101][101];
#define white 0
#define gray 1
#define black 2//0回目の訪問、1回目の訪問、2回目の訪問の3種類あるからboolを使わない

void dfs(int v,int n) {
	for (int i = 2; i <= n; ++i) {
		if (graph[v][i] == false)continue;
		if (visited[i] == white) {
			visited[i] = gray;
			++tt;
			first_time[i] = tt;
			dfs(i, n);
		}
	}
	visited[v] = black;
	++tt;
	last_time[v] = tt;

}

int main() {
	int n;
	cin >> n;
	int u, k;
	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v[u][j + 1];
			graph[u][v[u][j + 1]] = true;
		}
	}
	for (int i = 1; i <= n; ++i) {//1つの始点から全訪問可能とは限らないから
		if (visited[i] == white) {
			visited[i] = gray;
			++tt;
			first_time[i] = tt;
			dfs(i, n);
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << i << " " << first_time[i] << " " << last_time[i] << endl;
	}
	return 0;
}


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

int main()
{
	string s;
	cin>>s;
	for(int i=0;i+1<s.size();i++)
	if(s[i]==s[i+1])
	{
		cout<<"Bad";
		return 0;
	}
	cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    int n;
    cin >> n;
    int a[n];
    ll s[n];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        s[i] = sum;
    }
    int le[n];
    int ri[n];
    int l = 0;
    int r = 2;
    for(int i = 1; i <= n-3; i++){
        for(int j = l; j <= i-1; j++){
            if(s[j] >= s[i]-s[j]){ 
                ll t1 = abs(s[j] - (s[i]-s[j]));
                ll t2 = abs(s[max(j-1, l)] - (s[i]-s[max(j-1, l)]));
                if(t1 < t2 || j==l){
                    le[i] = j;
                    l = j;
                    break;
                }
                else if(t1 >= t2 && j != l){
                    le[i] = j-1;
                    l = j-1;
                    break;
                }
            }
            else if(j == i-1){
                le[i] = i-1;
                l = i-1;
                break;
            }
        }
    }
    for(int i = 1; i <= n-3; i++){
        for(int j = r; j <= n-2; j++){
            if(s[j]-s[i] >= s[n-1]-s[j]){ 
                ll t1 = abs((s[j]-s[i]) - (s[n-1]-s[j]));
                ll t2 = abs((s[max(j-1, r)]-s[i]) - (s[n-1]-s[max(j-1, r)]));
                if(t1 < t2 || j==r){
                    ri[i] = j;
                    r = j;
                    break;
                }
                else if(t1 >= t2 && j != r){
                    ri[i] = j-1;
                    r = j-1;
                    break;
                }
            }
            else if(j == n-2){
                ri[i] = n-2;
                r = n-2;
                break;
            }
        }
    }
    ll rtn = 10000000000000000;
    for(int i = 1; i <= n-3; i++){
        vector<ll> v;
        v.push_back(s[le[i]]);
        v.push_back(s[i]-s[le[i]]);
        v.push_back(s[ri[i]]-s[i]);
        v.push_back(s[n-1]-s[ri[i]]);
        sort(v.begin(), v.end());
        rtn = min(rtn, v[3]-v[0]);
    }
    cout << rtn << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
 #define watch(x) cout<<(#x)<<" is " <<x<<"\n"

#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9 + 7;
const ll MAX = 1e5+7;
const ll inf = 1e18+1;


int main(){
 fastio;
 ll n;
 cin>>n;
 cout<<n*n<<"\n";
 return 0; 
}

Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a>=b&&a>=c)cout << a*10+b+c << endl;
  else if(b>=a&&b>=c)cout << b*10+a+c << endl;
  else cout << c*10+a+b << endl;
  return 0;
}


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

int main() {
        unsigned long long int X;
        unsigned long long int M = 100;
        int i;
        scanf("%lld", &X);

        i = 1;
        while(1) {
                M = M * 1.01;
                if(M >= X) {
                        printf("%d\n", i);
                        return 0;
                }
                i++;
        }


        return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define vi vector<int>
typedef long long llong;
using namespace std;

int main(){
	int n,wl;
	cin>>n>>wl;
	
	vi w(n),v(n);
	llong suw=0;
	int suv=0;
	REP(i,n){
		cin>>w[i]>>v[i];
		suw+=w[i];
		suv+=v[i];
	}
	
	vector<llong> dp(suv+1,suw);//dp[i]は価値iに必要な最小の重さ.
	dp[0]=0;
	REP(i,n){
		for(int j=suv;j>=0;--j){
			if(j>=v[i]) dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			else dp[j]=min(dp[j],dp[0]+w[i]);
		}
	}
	
	for(int i=suv;i>=0;--i){
		if(dp[i]<=wl){
			cout<<i<<endl;
			return 0;
		}
	}
}//復習.解答参考.

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  string t=regex_replace(s,regex("BC"),"X");
  ll l=t.length(),counta=0,ans=0;
  rep(i,l) {
    if(t[i]=='A') counta+=1;
    else if(t[i]=='X') ans+=counta;
    else counta=0;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include<string>
using namespace std;
void tim(string &a){
     
    for(int i=0;a[i];i++){
        if(a[i]<97)
        {    a[i]=(char)(a[i]+32);     
        }   
    }   }

int main(){
    string w,t;
    cin >>w;
    tim(w) ;
    cin>>t;
    int d=0;
    while(t!="END_OF_TEXT") {
        tim(t);
        if(w==t)
            d++;
        cin>>t;
    }
    cout <<d<<endl;
    return 0;
}

Measured memory_bytes: 3148
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt();
    let A0 = new Array(N);
    let A1 = new Array(N);
    for (let n = 0; n < N; n++) A0[n] = cin.getInt();
    for (let n = 0; n < N; n++) A1[n] = cin.getInt();
for (let n = 1; n < N; n++) {
A0[n] += A0[n-1];
A1[N-n-1] += A1[N-n];
}
let ans =0;
   for (let n = 0; n < N; n++) {
        let s = A0[n] + A1[n];
    if (ans < s) ans =s;
}
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0;this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll n;
ll x,y,w;
map<P,ll> m;

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

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x >> y >> w;
    m[P(x,y)] = w;
  }

  ll res = 0;
  for(map<P,ll>::iterator it = m.begin();it!=m.end();it++){
    ll x = it->first.first, y = it->first.second;
    for(int i=0;i<4;i++){
      ll tmp = it->second;
      //cout << y << " " << x << endl;
      //cout << tmp << endl;
      for(int j=0;j<3;j++){
	//cout << y+dy[i][j] << " " <<  x+dx[i][j] << endl;
	P p = P(x+dx[i][j], y+dy[i][j]);
	if(m.find(p)!=m.end())tmp += m[p];
      }
      //cout << tmp << endl;
      res = max(res,tmp);
    }
  }

  cout << res << " / 1" << endl;
}

  

Measured memory_bytes: 7444
r,c,i,j,R[101],C[101],t;
main(){
    for(scanf("%d%d",&r,&c),i=0;i<=r;i++)
        for(j=0;j<=c;j++){
            if(i<r&&j<c){
                scanf("%d",&t);
                R[i]+=t;
                C[j]+=t;
                C[c]+=t;
            }
            printf("%d%s",i==r?C[j]
                         :j==c?R[i]
                         :t,
                          j==c?"\n"
                         :" ");
        }
}

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

using namespace std;

#define int long long
int a[505];
int n, k;

bool check(int x) {
    vector < pair < int, int > > Q;
    int sum1 = 0, cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] % x == 0) continue;
        int x1 = a[i] % x, x2 = x - x1;
        Q.push_back({x1, x2});
        cnt++;
        sum1 += x1;
    }
    sort(Q.begin(), Q.end());
    if (sum1 % x == 0) {
        int t = cnt - sum1 / x;
        int tt = 0;
        for (int j = 0; j < t; ++j) tt += Q[j].first;
        if (tt <= k) return true;
    }
    return false;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int sum = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 1;
    for (int i = 1; i * i <= sum; ++i) {
        if (sum % i == 0) {
            if (check(i)) ans = max(ans, i);
            if (check(sum / i)) ans = max(ans, sum / i);
        }
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <array>
#include <bitset>

using namespace std;

int func( int N, bool* h, bool* sw ){
  for(int i=1; i<N-1; i++){
    sw[i+1] = h[i]!=sw[i]^sw[i-1];
  }

  bool accept1 = sw[0]==sw[N-2]==h[N-1]^!sw[N-1];
  bool accept2 = sw[1]==sw[N-1]==h[0]  ^!sw[0];

  if( accept1&&accept2){
    for(int i=0; i<N; i++){
      if(sw[i]){
        printf("%c",'S') ;
      }
      else{
        printf("%c",'W') ;
      }
    }
    printf("\n") ;
    std::exit(0) ;
  }
}

int main( int argc, char *argv[] ){
  int N ;
  scanf("%d",&N) ;

  char* s  = new char[N] ;
  bool* h  = new bool[N] ;
  bool* sw = new bool[N] ;

  scanf("%s",s) ;

  for(int i=0; i<N; i++){
    h[i] = s[i]=='o';
  }

  sw[0] = true;  sw[1] = true;
  func( N, h, sw );
  sw[0] = true;  sw[1] = false;
  func( N, h, sw );
  sw[0] = false; sw[1] = true;
  func( N, h, sw );
  sw[0] = false; sw[1] = false;
  func( N, h, sw );

  printf("%d\n",-1) ;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>

#define INF 2000000000

using namespace std;

int n;
long long a, b;
long long arr[100000];

int main() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	long long l = 1, r = 1000000000;
	long long ans = 0;
	while (l <= r) {
		long long mid = (l + r) / 2;
		long long cnt = mid;
		for (int i = 0; i < n; i++) {
			long long ll = 0, rr = mid;
			long long curAns = INF;
			while (ll <= rr) {
				long long mm = (ll + rr) / 2;
				if (mm * b + (mid - mm) * a >= arr[i]) {
					curAns = mid - mm;
					ll = mm + 1;
				}
				else {
					rr = mm - 1;
				}
			}
			cnt -= curAns;
			if (cnt < 0)
				break;
		}
		if (cnt >= 0) {
			r = mid - 1;
			ans = mid;
		}
		else {
			l = mid + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(){

	double r,r_s,r_l;

	scanf("%lf",&r);

	r_s =(double)M_PI * r * r;
	r_l =(double)2 * M_PI * r;

	printf("%lf %lf\n",r_s,r_l);

	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int x;  
//  cout << a << endl;
//  cout << b << endl;
  if(((a + b) % 2 ) != 0 ){
    x = 1;
  }else{
    x = 0;
  }  
  cout << (a + b) / 2 + x   << endl;  
}


Measured memory_bytes: 256
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
args = sys.argv


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if len(args) == 2 and args[1] == "DEBUG" else dump_dummy
N = int(input())
S = [input() for i in range(N)]

D = {'M': [], 'A': [], 'R': [], 'C': [], 'H': []}
for Si in S:
    if Si[0] in D:
        D[Si[0]].append(Si)

dump(D)

ans = 0
for x in it.combinations("MARCH", 3):
    x0, x1, x2 = x
    dump(x0, x1, x2)
    ans += len(D[x0])*len(D[x1])*len(D[x2])
print(ans)


Measured memory_bytes: 60760
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;

int dat[1000100] = { 0 };
bool mlt[1000100] = { 0 };

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

	vector<int> a(n);

	rep(i, n) {
		cin >> a[i];
	}


	int m;
	rep(i, n) {
		dat[a[i]]++;
		if (dat[a[i]] > 1) continue;
		
		
		m = 2;
		while (a[i] * m <= 1000000) {
			mlt[a[i] * m] = true;
			m++;
		}
	}

	int ans = 0;
	rep(i, n) {
		if (mlt[a[i]] == false && dat[a[i]] == 1)
			ans++;
	}



	cout << ans;


}




Measured memory_bytes: 8904
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n,m,ans=0;
    cin>>n>>m;
    Graph G(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vec v(n);
    rep(i,n) v[i]=i;
    do{
        if(v[0]==0){
            bool ok=true;
            for(int i=0;i<n-1;i++){
                bool ok1=false;
                for(auto u:G[v[i]]){
                    if(u==v[i+1]) ok1=true;
                }
                if(!ok1){
                    ok=false;
                    break;
                }
            }
            if(ok)ans++;
        }
    }while(next_permutation(all(v)));
    cout<<ans<<endl;
}

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

int main(){
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> dish(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        dish[i] = {a, b};
    }
    sort(dish.begin(), dish.end());
    
    int ans = 0;
    vector<int> dp(T+1, 0);
    for (int i = 0; i < N; i++) {
        int a = dish[i].first;
        int b = dish[i].second;
        for (int j = max(T-a, 0); j < T; j++) {
            ans = max(ans, dp[j]+b);
            
        }
        for (int j = T; j >= a; j--) {
            dp[j] = max(dp[j], dp[j-a]+b);
        }
    }
    
    for (int i = 0; i <= T; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}


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

long long int dp[101010];

int main() {
    int n,m; cin>>n>>m;
    vector<bool> ok(101010, true);
    for(int i=0;i<m;++i) {
        int a;cin>>a;
        ok[a] = false;
    }
    
    dp[0] = 1;
    for(int i=0;i<n;++i) {
        if (ok[i+1]) dp[i+1] = (dp[i+1] + dp[i]) % (long long int)(1e9 + 7);
        if (ok[i+2]) dp[i+2] = (dp[i+2] + dp[i]) % (long long int)(1e9 + 7);
    }
    
    // for(int i=0;i<=n;++i) cout << dp[i] << endl;
    cout << dp[n] << endl;
    
    return 0;
}

Measured memory_bytes: 4316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

// mod付きpower
// x^n
ll modpow(ll x, int n) {
	if (n == 0) return 1LL;
	else if (n % 2 == 0) return modpow((x*x) % MOD, n / 2) % MOD;
	else return (modpow((x*x) % MOD, n / 2) * x) % MOD;
}

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

	vector<bool> V;
	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') V.push_back(true);
		else V.push_back(false);
	}

	ll ans = modpow(3, V.size() - 1);
	ll cnt = 2;
	for (int i = 1; i < V.size(); i++) {
		if (V[i]) {
			ans += cnt * modpow(3, V.size() - i - 1);
			ans %= MOD;
			cnt *= 2;
			cnt %= MOD;
		}
	}
	ans += cnt;

	cout << ans % MOD << endl;

	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> m;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        m[tmp]++;
    }
    vector<pair<int, int>> keys;
    for(auto itr : m) {
        keys.push_back({itr.first, itr.second});
    }

    sort(keys.begin(), keys.end(), [=](const auto lhs, const auto rhs) {
            return lhs.second > rhs.second;
            });

    int l = 0;
    int r = keys.size()-1;
    for(; r >=0; --r) {
        if(keys[r].second > 1)
            break;
    }
    if(r == l && keys[r].second < 3) {
        ++r;
    }

    int n = 0;
    while(l<=r) {
#if 0
        cout << n << ": l=(" << keys[l].first << "," << keys[l].second << ")";
        cout << " r=(" << keys[r].first << "," << keys[r].second << ")" << endl;;
#endif
        keys[l].second--;
        keys[r].second--;
        ++n;
        if(keys[l].second <= 1) {
            ++l;
        }
        if(keys[r].second <= 1) {
            --r;
        }
    }
    cout << N - (n*2) << endl;

    return 0;
}



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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  int N;
  cin >> N ;
  vi a(N);
  rep(i,N) cin >> a[i] ;
  double s = 0;
  rep(i,N) s+=a[i];
  s /= double(N);
  double mi = 1e10;
  int ans;
  rep(i,N){
    if(chmin(mi,abs(s-double(a[i])))) ans=i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

if a * a * b > 2 * x:
    print(90 - math.degrees(math.atan((2 * x / (a * b * b)))))

else:
    x = a * a * b - x
    print(math.degrees(math.atan((2 * x / (a * a * a)))))

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    int w, h, x, y, r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(x+r<=w && x-r>=0 && y+r<=h && y-r>=0){
      printf("Yes\n");
       } else{
       printf("No\n");
       }
       }

Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define foreach(c,itr) for(__typeof(c)::iterator itr=c.begin();itr!=c.end();itr++)
typedef long long ll;
typedef long double ld;
int i,j;

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

    ll x[2],y[2];
    cin>>x[0]>>x[1]>>y[0]>>y[1];
    ll ans=-1000000000000000005;
    rep(i,2){
    	rep(j,2){
    		if(x[i]*y[j]>ans) ans=x[i]*y[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
import scipy.misc as scm

h, w, a, b = [int(i) for i in input().split()]

p = 10**9 + 7
ans = 0

def fact(n, p=10**9 + 7):
    f = [1]
    for i in range(1, n+1):
        f.append(f[-1]*i%p)
    return f

def invfact(n, f, p=10**9 + 7):
    inv = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        inv.append(inv[-1]*i%p)
    return inv[::-1]

f = fact(h+w)
rf = invfact(h+w, f)

for i in range(b, w):
    ans += (f[h-a+i-1] * rf[h-a-1] % p * rf[i] % p) * (f[a+w-i-2] * rf[a-1] % p * rf[w-i-1] % p) % p
    ans %= p 

print(ans)

Measured memory_bytes: 31064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N; cin >> N;
    vector<double> v(N);
    for(int i=0; i<N; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double d=v[0];
    for(int i=1; i<N; i++){
        d = (d + v[i])/2;
    }
    cout << fixed << setprecision(10) << d << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> a(3 * N);
  REP(i,3 * N) cin >> a[i];

  priority_queue<int, vector<int>, greater<int>> quea;
  vector<ll> suma(N + 1, 0);
  REP(i,N) quea.push(a[i]);
  REP(i,N) suma[0] += a[i];
  for(int i = N; i < 2 * N; ++i) {
    quea.push(a[i]);
    int p = quea.top();
    quea.pop();
    suma[i - N + 1] = suma[i - N] + a[i] - p;
  }

  priority_queue<int> queb;
  vector<ll> sumb(N + 1, 0);
  REP(i,N) queb.push(a[3 * N - 1 - i]);
  REP(i,N) sumb[N] += a[3 * N - 1 - i];
  for(int i = 2 * N - 1; i >= N; --i) {
    queb.push(a[i]);
    int p = queb.top();
    queb.pop();
    sumb[i - N] = sumb[i - N + 1] + a[i] - p;
  }

  ll ret = -1e18;
  REP(i,N + 1) {
    ret = max(ret, suma[i] - sumb[i]);
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 4088
import java.util.*;

public class Main {

    private static int findF(int[] f, int x) {
        if (f[x] == x) return x;
        return f[x] = findF(f, f[x]);
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] f = new int[n];
        for (int i = 0; i < n; i++) f[i] = i;
        for (int i = 0; i < m; i++) {
            int a = scan.nextInt() - 1;
            int b = scan.nextInt() - 1;
            int fa = findF(f, a);
            int fb = findF(f, b);
            if (fa != fb) {
                if (fa < fb) f[fb] = fa;
                else f[fa] = fb;
            }
        }
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            int fa = findF(f, i);
            num[fa]++;
        }
        int ans = 1;
        for (int i = 0; i < n; i++) {
            ans = Math.max(ans, num[i]);
        }
        System.out.println(ans);
    }
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int p[3];
int main() {
	for (int i = 0; i < 3; ++i)
		std::cin >> p[i];

	std::sort(p, p + 3);

	std::cout << p[0] + p[1] << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

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

    for (int i = 0; i < (int)S.size(); i++) {
        if ((i + 1) % 2 == 0) {
            if (S[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <numeric>
#include <limits>

const long long int INF = 1 << 30;
const int V = 10;
struct edge { int to, cost; };
std::vector<edge>v[100];
typedef std::pair<int, int>p;

int main() {
	long long int n, a[200000], sum = 0;
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
		sum += a[i];
	}
	long long int nSum = 0, ans = 1000000000000000;
	for (int i = n - 1;i > 0;i--) {
		sum -= a[i];
		nSum += a[i];
		if (llabs(sum - nSum) < ans) {
			ans = llabs(sum - nSum);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <set>

using namespace std;

long long n, ans;
long long a[200005];
set<long long> se;

int main()
{
    scanf("%lld", &n);
    for(long long i = 1; i <= n; i++)
    {
        long long t;
        scanf("%lld", &t);
        a[t] = i;
    }
    se.insert(0);
    se.insert(n + 1);
    for(long long i = 1; i <= n; i++)
    {
        set<long long>::iterator it = se.lower_bound(a[i]);
        long long now = i * (*it - a[i]);
        it--;
        ans += now * (a[i] - *it);
//        ans += i * (*it - a[i]) * (a[i] - *(it - 1));
        se.insert(a[i]);
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    set<int> s;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        s.insert(A);
        if(s.size() != i + 1){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<queue>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
int pap[10][10] = { 0 };
void big( int, int);
void medium(int, int);
void small(int, int);
int sx[5] = { 0,1,-1,0,0 }, sy[5] = { 0,0,0,1,-1 };
int mx[4] = { 1,1,-1,-1 }, my[4] = { 1,-1,1,-1 };
int bx[4] = { 0,0,2,-2 }, by[4] = { 2,-2,0,0 };
int nana = 100;
int main() {
	string str;
	while (cin >> str) {
		if (str[4] == '1') small(str[0]-'0', str[2] - '0');
		else if (str[4] == '2')medium(str[0]-'0', str[2] - '0');
		else if (str[4] == '3')big(str[0] - '0', str[2] - '0');
	}
	int max = -1;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			if (max < pap[i][j])max = pap[i][j];
		}
	}
	cout << nana << endl << max << endl;
	return 0;
}
void big( int x, int y) {
	for (int i = 0; i < 5; ++i) {
		if (x + sx[i] >= 0 && x + sx[i] < 10 && y + sy[i] >= 0 && y + sy[i] < 10) {
			if (pap[x + sx[i]][y + sy[i]]==0) nana--;
			pap[x + sx[i]][y + sy[i]]++;
		}
	}
	for (int i = 0; i < 4; ++i) {
		if (x + mx[i] >= 0 && x + mx[i] < 10 && y + my[i] >= 0 && y + my[i] < 10) {
			if (pap[x + mx[i]][y + my[i]]==0) nana--;
			pap[x + mx[i]][y + my[i]]++;
		}
	}
	for (int i = 0; i < 4; ++i) {
		if (x + bx[i] >= 0 && x + bx[i] < 10 && y + by[i] >= 0 && y + by[i] < 10) {
			if (pap[x + bx[i]][y + by[i]] == 0) nana--;
			pap[x + bx[i]][y + by[i]]++;
		}
	}
	return;
}
void medium( int x, int y) {
	for (int i = 0; i < 5; ++i) {
		if (x + sx[i] >= 0 && x + sx[i] < 10 && y + sy[i] >= 0 && y + sy[i] < 10) {
			if (pap[x + sx[i]][y + sy[i]] == 0) nana--;
			pap[x + sx[i]][y + sy[i]]++;
		}
	}
	for (int i = 0; i < 4; ++i) {
		if (x + mx[i] >= 0 && x + mx[i] < 10 && y + my[i] >= 0 && y + my[i] < 10) {
			if (pap[x + mx[i]][y + my[i]] == 0) nana--;
			pap[x + mx[i]][y + my[i]]++;
		}
	}
	return;
}
void small( int x, int y) {
	for (int i = 0; i < 5; ++i) {
		if (x + sx[i] >= 0 && x + sx[i] < 10 && y + sy[i] >= 0 && y + sy[i] < 10) {
			if (pap[x + sx[i]][y + sy[i]] == 0) nana--;
			pap[x + sx[i]][y + sy[i]]++;
		}
	}
	return;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a==b && a!=c)||(a==c && a!=b)||(b==c && a!=b))
    cout<<"Yes";
  else
    
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int i, j, k, n, res, flg;
    int score[200][3] = { 0 };
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        for (j = 0; j < 3; j++) {
            scanf("%d", &score[i][j]);
        }
    }
    
    for (i = 0; i < n; i++) {
        res = 0;
        for (j = 0; j < 3; j++) {
            flg = 0;
            for (k = 0; k < n; k++) {
                if (i != k) {
                    if (score[i][j] == score[k][j]) flg = 1;
                }
            }
            if (flg == 0) res += score[i][j];
        }
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define tr(container , s ) for(auto x : container ){cout << x << s;} cout<<endl;
#define one(x) cerr<<#x<<" : "<<x<<endl;
#define two(x,y) cerr<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<endl;
#define three(x,y,z) cerr<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<" , "<<#z<<" : "<<z<<endl;
#define PI acos(-1)
const int M = 1000000007;
const int N=3e5+5;
signed main()
{
    int tc , n , m , i , j;
    cin >> n >> m;
    int a[n];
    int sum=0;
    for(i=0 ;i <n; i++) {
        cin >> a[i];
        sum+=a[i];
    }
    sort(a , a+n , greater< int > ());
    for(i=0 ; i<m ; i++)
    {
        if(4*m*a[i] >= sum);
        else break;
    }
    if(i==m)
    {
        cout<<"Yes\n";
    }
    else cout<<"No\n";

}


Measured memory_bytes: 256
import sys
h,w,n = map(int,input().split())
y,x = map(int,input().split())
s = list(input())
t = list(input())

up = h
down = 1 
right = w
left = 1
for i in range(n-1,-1,-1):
    if i != n-1:
        if t[i] == 'D':
            down = max(down-1,1)
        elif t[i] == 'U':
            up = min(up+1,h)
        elif t[i] == 'R':
            left = max(left-1,1)
        else:
            right = min(right+1,w)
    if s[i] == 'D':
        up -= 1
    elif s[i] == 'U':
        down += 1
    elif s[i] == 'R':
        right -= 1
    else:
        left += 1
    
    #print(left,right)
    #print(down,up)

    if right == 0 or left == w or up == 0 or down == h:
        print('NO')
        exit()
    if right<left or up<down:
        print('NO')
        exit()

if up>=y and down<=y and right >= x and left<=x:
    print('YES')
else:
    print('NO') 

Measured memory_bytes: 70748
import math

n = int(input())

a = []
b = []

for i in range(1,int(math.sqrt(n))+1):
    if n % i == 0:
        a.append(i)
        b.append(n // i)

arr = []
for i in range(len(a)):
    arr.append(a[i] + b[i])

print(min(arr)-2)


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

using namespace std;
int main()
{
  int N;
  cin >> N;
  int point = 0;
  for (int i = 1; i < N + 1; i++)
  {
    if (to_string(i).size() % 2 != 0)
    {
      point++;
    }
  }
  cout << point << endl;
}

Measured memory_bytes: 384