akhauriyash/Code-Regression huggingface dataset:
open Hashtbl
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let k = n / 3
let h = create 100000
let c = Array.iter (fun a -> replace h a @@ if mem h a then find h a + 1 else 1) a_s; length h
let f2 z m = mem h 0 && find h 0 = z && fold (fun a c b -> if a <> 0 && c = m then true else b) h false
let f3 () = if c = 2 then f2 k (2 * k) else
  if c = 3 then
    let b, ns = fold (fun a c (b, acc) -> if not b then b, acc else c = k, a :: acc) h (true, []) in
    let ns = Array.of_list ns in b && ns.(0) lxor ns.(1) lxor ns.(2) = 0
  else false
let b = if c = 1 then mem h 0 else n mod 3 = 0 && f3 ()
let _ = print_endline @@ if b then "Yes" else "No"

Measured memory_bytes: 6528
import math

n = int(raw_input())
num = list()
count = 0
max = 0

for i in range(n):
    num.append(int(raw_input()))

for i in range(n):
    root_num = math.sqrt(num[i])
    for j in range(2, int(root_num) + 1):
        if num[i] % j == 0:
            count = count + 1
            break

print n - count

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }




void solve() {
    int n;
    cin >> n;
    vector<int> t(n), v(n);
    
    int sum = 0;
    rep(i, n) {
        cin >> t[i];
        sum += t[i];
    }
    rep(i, n) {
        cin >> v[i];
        v[i] *= 2;
    }
    vector<double> masp(2 * sum + 1);
    
    int acc = 1;
    rep(i, n) {
        if (i) {
            chmin(masp[acc - 1], v[i]);
        }
        rep(j, 2 * t[i]) {
            chmax(masp[acc + j], v[i]);
        }
        acc += 2 * t[i];
    }
    
    // cout << endl; rep(i, 2 * sum + 1) cout << i << " " << masp[i] << endl;
    
    
    rep3(i, 1, 2 * sum + 1) chmin(masp[i], masp[i - 1] + 1);
    // cout << endl; rep(i, 2 * sum + 1) cout << i << " " << masp[i] << endl;
    
    masp[2 * sum] = 0;
    for (int i = 2 * sum - 1; i >= 0; --i) chmin(masp[i], masp[i + 1] + 1);
    // cout << endl; rep(i, 2 * sum + 1) cout << i << " " << masp[i] << endl;
    
    rep(i, 2 * sum) masp[i] /= 2.0;
    // cout << endl; rep(i, 2 * sum + 1) cout << i << " " << masp[i] << endl;
    
    
    pair<double, int> st = pair<double, int>(0, 0); // debuged, double
    double ans = 0;
    rep3(i, 1, 2 * sum + 1) {
        if (i == 2 * sum || (masp[i] - masp[i - 1]) * (masp[i + 1] - masp[i]) <= 0) {
            // cout << "i " << i << " " << masp[i] << " " << st.F << " " << st.S << endl;
            if (masp[i] != masp[i - 1]) { // 山, 谷
                ans += (masp[i] + st.F) * (i - st.S) / 4.0;
            } else {
                ans += masp[i] / 2.0;
            }
            st = pair<double, int>(masp[i], i);
        }
        // cout << i << " " << ans << endl;
    }
    cout << fixed << setprecision(4) << ans << endl;
    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}





Measured memory_bytes: 640
from collections import defaultdict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

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

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    
    bool ok = false;
    for(int i=0;i<b;i++){
        int num = (i+1)*a;
        if(num%b==c) ok=true;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

	ll N;
	cin >> N;
	vll A(N), B(N), C(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) cin >> C[i];

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	// 各Bについて、その上にいくつのAを置けるかを計算する
	vll n_AonB(N);
	for (int i = 0; i < N; i++)
	{
		n_AonB[i] = 0;
	}


	for (int i = 0; i < N; i++)
	{
		// 初めてそのAが置けるBのインデックス
		auto Iter = upper_bound(B.begin(), B.end(), A[i]);
		ll idx = Iter - B.begin();

		if (idx < N)
		{
			n_AonB[idx]++;
		}
	}

	for (int i = 1; i < N; i++)
	{
		n_AonB[i] += n_AonB[i - 1];
	}


	vll n_onC(N);
	for (int i = 0; i < N; i++)
	{
		n_onC[i] = 0;
	}

	for (int i = 0; i < N; i++)
	{
		// 初めてそのBが置けるCのインデックス
		auto Iter = upper_bound(C.begin(), C.end(), B[i]);
		ll idx = Iter - C.begin();

		if (idx < N)
		{
			n_onC[idx]+= n_AonB[i];
		}
	}

	for (int i = 1; i < N; i++)
	{
		n_onC[i] += n_onC[i - 1];
	}


	ll ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += n_onC[i];
	}

	cout << ans << endl;

}





Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e6+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=500001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound

