akhauriyash/Code-Regression huggingface dataset:
#import <stdio.h>
int main() {
    int n;
    scanf("%d ", &n);
    char A[101];
    char B[101];
    char C[101];
    scanf("%s", A);
    scanf("%s", B);
    scanf("%s", C);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        char a = A[i];
        char b = B[i];
        char c = C[i];
        if (a != b && b != c && c != a) ans += 2;
        else if (!(a==b && b==c))
            ans++;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 2164
'use strict'
 
function main(input) {
  input = input.trim().split('\n')

  const N = Number(input.shift())

  const vals = input.map(v => v.split(' ').map(v => Number(v)))
   
  // 右か下にしかいけないので、どこで下にいくか、2 * N<=100通りでいけそう = o(200)
  let tmpmax = 0

  for (let i = 0; i <= N - 1; i++) {
    // i... どこで下に行くか
    let tmp = vals[0][0]

    let row1 = 0
    if (i > 0) {
      row1 = vals[0].slice(1, i + 1).reduce((a, b) => a + b)
    }

    let row2 = 0
    row2 = vals[1].slice(i, N).reduce((a, b) => a + b)
    tmp += row1 + row2 //vals[1][N - 1]

    tmpmax = Math.max(tmp, tmpmax)
  }

  console.log(tmpmax)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7624
#include<cstdio>

using namespace std;

long long x, y;

long long abs(long long a){
	if(a < 0) return -a;
	return a;
}

long long solve(){
	if(x == 0){
		if(y >= 0) return y;
		else return abs(y) + 1;
	}
	if(y == 0){
		if(x < 0) return abs(x);
		else return abs(x) + 1;
	}
	long long v = abs(abs(x) - abs(y));
	if(y - x == v) return v;
	if(-(x + v) == y) return v + 1;
	if(-x + v == y) return v + 1;
	return v + 2;
}

int main(){
	scanf("%lld%lld", &x, &y);
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::pair;using std::set;using std::string;using std::vector;
using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;
#define ff first
#define ss second
#define pb emplace_back
template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}
template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#endif
}}init;
const int MAXN = 2018;
int a[MAXN];

int32_t main() {
    
    int n, k, q;
    cin >> n >> k >> q;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    int ans = 1e9 + 7;
    for (int i = 0; i < n; ++i) {
        vector<int> pos = {-1};
        vector<int> cp;
        cp.reserve(n);
        for (int j = 0; j < n; ++j) {
            if (a[j] < a[i])
                pos.pb(j);
            cp.pb(a[j]);
        }
        pos.pb(n);
        dbg(a[i]);
        vector<int> rem;
        for (int j = 1; j < pos.size(); ++j) {
            int ft = pos[j - 1] + 1;
            int lt = pos[j];
            dbg(ft, lt);
            sort(cp.begin() + ft, cp.begin() + lt);
            for (int x = ft; x + k <= lt; ++x) {
                rem.pb(cp[x]);
            }
        }
        if (rem.size() < q)
            continue;
        sort(rem.begin(), rem.end());
        int pot = rem[q - 1] - rem[0];
        if (ans > pot)
            ans = pot;
    }
    cout << ans << '\n';
    

    return 0;
}


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

