akhauriyash/Code-Regression huggingface dataset:
class Node:
    id = None
    parent = None
    left = None
    right = None
    sibling = -1
    depth = None
    height = None

    def __str__(self):
        degree = None
        _type = None

        return 'node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(self.id, self.parent, self.sibling, self.get_degree(), self.depth, self.height, self.get_type())

    def get_degree(self):
        degree = 0
        if self.left is not None:
            degree += 1
        if self.right is not None:
            degree += 1
        return degree

    def get_type(self):
        if self.parent == -1:
            return 'root'
        if self.get_degree() == 0:
            return 'leaf'
        else:
            return 'internal node'


def set_depth(node_id, depth):
    if node_id is None:
        return

    global T
    T[node_id].depth = depth
    set_depth(T[node_id].left, depth + 1)
    set_depth(T[node_id].right, depth + 1)


def set_height(node_id):
    global T

    h1, h2 = 0, 0
    if T[node_id].left is not None:
        h1 = set_height(T[node_id].left) + 1
    if T[node_id].right is not None:
        h2 = set_height(T[node_id].right) + 1

    T[node_id].height = max(h1, h2)

    return max(h1, h2)


def pre_order(node_id, _order):
    if node_id is None:
        return

    global T
    _order.append(node_id)
    pre_order(T[node_id].left, _order)
    pre_order(T[node_id].right, _order)


def in_order(node_id, _order):
    if node_id is None:
        return

    global T
    in_order(T[node_id].left, _order)
    _order.append(node_id)
    in_order(T[node_id].right, _order)


def post_order(node_id, _order):
    if node_id is None:
        return

    global T
    post_order(T[node_id].left, _order)
    post_order(T[node_id].right, _order)
    _order.append(node_id)


n = int(input())
T = []
root = 0

for i in range(n):
    T.append(Node())

for i in range(n):
    _ = list(map(int, input().split()))
    _id = _[0]
    left = _[1]
    right = _[2]
    if left == -1:
        left = None
    if right == -1:
        right = None

    T[_id].id = _id
    T[_id].left = left
    T[_id].right = right

    if left is not None:
        T[left].parent = _id
    if right is not None:
        T[right].parent = _id

    if left is not None and right is not None:
        T[left].sibling = right
        T[right].sibling = left

for i in range(n):
    if T[i].parent is None:
        T[i].parent = -1
        root = i
        break

set_depth(root, 0)
set_height(root)

# for i in range(n):
#     print(T[i])

order = []
print('Preorder')
pre_order(root, order)
print(' ' + ' '.join(map(str, order)))

order = []
print('Inorder')
in_order(root, order)
print(' ' + ' '.join(map(str, order)))

order = []
print('Postorder')
post_order(root, order)
print(' ' + ' '.join(map(str, order)))



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
const int ms = 1e5+9;
int h[ms], cost[ms];

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

  for(int i = 1; i <=n; i++) cost[i] = 1e9+10;

  for(int i = 0; i < n; i++){
    cost[i+1] = min(cost[i+1], cost[i] + abs(h[i] - h[i+1]));
    cost[i+2] = min(cost[i+2], cost[i] + abs(h[i] - h[i+2]));
  }

  cout<<cost[n-1];

}

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

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define mod               1000000007
#define fr                first
#define sc                second
#define vl                vector<ll>
#define pll               pair<ll,ll>
#define u_map             unordered_map<ll,ll>

#define pi                3.141592653589793
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define printV(v) for(auto itr:v) cout<<itr<<" "; cout<<endl;
#define printA(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printC cout<<"yes"<<endl;
#define printVP(v) for(auto itr:v) cout<<itr.fr<<" "<<itr.sc<<endl;
#define cinarr(a,n) for(int i=0; i<n; i++) cin>>a[i];