ll k1=0;
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
	k1=max(k1,abs(a.ff-b.ff)+abs(a.ss-b.ss));
	if(a.ff>b.ff)
		return 1;

	if(a.ff==b.ff&&a.ss>b.ss)
		return 1;
	return 0;
}
int dx[]={1,-1};
int dy[]={1,-1};
int main()
{
	fastio;
	int t;
	ll i,j,k,n,m,l;
	cin>>n;
	ll a[n],b[n];

	for(i=0;i<n;i++)
		cin>>a[i]>>b[i];
	ll ans=0;
	for(auto p:dx)
	{
		for(auto q:dy)
		{
			j=p*a[0]+q*b[0];
			for(i=1;i<n;i++)
			{
				k=p*a[i]+q*b[i];
				ans=max(ans,k-j);
				j=min(j,k);
			}

		}
	}
	cout<<ans;

	
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 4 * 1e18;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
int n,K;
ll check(T4 area,VL&x,VL&y){
  int u,d,r,l;
  tie(u,d,r,l)=area;
  int in=0;
  rep(i,n){
    bool yin=(u>=y[i] && d<=y[i]);
    bool xin=(r>=x[i] && l<=x[i]);
    in+=(yin && xin);
  }
  return in;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  
  cin>>n>>K;
  VL x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];

  ll res=INF;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        rep(m,n){
          ll u,d,r,l;
          u=max({y[i],y[j],y[k],y[m]});
          d=min({y[i],y[j],y[k],y[m]});
          r=max({x[i],x[j],x[k],x[m]});
          l=min({x[i],x[j],x[k],x[m]});
          T4 area=m_t(u,d,r,l);
          ll in=check(area,x,y);
          if(in>=K)chmin(res,1LL*abs(u-d)*abs(r-l));
        }
      }
    }
  }
  out(res);
  
  
  return 0;
}



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