using namespace std;

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

    int l = S.length();
    for(int i = l - 2; i >= 0; i -= 2)
    {
        string s0 = S.substr(0, i / 2);
        string s1 = S.substr(i / 2, i / 2);
        if(s0 == s1)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n,k;cin>>n>>k;
  ll ans=0;
  rep(i,k,n+2){
    ll f=i*(i-1)/2;
    ll e=i*(n+(n-i+1))/2;
    (ans+=e-f+1)%=mod;
  }
  out(ans);

  return 0;
}


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

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

    string s, t;
    cin >> s >> t;

    int n = s.size();

    vector<int> A(26, 0), B(26, 0);
    REP(i, n){
        A[(int)(s[i] - 'a')]++;
        B[(int)(t[i] - 'a')]++;
    }

    vector<int> C, D;
    int cnt = 0;
    REP(i, 26){
        if(A[i] == B[i]){
            cnt++;
            continue;
        }else{
            if(A[i] > 0){
                C.push_back(A[i]);
            }
            if(B[i] > 0){
                D.push_back(B[i]);
            }
        }
    }
    if(cnt == 26){
        cout << "Yes" << endl;
        return 0;
    }

    if((int)(C.size()) != (int)(D.size())){
        cout << "No" << endl;
        return 0;
    }

    sort(C.begin(), C.end());
    sort(D.begin(), D.end());

    REP(i, (int)(C.size())){
        if(C[i] == D[i]) continue;
        else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 916
// ------------------------------------
// Date:2018/ 4/21
// Problem:/ / / c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int A, B, C, X, Y;

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

  cin >> A >> B >> C >> X >> Y;
  int mn = min(X, Y);
  int ans = 0;
  ans = A * X + B * Y;
  if (X > Y) {
    ans = min(ans, 2 * C * mn + (X - Y) * A);
  } else if (X < Y) {
    ans = min(ans, 2 * C * mn + (Y - X) * B);
  }
  ans = min(ans, 2 * C * max(X, Y));
  

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

/* include file*/
#include <functional>
#include <vector>
using namespace std;

template <class Monoid>
struct Segment {
  using Func = function<Monoid(Monoid, Monoid)>;

  vector<Monoid> node;
  Monoid ide;
  int n = 1;

  Func bin_f;
  Func update_f;

  Segment(const vector<Monoid>& init, Monoid ide_, Func f_, Func u_f)
    : bin_f(f_), ide(ide_), update_f(u_f) {
      int sz = init.size();
      while (n < sz) n *= 2;
      node.assign(n * 2 - 1, ide);
      for (int i = 0; i < sz; i++) node[i + n - 1] = init[i];
      for (int i = n - 2; i >= 0; i--)
        node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }

  void update(int i, Monoid x) {
    i += n - 1;
    node[i] = update_f(node[i], x);
    while (i) {
      i = (i - 1) / 2;
      node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  Monoid get_inter(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (a <= l && r <= b) return node[k];
    if (r <= a || b <= l) return ide;

    Monoid lm = get_inter(a, b, k * 2 + 1, l, (l + r) / 2);
    Monoid rm = get_inter(a, b, k * 2 + 2, (l + r) / 2, r);
    return bin_f(lm, rm);
  }

};

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730414#1
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730425#1

int com[101010];
i64 t[101010],p[101010],m[101010];
i64 temp[101010];
i64 before[101010];
int main(){
  i64 N,C;
  cin >> N >> C;
  vector<pair<i64,int>> vec;
  rep(i,0,N - 1){
    vec.push_back(make_pair(0,N - 1 - i));
  }
  rep(i,0,C - 1){
    cin >> com[i];
    if(com[i] == 0){
      cin >> t[i] >> p[i];
      t[i]--;
      temp[t[i]] += p[i];
      vec.push_back(pair<i64,int>(temp[t[i]], N - 1 - t[i]));
    }
    else{
      cin >> m[i];
    }
  }
  sort(all(vec));
  vec.erase(unique(all(vec)),vec.end());
  int M = vec.size();
  Segment<i64> seg(vector<i64>(M,0),0,[](i64 a,i64 b){return a + b;},[](i64 a,i64 b){return a + b;});
  rep(i,0,N - 1){
    int idx = lower_bound(all(vec),pair<i64,int>(0LL,N - 1 - i)) - vec.begin();
    seg.update(idx,1);
    temp[i] = 0;
    before[i] = idx;
  }
  vector<int> ans;
  rep(i,0,C - 1){
    if(com[i] == 0){
      i64 T = t[i];
      temp[T] += p[i];
      i64 nxt = (lower_bound(all(vec),pair<i64,int>(temp[T], N - 1 - t[i])) - vec.begin());
      seg.update(before[T],-1);
      seg.update(nxt,1);
      before[T] = nxt;
    }
    else{
      int ok = -1;
      int ng = seg.n;
      while(ng - ok > 1){
        int mid = (ok + ng) / 2;
        if(seg.get_inter(mid,seg.n) >= m[i]) ok = mid;
        else ng = mid;
      }
      ans.push_back(ok);
    }
  }
  for(int i = 0;i < ans.size();i++){
    cout << N - vec[ans[i]].second << " " << vec[ans[i]].first<< endl;
  }

}



Measured memory_bytes: 15616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B, K;
    cin >> A >> B >> K;
    if(A>K) {
        A = A - K;
    }  
    else{
        B = B - (K - A);
        A = 0;
    }
    if(B < 0) B = 0;
    cout << A << " " << B << endl;
    
    return 0;
}


Measured memory_bytes: 256
let m, c, (n, h) = ref 0, ref 0, Scanf.scanf " %d %d" @@ fun a b -> a, ref b
let bs = Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> m := max !m a; b
let _ = Array.(sort (fun x y -> y - x) bs; iter (fun b -> if b > !m && !h > 0 then (incr c; h := !h - b)) bs); Printf.printf "%d\n" @@ !c + (max 0 !h + !m - 1) / !m

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

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

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/


//#define int int64_t
signed main()
{
    int n; cin >> n;
	vector<int> a(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];
	vector<int> L(n,-1);
	L[0] = a[0];
	vector<int> R(n,-1);
	R[n-1] = a[n-1];	
	
	//cumGCD
	for(int l = 1; l < n; ++l){
		L[l] = GCD(L[l-1], a[l]);
	}
	for(int r = n-2; r >= 0; --r){
		R[r] = GCD(R[r+1], a[r]);
	}
	int ans = max(L[n-2], R[1]);//下のfor文だと,これらを計算しないから.
	for(int i = 1; i < n-1; ++i){
		int l = L[i-1];

		int r = R[i+1];

		amax(ans, GCD(l,r));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<vector>


using namespace std;
using ll=long long;


int main(void)
{
	int n, p;

	while(scanf("%d%d", &n, &p)==2)
	{
		vector<int> a(n);

		for(int i=0;i<n;i++) scanf("%d", &a[i]);
		vector<ll> dp(2);

		dp[0]=1;
		for(int i=0;i<n;i++)
		{
			auto prev=dp;
			if(a[i]&1)
			{
				dp[1]+=prev[0];
				dp[0]+=prev[1];
			}
			else
			{
				dp[0]+=prev[0];
				dp[1]+=prev[1];
			}
		}
		printf("%lld\n", dp[p]);
	}

	return 0;
}


Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())

    if n == x == 0:
        break
    else:
        ans = 0
        for i in range(1, n - 1):
            for j in range(i + 1, n):
                k = x - i - j
                if i == j or i >= k or j >= k or i + j >= x or k > n:
                    continue
                ans += 1

        print(ans)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int r;cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

void DrawRect(int h, int w)
{
	int i,j;
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}

int main(int argc, char *argv[])
{
	int H, W;
	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
		{
			break;
		}
		DrawRect(H, W);
	}
	return 0;
}

Measured memory_bytes: 572
n = int(input())
d,x = map(int, input().split())
a = [int(input()) for i in range(n)]
tabeta = 0
for i in range(n):
  total = 0
  for j in range(1,d+1):
    if (j-1)%a[i] == 0:
      total += 1
  tabeta += total
print(tabeta+x)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n,i;
  int *node;

  scanf("%d",&n);
  node = malloc((n + 1) * sizeof(int));
  for(i=1;i<n+1;i++)
    scanf("%d",&node[i]);

  for(i=1;i<n+1;i++){
    
    printf("node %d: key = %d, ",i,node[i]);

    if(1 <= i/2)  printf("parent key = %d, ",node[i/2]);

    if(i * 2 <= n)  printf("left key = %d, ",node[2*i]);

    if(i * 2 + 1 <= n)  printf("right key = %d, ",node[2*i +1]);
  
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;
 
typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;




#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);


ll N, C[100005];
ll best[100005];
int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		cin >> N;
		F0R(i, N) cin >> C[i + 1];


		for (int i = 1; i <= N; i++) best[i] = INF;

		best[1] = 0;
		for (int i = 1; i <= N; i++) {
				for (int j = 1; j <= 2; j++) best[i + j] = MIN(best[i + j], best[i] + abs(C[i + j] - C[i]));
		}
		cout << best[N] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double hour = 30 * h + 0.5 * m;
  double minute = 6 * m;

  if (hour == minute) cout << abs(a-b) << endl;
  else if (abs(hour - minute) == 180) cout << abs(a+b) <<endl;
  else {
    double dif = max(hour, minute) - min(hour, minute);
    if (dif > 180) dif = 360 - dif;
    double ans2 = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(dif / 180.0 * pi);
    printf("%.10f\n", pow(ans2, 0.5));
  }

  return 0;
}


Measured memory_bytes: 4356
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans = Math.min(Math.min(sc.nextInt(), sc.nextInt()), sc.nextInt()) + Math.min(sc.nextInt(), sc.nextInt()) - 50;
        System.out.println(ans);
    }
}



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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  if(L>R){
    cout << "Left" << endl;
  }
  if(L==R){
    cout << "Balanced" << endl;
  }
  if(L<R){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3632
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

from sys import stdin


class Tree():
    def __init__(self):
        self.root = None

    def insert(self, z):

        y = None
        x = self.root

        while x != None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right

        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def find(self, key):
        x = self.root
        while x != None:
            if key == x.key:
                return True
            elif key < x.key:
                x = x.left
            else:
                x = x.right
        return False

    def print_inorder(self):
        def rec(node):
            if not node:
                return
            else:
                rec(node.left)
                print("", node.key, end="")
                rec(node.right)

        rec(self.root)
        print()

    def print_preorder(self):

        def rec(node):
            if not node:
                return
            else:
                print("", node.key, end="")
                rec(node.left)
                rec(node.right)

        rec(self.root)
        print()


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


def main():
    _ = int(stdin.readline())
    T = Tree()

    for line in stdin:
        cmd, *args = line.split()
        if cmd == "insert":
            T.insert(Node(int(args[0])))
        if cmd == "find":
            print("yes" if T.find(int(args[0])) else "no")
        elif cmd == "print":
            T.print_inorder()
            T.print_preorder()


main()



Measured memory_bytes: 85372
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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; }