void solve(){
	ll d,t,s; cin>>d>>t>>s;
	ll dt=t*s;
	if(dt>=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}



signed main(){
    ios;
	int testcases=1;
	//cin >> testcases;

	while(testcases--){
	    solve();
	}

	return 0;
}


Measured memory_bytes: 3644
m = int(input())
q_list = list(map(int, input().strip().split()))
n = [0] * m
k = [0] * m

for i in q_list:
    n[i - 1] += 1
for j, l in zip(range(m), n):
    k[j] = int(l * (l - 1)/2)
sum_n = sum(k)

for j in q_list:
    print(sum_n - n[j - 1] + 1)


Measured memory_bytes: 26012
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]

dp1 = abc[0]
dp2 = [0, 0, 0]

for i in range(1, n):
    dp2[0] = abc[i][0] + max(dp1[1], dp1[2])
    dp2[1] = abc[i][1] + max(dp1[0], dp1[2])
    dp2[2] = abc[i][2] + max(dp1[0], dp1[1])
    dp1 = dp2
    dp2 = [0, 0, 0]

print(max(dp1))

Measured memory_bytes: 30580
from collections import deque


def main():
    N, M = map(int, input().split())
    edges = [[] for _ in range(3 * N)]

    for _ in range(M):
        u, v = map(lambda x: int(x) - 1, input().split())
        edges[3 * u].append(3 * v + 1)
        edges[3 * u + 1].append(3 * v + 2)
        edges[3 * u + 2].append(3 * v)

    S, T = map(lambda x: (int(x) - 1) * 3, input().split())
    q = deque([(S, 0)])
    nodes = [-1] * (3 * N)

    while q:
        cv, count = q.popleft()

        if cv == T:
            nodes[cv] = count if nodes[cv] == -1 else min(nodes[cv], count)
        else:
            if nodes[cv] == -1 or count < nodes[cv]:
                nodes[cv] = count
                for u in edges[cv]:
                    q.append((u, count + 1))

    print(nodes[T] // 3 if nodes[cv] != -1 else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86052
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;



int main()
{
	string s;
	cin >> s;
	int num = s.length() - 2;
	ostringstream ans;

	ans << s[0] << num << s[s.length() - 1];
	cout << ans.str() << endl;

	return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = 1e5 + 5;
const ll mod = 1e9 + 7;

vector < ll > fact(N);

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

ll inv (ll a) {
  return pwr(a, mod - 2);
}

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

  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = (i * fact[i - 1]) % mod;

  int n;
  cin >> n;
  vector < int > x(n + 1);
  vector < ll > p(n + 1);
  for (int i = 1; i <= n; i++) cin >> x[i];
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    p[i] = (p[i - 1] + inv(i)) % mod;
  }
  for (int i = 1; i < n; i++) {
    ans = (ans + (((x[i + 1] - x[i]) * p[i]) % mod)) % mod;
  }
  ans = (ans * fact[n - 1]) % mod;
  cout << ans << '\n';
}


Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> P;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int W,H,T;
char c[32][32];
int dist[16][16];
int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
map<P, int>m;

int dfs(int S, int cur){
  if((1<<T)-1 == S) return 0;
  int res = INF;
  rep(i,T){
    if((S>>i)&1) continue;
    if(dist[cur][i]!=INF);
    res = min(res, dfs(S | (1<<i), i)+dist[cur][i]);
  }
  return res;
}