int main(){
int n;
cin >> n;
cout << 3*n*n<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ans = 0;
		
		for(int i = 1 ;i <= 3 ;i++) {
			if(i % 3 == a % 3 || i % 3 == b % 3) {
				continue;
			}
			else {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
		
		
	}
}


Measured memory_bytes: 21460
let array_of_string str = Array.init (String.length str) (fun i -> str.[i])
let string_of_array arr = String.init (Array.length arr) (fun i -> arr.(i))

let () =
  let s = read_line () |> array_of_string in
  let t = read_line () |> array_of_string in
  Array.sort (fun x y -> int_of_char x - int_of_char y) s;
  Array.sort (fun x y -> int_of_char y - int_of_char x) t;
  print_endline @@
    if string_of_array s < string_of_array t then "Yes" else "No"




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

int main(){
    long long int n, a, b; cin >> n >> a >> b;
    if ((b-a) % 2 == 0) cout << (b-a)/2 << endl;
    else cout << min(a-1, n-b) + 1 + (b-a-1)/2 << endl;
}


Measured memory_bytes: 256
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


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


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret




def main():
    # n, k, s = map(int, input().split())
    
    # v = n - k + 1
    # t = s // v
    # t2 = s % v
    # l = [t] * (v - 1) + [t + t2]
    # ansl = []
    # for i in range(n // len(l) + 1):
    #     ansl+=l
    
    
    
    # print(*ansl[:n])

    n = int(input())
    xl = [list(map(int, input().split())) for i in range(n)]
    lr = []
    for i in range(n):
        x,l = xl[i]
        lr.append([x - l, x + l])
    
    lr = sorted(lr, key=lambda x: x[1])
    now = lr[0][1]
    ans = 1
    for i in range(1, n):
        if now <= lr[i][0]:
            ans += 1
            now = lr[i][1]
    print(ans)
    


    


if __name__ == '__main__':
    main()


Measured memory_bytes: 102392
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int main() {
  int n;
  while(R n && n) {
    ll t[n];
    vector<int> a[31];
    memset(t,0LL,sizeof(t));
    rep(i,n) {
      int k;
      scanf("%d",&k);
      rep(j,k) {
	int x;
	scanf("%d",&x);
	a[x].pb(i);
      }
      t[i]|=(1LL<<i);
    }
    int ans=-1;
    rep(i,31) {
      rep(j,a[i].size()) {
	rep(k,a[i].size()) t[a[i][j]]|=t[a[i][k]];
	if(t[a[i][j]]==(1LL<<n)-1LL) ans=i;
      }
      if(ans!=-1) break;
    }
    pr(ans);
  }
  return 0;
}


Measured memory_bytes: 1280
/*
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
*/
#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define db double
#define ull unsigned long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int A[maxn],B[maxn];
struct seg_tree{
    ll tr[maxn<<2],lazy[maxn<<2];

    void push_up(int id)
    {
        tr[id] = min(tr[id<<1], tr[id<<1|1]);
    }
    void push_down(int id)
    {
        if(lazy[id]!=0){
            tr[id<<1] += lazy[id],tr[id<<1|1] += lazy[id];
            lazy[id<<1] += lazy[id],lazy[id<<1|1] += lazy[id];
            lazy[id] = 0;
        }
    }
    void update(int id,int stl,int str,int l,int r,ll k)
    {
        if(stl==l && str==r){
            tr[id] += k;
            lazy[id] += k;
            return ;
        }
        push_down(id);
        int mid = (stl+str)>>1;
        if(r<=mid) update(id<<1,stl,mid,l,r,k);
        else if(l>mid) update(id<<1|1,mid+1,str,l,r,k);
        else update(id<<1,stl,mid,l,mid,k),update(id<<1|1,mid+1,str,mid+1,r,k);
        push_up(id);
    }
    ll query(int id,int stl,int str,int l,int r)
    {
        if(stl==l && str==r) return tr[id];
        push_down(id);
        int mid = (stl+str)>>1;
        if(r<=mid) return query(id<<1,stl,mid,l,r);
        else if (l>mid) return query(id<<1|1,mid+1,str,l,r);
        else return min(query(id<<1,stl,mid,l,mid), query(id<<1|1,mid+1,str,mid+1,r));
    }
}dp,rec;
int main()
{
    fastio();
    int n,m; cin>>n>>m;
    rep(i,1,n) cin>>A[i]>>B[i];
    rep(i,1,m) rec.update(1,1,m,i,i,-i);
    rep(i,1,n){
        int R = B[i] + 1;
        if(R<=m){
            ll mi = rec.query(1,1,m,1,B[i]);
            ll now = dp.query(1,1,m,R,R);
            if(now > mi + R){
                dp.update(1,1,m,R,R,mi+R-now);
                ll tmp = rec.query(1,1,m,R,R);
                rec.update(1,1,m,R,R,mi-tmp);
            }
        }
        dp.update(1,1,m,A[i],B[i],inf);
        rec.update(1,1,m,A[i],B[i],inf);
        dp.update(1,1,m,1,m,1);
        rec.update(1,1,m,1,m,1);
        ll ans = dp.tr[1];
        if(ans >= inf) cout<<-1<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    bool ans = false;
    function<int(int, int)> dfs = [&] (int v, int p) {
        int up = 0;
        for(auto to : g[v]) {
            if(to == p) continue;
            up += dfs(to, v);
        }
        if(up >= 2) ans = true;
        return !up;
    };
    ans |= dfs(0, -1) != 0;

    cout << (ans ? "First" : "Second") << endl;
}


Measured memory_bytes: 5888
n = int(input())

targets = []
for i in range(1, n + 1):
    if i % 2 == 0:
        continue
    cnt = 0
    for j in range(1, n + 1):
        if i % j == 0:
            cnt += 1
    if cnt == 8:
        targets.append(i)
print(len(targets))


Measured memory_bytes: 2940
X,Y=map(int,input().split())
ans=10**10
for i in range(2):
  for j in range(2):
    x=(1-2*i)*X
    y=(1-2*j)*Y
    if x<=y:
      if ans>y-x+i+j:
        ans=y-x+i+j
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

void swap(int *x, int *y){
	int tmp=*x;*x=*y;*y=tmp;
}

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a>c) swap(&a,&c);
	if (a>b) swap(&a,&b);
	if (b>c) swap(&b,&c);
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
int main(void){
  long int A,V,B,W,T;
  double U;
  scanf("%ld %ld %ld %ld %ld",&A,&V,&B,&W,&T);
  if(V <= W){
    printf("NO");
  }
  else{
    U = fabs(B - A) / (double)(V - W);
    if(U <= T){
      printf("YES");
    }
    else{
    printf("NO");
    }
  }
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


struct Segtree {
	int size = 1;
	vector<int>dat1, dat2;
	Segtree(int x) {
		while (size < x)size *= 2;
		dat1.resize(2 * size - 1, -1);
		dat2.resize(2 * size - 1, inf);
	}
	void update(int x, int y, int k = 0, int l = 0, int r = -1) {
		if (r == -1)r = size;
		if (r - l == 1) {
			dat1[k] = y;
			dat2[k] = y;
			return;
		}
		if (x < (l + r) / 2) {
			update(x, y, k * 2 + 1, l, (l + r) / 2);
		}
		else {
			update(x, y, k * 2 + 2, (l + r) / 2, r);
		}
		dat1[k] = max(dat1[k * 2 + 1], dat1[k * 2 + 2]);
		dat2[k] = min(dat2[k * 2 + 1], dat2[k * 2 + 2]);
	}
	int querymax(int x, int y, int k = 0, int l = 0, int r = -1) {
		if (r == -1)r = size;
		if (r <= x || y <= l)return -1;
		if (x <= l && r <= y) {
			return dat1[k];
		}
		int lval = querymax(x, y, k * 2 + 1, l, (l + r) / 2);
		int rval = querymax(x, y, k * 2 + 2, (l + r) / 2, r);
		return max(lval, rval);
	}
	int querymin(int x, int y, int k = 0, int l = 0, int r = -1) {
		if (r == -1)r = size;
		if (r <= x || y <= l)return inf;
		if (x <= l && r <= y) {
			return dat2[k];
		}
		int lval = querymin(x, y, k * 2 + 1, l, (l + r) / 2);
		int rval = querymin(x, y, k * 2 + 2, (l + r) / 2, r);
		return min(lval, rval);
	}
};
int n, k;
int p[214514];
signed main() {
	cin >> n >> k;
	Segtree S(n);
	rep(i, n) {
		cin >> p[i];
		S.update(i, p[i]);
	}
	int ans = 1;
	int cnt = 1;
	REP(i, k) {
		if (p[i - 1] < p[i])cnt++;
		else cnt = 1;
	}
	bool flag = cnt == k;
	for (int i = k; i < n; i++) {
		if (p[i - 1] < p[i])cnt++;
		else cnt = 1;
		if (S.querymin(i - k + 1, i) < p[i - k] || S.querymax(i - k, i) > p[i]) {
			if (cnt >= k && flag)continue;
			ans++;
		}
		if (cnt >= k)flag = true;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11008
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder ans = new StringBuilder();
		while(true) {
			String S = sc.nextLine();
			if(S.length() == 1 && S.charAt(0) == '.') break;
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < S.length(); i++) {
				char c = S.charAt(i);
				if(c == '(' || c == ')' || c == '[' || c == ']') {
					sb.append(c);
				}
			}
			int l = sb.length();
			Deque<Character> stack = new ArrayDeque<Character>();
			for(int i = 0; i < l; i++) {
				char c = sb.charAt(i);
				if(c == '(' || c == '[') {
					stack.addFirst(c);
				}else if(c == ')' || c == ']'){
					if(stack.isEmpty()) {
						stack.addFirst(' ');
						break;
					}
					char t = stack.getFirst();
					if(t == '(' && c == ')' || t == '[' && c == ']') {
						stack.removeFirst();
					}else {
						stack.addFirst(' ');
						break;
					}
				}
			}
			if(stack.isEmpty()) {
				ans.append("yes").append("\n");
			}else {
				ans.append("no").append("\n");
			}
		}
		sc.close();
		System.out.print(ans.toString());
	}
}


Measured memory_bytes: 46504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    vector<vector<int>> masu(3,vector<int>(3));
    vector<int> a(3);
    vector<int> b(3);
    bool hantei=true;
    rep(i,3){
        rep(j,3) cin >> masu[i][j];
    }
    a[0] = 0;
    b[0] = masu[0][0];
    b[1] = masu[0][1];
    b[2] = masu[0][2];
    a[1] = masu[1][0] - b[0];
    a[2] = masu[2][0] - b[0];
    
    rep(i,3){
        rep(j,3){
            if(masu[i][j] != a[i] + b[j]) hantei=false;
    }
    }
    if(hantei) cout << "Yes"<<endl;
    else cout << "No" <<endl;
}

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