int main()
{
    int N; cin >> N;
    vector<int> d(N);
    rep (i, N) { cin >> d[i]; }

    sort(ALL(d));

    int half = N / 2;

    cout << d[half] - d[half - 1] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
#include <stack>
using namespace std;
typedef long long ll;
#define T int t_;Read(t_);while(t_--)
#define dight(chr) (chr>='0'&&chr<='9')
#define alpha(chr) (chr>='a'&&chr<='z')
#define INF (0x3f3f3f3f)
#define maxn (100005)
#define maxm (10005)
#define mod 1000000007
#define ull unsigned long long
#define repne(x,y,i) for(int i=(x);i<(y);++i)
#define repe(x,y,i) for(int i=(x);i<=(y);++i)
#define repde(x,y,i) for(int i=(x);i>=(y);--i)
#define repdne(x,y,i) for(int i=(x);i>(y);--i)
#define ri register int
inline void Read(int &n){char chr=getchar(),sign=1;for(;!dight(chr);chr=getchar())if(chr=='-')sign=-1;
    for(n=0;dight(chr);chr=getchar())n=n*10+chr-'0';n*=sign;}
inline void Read(ll &n){char chr=getchar(),sign=1;for(;!dight(chr);chr=getchar())if
    (chr=='-')sign=-1;
    for(n=0;dight(chr);chr=getchar())n=n*10+chr-'0';n*=sign;}
int x,c[maxn][2];
int main()
{
  //  freopen("a.in","r",stdin);
  //  freopen("b.out","w",stdout);
    int n;
    Read(n);
    repe(1,n,i) Read(x),++c[x][i&1];
    int ans = 0,s = 0,a,b = 0;
    repe(1,100000,i) if(s <= c[i][0]) s = c[i][0],a = i;
    ans = ans + n/2 - s;
    s = 0;
    repe(1,100000,i) if(s <= c[i][1] && a != i) s = c[i][1];
    ans = ans + n/2 - s;
    repe(1,100000,i) if(s <= c[i][1]) s = c[i][1],a = i;
    b = b + n/2 - s;
    s = 0;
    repe(1,100000,i) if(s <= c[i][0] && a != i) s = c[i][0];
    b = b + n/2 - s;
    ans = min(ans,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int n;
  string s,t;
  cin>>n>>s>>t;
  rep(i,n){
    if(i<n-1){cout<<s.at(i)<<t.at(i);}
    else cout<<s.at(i)<<t.at(i)<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

bool isPrime(int a){
    bool f=true;
    if(a==2) return f;
    int x=pow(a,0.5)+1;
    for(int i=2;i<=x;++i){
        if(a%i==0) f=false;
    }
    return f;
}

int main()
{
    int n;
    cin >> n;
    int a,cnt=0;
    F(i,0,n){
        cin >> a;
        if(isPrime(a)){
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main()
{
  int N, K[100], L[100], dp[1 << 16];

  while(cin >> N, N) {
    for(int i = 0; i < N; i++) {
      int M;
      cin >> M >> L[i];
      K[i] = 0;
      while(M--) {
        int S, E;
        cin >> S >> E;
        S -= 6, E -= 6;
        K[i] |= (1 << E) - (1 << S);
      }
    }
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    int ret = 0;
    for(int j = 0; j < 1 << 16; j++) {
      if(~dp[j]) {
        ret = max(ret, dp[j]);
        for(int i = 0; i < N; i++) {
          if(!(K[i] & j)) {
            dp[K[i] | j] = max(dp[K[i] | j], dp[j] + L[i]);
          }
        }
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1424
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <unistd.h>
#include <utility>
#include <vector>
#define dbc(x) cerr << x << '\n'
#define dbn(x) cerr << #x << " == " << x << '\n'
#define pb push_back
#define endl '\n'

using namespace std;

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

//

int v[112];

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

	int n; cin >> n;

	for (int i=0; i<n; i++) {
		cin >> v[i];
	}

	int aux = 0x3f3f3f3f;
	for (int i=-100; i<=100; i++) {
		int cost = 0;

		for (int j=0; j<n; j++) {
			cost += (v[j] - i) * (v[j] - i);
		}

		if (cost < aux) {
			aux = cost;
		}
	}

	cout << aux << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, m;
    cin >>n>> m;
    if (n == m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int graph[1001][1001];
int from[1001][1001];
int coun[1001][1001];
int level[1001][1001];
bool fin[1001][1001];
queue<pair<int, int> > que;
int ans, n, fuga;
bool flg;

bool is_loop(){
	for (int i = 1; i <= n; i++){
		for (int j = i+1; j <= n; j++){
			if (from[i][j] == 0){
				que.push(make_pair(i, j));
			}
			if (graph[i][j] == 0 && graph[j][i] == 0){
				fin[i][j] = true;
			}
		}
	}
	if (que.empty()) return true;
	return false;
}

int dfs(int now1, int now2){
	fuga++;
	if (fuga >= n*n){
		flg = true;
		return 0;
	}
	if (level[now1][now2] != 0) return level[now1][now2];
	if (fin[now1][now2]) return 0;
	if (graph[now1][now2] && graph[now2][now1]){
		int a = dfs(min(now1, graph[now1][now2]), max(now1, graph[now1][now2])) + 1;
		int b = dfs(min(now2, graph[now2][now1]), max(now2, graph[now2][now1])) + 1;
		level[now1][now2] = max(a, b);
		return level[now1][now2]; 
	}
	if (graph[now1][now2]){
		return level[now1][now2] = dfs(min(now1, graph[now1][now2]), max(now1, graph[now1][now2])) + 1;
	}
	if (graph[now2][now1]){
		return level[now1][now2] = dfs(min(now2, graph[now2][now1]), max(now2, graph[now2][now1])) + 1;
	}
}

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		int hoge;
		cin >> hoge;
		for (int j = 0; j < n-2; j++){
			cin >> graph[i][hoge];
			hoge = graph[i][hoge];
		}
	}

	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			if (i != j){
				from[min(i, graph[i][j])][max(i, graph[i][j])]++;
			}
		}
	}

	if (is_loop()){
		cout << -1 << endl;
		return 0;
	}

	while(!que.empty()){
		pair<int, int> p = que.front();
		que.pop();
		dfs(p.first, p.second);
	}

	if (flg){
		cout << -1 << endl;
		return 0;		
	}

	int ans = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			ans = max(ans, level[i][j]);
		}
	}
	cout << ans+1 << endl;
	return 0;
}

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

int main(void)
{
   string s;
   cin >> s;
   bool flag = true;
   if(s[2] != s[3]) flag = false;
   if(s[4]!= s[5]) flag = false;
   if(flag) puts("Yes");
   else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
using namespace std;

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

    vector<int> l(n);
    rep(i, n) cin >> l[i];

    int cnt = 0;

    if (n >= 3) {
        rep(i, n) {
            for (int j = i + 1; j < n; j++) {
                for (int k = j + 1; k < n; k++) {
                    if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                    if ((l[i] + l[j] <= l[k]) || (l[j] + l[k] <= l[i]) || (l[k] + l[i] <= l[j])) continue;
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3620
n,k = map(int,input().split())

from collections import defaultdict
dic = defaultdict(int)


for _ in range(k):
    d = int(input())
    al = list(map(int,input().split()))
    for a in al:
        dic[a] += 1
ans = 0
for i in range(1,n+1):
    if dic[i] == 0:
        ans += 1
print(ans)









Measured memory_bytes: 68288
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();

		int[] dp = new int[N+1];
		for(int i=1;i<dp.length;i++){
			dp[i]=N+10;
		}
		dp[0]=0;
		ArrayList<Integer> p = new ArrayList<>();
		p.add(1);
		for(int i=1;Math.pow(6, i)<=N;i++){
			p.add((int)Math.pow(6, i));
		}
		for(int i=1;Math.pow(9, i)<=N;i++){
			p.add((int)Math.pow(9, i));
		}

		for(int i=0;i<=N;i++){
			for(int v:p){
				if(i-v>=0){
					dp[i]=Math.min(dp[i],dp[i-v]+1);
				}
			}
		}
		System.out.println(dp[N]);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

set<int> pos[26];

int eval(char c) {
    return c - 'a';
}

void solve() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    fori (i, 0, s.size()) pos[eval(s[i])].insert(i);
    fori (tt, 0, q) {
        int type;
        cin >> type;
        if (type == 1) {
            int idx;
            char c;
            cin >> idx >> c;
            idx--;
            int a = eval(s[idx]);
            int b = eval(c);
            pos[a].erase(idx);
            pos[b].insert(idx);
            s[idx] = c;
        }
        else {
            int l, r;
            cin >> l >> r;
            l--, r--;
            int ans = 0;
            fori (i, 0, 26) {
                auto it = pos[i].lower_bound(l);
                ans += it != pos[i].end() && *it <= r;
            }
            cout << ans << "\n";
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 24220
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <limits>
#include <math.h>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
ll ans = 0;
map<int, int> m;

void getPrimeDivisors(int n) {
  for (int i = 2; i < n; ++i) {
    while (n % i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n > 1) m[n]++;
}

int rec(map<int, int>::iterator p, int n) {
  if (p == m.end()) {
    if (n == 1) return 1;
    else return 0;
  }

  int res = 0;
  for (int i = 0; i < p->second + 1; ++i) {
    if (n % (i + 1) != 0) continue;
    res += rec(++p, n / (i + 1));
    --p;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    getPrimeDivisors(i);
  }

  int ans = rec(m.begin(), 75);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10**9+7
ans = pow(2, n, mod)-1

modp = mod                     # 素数であることが前提
max_r = 10 ** 7               # 必要分だけ用意する 10**7が限度
factinv = [1, 1] + [0]*max_r  # factinv[n] = ((n!)^(-1) mod modp)
inv = [0, 1] + [0]*max_r      # factinv 計算用

fact = {}

def cmb(n, r, p):
    assert n < p, 'n is less than modp'
    assert r < max_r, 'n in less than max_n'
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    if (n, r) in fact:
        return fact[(n, r)] * factinv[r] % p
    else:
        f = 1
        for i in range(n, n-r, -1):
            f = f * i % p
        fact[(n, r)] = f
        return f * factinv[r] % p

for i in range(2, max_r + 1):
    inv[i] = (-inv[modp % i] * (modp // i)) % modp
    factinv[i] = (factinv[i-1] * inv[i]) % modp

ans-=cmb(n, a, mod)
ans-=cmb(n, b, mod)
print(ans%mod)


Measured memory_bytes: 298916
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int N = 255;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {

int MOD;

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}
inline void Dec(int &x, int y) {
	x -= y; if (x < 0) x += MOD;
}
inline int Add(int x, int y) {
	Inc(x, y); return x;
}
inline int Sub(int x, int y) {
	Dec(x, y); return x;
}
inline int Mul(int x, int y) {
	return 1LL * x * y % MOD;
}

}
using namespace ModCalculator;

int n, nn;
pair<int, int> p[N << 1];
int dp[N << 1][N];

inline int lim(int i, int up) {
	int ret = nn - 1;
	while (i * i + ret * ret > up) --ret;
	return ret + 1;
}

void init() {
	read(n); read(MOD);
	nn = n + n;
	for (int i = 0; i < nn; ++i) {
		if (i < n) {
			p[i] = make_pair(lim(i, n * n - 1), lim(i, 4 * n * n));
		} else {
			p[i] = make_pair(lim(i, 4 * n * n), 0);
		}
	}
	sort(p, p + nn);
}

void solve() {
	int ans = 0;
	for (int k = 0; k <= n; ++k) {
		mset(dp, 0);
		dp[0][0] = 1;
		int c1 = 0, c2 = 0;
		for (int i = 0; i < nn; ++i) {
			if (p[i].se == 0) {
				for (int j = 0; j <= k; ++j) {
					Inc(dp[i + 1][j], Mul(dp[i][j], p[i].fi - c1 - j));
				}
				++c1;
			} else {
				for (int j = 0; j <= k; ++j) {
					if (j < k) Inc(dp[i + 1][j + 1], Mul(dp[i][j], p[i].fi - c1 - j));
					Inc(dp[i + 1][j], Mul(dp[i][j], p[i].se - n - k - c2 + j));
				}
				++c2;
			}
		}
		(k & 1)? Dec(ans, dp[nn][k]) : Inc(ans, dp[nn][k]);
	}
	printf("%d\n", ans);
}

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


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

int main() {
    long long A;
    long long B;
    long long K;
    cin >> A >> B >> K;
    if (A >= K) {
        A -= K;
    }
    else {
        K -= A;
        A = 0;
        if (B >= K) {
            B -= K;
        } else {
            B = 0;
        }
    }
    cout << A << " " << B << endl;
    //~ cout << difference1 << " " << difference2 << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll Xi;
    cin >> Xi;
    ll cache = Xi;
    ll res=0;
    for(int i=1;i<N;i++){
        cin >> Xi;
        res += min(A*(Xi-cache), B);
        cache = Xi;
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
char str[500000];
int f[27][500002],g[19][500002],n,q;
int main()
{
    scanf("%s%d",str,&q),n=strlen(str);
    for(int i=0;i<27;++i)f[i][n+1]=f[i][n]=n+1;
    g[0][n+1]=g[0][n]=n+1;
    for(int i=n-1;i>=0;--i)
    {
        f[str[i]-='a'][i]=i+1;
        for(int j=str[i]+1;j<27;++j)
            f[j][i]=f[j-1][f[j-1][i]];
        if(str[i])f[0][i]=f[0][f[26][i]];
        for(int j=1;j<str[i];++j)
            f[j][i]=std::min(f[j-1][f[j-1][i]],f[j][f[26][i]]);
        g[0][i]=f[26][i];
    }
    ++n;
    for(int i=1;i<19;++i)
        for(int j=0;j<=n;++j)
            g[i][j]=g[i-1][g[i-1][j]];
    for(int i=q,l,r,j;i;--i)
    {
        scanf("%d%d",&l,&r),--l,j=18;
        while(l<r)
        {
            while(j&&g[j][l]>r)--j;
            l=g[j][l];
        }
        puts(l==r?"Yes":"No");
    }
    return 0;
}


Measured memory_bytes: 91008
function main(input) {
    const S = input.toString();

    var ans = 0;
    var max_ans = 0;
    var test_word;

    for(var i = 0; i < S.length; i++) {
        test_word = S.charAt(i);
        switch(test_word){
            case 'A':
            case 'G':
            case 'T':
            case 'C':
                ans++;
                break;
            default:
                if(max_ans < ans)
                    max_ans = ans;
                ans = 0;
                break;
        }
    }

    if (max_ans < ans)
        max_ans = ans;

    console.log(max_ans)

    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// 配列がソートされたときに移動するインデックスの配列を返す
// 配列自体はソートされない
// {1, 6, 2, 3, 6} -> {0, 3, 1, 2, 4}
template<typename T>
vi sortIndex(const vector<T>& vec){
    vi idx(SZ(vec));
    iota(ALL(idx), 0);
    sort(ALL(idx), [vec](int l, int r){
        return vec[l] < vec[r];
    });
    return idx;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    /*
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    vi ans = sortIndex(a);
    rep(i, n){
        cout << ans[i]+1 << " \n"[i==n-1];
    }
    */
    vp a(n);
    rep(i, n){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(ALL(a));
    rep(i, n){
        cout << a[i].second << " \n"[i==n-1];
    }
    return 0;
}

Measured memory_bytes: 2432
n, m = map(int, input().split())
H = list(map(int, input().split()))
path = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    path[a - 1].append(b - 1)
    path[b - 1].append(a - 1)

cnt = 0
for i in range(n):
    flag = True
    path_i = path[i]
    for x in path_i:
        if H[i] <= H[x]:
            flag = False
    if flag:
        cnt += 1

print(cnt)

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

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

  string buf;

  for(long long i = 0; i < s.size(); i++){
    switch(s[i]){
      case '0':
      buf.push_back('0');
      break;
      case '1':
      buf.push_back('1');
      break;
      case 'B':
      if(buf.size() != 0) buf.pop_back();
      break;
    }
  }

  cout << buf << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	class Edge {
		int to, dist;
		Edge(int to, int dist) {
			this.to = to; this.dist = dist;
		}
	}
	class Pair {
		int f, s;
		Pair(int f, int s) {
			this.f = f; this.s = s;
		}
	}
	class Graph {
		LinkedList<Edge> edges = new LinkedList<Edge>();
	}

	final int INF = Integer.MAX_VALUE;
	final int MAX_V = 10000;

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		Graph[] g = new Graph[MAX_V];
		for (int i = 0; i < MAX_V; i++)
			g[i] = new Graph();
		
		for (int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			for (int j = 0; j < k; j++) {
				int v = scan.nextInt();
				int c = scan.nextInt();
				g[u].edges.add(new Edge(v, c));
			}
		}

		int[] dist = new int[MAX_V];
		for (int i = 0; i < MAX_V; i++)
			dist[i] = INF;

		Queue<Pair> que = new PriorityQueue<Pair>(new Comparator<Pair>() {
			@Override
			public int compare(Pair p1, Pair p2) {
				return p1.f - p2.f;
			}
		});
		
		dist[0] = 0;
		que.add(new Pair(0, 0));
		
		while (!que.isEmpty()) {
			Pair p = que.poll();
			int v = p.s;
			if (dist[v] < p.f) continue;
			for (int i = 0; i < g[v].edges.size(); i++) {
				Edge e = g[v].edges.get(i);
				if (dist[e.to] > dist[v] + e.dist) {
					dist[e.to] = dist[v] + e.dist;
					que.add(new Pair(dist[e.to], e.to));
				}
			}
		}
		for (int i = 0; i < n; i++)
			System.out.println(i + " " + dist[i]);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}




Measured memory_bytes: 287168
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 aa, bb, ans = 1, tmp1, tmp2;
	cin >> aa >> bb;
	tmp1 = tmp2 = gcd(aa, bb);
	for(int64 ii = 2;ii * ii <= tmp2;ii++)
	{
		if(tmp1 % ii == 0)
		{
			ans++;
			while(tmp1 % ii == 0)
			{
				tmp1 /= ii;
			}
		}
	}
	if(tmp1 != 1)
	{
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	ll k,a,b;cin>>k>>a>>b;k++;
	if(b-a<=1){
		cout<<k<<endl;
	}else{
		if(k<=a+1){
			cout<<k<<endl;
			return 0;
		}
		k-=a;
		ll ans=(k/2LL)*b-(k/2LL-1LL)*a;
		if(k%2){
			ans++;
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, A, B, C, i, j, k, a, b, c, s, t, u, r, ans=1e9;
cin >> N >> A >> B >> C; int l[N], M=pow(4, N);
for(i=0; i<N; i++){ cin >> l[i]; }
for(i=0; i<M; i++){
for(a=b=c=s=t=u=j=0, k=i; j<N; j++){
  r=k%4;
  if(r==1){ a++; s+=l[j];}else if(r==2){ b++; t+=l[j];}else if(r==3){ c++; u+=l[j];}
  k=k/4;
}
if(a&&b&&c){ ans=min(ans, 10*(a-1)+abs(A-s)+10*(b-1)+abs(B-t)+10*(c-1)+abs(C-u)); }
}
cout << ans << "\n";
}

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

int n, mx, m, x, i, j, t, a[100005];
int main()
{
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%d", &a[i]);
		mx = max(mx, a[i]);
	}
	for (i = 0; i < n; i++) {
		t = min(a[i], mx - a[i]);
		if (t > m) {
			m = t;
			x = a[i];
		}
	}
	cout << mx << " " << x;
    return 0;
}


Measured memory_bytes: 640