void solve(){
  vector<P>crd;
  int vis[32][32];
  int sy, sx;
  rep(i,16) rep(j,16) dist[i][j] = INF;
  rep(i,H) rep(j,W){
    if(c[i][j]=='o'||c[i][j]=='*') crd.push_back(P(i,j));
    if(c[i][j]=='o') sy = i, sx = j;
  }
  T = crd.size();
  rep(i,T) if(crd[i].first == sy && crd[i].second == sx) swap(crd[0], crd[i]);
  rep(i,T) m[crd[i]] = i;

  rep(i,T){
    queue<P>q;
    memset(vis, -1, sizeof(vis));
    q.push(crd[i]);
    vis[crd[i].first][crd[i].second] = 0;

    while(!q.empty()){
      P p = q.front(); q.pop();
      int y = p.first, x = p.second;
      if(c[y][x] == '*'){
	dist[i][m[P(y,x)]] = vis[y][x];
      }

      rep(d,4){
	int ny=y+dy[d], nx=x+dx[d];
	if(ny<0||ny>=H||nx<0||nx>=W||c[ny][nx]=='x'||vis[ny][nx]!=-1) continue;
	vis[ny][nx] = vis[y][x]+1;
	q.push(P(ny,nx));
      }
    }
  }
  int res = dfs(1,0);
  printf("%d\n", res!=INF?res:-1);
}