using namespace std;

int n;
int a[205], k[205];
int dp[50];

int calc(int n, int k)
{
	if(n/k == 0) return 0;
	if(n % k) return calc(n-n/k-1, k);
	else return n/k;
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> k[i];
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans ^= calc(a[i], k[i]);
	}
	
	if(ans) cout << "Takahashi" << endl;
	else cout << "Aoki" << endl;
	
	return 0;
}

Measured memory_bytes: 384
while True:
    n = int(input())
    if n==0:
        break
    
    N = 1
    for i in range(1,n+1,1):
        N *= i
    
    zero = 0
    while True:
        if N%10 > 0:
            break
        
        N = N//10
        zero += 1
    
    print(zero)


Measured memory_bytes: 5632
from collections import defaultdict
dic = defaultdict(int)
N, M = map(int, input().split())
P = []
S = []
wa = 0
ac = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if s=="AC":
        if not dic[p]==-1:
            wa+=dic[p]
            ac+=1
            dic[p]=-1
    elif s=="WA":
        if not dic[p]==-1:
            dic[p]+=1
print(ac, wa)


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

#define Bye return 0
#define ll long long

using namespace std;

void solve(){
    ll n, k; cin>>n>>k;
    ll h[n];
    for (int i=0; i<n; i++) cin>>h[i];

    sort(h, h+n);

    ll sum = 0;
    for (int i=0; i<n-k; i++)
        sum += h[i];

    cout<<sum<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K,N,dekaimiti=0;
    cin>>K>>N;
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    for(int i=0;i<N-1;i++){
        if(a.at(i+1)-a.at(i)>dekaimiti)dekaimiti=a.at(i+1)-a.at(i);
    }
    if(a.at(0)+K-a.at(N-1)>dekaimiti)dekaimiti=a.at(0)+K-a.at(N-1);
    cout<<K-dekaimiti;
    
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

const int SZ = 1e5 + 10;
vector<vi> adj;
vector<bool> vis;
vector<int> dp;

void init(int n) {
    adj.clear(), vis.clear();
    adj.resize(n), vis.resize(n, false);
    dp.clear(), dp.resize(n);
}

void dfs(int v) {
    vis[v] = true;
    dp[v] = 0;
    for (auto u : adj[v]) {
        if (!vis[u])    dfs(u);
        dp[v] = max(dp[u] + 1, dp[v]);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    init(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        adj[x].pb(y);
    }    
    for (int i = 0; i < n; ++i)
        if (!vis[i])    dfs(i);
    int ans = 0;
    for (auto i : dp)   ans = max(ans, i);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++){
    cout << '#';
  }
  cout << endl;
  char c;
  for (int i = 0; i < H; i++){
    cout << '#';
    for (int j = 0; j < W; j++){
      cin >> c;
      cout << c;
    }
    cout << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++){
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
s = input()

id_a = len(s)
id_z = 0
for i in range(len(s)):
  if s[i] == 'A':
    id_a = min(id_a, i)
  if s[i] == 'Z':
    id_z = max(id_z, i)
    
print(id_z - id_a + 1)

Measured memory_bytes: 3516
#!/usr/bin/env python3
import sys
from itertools import combinations

def solve(N: int):   
    d = {n:[] for n in range(1, N+1)} 
    d[1] = [[1]]

    for n in range(1, N):
        
        for lst in d[n]:
            last_element = lst[-1]

            for new_element in range(1, max(lst)+2):
                d[n+1].append(lst+[new_element])

    ans_lst = d[N]

    for i, lst in enumerate(ans_lst):
        ans_lst[i] = ''.join([chr(num+96) for num in lst])

    for lst in ans_lst:
        print(lst)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26100
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
//#include<random>
#include<unordered_set>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}//a>b
int main(void){
	llint i,j,n,wa=0;cin>>n;//
	vector<llint>a(n);
	for(i=0;i<n;i++){cin>>a[i];wa+=a[i];}
	llint ans=max((llint)0,wa-10000);
	while(-1){
		llint now=0;
		for(i=0;i<n;i++){
			now+=max((llint)0,(a[i]+ans+1)/(n+1));
		}
		if(now<=ans){cout<<ans<<endl;return 0;}//足りる
		ans++;
	}
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long a;
    double b;
    cin >> a >> b;
    double c = b * 100;
    long long d = lround(c);
    long long product = d * a;
    cout << product / 100;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    char c;
    cin >> c;
    if(c == 'a'|| c == 'i' || c == 'u'|| c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
  N,P = map(int,input().split())
  S = input()

  ans = 0
  if P == 2 or P == 5:
    for i in range(N):
      if int(S[i])%P == 0:
        ans += i+1
  else:
    # r = [0] * (N+1)
    # for i in range(N):
    #   r[N-1-i] = int(S[N-1-i:])%P
    # for i in range(N):
    #   for j in range(i,N):
    #     if (r[i]-r[j+1])%P == 0:
    #       ans += 1
    d = {}
    r = 0
    for i in range(N):
      # r = int(S[N-1-i:])%P
      # とするとTLEになってしまう。
      r = (r + int(S[N-1-i])*pow(10,i,P))%P
      if r in d:
        d[r] += 1
      else:
        d[r] = 1
    if 0 in d:
      d[0] += 1
    for k,v in d.items():
      ans += v*(v-1)//2
  
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 42700
import collections
sent = -1

def insert(hoge, new_node, root):
    #print(hoge)
    parent_maybe = sent
    now_looking = root
    hoge[new_node]['node_id'] = new_node
    while now_looking != sent:
        parent_maybe = now_looking
        if new_node < hoge[now_looking]['node_id']:
            now_looking = hoge[now_looking]['left']
        else:
            now_looking = hoge[now_looking]['right']
    hoge[new_node]['parent'] = parent_maybe
    
    if parent_maybe == sent:
        root = new_node
        hoge[new_node]['parent'] = sent
        hoge[new_node]['left'] = sent
        hoge[new_node]['right'] = sent
    elif new_node < hoge[parent_maybe]['node_id']:
        hoge[parent_maybe]['left'] = new_node
        hoge[new_node]['left'] = sent
        hoge[new_node]['right'] = sent
    else:
        hoge[parent_maybe]['right'] = new_node
        hoge[new_node]['left'] = sent
        hoge[new_node]['right'] =sent
    
    return root
    
def inorder(node_id):
    if node_id == sent:
        return None
    inorder(hoge[node_id]['left'])
    print(' {}'.format(node_id), end='')
    inorder(hoge[node_id]['right'])

def preorder(node_id):
    if node_id == sent:
        return None
    print(' {}'.format(node_id), end='')
    preorder(hoge[node_id]['left'])
    preorder(hoge[node_id]['right'])
    
    
def getTree(root):
    inorder(root)
    print()
    preorder(root)
    print()
    
def searchNode(hoge, num, node_id):
    if node_id == -1:
        return 'no'
    
    if num == node_id:
        return 'yes'
    elif num < node_id:
        return searchNode(hoge, num, hoge[node_id]['left'])
    elif num > node_id:
        return searchNode(hoge, num, hoge[node_id]['right'])

if __name__ == '__main__':
    num = int(input())
    hoge = collections.defaultdict(dict)
    root = -1
    for _ in range(num):
        command = input()
        if command.split()[0] == 'insert':
            root = insert(hoge, int(command.split()[1]), root)
        elif command.split()[0] == 'find':
            print(searchNode(hoge, int(command.split()[1]), root))
        else:
            getTree(root)


Measured memory_bytes: 134724
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <string.h>
#include <algorithm>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define clr(a,b) memset((a),b,sizeof(a))
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = 2e5+77;
//const ll mod = 1e9+7;

int n,p[N];
pair<pii,int> xy[N];
priority_queue<pair<int,pii>> q;

int root(int x){
    while(x!=p[x]) p[x]=p[p[x]], x=p[x];
    return x;
}

int main(){
    fast;
    cin>>n;
    forn(i,n){
        p[i]=i;
        cin>>xy[i].first.first>>xy[i].first.second;
        xy[i].second=i;
    }
    sort(xy,xy+n);
    forn(i,n-1){
        q.push({-(xy[i+1].first.first-xy[i].first.first),{xy[i].second,xy[i+1].second}});
    }
    
    forn(i,n) swap(xy[i].first.first,xy[i].first.second);
    
    sort(xy,xy+n);
    forn(i,n-1){
        q.push({-(xy[i+1].first.first-xy[i].first.first),{xy[i].second,xy[i+1].second}});
    }
    ll ans=0;
    while(q.size()){
        auto zz = q.top();
        q.pop();
        int x = root(zz.second.first);
        int y = root(zz.second.second);
        if(x==y) continue;
        p[x] = y;
        ans+=-zz.first;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6516
import sys
from collections import defaultdict

input = sys.stdin.readline


class AtCoder:
    def main(self):
        H, W = map(int, input().split())
        field = defaultdict(lambda: '#')
        dot_cnt = 0
        for h in range(H):
            for w, c in enumerate(list(input().rstrip())):
                field[str(h + 1) + '-' + str(w + 1)] = c
                if c == '.':
                    dot_cnt += 1

        q = [(1, 1)]
        field['1-1'] = '#'
        moving_range = ((1, 0), (-1, 0), (0, 1), (0, -1))
        moves = 1
        goal_is_reachable = False
        while q:
            if (H, W) in q:
                goal_is_reachable = True
                break

            next_q = []
            for x, y in q:
                for m_x, m_y in moving_range:
                    n_x, n_y = x + m_x, y + m_y
                    if field[str(n_x) + '-' + str(n_y)] == '.':
                        next_q.append((n_x, n_y))
                        field[str(n_x) + '-' + str(n_y)] = '#'
            moves += 1
            q = next_q

        if not goal_is_reachable:
            print(-1)
        else:
            print(dot_cnt - moves)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 3692
#include<stdio.h>

int main(){
  int i,j,k,a,h[3]={0,0,0};

  for(i=0;i<10;i++){
    scanf("%d",&a);
    for(j=0;j<3;j++){
      if(h[j] < a){
        for(k=2;k>j;k--)
          h[k] = h[k-1];
        h[j] = a;
        break;
      }
    }
  }

  for(i=0;i<3;i++)
    printf("%d\n",h[i]);

    return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>
int main(){
  char s[202];
  scanf("%s",s);
  int i,j,len=strlen(s);
  for(i=2;i<len;i+=2){
    int check=0;
    for(j=0;j<(len-i)/2;j++)
      if(s[j]!=s[j+(len-i)/2])
        check=1;
    if(check==0)
      break;
  }
  printf("%d\n",len-i);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;

constexpr uint64_t prime = 1000000009;
constexpr uint64_t base = 10007;
uint64_t rolling_hash_push(uint64_t hash, char c) {
    return (hash * base + c) % prime;
}
uint64_t rolling_hash_shift(uint64_t hash, uint64_t k) {
    uint64_t e = base;
    for (; k; k >>= 1) {
        if (k & 1) hash = hash * e % prime;
        e = e * e % prime;
    }
    return hash;
}
template <class Iterator>
vector<uint64_t> rolling_hash_prepare(Iterator first, Iterator last) {
    vector<uint64_t> hash(last - first + 1);
    REP (i, last - first) {
        hash[i + 1] = rolling_hash_push(hash[i], *(first + i));
    }
    return hash;
}

template <class Iterator>
vector<bool> make_is_good_array(Iterator first, Iterator last) {
    int n = last - first;
    auto hash = rolling_hash_prepare(first, last);
    vector<bool> p(n + 1, true);
    uint64_t h = 0;
    uint64_t shift = 1;
    REP3 (l, 1, n + 1) {
        h = rolling_hash_push(h, *(first + l - 1));
        shift = rolling_hash_push(shift, 0);
        uint64_t h1 = h;
        for (int r = 2 * l; r <= n; r += l) {
            h1 = (h1 * shift + h) % prime;
            if (h1 != hash[r]) break;
            p[r] = false;
        }
    }
    return p;
}

pair<int, int> solve(string const & w) {
    int n = w.length();
    if (count(ALL(w), w[0]) == n) {
        return make_pair(n, 1);  // w has only one letter
    }

    // m = 1
    auto is_good = make_is_good_array(ALL(w));
    if (is_good[n]) {
        return make_pair(1, 1);
    }

    // m = 2
    auto is_good_rev = make_is_good_array(w.rbegin(), w.rend());
    int cnt = 0;
    REP3 (i, 1, n) {
        cnt += is_good[i] and is_good_rev[n - i];
    }
    if (cnt) {
        return make_pair(2, cnt);
    }

    // m = 3
    REP3 (i, 1, n) if (is_good[i]) {
        auto is_good_shifted = make_is_good_array(w.begin() + i, w.end());  // :pray:
        REP (j, n - i) {
            cnt += is_good_shifted[j] and is_good_rev[n - j];
        }
    }
    assert (cnt);  // :pray:
    return make_pair(3, cnt);
}

int main() {
    string w; cin >> w;
    int m, cnt; tie(m, cnt) = solve(w);
    cout << m << endl;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4800
#include <stdio.h>

int main(void) 
{
	int ab,bc,ca,min;
	scanf("%d%d%d",&ab,&bc,&ca);
	int aaa = ab + bc;
	int bbb = ca + bc;
	int ccc = ab + ca;
	if(aaa >= bbb){
		min = bbb;
	}else{
		min = aaa;
	}
	if(min >= ccc) min = ccc;
	printf("%d\n",min);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {

	int a;

	std::cin >> a;

	int count = 0;
	for (size_t i = 1; i <= a; i+=2) {
		int ya = 0;

		for (size_t j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				ya += 2;
				if (j * j == i) {
					ya--;
				}
			}
		}
		if (ya == 8) {
			count++;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

const int DATA[10] = { 0,2,5,5,4,5,6,3,7,6 };

int N, M, A[9];
bool DP[11111][5555];
string res;

int main() {
	cin >> N >> M;
	for (int i = 0; i != M; ++i)
		cin >> A[i];
	sort(A, A + M);
	DP[0][0] = true;
	for (int i = 0; i != N; ++i) {
		for (int j = 0; j <= i / 2; ++j) {
			if (DP[i][j]) {
				for (int k = 0; k != M; ++k) {
					DP[i + DATA[A[k]]][j + 1] = true;
				}
			}
		}
	}
	for (int i = N / 2; i; --i) {
		if (DP[N][i]) {
			int p = N;
			while (i) {
				for (int j = M - 1; j != -1; --j) {
					if (p - DATA[A[j]] >= 0 && DP[p - DATA[A[j]]][i - 1]) {
						cout<<char('0' + A[j]);
						p -= DATA[A[j]];
						break;
					}
				}
				--i;
			}
			cout << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 55040
#include <iostream>
#include <algorithm>
using namespace std;
int a[1000006];
int aabs(int x){
	return x >= 0 ? x : -x;
}
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i)
		cin >> a[i];
	sort(a + 1, a + 1 + n);
	int x = (a[n] + 1) / 2;
	int ans = n;
	for (int i = 1; i < n; ++ i)
		if (ans == n || aabs(x - a[i]) < aabs(x - a[ans]))
			ans = i;
	cout << a[n] << " " << a[ans] << endl;
}


Measured memory_bytes: 640
import java.math.*

fun main(args: Array<String>) {
    val (N, A, B) = readInputLine().split(" ").map { it.toLong() }
    val XArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()
    
    var ans = 0L
    
    for (i in 1 until N.toInt()) {
        ans += Math.min((XArr[i] - XArr[i - 1]) * A, B)
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 53936
import java.lang.Integer.parseInt
import java.util.*

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)

    val arg = argList.nextLine().split(" ")
    var N = parseInt(arg[0])
    val X = parseInt(arg[1])
    val L = argList.nextLine().split(" ").map { parseInt(it) }

    var count = 0
    var current = 0

    L.forEach {
        if (current <= X) {
            count++
            current += it
        }
    }.let { if (current <= X) count++  }

    println(count)
}


Measured memory_bytes: 36076
A,B,C=map(int,input().split())
K=int(input())
list=[A,B,C]
presum=A+B+C-max(list)
i=0
preanswer=max(list)
while i<K:
    preanswer=preanswer*2
    i+=1
print(preanswer+presum)

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


using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
const int mod = 1e9+9;



const int nax = 1e5+103;
int n, k;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}


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

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int x[] = new int[100];
		int y[] = new int[100];
		int n = sc.nextInt();
		double p1 = 0.0;
		double p2 = 0.0;
		double p3 = 0.0;
		double pinf = 0.0;
		for(int i = 0; i < n; i++){
			x[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			y[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++){
			p1 += (double)Math.abs(x[i] - y[i]);
		}
		
		for(int i = 0; i < n; i++){
			p2 += (double)Math.pow((double)Math.abs(x[i] - y[i]),2.0);
		}
		p2 = Math.sqrt(p2);
		
		for(int i = 0; i < n; i++){
			p3 += (double)Math.pow((double)Math.abs(x[i] - y[i]),3.0);
		}
		p3 = Math.pow(p3,1.0/3.0);
		
		for(int i = 0; i < n; i++){
			pinf = Math.max(pinf,(double)Math.abs(x[i] - y[i]));
		}
		
		System.out.println(p1);
		System.out.println(p2);
		System.out.println(p3);
		System.out.println(pinf);
	}
}

Measured memory_bytes: 26456
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

//date,last activity
int n, dp[100005][5];
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i - 1][1] + b, dp[i - 1][2] + c);
		dp[i][1] = max(dp[i - 1][0] + a, dp[i - 1][2] + c);
		dp[i][2] = max(dp[i - 1][1] + b, dp[i - 1][0] + a);
	}

	cout << max({ dp[n][0],dp[n][1],dp[n][2] }) << endl;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	char b;
	cin >> b;

	vector<char> base_pair(128);
	base_pair['A'] = 'T';
	base_pair['T'] = 'A';
	base_pair['G'] = 'C';
	base_pair['C'] = 'G';

	cout << base_pair[b] << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	register int i; int N = 0, S = 0, W = 0, E = 0;
	char str[1010];
	scanf( "%s", str );
	for( i = 0; i < (int) strlen(str); ++i )
		N |= str[i] == 'N', S |= str[i] == 'S', W |= str[i] == 'W', E |= str[i] == 'E';
	puts( N ^ S || W ^ E ? "No" : "Yes" );
	return 0;
}

Measured memory_bytes: 256