akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

namespace TYC
{
	typedef long long ll;
	const int N = 405, mod = 998244353;

	int n, m, A[N], B[N], G[N][N], F[N], S[N][N], L[N], C[N][N];

	int inv(const int x) { return x == 1 ? 1 : int((ll)inv(mod % x) * (mod - mod / x) % mod); }

	void work()
	{
		scanf("%d", &n);
		int sum = 0;
		for (int i = 1; i <= n; i++)
		{
			scanf("%d%d", &A[i], &B[i]);
			sum += A[i], m += B[i];
		}
		int invsum = inv(sum), tot = max(n, max(sum, m));
		G[0][0] = 1;
		for (int i = 1; i <= n; i++)
		{
			int t = int((ll)A[i] * invsum % mod);
			for (int j = 0, fac = 1, v = 1; j < B[i]; j++, fac = int((ll)fac * j % mod), v = int((ll)v * t % mod))
				F[j] = int((ll)(mod - v) * inv(fac) % mod);
			static int T[N][N];
			memcpy(T, G, sizeof(G));
			memset(G, 0, sizeof(G));
			for (int d = 0; d <= m; d++)
			{
				if (d >= A[i])
					for (int k = 0; k <= m; k++)
						G[d][k] = (G[d][k] + T[d - A[i]][k]) % mod;
				for (int a = 0; a <= m; a++)
					for (int b = 0; b < B[i]; b++)
						G[d][a + b] = int((G[d][a + b] + (ll)T[d][a] * F[b]) % mod);
			}	
		}
		for (int i = 0; i <= tot; i++)
		{
			C[i][0] = 1;
			for (int j = 1; j <= i; j++)
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
		S[0][0] = 1;
		for (int i = 1; i <= tot; i++)
			for (int j = 0; j <= i; j++)
				S[i][j] = int((S[i - 1][j - 1] + (ll)(i - 1) * S[i - 1][j]) % mod);
		int ans = 0;
		for (int k = 0, fac = 1; k <= m; k++, fac = int((ll)fac * k % mod))
			ans = int((ans + (ll)G[0][k] * fac) % mod);
		for (int d = 1; d < sum; d++)
		{
			int c = int((ll)d * invsum % mod);
			L[0] = inv(1 - c + mod);
			for (int t = 1; t <= m; t++)
			{
				L[t] = 0;
				for (int i = 0; i < t; i++)
					L[t] = int((L[t] + (ll)C[t][i] * L[i]) % mod);
				L[t] = int((ll)L[t] * c % mod * L[0] % mod);
			}
			for (int k = 0, v = 1, t = inv(c); k <= m; k++, v = int((ll)v * t % mod))
			{
				int s = 0;
				for (int i = k, w = 1; ~i; i--, w = -w)
					s = int((s + (ll)S[k][i] * (w + mod) % mod * L[i] % mod) % mod);
				ans = int((ans + (ll)s * G[d][k] % mod * v % mod) % mod);
			}
		}
		printf("%d\n", mod - ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 2816
function Main(string){
  var line2 = string.split('\n')[1]
  var listInt = line2.split(' ').map(v=>+v)
  var head  = listInt.sort((a,b)=>a<b?-1:1).slice(0,-1)
  var max   =  listInt.sort((a,b)=>a<b?-1:1).slice(-1)[0]
  var headSum = head.reduce((s,v)=>s+v)
  console.log(max < headSum ? 'Yes' : 'No')
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  long long t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (a1 < b1) {
    swap(a1, b1);
    swap(a2, b2);
  }
  long long diff = (b1 * t1 + b2 * t2) - (a1 * t1 + a2 * t2);
  if (diff == 0) {
    cout << "infinity\n";
    return 0;
  }
  if (diff < 0) {
    cout << 0 << '\n';
    return 0;
  }
  long long dist = a1 * t1 - b1 * t1, ans = 1;
  dist -= diff;
  if (dist < 0) {
    cout << 1 << '\n';
    return 0;
  }
  ans += ((dist + diff - 1) / diff) * 2;
  if (dist % diff == 0) ++ans;
  cout << ans << '\n';
  return 0;
}


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

fn main(){
    let mut s : String = input();
    s = s.replace(",", " ");
    println!("{}", s);
}

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

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string s, c;
    int q, t, f;
    int i;
    bool rev = false;
    cin >> s >> q;
    //StringBuilder sb = new StringBuilder();
    //sb.append(s);
    s.reserve(q);
    for(i=0;i<q;i++){
        cin >> t;
        if(t==1){
            rev = !rev;
            //reverse(s.begin(), s.end());
        }else{
            cin >> f >> c;
            if((f==1)!= rev){
                s.insert(0, c);
            }else{
                s.append(c);
            }
        }
    }
    if(rev) reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 924
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll>a(n+1,0);
    FOR(i,1,n+1){
        for(ll j = 1;i*j <= n;j++){
            a[i*j]++;
        }
    }
    ll answer = 0;
    FOR(i,1,n+1){
        answer+=a[i]*i;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 81404
//
// Created on 2020/04/28.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans;
    int n;
    cin>>n;
    vector<int>d(n);
    if(n%2 == 1){
        ans = 0;
        return 0;
    }

    for (int i = 0; i < n; ++i) {
        cin>>d[i];
    }
    sort(all(d));
    int low = d[n/2-1];
    int top = d[n/2];

    ans = top - low;

    cout<<ans<<endl;
    return 0;
}


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

int main(){
	
	int N;
	cin>>N;
	while(N--){
		double x1, x2, x3,y1, y2, y3;
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		double a, b, c, d, e, f;
		double px,py,r;
		a=2.0*(x2-x1);
		b=2.0*(y2-y1);
		c=x1*x1+y1*y1-x2*x2-y2*y2;
		d=2.0*(x3-x1);
		e=2.0*(y3-y1);
		f=x1*x1+y1*y1-x3*x3-y3*y3;
		px=(b*f-c*e)/(a*e-b*d);
		py=(c*d-a*f)/(a*e-b*d);
		r=sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
		printf("%.3f %.3f %.3f\n",px,py,r);
	}
	
	return 0;
}


Measured memory_bytes: 1244
N = int(input())
a = list(map(int,input().split()))
a.sort()

for i in range(1,N):
    a[i] = a[i-1] + a[i]
cnt = 1
for i in reversed(range(1,N)):
    if(a[i] > a[i-1] * 3): 
        break
    cnt += 1
print(cnt)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    ll k;
    cin >> k;
    ll a[50], plus = k / 50LL, rest = k % 50LL;
    rep(i, 50) a[i] = i + plus;
    rep(i, rest) {
        rep(j, 50) {
            if (i == j) a[j] += 50LL;
            else a[j]--;
        }
    }
    cout << 50 << endl;
    rep(i, 50) cout << a[i] << ((i < 49) ? " " : "\n");
    return 0;
}

Measured memory_bytes: 256
import math
q=int(input())
for i in[0]*q:
	a,b=map(int,input().split())
	c=int(math.sqrt(a*b))
	if c*(c+1)<a*b:print(2*c-1)
	elif a*b==c*c and a!=b:print(2*c-3)
	else:print(2*c-2)


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

using namespace std;
using lint = long long;

int main(void)
{
    int N, k;
    cin >> N >> k;
    string S;
    cin >> S;
    char sm = S[k-1];
    if(sm  == 'A')  sm = 'a';
    else if(sm == 'B') sm = 'b';
    else sm = 'c';
    S[k-1] = sm;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
int n, a=1000;

int main(){
	IOS
	cin >> n;
	while(a<n){
		a+=1000;
	}
	cout << a-n << '\n';
}



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

from __future__ import division, print_function, absolute_import, unicode_literals

N, A, B = map(int, input().split())
S = input()

cb = 0
c = A + B
cnt = 0
for index, s in enumerate(S, 1):
    if s == 'c':
        print("No")
        continue
    if s == 'a':
        if cnt < c:
            print("Yes")
            cnt += 1
        else:
            print("No")
    elif s == 'b':
        cb += 1
        if cnt < c and cb <= B:
            print("Yes")
            cnt += 1
        else:
            print("No")


Measured memory_bytes: 4040
#include <climits>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;

int count(vector<ll>&lx, vector<ll>&ly, ll xl, ll xr, ll yl, ll yr) {
  int ret = 0;
  int size = lx.size();
  for (int i = 0; i < size; ++i) {
    ll x = lx[i];
    ll y = ly[i];
    if (x < xl || x > xr) continue;
    if (y < yl || y > yr) continue;
    ++ret;
  }
  return ret;
}

int main() {
  int n, K;
  cin >> n >> K;
  vector<ll> lx, ly;
  for (int i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    lx.push_back(x);
    ly.push_back(y);
  }

  ll ans = LONG_MAX;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      ll xl, xr;
      xl = min(lx[i], lx[j]);
      xr = max(lx[i], lx[j]);
      for (int k = 0; k < n; ++k) {
        for (int l = 0; l < n; ++l) {
          if (k == l) continue;
          ll yl, yr;
          yl = min(ly[k], ly[l]);
          yr = max(ly[k], ly[l]);
          int c = count(lx, ly, xl, xr, yl, yr);
          if (c < K) continue;
          // cout << i << j << k << l << c << endl;
          // cout << xl << " " << xr << " " << yl << " " << yr << endl;
          ans = min(ans, (xr-xl)*(yr-yl));
        }
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.round
import kotlin.math.sin

fun main() {
    val n = readInt()

    var sum = 0
    for (i in 1..n) {
        sum += i
        if (sum < n) continue

        val diff = sum - n
        val ans = StringBuilder()
        for (j in 1..i) {
            if (j == diff) continue
            println(j)
        }
        //print(ans.toString())
        return
    }
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()

Measured memory_bytes: 35872
n = int(input())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i],b[i] = map(int,input().split())
ans = 0
for i in range(n-1,-1,-1):
    a[i] += ans
    num = (a[i] % b[i])
    if num != 0:
        ans += (b[i]-(a[i]%b[i]))
print(ans)

Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    using P = pair<ll, ll>;

    ll n, k;
    cin(n); cin(k);

    vector<ll> p(n), c(n);
    rep2(i, n) cin(p[i]);
    rep2(i, n) --p[i];
    rep2(i, n) cin(c[i]);

    ll result = LLONG_MIN;

    rep2(i, n) {
        ll position = i;
        ll total = 0;
        vector<ll> s;

        while (true) {
            position = p[position];
            total += c[position];
            s.push_back(c[position]);

            if (position == i) break;
        }

        if (total <= 0) {
            ll max = 0;
            rep2(i, s.size()) {
                max += s[i];
                if (max > result) result = max;
                if (i == k) break;
            }
        } else {
            if (k < s.size()) {
                ll max = 0;
                rep2(i, k) {
                    max += s[i];
                    if (max > result) result = max;
                }
            } else {
                ll si = k - s.size();
                ll max = total * (si / s.size());
                rep2(i, s.size() + si % s.size()) {
                    max += s[i % s.size()];
                    if (max > result) result = max;
                }
            }
        }
    }

    print(result);
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long N; cin >> N;
    vector<long long> A(N+1);
    for (int i = 0; i <= N; i++) cin >> A[i];
    vector<long long> L(N+1), U(N+1); L[N] = A[N], U[N] = A[N];
    for (int i = N; i > 0; i--) {
        L[i-1] = (L[i] / 2) + A[i-1];
        U[i-1] = U[i] + A[i-1];
    }
    
    long long rem = 1; bool ok = true;
    long long ans = 0;
    for (int i = 0; i <= N && ok; i++) {
        if (L[i] <= rem) {
            if (rem > U[i]) rem = U[i];
            ans += rem;
            rem -= A[i];
            rem *= 2;
        } else {
            ok = false;
        }
    }

    if (ok) cout << ans << "\n";
    else cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 5576
import itertools

n=int(input())
l=[int(i) for i in range(n)]
ans=chk=p=0
w=[]
for i in range(n):
    x,y=map(int,input().split())
    w.append((x,y))
for i in list(itertools.permutations(l,n)):
    chk=0
    for j in range(n-1):
        chk+=((w[i[j]][0]-w[i[j+1]][0])**2+(w[i[j]][1]-w[i[j+1]][1])**2)**0.5
    ans+=chk
    p+=1

print(ans/p)

Measured memory_bytes: 80732
N = int(input().strip())
data = [[int(str) for str in input().strip().split()] for _ in range(N)]

data.sort(key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        H = abs(data[0][0] - cx) + abs(data[0][1] - cy) + data[0][2]
        flag = True
        for x, y, h in data:
            if h > 0 and h != H - abs(x - cx) - abs(y - cy):
                flag = False
                break
            if h == 0 and H > abs(x - cx) + abs(y - cy):
                flag = False
                break
        
        if flag:
            print(cx, cy, H)
            exit()

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


void solve(string S){
    string S1 = S;
    ll n= S.size();
    if(n== 1) {
        cout << 0 << endl;
        return;
    }
    ll cnt1=0, cnt2=0;
    for(ll i=1; i< n; i++){
        char p = S[i-1], q = S[i];
        if(p == q){
            cnt1 ++;
            if (p == '0') S.at(i)='1';
            else S.at(i)='0';
        }
    }

    for(ll i= n-2; i>=0; i--){
        char p = S1[i+1], q = S1[i];
        if(p == q){
            cnt2 ++;
            if (p == '0') S1.at(i)='1';
            else S1.at(i)='0';
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
	int n;
	cin >> n;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(n==j*i){
				cout <<"Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	
	return 0;

}

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += (int) (s[i] - '0');
  }

  cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
   ll p= abs(x);
   ll q= p/d;//this many moves to get closest to 0;
    ll m= p-q*d;
   ll f= abs(m-d);
   if(q>=k){
    q=k;
    m=p-q*d;
    f=abs(m+d);

   }

   //movesleft;
   ll r=k-q;
   if(r&1)cout<<f;
   else cout<<m;




    return 0;
}


Measured memory_bytes: 3628
Scanf.sscanf(read_line()) "%d"
  (fun a ->
    let num = a/2 in
    if(a == 1) then print_int(1)
    else if (a mod 2 == 0) then print_float((float_of_int num)/.(float_of_int a) )
    else print_float((float_of_int (num+1))/.(float_of_int a))
  );;
print_string "\n";;


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Stack;

public class Main{
	
	static boolean check(String s) {
	       Stack<Character> stack = new Stack<>(); //
	       for(int i = 0; i < s.length(); i++) {
	            char c = s.charAt(i);
	            if(c == '.') {
	                break;
	            }
	            if(c == '(') {
	                stack.push(')');
	            }
	            if(c == '[') {
	                stack.push(']');
	            }
	            if(c == ')' || c == ']') {
	                if(stack.isEmpty() || stack.pop() != c) {
	                    return false;
	                }
	            }
	        }
	        return stack.isEmpty();
	    }

	 public static void main(String[] args) {
	        try (Scanner sc = new Scanner(System.in)) {
	            while(sc.hasNextLine()){
	                String s = sc.nextLine();
	                if(s.equals(".")) {
	                    break;
	                }
	                if(check(s)) {
	                    System.out.println("yes");
	                }
	                else {
	                    System.out.println("no");
	                }
	            }
	        }
	 }
}



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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans=0;
    bool even=true;
    while(even){
        for(int i=0;i<n;i++){
            if(a[i]%2==0){
                a[i]/=2;
            }else{
                even=false;
            }
        }
        if(even) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    int pre=-1;
    ll ans=1;
    for(int i=0;i<n;i++)
    {
        if(s[i]==t[i])
        {
            if(pre==-1) ans*=3;
            else if(pre==0)
                ans=ans*2%mod;
            pre=0;
        }
        else{
            if(pre==-1) ans*=6;
            else if(pre==0) ans=(ans*2)%mod;
            else ans=ans*3%mod;
            i++;
            pre=1;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include<cstdio>
inline int in();
inline void wr(int);
char s[5];int tot[5];
int main(int argc,char**argv){
	register int n=in();
	while(n--){
		scanf("%s",s+1);
		if(s[1]=='A')++tot[1];
		else if(s[1]=='W')++tot[2];
		else if(s[1]=='T')++tot[3];
		else ++tot[4];
	}
	printf("AC x %d\n",tot[1]);
	printf("WA x %d\n",tot[2]);
	printf("TLE x %d\n",tot[3]);
	printf("RE x %d\n",tot[4]);
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


Measured memory_bytes: 1728
#!/usr/bin/env python

if __name__ == '__main__':
    trump = [ '%c %d' % (c, r) for c in 'SHCD' for r in range(1,14) ]

    n = int(raw_input())
    for _ in range(n):
        trump.remove(raw_input())

    for t in trump:
        print t



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

int n;
float arr[100000];
float maxs=0;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%f",&arr[i]);
	}
	sort(arr+1,arr+n+1);
	float maxs2=arr[1];
	for(int i=2;i<=n;i++){
		maxs2=(arr[i]+maxs2)/2;
	}
	
//	permu(arr,0,n-1);
//	float maxs=0;
//	do{
//		float maxs2=arr[1];
//		for(int i=2;i<=n;i++){
//			maxs2=(maxs2+arr[i])/2;
//		}
//		if(maxs<maxs2){
//			maxs=maxs2;
//		}
//	}while(prev_permutation(arr+1,arr+n+1));
	printf("%f",maxs2);
	return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,M,K,L,A[200005],B[200005];
string str,str2;

int main() {
	
	cout << fixed << setprecision(18);
	cin>>N>>M>>K;
	if(N>=K){
		cout<<N-K<<" "<<M<<endl;
	}else{
		cout<<0<<" "<<max(M-(K-N),0LL)<<endl;
	}
	
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> ans;
ll A,B,C,D;
ll solve(ll x){
	// cerr << x << endl;
	if(!x)return 0;
	if(ans.find(x)!=ans.end())return ans[x];
	ll j=(x+2)/3*3,j2=x/3*3;
	ans[x] = min((__int128)D*x,(__int128)5000000000000000000);
	ans[x]=min(ans[x], solve(j/3)+D*abs(x-j)+B),ans[x]=min(ans[x], solve(j2/3)+D*abs(x-j2)+B*(j2>0));
	
	j=(x+4)/5*5,j2=x/5*5;
	ans[x]=min(ans[x],solve(j/5)+D*abs(x-j)+C),ans[x]=min(ans[x], solve(j2/5)+D*abs(x-j2)+C*(j2>0));

	j=(x+1)/2*2,j2=x/2*2;
	ans[x]=min(ans[x],solve(j/2)+D*abs(x-j)+A),ans[x]=min(ans[x], solve(j2/2)+D*abs(x-j2)+A*(j2>0));
	// cerr << x << ":" << ans[x] << ":" << endl;
	return ans[x];
}

int main()
{
	int T;cin >> T;
	while(T--){
		ll n;cin >> n >> A >> B >> C >> D;
		ans.clear();
		printf("%lld\n",solve(n));
	}
}

Measured memory_bytes: 4568
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

typedef long long ll;

ll encode(int* state)
{
	ll res = 0;
	for (int i = 0; i < 13; ++i)
		res = res << 4 | state[i];
	return res;
}
void decode(int* d, ll e)
{
	for (int i = 12; i >= 0; --i, e >>= 4)
		d[i] = e & 15;
}
void p(ll s)
{
	int d[13];
	decode(d, s);
	for (int i = 0; i < 13; ++i)
		printf("%d ", d[i]);
	printf("\n");
}

int main()
{
	map<ll, int> minSteps;
	int dir[] = { -1, 1, -2, 2, -4, 4 };
	map<int, bool> ok[3];

	int o[][9] = {
		{ 1, 2, 4, 5, 6, 7, 9, 10, -1 },
		{ 0, 10, -1 },
		{ 1, 2, 3, 5, 6, 7, -1 }
	};
	for (int i = 0; i < 3; ++i)
		for (int j = 0; o[i][j] != -1; ++j)
			ok[i][o[i][j]] = true;

	int initial[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 };
	ll t = encode(initial);
	minSteps[t] = 0;
	queue<ll> q;
	q.push(t);

	while (!q.empty())
	{
		ll e = q.front();
		q.pop();
		int d[13];
		decode(d, e);

		int zero_pos[2];
		for (int i = 0, j = 0; j < 2; ++i)
			if (!d[i])
				zero_pos[j++] = i;

		for (int i = 0; i < 2; ++i)
		{
			for (int j = 0; j < 6; ++j)
			{
				int a = zero_pos[i];
				int b = a + dir[j];
				if (a > b)
					swap(a, b);
				if (a < 0 || b > 12 || !d[a] && !d[b] || !ok[j/2][a])
					continue;

				int copy[13];
				memcpy(copy, d, sizeof(copy));
				swap(copy[a], copy[b]);
				ll next = encode(copy);

				if (!minSteps.count(next))
				{
					minSteps[next] = minSteps[e] + 1;
					if (minSteps[next] < 10)
						q.push(next);
				}
			}
		}
	}

	while (true)
	{
		int d[13];
		for (int i = 0; i < 13; ++i)
			scanf("%d", d + i);
		if (d[0] == -1)
			break;

		int ans = -1;
		ll s = encode(d);
		if (minSteps.count(s))
			ans = minSteps[s];
		else
		{
			map<ll, int> c;
			c[s] = 0;
			q = queue<ll>();
			q.push(s);
			while (!q.empty())
			{
				ll e = q.front();
				q.pop();
				int d[13];
				decode(d, e);

				int zero_pos[2];
				for (int i = 0, j = 0; j < 2; ++i)
					if (!d[i])
						zero_pos[j++] = i;

				for (int i = 0; i < 2; ++i)
				{
					for (int j = 0; j < 6; ++j)
					{
						int a = zero_pos[i];
						int b = a + dir[j];
						if (a > b)
							swap(a, b);
						if (a < 0 || b > 12 || !d[a] && !d[b] || !ok[j/2][a])
							continue;

						int copy[13];
						memcpy(copy, d, sizeof(copy));
						swap(copy[a], copy[b]);
						ll next = encode(copy);

						if (minSteps.count(next))
						{
							ans = 10 + c[e] + 1;
							goto End;
						}
						if (!c.count(next) && c[e] < 9)
						{
							c[next] = c[e] + 1;
							q.push(next);
						}
					}
				}
			}
		}
End:
		if (ans != -1)
			printf("%d\n", ans);
		else
			puts("NA");
	}

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int count=0;
  int ans=0;
  for(int i=1;i<=n;i+=2){
      for(int j=1;j<=i;j+=2){
    if(i%j==0){
      count++;
    }
      }
    if(count==8){
      ans++;
    }
    count=0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import copy

N,K = map(int, input().split())
A = list(map(int, input().split()))

# 累積和
AS = [0] * (N+1)
for i in range(N):
  AS[i+1] = AS[i] + A[i]
  
# 全要素をリスト化する
B = []
for i in range(N+1):
  for j in range(i+1,N+1):
    wk = AS[j] - AS[i]
    if wk > 0:
      B.append(wk)

ans = 0
for m in range(38,-1,-1):
  cnt = 0
  p = pow(2,m)
  nxt = []
  for b in B:
    if p & b == p:
      nxt.append(b)
  if len(nxt) >= K:
    ans += p
    B = nxt
    # Bの候補が減っていくところがポイント！
  else:
    pass
    # Bは変わらないところがポイント！

print(ans)
#print(B)

Measured memory_bytes: 29972
while True:
    n, m = map(int, raw_input().split())
    if n == 0: break
    
    lis = [i+1 for i in range(n)]
      
    while True:  
        for i in range(m):
            if i == m-1:
                del lis[0]
            else:
                lis.append(lis[0])
                del lis[0]
        
        if len(lis) == 1:
            print lis[0]
            break

Measured memory_bytes: 4252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int read() {
    static char s[1 << 18];
    static int i, j;
    int r = 0, t = 1, b = 0;
    while (1) {
        if (i == j) {
            cin.read(s, sizeof(s));
            i = 0;
            j = cin.gcount();
            if (j == 0) break;
        }
        int c = s[i++];
        if ('0' <= c && c <= '9') {
            r = r * 10 + (c - '0');
            b = 1;
        } else if (c == '-') {
            t = -1;
        } else if (b) {
            break;
        }
    }
    return r * t;
}

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

    int n = read();

    int a0 = read(), a1 = read();

    ll r0 = 0, r1 = max(a0, a1), r2;
    ll s = a0;

    for (int i = 2; i < n; i++) {
        int a = read();

        if (i & 1) {
            r2 = max(r0 + a, s);
        } else {
            r2 = max(r0 + a, r1);
            s += a;
        }
        r0 = r1;
        r1 = r2;
    }

    cout << r1 << endl;

    return 0;
}


Measured memory_bytes: 3908
k = gets.to_i

m = (k / 2) ## 奇数 50 偶数 50

count = 0

if k % 2 == 0 
  count = m * m  ## 偶数
else
  count = m * (m + 1) ## 奇数
end

puts count.to_s  ## 文字列を出力


Measured memory_bytes: 1788
// Sleeping Time
import java.util.*;

public class Main {
	static double P, E, T;
	static int K;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		K = sc.nextInt();
		int R = sc.nextInt();
		int L = sc.nextInt();
		P = sc.nextDouble();
		E = sc.nextDouble();
		T = sc.nextDouble();
		System.out.printf("%.6f", search(0, (double) R, (double) L));
		System.out.println();
		sc.close();
	}

	static double search(int t, double R, double L) {
		double H = (R + L) / 2;
		if (t == K) {
			if (isIn(H))
				return 1;
			return 0;
		}
		if (L < T - E || T + E < R)
			return 0;
		if (isIn(L) && isIn(R))
			return 1;
		if (T <= H)
			return (1 - P) * search(t + 1, R, H) + P * search(t + 1, H, L);
		return (1 - P) * search(t + 1, H, L) + P * search(t + 1, R, H);
	}

	static boolean isIn(double H) {
		return Math.abs(T - H) < E;
	}
}

Measured memory_bytes: 19168
#include <stdio.h>
int main(void){
	while(1){
		int i,j,H,W;
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1752
from collections import deque
n,q=map(int,input().split())
L=[[]for _ in range(n)]
V=[False]*n
P=[0]*n
for i in range(n-1):
   a,b=map(int,input().split())
   L[a-1].append(b-1)
   L[b-1].append(a-1)
for i in range(q):
   p,x=map(int,input().split())
   P[p-1]+=x
que=deque([0])
while que:
   s=que.popleft()
   V[s]=True
   for ni in L[s]:
       if V[ni]==False:
           P[ni]+=P[s]
           que.append(ni)
print(*P)

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

int main(){
	int n, d, l;
	cin >> n >> d;
	if(n%(d*2+1)==0){
		l = 0;
	}else{
		l = 1;
	}
	cout << n/(d*2+1) + l << endl;
	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;
using std::string;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

int i = 0;
int X;
int N;
int Min = 1145141919;

int main()
{
	IN >> N >> X;

	for(int a = 0; a < N; ++a)
	{
		IN >> i;
		X -= i;
		Min = std::min(Min, i);
	}

	OUT << (N + X / Min) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,m,l, i,j;
    int A[100][100]={},B[100][100]={};
    long C[100][100]={};
    int k;
    scanf("%d %d %d",&n, &m, &l);

    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d",&A[i][j]);
        }
    }

    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            scanf("%d",&B[i][j]);
        }
    }


  
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            for(k = 0; k < m; k++){
            C[i][j] += A[i][k] * B[k][j];
        }
    }
    }

    for(i = 0; i < n; i++){
        for(j = 0; j < l-1; j++){
            printf("%ld ", C[i][j]);
        }
            printf("%ld", C[i][j]);
        printf("\n");
    }




    return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll x,k,d;
    cin >> x >> k >> d;
    if(x < 0) {
    	x = -x;
    }
    ll val = x/d;
    if(val > k) {
    	cout << x - k*d << "\n";
    	return;
    } else {
    	x = x - val*d;
    	k -= val;
    }
    if(k % 2 == 0) {
    	cout << x << "\n";
    } else {
    	cout << d - x << "\n";
    }
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
}

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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  
  int ret;
  if (op == '+') {
  	ret = a + b;
  } else if (op == '-') {
  	ret = a - b;
  }
  
  cout << ret << endl;
}


Measured memory_bytes: 384
/*********************
    メモ化再帰で解いてみた
**********************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a,T b){
    if (a > b) {
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a,T b){
    if(a < b) {
        a=b;
        return true;
    }
    return false;
}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define INF 999999999

    /*Solve*/

//dpテーブル
ll dp[100010];

//足場の高さ
int h[100010];

//再帰関数(recursion)
ll rec(int i,int k){
    //戻り値
    ll res = INF;
    
    //dp[i]が更新されている場合はそのまま返す
    if(dp[i]<INF)return dp[i];
    
    //dp[0]=0
    if(i==0)return 0;
    
    //i-1,i-2,...,i-Kからきた場合
    for(int j=1;j<=k;j++){
        if(j<=i){
            chmin(res,rec(i-j,k)+abs(h[i-j]-h[i]));
        }
    }
    return dp[i] = res;
}

int main(){
    //入力
    int n;cin>>n;
    int k;cin>>k;
    rep(i,n){cin >> h[i];dp[i]=INF;}
    //出力
    cout << rec(n-1,k) << endl;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<b; i++)
using namespace std;
typedef long long int ll;
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t,cnt=0,k=0;
    cin>>t;
    while(t>0){
        if(t==1){
            cnt++;
            //t=0;
            break;
            }
        else{while(t>1){
            t=floor(t/2);
            k++;
            cnt+=pow(2,k);
          //  cout<<t<<" "<<cnt<<endl;
        }
        }         
    }
    cout<<cnt<<endl;
return 0;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

int main() {
    int N, X;
    cin >> N >> X;
    int total_price = 0;
    vector<int> m(N);
    for(int i=0; i<N; i++) {
        cin >> m[i];
    }
    int count = 0;
    int sum_of_donuts = accumulate(m.begin(), m.end(), 0);
    int minimum_price = *min_element(m.begin(), m.end());
    total_price += sum_of_donuts;
    count += m.size();
    while(total_price <= X - minimum_price) {
       total_price += minimum_price; 
        count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MAXN = 301;

//vector<set<ll>> G(MAXN);
//ll N, M;
//ll C[MAXN][MAXN];
//ll D[MAXN][MAXN];

int main() {
    int H, W; cin >> H >> W;
    vector<vector<int>> C(10, vector<int>(10));
    for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) cin >> C[i][j];
    vector<vector<int>> A(H, vector<int>(W));
    for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) cin >> A[i][j];

    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                C[i][j] = min(C[i][j], C[i][k]+C[k][j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(A[i][j] != -1) ans+= C[A[i][j]][1];
        }
    }
    cout << ans << endl;

}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[30];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    FOR(i, N - 1, 1) {
        if ((A[i] > A[i - 1] && A[i] < A[i + 1]) || (A[i] < A[i - 1] && A[i] > A[i + 1]))
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys;sys.setrecursionlimit(10**9)
class UnionFind:
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
    self.siz=n
  def find_root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.find_root(self.n[x])
      return self.n[x]
  def unite(self,x,y):
    x=self.find_root(x)
    y=self.find_root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
    self.siz-=1
  def root_same(self,x,y):
    return self.find_root(x)==self.find_root(y)
  def count(self,x):
    return -self.n[self.find_root(x)]
  def size(self):
    return self.siz

n=int(input())
xy=[list(map(int,input().split()))+[i]for i in range(n)]
xy.sort()
edge=[]
for j in range(1,n):
  sx,sy,si=xy[j-1]
  tx,ty,ti=xy[j]
  edge.append((min(abs(sx-tx),abs(sy-ty)),si,ti))
xy.sort(key=lambda x:x[1])
for j in range(1,n):
  sx,sy,si=xy[j-1]
  tx,ty,ti=xy[j]
  edge.append((min(abs(sx-tx),abs(sy-ty)),si,ti))
u=UnionFind(n)
ans=0
edge.sort()
for c,x,y in edge:
  if u.root_same(x,y):continue
  u.unite(x,y)
  ans+=c
print(ans)

Measured memory_bytes: 47932
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  string s;
  cin>>n>>s;
  int ans = 0;
  rep(i,1000) {
    string t;
    int x = i;
    rep(j,3) {
      t += '0'+x%10;
      x /= 10;
    }
    int ti = 0;
    rep(j,n) {
      if (s[j] == t[ti]) {
        ++ti;
        if (ti == 3) {
          break;
        }
      }
    }
    if (ti == 3) {
      ans ++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3564
/*-------------------------------"ANJAN AGARWALA"-----------------------------

         _/_/_/_/    _/_/    _/   _/_/_/_/   _/_/_/_/    _/_/    _/   
        _/    _/    _/ _/   _/         _/   _/    _/    _/ _/   _/        
       _/_/_/_/    _/   _/ _/         _/   _/_/_/_/    _/  _/  _/         
      _/    _/    _/    _/_/   _/    _/   _/    _/    _/    _/_/  
     _/    _/    _/      _/   _/_/_/_/   _/    _/    _/      _/   

-------------------------------------@anjn98---------------------------------*/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/


#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
//#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007

const int N=1e5+99;
ll dp[N];


int main() 
{
    
    IO
    /*#ifndef ONLINE_JUDGE
    FILEIO
    #endif
    */
    ll n,W,v,w;
    cin>>n>>W;  

    fr(N) dp[i]=1e18;
    dp[0]=0;

    for(int i=0;i<n;i++)
    {
        cin>>w>>v;

        for(int j=N-1;j>=v;j--)
            if( dp[j-v]!=1e18)
                dp[j]= min(dp[j],dp[j-v] + w);
    }
 
    ll ans=0;
    for(ll i=1;i<N;i++)
        if(dp[i]<=W)
        ans=max(ans,i);

    cout<<ans<<endl;


}

Measured memory_bytes: 1024
/*
ABC159
2020/03/23/ 自力AC
*/
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int l;
  cin >> l;
  double x = l;
  printf("%.12f\n", x * x * x / 27);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,i,j;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
//@HelloElwin-20190817
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
int n, m, p, ghd, ghd1, hd[3000], hd1[3000];
long long d[3000];
bool inQ[3000];
int cnt[3000];
bool bk[3000];

struct Edge {
	int u, v, w, nxt;
}g[5005], g1[5005];

void AddEdge (int a, int b, int c) {
	g[ghd] = (Edge){a, b, c};
	g[ghd].nxt = hd[a];
	hd[a] = ghd++;
	g1[ghd1] = (Edge){b, a, c};
	g1[ghd1].nxt = hd1[b];
	hd1[b] = ghd1++;
}

bool Spfa () {
	queue<int> Q; d[1] = 0;
	Q.push(1); inQ[1] = true;
	while (!Q.empty()) {
		int u = Q.front();
		inQ[u] = false; Q.pop();
		for (int i = hd[u]; ~i; i = g[i].nxt) {
			int v = g[i].v, w = g[i].w;
			if (!bk[v]) continue;
			if (d[u] + w > d[v]) {
				d[v] = d[u] + w;
				if (inQ[v]) continue;
				if (++cnt[v] > n) return true;
				inQ[v] = true;
				Q.push(v);
			}
		}
	}
	return 0;
}

// int cccccnt = 0;

void Dfs (int u) {
	// cccccnt++;
	// if (cccccnt > 9000) return;
	bk[u] = true;
	for (int i = hd1[u]; ~i; i = g1[i].nxt) {
		// cccccnt++;
		// if (cccccnt > 9000) return;
		int v = g1[i].v;
		if (bk[v]) continue;
		Dfs(v);
	}
}

int main() {
	
	memset(hd, -1, sizeof(hd));
	memset(hd1,-1,sizeof(hd1));
	scanf("%d %d %d", &n, &m, &p);
	for (int i = 0; i <= n; i++) d[i] = -1000000000;
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		AddEdge(a, b, c - p);
	}

	Dfs(n);

	if (Spfa()) {
		printf("-1\n");
		return 0;
	}

	printf("%lld\n", max(0ll, d[n]));

	return 0;
}


Measured memory_bytes: 640