int main(){
  while(scanf("%d%d",&W,&H) && W||H){
    rep(i,H) scanf("%s", c[i]);
    solve();
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    ll h = 0;
    ll ans = 0;
    rep(i,n){
        if(h <= a[i]){
            h = a[i];
        }
        else{
            ans += h - a[i];
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 4772
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    NN=N=ii()
    ans = 0
    for i in range(2, int(N**0.525)+1):
        c = i
        while N%c == 0:
            N //= c
            c *= i
            ans += 1
        while N%i==0:
            N//=i
    if N>1:
        ans += 1
    print(ans)





main()



Measured memory_bytes: 10124
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////



int main () {
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.precision(10);
	string s;
	cin >> s;
	if(s == "ABC")
		cout << "ARC";
	else
		cout << "ABC";
	cout << '\n';

	return 0;
}


Measured memory_bytes: 3592
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll p(n);
  rep(i, n){
    cin >> p[i];
  }
  ll mi = INF;
  ll ans = 0;
  rep(i, n){
    if(chmin(mi, p[i])){
      ans++;
    }
  }
  print(ans);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long ll;
const int maxn = 250002;
char buf[maxn];
int n,sum,s[maxn];
inline void reduce(int & x,const int & mod){ x += x >> 31 & mod; }
inline int pow(int a,int b,const int & mod,int ret = 1){
	for(b = b % (mod - 1) + mod - 1;b;b>>=1,a=ll(a) * a % mod)if(b & 1)
		ret = ll(ret) * a % mod;
	return ret;
}
constexpr int m0 = 1192230913,b0 = 233333;
constexpr int m1 = 1085276161,b1 = 2333333;
struct Int{
	int a0,a1;
	inline Int(int x0 = 0,int x1 = 0){ a0 = x0,a1 = x1; }
	inline void add(){ reduce(a0 += b0 - m0,m0); reduce(a1 += b1 - m1,m1); }
	inline void dec(){ reduce(a0 -= b0,m0); reduce(a1 -= b1,m1); }
	inline void mul(int cnt){ a0 = pow(b0,cnt,m0,a0); a1 = pow(b1,cnt,m1,a1); }
	inline bool operator < (const Int & b) const { return * (ll*) this < * (ll*) & b; }
} a[maxn], b[maxn];

int main()
{
	std::ios::sync_with_stdio(false),std::cin.tie(0);
	std::cin >> n >> buf + 1;
	for(int i = 1;i <= n;++i){
		a[i] = a[i - 1];
		if(buf[i] == '+') a[i].add();
		if(buf[i] == '-') a[i].dec();
		if(buf[i] == '>') a[i].mul(1),--sum;
		if(buf[i] == '<') a[i].mul(-1),++sum;
		s[i] = sum;
		(b[i] = a[i]).mul(sum);
	}
	ll ans = 0;
	std::map<Int,int> map;
	for(int i = n;i >= 0;--i){
		Int x = b[n]; x.mul(s[i]);
		ans += map[Int(((ll)b[i].a0 + x.a0) % m0,(b[i].a1 + x.a1) % m1)];
		++map[b[i]];
	}
	std::cout << ans << '\n';
}

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

using namespace std;

typedef long long ll;

const int N = 1000010;
const ll INF = 1e16 + 69;

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

char tmp[7];
int n, dir[N];
ll x[N], y[N];
map <ll, vector <pair <ll, int>>> hor, ver, oneUp, oneDown, twoUp, twoDown;

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld %lld %s", x + i, y + i, tmp);
    x[i] <<= 1, y[i] <<= 1;
    if (tmp[0] == 'U') dir[i] = 0;
    if (tmp[0] == 'D') dir[i] = 1;
    if (tmp[0] == 'L') dir[i] = 3;
    if (tmp[0] == 'R') dir[i] = 2;
    if (tmp[0] == 'U' or tmp[0] == 'D') ver[x[i]].emplace_back(y[i], dir[i]);
    else hor[y[i]].emplace_back(x[i], dir[i]);
    if (tmp[0] == 'U' or tmp[0] == 'R') twoUp[x[i] + y[i]].emplace_back(x[i], dir[i]);
    else twoDown[x[i] + y[i]].emplace_back(x[i], dir[i]);
    if (tmp[0] == 'U' or tmp[0] == 'L') oneUp[x[i] - y[i]].emplace_back(x[i], dir[i]);
    else oneDown[x[i] - y[i]].emplace_back(x[i], dir[i]);
  }
  ll ans = INT_MAX / 2;
  for (auto it : hor) {
    auto &vec = it.second;
    if (vec.size() > 1) {
      sort(vec.begin(), vec.end());
      for (int j = 0; j + 1 < vec.size(); ++j) {
        if (vec[j].second == 2 and vec[j + 1].second == 3) {
          ans = min(ans, (vec[j + 1].first - vec[j].first) / 2);
        }
      }
    }
  }
  for (auto it : ver) {
    auto &vec = it.second;
    if (vec.size() > 1) {
      sort(vec.begin(), vec.end());
      for (int j = 0; j + 1 < vec.size(); ++j) {
        if (vec[j].second == 0 and vec[j + 1].second == 1) {
          ans = min(ans, (vec[j + 1].first - vec[j].first) / 2);
        }
      } 
    }
  }
  for (auto it : oneUp) {
    auto &vec = it.second;
    if (vec.size() > 1) {
      sort(vec.begin(), vec.end());
      for (int j = 0; j + 1 < vec.size(); ++j) {
        if (vec[j].second == 0 and vec[j + 1].second == 3) {
          ans = min(ans, abs(vec[j + 1].first - vec[j].first));
        }
      } 
    } 
  }
  for (auto it : oneDown) {
    auto &vec = it.second;
    if (vec.size() > 1) {
      sort(vec.begin(), vec.end());
      for (int j = 0; j + 1 < vec.size(); ++j) {
        if (vec[j].second == 2 and vec[j + 1].second == 1) {
          ans = min(ans, abs(vec[j + 1].first - vec[j].first));
        }
      } 
    } 
  }
  for (auto it : twoUp) {
    auto &vec = it.second;
    if (vec.size() > 1) {
      sort(vec.begin(), vec.end());
      for (int j = 0; j + 1 < vec.size(); ++j) {
        if (vec[j].second == 2 and vec[j + 1].second == 0) {
          ans = min(ans, abs(vec[j + 1].first - vec[j].first));
        }
      } 
    } 
  }
  for (auto it : twoDown) {
    auto &vec = it.second;
    if (vec.size() > 1) {
      sort(vec.begin(), vec.end());
      for (int j = 0; j + 1 < vec.size(); ++j) {
        if (vec[j].second == 1 and vec[j + 1].second == 3) {
          ans = min(ans, abs(vec[j + 1].first - vec[j].first));
        }
      } 
    } 
  }
  if (ans > INT_MAX / 4) cout << "SAFE\n";
  else cout << ans * 5 << '\n';
  return 0;
}



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

int main(){
  long long N,C,K;
  cin >> N >> C >> K;
  
  vector<long long> T(N);
  for(int i=0;i<N;i++){
    cin >> T.at(i);
  }
  sort(T.begin(),T.end());
  
  long long bus = 0;
  long long tmp = 0;
  long long time = T.at(0);
  for(int i=0;i<N;i++){
    if(tmp==0){
      time = T.at(i);
    }
    if( T.at(i) - time > K ){
      bus ++;
      tmp = 1;
      time = T.at(i);
    }else{
      tmp++;
      if( C == tmp ){
        bus ++;
        tmp = 0;
      }
    }
  }

  if( tmp > 0){
    bus ++;
  }

  cout << bus << "\n";
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N,X;
    cin >> N >> X;
    int M[N];
    rep(i,N) cin >> M[i];
    sort(M,M+N);
    int ans=N;
    rep(i,N) X-=M[i];
    ans+=X/M[0];
    cout << ans << endl;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int MOD = 1e9+7;

signed main(){

  int n,k; cin >> n >> k;

  static int dp[2001][2001]; // dp[n][r] = nCr
  for(int i = 0; i <= n; i++){
    dp[i][0] = 1;
    for(int j = 1; j <= i; j++){
      dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
      dp[i][j] %= MOD;
    }
  }

  for(int i = 1; i <= k; i++){
    cout << (dp[n-k+1][i] * dp[k-1][i-1]) % MOD << endl;
  }

  return 0;
}


Measured memory_bytes: 30080
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

void dijkstra(const vector<vector<pair<ll, ll>>>&edge, vector<ll>&cost, ll start = 0)
{
	fill(ALL(cost), INFLL); cost[start] = 0;
	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> node_queue; node_queue.push(make_pair(0, start));
	while (!node_queue.empty()) {
		ll tpn_cost = node_queue.top().first, tpn_index = node_queue.top().second; node_queue.pop();
		for (auto i : edge[tpn_index]) {
			ll dst_index = i.first, dst_cost = i.second;
			if (tpn_cost + dst_cost < cost[dst_index]) {
				cost[dst_index] = tpn_cost + dst_cost;
				node_queue.push(make_pair(cost[dst_index], dst_index));
			}
		}
	}
	return;
}
signed main()
{
	ll n = in();
	vector<vector<pair<ll, ll>>>edge(n);
	REP(i, n - 1) {
		ll a = in() - 1, b = in() - 1, c = in();
		edge[a].push_back(make_pair(b, c));
		edge[b].push_back(make_pair(a, c));
	}
	ll q = in(), k = in() - 1;
	vector<ll>cost(n);
	dijkstra(edge, cost, k);
	REP(i, q) {
		ll x = in() - 1, y = in() - 1;
		cout << cost[x] + cost[y] << endl;
	}
}

Measured memory_bytes: 11120
#include<bits/stdc++.h>
#define int long long
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
using namespace std;

const int inf = 1e18;

const int N = 100;

int32_t main(){

    FAST;

    int dp[N] = {0};
    dp[0] = 2 , dp[1] = 1;

    for(int x=2;x<N;x++)
        dp[x] = dp[x-1] + dp[x-2];


    int n;  cin >> n;
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define MOD 1000000007
#define INT_MAX
#define ll long long

int main()
{
	ll a, b, x;
	cin >> a >> b >> x;
	
	ll res = 0;
	if (a == 0) {
		a++;
		res++;
	}
	res +=  b / x - (a - 1) / x;
	
	cout << res << endl;

	return (0);
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	vector<int>d(N);
	for (int i = 0; i < N; i++){
		cin >> d[i];
	}
	int sum = 0;
	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++) {
			sum += d[i] * d[j];
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque

H,W = map(int, input().split())
L = [input() for _ in range(H)]

dp = [[0]*W for _ in range(H)]
dp[0][0] = 1
used = [[0]*W for _ in range(H)]
q = deque()
q.append((0, 0))
while q:
    t = q.popleft()
    i = t[0]
    j = t[1]
    used[i][j] = 2
    if i != H-1 and L[i+1][j] == "." and used[i+1][j] < 2:
        dp[i+1][j] += dp[i][j]
        if used[i+1][j] == 0:
            q.append((i+1, j))
            used[i+1][j] = 1
    if j != W-1and L[i][j+1] == "." and used[i][j+1] < 2:
        dp[i][j+1] += dp[i][j]
        if used[i][j+1] == 0:
            q.append((i, j+1))
            used[i][j+1] = 1
        
print(dp[H-1][W-1]%(10**9+7))

Measured memory_bytes: 239092
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
p = 0
for i in range(n):
    j = n-1-i
    q = ls[j][1] - ((ls[j][0]+p)%ls[j][1])
    if q == ls[j][1]:
        q = 0
    p += q
print(p)

Measured memory_bytes: 27252
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}
int main(){
	ll n ,k;
	cin>>n>>k;
	ll a=0;
	while(k<=n+1)
	{
		a=(a+(n-k+1)*k+1)%mod;
		k++;
	}
	cout << a << endl;
	return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int R=n/r,G=n/g,B=n/b;
    int cnt=0;
    for(int i=0;i<=R;++i){
        for(int j=0;j<=G;++j){
            if((n-(r*i+g*j))%b==0&&n>=(r*i+g*j)){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}


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



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

Measured memory_bytes: 256
//srinivas
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
// using namespace __gnu_pbds;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(x=in;x<n;x+=r)
#define ifr(x,n) for(x=0;x<n;x++)
#define dfr(x,n) for(x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007

struct chash{ 
    ll operator()(ll x) const {return hash<ll>{}(x);}
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a>b)
    	swap(a,b);
    if(c>=a && c<=b)
    	cout<<"Yes\n";
    else
    	cout<<"No\n";
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	string s;
	cin >> s;
	int a = 0;
	int b = 0;
	rep(i, s.size()) {
		if (s[i] == '1') a++;
		if (s[i] == '0') b++;
	}
	cout << 2 * min(a, b) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_V = 410;

int main() {
    ll n, m, R;
    cin >> n >> m >> R;

    vl r(R);
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }

    vvl dist(MAX_V, vl(MAX_V));  // dist[v][u] : 頂点vと頂点uの最短距離
    rep(v, n) {
        rep(u, n) {
            if(v != u) {
                dist[v][u] = INF;
            }
        }
    }
    
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        if(dist[a][b] > c) {
            dist[a][b] = dist[b][a] = c;
        }
    }
    
    // ワーシャルフロイド法。計算量はO(V^3)
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    vl perm(R);
    rep(i, R) {
        perm[i] = i;
    }

    ll ans = INF;
    do {
        ll now = 0;
        rep(i, R-1) {
            now += dist[r[perm[i]]][r[perm[i+1]]];
        }
        chmin(ans, now);
    } while(next_permutation(all(perm)));
    
    out(ans);
    re0;
}

Measured memory_bytes: 1536
import numpy as np
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp=np.zeros(n,dtype="int32")

for i in range(1,n):
    start=0 if i<k else i-k
    dp[i]=np.min(dp[start:i]+np.abs(h[i]-h[start:i]))
print(dp[n-1])

Measured memory_bytes: 22832
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n;
    cin >> n;
    n = 1<<n;
    vector<int> a;
    multiset<int> st;
    rep(i, n) {
        int x;
        cin >> x;
        st.insert(x);
    }

    a.push_back(*prev(st.end()));
    auto itr = st.end();
    --itr;
    st.erase(itr);
    while(st.size()) {
        vector<int> b = a;
        for(auto x : a) {
            auto itr = st.lower_bound(x);
            if(itr==st.begin()) {
                cout << "No" << endl;
                return 0;
            }
            --itr;
            b.push_back(*itr);
            st.erase(itr);
        }
        b.swap(a);
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i) // ROF(i,n,0)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
constexpr ll inf = 1ll<<61;

signed main(){
  string s, t;
  cin >> s >> t;
  vvi table(s.size()*3,vi(26,inf));
  ROF(i,2*s.size(),0){
    table[i] = table[i+1];
    table[i][s[i%s.size()]-'a'] = i+1;
  }
  int ans = 0;
  int pos = 0;
  rep(i,t.size()){
    if(table[pos][t[i]-'a'] == inf){
      cout << -1 << endl;
      return 0;
    }
    ans += table[pos][t[i]-'a'] - pos;
    pos = table[pos][t[i]-'a'] % s.size();
  }
  cout << ans << endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<array<int, 3>> vt(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> vt[i][0] >> vt[i][1] >> vt[i][2];
  }

  for (int i = 0; i < vt.size(); ++i) {
    int cur = i, t = 0;
    while (cur < vt.size()) {
      // cur -> cur + 1
      int c, f, s;
      c = vt[cur][0];
      s = vt[cur][1];
      f = vt[cur][2];

      if (s >= t) {
        t = s;
      } else if (t % f != 0) {
        t = t + (f - t % f);
      }

      t += c;

      cur++;
    }

    cout << t << '\n';
  }

  cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int A, B, H, M;
long double res;

int main()
{
    //cin >> A >> B >> H >> M;

    //res = sqrt(((long double)A * A + B * B) - (long double)(2 * A * B * cos(abs((H * 30.0 + M * 0.5) - (M * 6.0)) * PI / 180.0)));
    //cout << fixed << setprecision(20) << res << endl;

    
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double ang_a = (30 * h) + (m / 2);
    double ang_b = 6 * m;

    double ang = abs(ang_a - ang_b);
    if (ang > 180)
    {
        ang = 360 - ang;
    }

    double rad = (ang / 180) * M_PI;

    double length = sqrt(a * a + b * b - 2 * a * b * cos(rad));

    cout << fixed << setprecision(12);
    cout << length << endl;
    return 0;
}

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

int main(){
    int k,n,kmax,sa,i,j;
    
    kmax=0;
    sa=0;
    cin >> k >> n ;
    int a[n+1];
    rep(i,n) cin >> a[i] ;
    kmax=k-a[n-1]+a[0];
    rep(j,n-1){
        //cout << a[j] << endl;
        //cout << a[j+1] << endl;
        //cout << a[2] << endl;
        sa=a[j+1]-a[j];
        
        kmax=max(sa,kmax);
    }
    cout << k-kmax << endl;

    
    

    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, ac = 0, wa = 0;
    cin >> n >> m;
    vector<int> vac(n+1), vwa(n+1);
    for (int i = 0; i < m; ++i) {
        int x;
        string s;
        cin >> x >> s;
        if (s == "AC") {
            if (vac[x] == 0) {
                vac[x] = 1;
                ac++;
                wa += vwa[x];
            }
        } else {
            vwa[x]++;
        }
    }
    cout << ac << ' ' << wa << '\n';
    return 0;
}


Measured memory_bytes: 1024
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   998244353
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(20)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int main()
{       io 
int testcases=1;       //    cin>>testcases;
while(testcases--)
{

ld a,b,h,m;

cin>>a>>b>>h>>m;

ld an=(a*a)+(b*b);



ld l=(2*PI*(h)/12.00);
ld r=(2*PI*m/60.00);
l+=((2*PI/12.0)*(m/60.00));
l=abs(l-r);


ld ad=2.00*a*b*((ld)cos(l));



an-=ad;
an=abs(an);
//cout<<an<<"\n";
an=(ld)sqrt(an);

coutd<<an;





}return 0;}

Measured memory_bytes: 4152
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(ALL(a));
    int ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if((a[i]+a[j])>a[k]&&a[i]!=a[j]&&a[j]!=a[k])ans++;
            }
        }
    }
    cout<<ans<<"\n";
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

string solve(int sx, int sy, int tx, int ty) {
	string res = "";
	int w = tx - sx;
	int h = ty - sy;
	rep(i,w) res += 'R';
	rep(i,h) res += 'U';
	rep(i,w) res += 'L';
	rep(i,h) res += 'D';
	res += 'D';
	rep(i,w+1) res += 'R';
	rep(i,h+1) res += 'U';
	res += 'L'; 	
	res += 'U';
	rep(i,w+1) res += 'L';
	rep(i,h+1) res += 'D';
	res += 'R';
	return res;
}

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	cout << solve(sx, sy, tx, ty) << endl;
}

Measured memory_bytes: 3604
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define MAX_N 100
#define MAX_LEN 100

const char *alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(int argc, const char *argv[]) {
	int n;
	int k[MAX_N];
	char s[MAX_LEN + 1];
	int i;

	while(scanf("%d", &n) == 1 && n) {
		for(i = 0; i < n; ++i) {
			scanf("%d", k + i);
		}

		scanf("%s", s);

		const int len = strlen(s);
		for(i = 0; i < len; ++i) {
			const int index = strchr(alpha, s[i]) - alpha;
			const int next_index = (index - k[i % n] + 52) % 52;
			s[i] = alpha[next_index];
		}

		printf("%s\n", s);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,M;
    cin >> N >> M;
    vector<pair<ll,ll>> c(0);
    for(int i = 0;i < N; i++){
        ll tmp;
        cin >> tmp;
        c.push_back(make_pair(tmp,1));
    }
    for(int i = 0; i < M; i++){
        ll B,C;
        cin >> B >> C;
        c.push_back(make_pair(C,B));
    }
    sort(c.begin(),c.end(),greater<pair<ll,ll>>());
    ll sum = 0;
    ll count = N;
    for(ll i = 0; i < c.size(); i++){
        if(N - c[i].second >= 0){
            sum += c[i].first * c[i].second;
            N -= c[i].second;
        }else{
            sum += c[i].first * N;
            N = 0;
        }
        if(N == 0){
            cout << sum << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=200+10;

    char mp[N][N];
    int val[N];bool vis[N];
    bool err;int n;
    queue<int> q;
    void bfs(int st)
    {
        while(q.size())q.pop();
        q.push(st);vis[st]=1;
        while(q.size())
        {
            int x=q.front();q.pop();
            fo(y,1,n) if(mp[x][y]=='1')
            {
                if(vis[y])
                {
                    if(abs(val[x]-val[y])%2==0) {err=1;break;}
                }
                else val[y]=val[x]+1,vis[y]=1,q.push(y);
            }
        }
    }
    void main()
    {
        n=qread();fo(i,1,n) scanf("%s",mp[i]+1);
        int mx=-1;
        fo(st,1,n)
        {
            memset(vis,0,sizeof vis);
            memset(val,0,sizeof val);
            err=0;bfs(st);
            if(!err) fo(i,1,n) chmax(mx,val[i]+1);
        }
        write(mx);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 384
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();
		int a = sc.nextInt();

		if (x < a) {
			pr.println(0);
		} else {
			pr.println(10);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int a,b,c,n;
    cin >> a >> b >> c;
    cin >> n;

    cout << pow(2,n) * max({a,b,c}) + a + b + c - max({a,b,c}) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  bool dig  = true;
  int digit = 1;
  int ans   = 0;
  for (int i = 1; i <= N; i++) {
	  if (dig) {
		  ans++;
		}
	  if (i == 10 * digit - 1) {
		  digit *= 10;
		  dig    = !dig;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384