akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int N,H;
	cin >> N >> H;
	vector<int> many(N);
	vector<int> only(N + 1);
	for(int i = 0;i < N;i++) {
		int A,B;
		cin >> A >> B;
		many.at(i) = A;
		only.at(i) = B;
	}
	only.at(N) = 0;
	int A = 0;
	int B = 0;
	int cnt = 0;
	int answer = 0;
	sort(many.begin(),many.end());
	reverse(many.begin(),many.end());
	sort(only.begin(),only.end());
	reverse(only.begin(),only.end());
	for(int i = 0;i < N * 2;i++) {
		if(many.at(A) >= only.at(B)) {
          	int fd = cnt;
			cnt += ((H - cnt + (many.at(A) - 1)) / many.at(A)) * many.at(A);
			answer += (H - fd + (many.at(A) - 1)) / many.at(A);
		}
		else {
			cnt += only.at(B);
			answer++;
			if(B == N - 1 || B == N) {
				B = N;
			}
          	else {
              	B++;
            }
		}
		if(cnt >= H) {
			break;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        double t = 0;
        double[] arr = new double[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextDouble();
            t += arr[i];
        }
        double rate = t / (4 * m);
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i] >= rate) {
                c++;
            }
        }
        System.out.println(c >= m ? "Yes" : "No");
    }
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int t = a-b;
	if(t>=c)
		cout<<0<<endl;
	else
		cout<<c-t<<endl;
	return 0;
} 

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    x:i64,}
    println!("{}", 8 - (x - 400) / 200);
}


Measured memory_bytes: 2164
data_pre=input().split()
data=[int(s) for s in data_pre]
A=data[0]
B=data[1]
H=data[2]
M=data[3]
import math
if math.fabs(H*30+M*0.5-M*6)<=180:
    theta=math.fabs(H*30+M*0.5-M*6)
else:
    theta=360-math.fabs(H*30+M*0.5-M*6)
cos=math.cos(math.radians(theta))
ans_2=A**2+B**2-2*A*B*cos
ans=ans_2**(1/2)
print(ans)

Measured memory_bytes: 9452
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

const ll N = 1e5;

ll n, W;
ll dp[N + 5];

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>W;
    for (int i = 1; i <= N; i++)
        dp[i] = W + 5;
    for (int i = 1; i <= n; i++){
        ll a, b;
        cin>>a>>b;
        for (int j = N; j >= b; j--)
            dp[j] = min (dp[j], dp[j - b] + a);
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++)
        if (dp[i] <= W)
            ans = i;
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int N;

	cin >> N;
	vector<pair<int, int>> xy( N );
	for( int i = 0; i < N; i++ ) {
		int x, y;
		cin >> x >> y;
		xy[i] = make_pair( x, y );
	}

	sort( xy.begin(), xy.end() );
	map<pair<int, int>, int> m;
	for( int i = 0; i < N - 1; i++ ) {
		for( int j = i + 1; j < N; j++ ) {
			int p = xy[j].first - xy[i].first;
			int q = xy[j].second - xy[i].second;
			m[make_pair( p, q ) ]++;
		}
	}
	int ma = 0;
	for( auto it = m.begin(); it != m.end(); it++ ) {
		if( it->second > ma ) {
			ma = it->second;
		}
	}
	int ans = N - ma;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int R; cin >> R;
    if (R < 1200) cout << "ABC" << endl;
    else if (1200 <= R && R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

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

double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}

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


///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++){
        cin >> a[i];
    }
    ll ans = 0;
    sort(a.begin(), a.end(), greater<int>());
    queue<int> q;
    for (int i = 0;i < n;i++){
        if (i == 0) {
            q.push(a[i]);
        } else {
            ans += q.front();
            q.pop();
            q.push(a[i]);
            q.push(a[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4752
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var x=Int64.Parse(Console.ReadLine());
        var waru = x / 11;
        var ans = waru*2;
        var amari = x - (waru*11);
        var count = 0L;
        if (amari != 0) count = amari <= 6 ? 1 : 2;
        Console.WriteLine(ans+count);
    }
}

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

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

   vector<int> A(N + 1), r(N + 1, 0);

   rep(i, 1, N + 1) cin >> A.at(i);

   rep(i, 1, N + 1) r.at(1) += A.at(i) * pow(-1, i % 2 + 1);

   rep(i, 2, N + 1) r.at(i) = 2 * A.at(i - 1) - r.at(i - 1);

   rep(i, 1, N) cout << r.at(i) << " ";
   cout << r.at(N) << endl;
 }


Measured memory_bytes: 2048
#ifndef ___Geometry_Library
#define ___Geometry_Library

// ------ Includes ------ //
#include <cmath>
#include <complex>
#include <utility>
#include <algorithm>

// ------ Defines ------ //
typedef long double GType;
typedef std::complex<GType> Point;
typedef std::pair<Point, Point> Segment;

// ------ Constants ------ //
const GType EPS = 1.0e-10L;

// ------ Functions Level 1 ------ //
GType dot(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).real();
}
GType cross(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).imag();
}
int ccw(const Point& p1, const Point& p2, const Point& p3) {
	Point v1 = p2 - p1, v2 = p3 - p1;
	if (cross(v1, v2) > EPS) return +1;
	if (cross(v1, v2) < -EPS) return -1;
	if (dot(v1, v2) < -EPS) return +2;
	if (std::norm(v1) < std::norm(v2)) return -2;
	return 0;
}

#endif

#include <iomanip>
#include <iostream>
using namespace std;
int q, xa, ya, xb, yb; Point p1, p2, p3;
int main() {
	cin >> xa >> ya >> xb >> yb;
	p1 = Point(xa, ya);
	p2 = Point(xb, yb);
	cin >> q;
	while (q--) {
		cin >> xa >> ya; p3 = Point(xa, ya);
		int res = ccw(p1, p2, p3);
		if(res == +1) cout << "COUNTER_CLOCKWISE" << endl;
		if(res == -1) cout << "CLOCKWISE" << endl;
		if(res == +2) cout << "ONLINE_BACK" << endl;
		if(res == -2) cout << "ONLINE_FRONT" << endl;
		if(res == +0) cout << "ON_SEGMENT" << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N, M;
    cin >> N >> M;
    vector<lint> parts[M];
    for(int i = 0; i < N; i++){
        lint A, B;
        cin >> A >> B;
        if(A <= M){
            parts[A - 1].push_back(B);
        }
    }
    lint ans = 0;
    priority_queue<lint> usable;
    for(int i = 0; i < M; i++){
        for(lint j: parts[i]){
            usable.push(j);
        }
        if(usable.size()){
            ans += usable.top();
            usable.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5632
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log,pi #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    R=I()
    print(pi*R*2)
if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int h, w;
  cin >> h >> w;
  V<string> s(h);
  REP(i, h) cin >> s[i];

  V<string> t;
  REP(i, h) {
    bool flag = true;
    REP(j, w) {
      if(s[i][j]=='#') flag = false;
    }
    if(!flag) t.PB(s[i]);
  }

  V<string> ans(t.size());
  REP(i, w) {
    bool flag = true;
    REP(j, t.size()) {
      if(t[j][i]=='#') flag = false;
    }
    if(!flag) {
      REP(j, t.size()) {
       ans[j].PB(t[j][i]);
      }
    }
  }

  for(auto i: ans) cout << i << endl;

  return 0;
}


Measured memory_bytes: 384
open Printf
open Scanf

module type Monoid = sig
    type t
    val append : t -> t -> t
    val default : t
end

module Segtree(M : Monoid) = struct
    type elt = M.t
    type t = Leaf of elt | Node of t * elt * t * int

    let value_of = function
        | Leaf x -> x
        | Node(_, x, _, _) -> x

    let size = function
        | Leaf _ -> 1
        | Node(_, _, _, n) -> n

    let rec range_query a b = function
        | Leaf x -> if a <= 0 && 1 <= b then x else M.default
        | Node(lch, x, rch, n) ->
                if a <= 0 && n <= b then x
                else if b <= 0 || n <= a then M.default
                else
                    let l_size = size lch in
                    M.append (range_query a b lch) (range_query (a - l_size) (b - l_size) rch)

    let rec updated k x = function
        | Leaf _ -> Leaf x
        | Node(lch, _, rch, n) ->
                if k < size lch then
                    let new_lch = updated k x lch in
                    Node(new_lch, M.append (value_of new_lch) (value_of rch), rch, n)
                else
                    let new_rch = updated (k - size lch) x rch in
                    Node(lch, M.append (value_of lch) (value_of new_rch), new_rch, n)

    let rec build n =
        if n <= 1 then Leaf M.default
        else Node(build (n / 2), M.default, build (n - n / 2), n)
end

module RMQ = Segtree(
    struct
        type t = int
        let append = min
        let default = int_of_float (2. ** 31.) - 1
    end)

let _ = scanf "%d %d\n" (fun n q ->
    let rec loop tree = function
        | 0 -> ()
        | i -> scanf "%d %d %d\n" (fun com x y ->
                if com = 0 then loop (RMQ.updated x y tree) (i - 1)
                else begin
                    printf "%d\n" (RMQ.range_query x (y + 1) tree);
                    loop tree (i - 1)
                end) in
    loop (RMQ.build n) q)

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

// ll fact[nax], invfact[nax];

// void pre()
// {
// 	fact[0] = 1;
// 	forn(i, 1, nax)
// 	{
// 		fact[i] = mult(fact[i - 1], i);
// 	}

// 	invfact[nax - 1] = mypow(fact[nax - 1], mod - 2);

// 	ford(i, nax, 1)
// 	{
// 		invfact[i - 1] = mult(invfact[i], i);
// 	}
// }

// ll ncr(ll n, ll r)
// {
// 	if (r > n)
// 		return 0;

// 	ll ans = mult(fact[n], mult(invfact[n - r], invfact[r]));

// 	return ans;
// }

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll a[3][3];

		forn(i,0,3)
		{
			forn(j,0,3)
			{
				cin>>a[i][j];
			}
		}

		ll n;
		cin>>n;

		ll b[n];
		bool mark[101];
		forn(i,0,101)
		mark[i]=0;
		forn(i,0,n)
		{
			cin>>b[i];
			mark[b[i]] = 1;
		}

		bool ok = 0;
		forn(i,0,3)
		{
			if(mark[a[i][0]] && mark[a[i][1]] && mark[a[i][2]])
			{
				ok = 1;
			}
		}

		forn(i,0,3)
		{
			if(mark[a[0][i]] && mark[a[1][i]] && mark[a[2][i]])
			{
				ok = 1;
			}
		}

		bool f = 1;
		forn(i,0,3)
		{
			f = f && mark[a[i][i]];
		}

		if(f)
		{
			ok = 1;
		}

		if(mark[a[0][2]] && mark[a[1][1]] && mark[a[2][0]])
		{
			ok = 1;
		}

		if(ok)
		{
			cout<<"Yes";
		}	
		else
		{
			cout<<"No";
		}
	}

	return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
w = tx - sx
h = ty - sy
ans = ""

# go first time
for i in range(h):
    ans += "U"

for i in range(w):
    ans += "R"

# back first time
for i in range(h):
    ans += "D"

for i in range(w):
    ans += "L"

# go second time
ans += "L"
for i in range(h + 1):
    ans += "U"

for i in range(w + 1):
    ans += "R"
ans += "D"

# back second time
ans += "R"
for i in range(h + 1):
    ans += "D"

for i in range(w + 1):
    ans += "L"
ans += "U"

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<bitset>
using namespace std;
const int MAXN=2005,MAXK=10005,MAXS=1000005;

int N,K;
char str[MAXN][MAXK];
int len[MAXN];
bitset<MAXK> dp[MAXN];
pair<int,int> ch[2][MAXK];
int cnt,ncnt;

int main()
{
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++)
	{
		scanf("%s",str[i]);
		len[i]=strlen(str[i]);
	}
	dp[N+1][0]=1;
	for(int i=N;i>0;i--)
		dp[i]=dp[i+1]|(dp[i+1]<<len[i]);
		
	for(int i=1;i<=N;i++)
		if(dp[i+1][K-len[i]])
			ch[0][cnt++]=(make_pair(i,0));
	
	for(int ii=1,i=1;ii<=K;ii++,i^=1)
	{
		ncnt=0;
		char minc='z';
		for(int j=0;j<cnt;j++)
			minc=min(minc,str[ch[i^1][j].first][ch[i^1][j].second]);
		putchar(minc);
		int minid=N+1;
		for(int j=0;j<cnt;j++)
		{
			int id=ch[i^1][j].first,pos=ch[i^1][j].second;
			if(str[id][pos]!=minc)
				continue;
			if(pos<len[id]-1)
				ch[i][ncnt++]=(make_pair(id,pos+1));
			else
				minid=min(minid,id);
		}
		for(int j=minid+1;j<=N;j++)
			if(K-ii-len[j]>=0&&dp[j+1][K-ii-len[j]])
				ch[i][ncnt++]=(make_pair(j,0));
		cnt=ncnt;
	}
	puts("");
	
	return 0;
}


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

int main() {
	long int N;
	cin >> N;
	long long int ans = 0;
	long long int a = 0;
	vector<long long int> vec (N);
	for(long int i = 0;i < N;i++){
		cin >> vec.at(i);
		vec.at(i) -= i + 1;
	}
	sort(vec.begin(),vec.end());
	a = vec.at(N/2);
	for(long int i = 0;i < N;i++){
		ans += abs(vec.at(i) - a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n + 1];
    memset(a, 0, sizeof(a));
    for(int i = 1; i <= n; i ++) cin >> a[i];
    int c[n + 1];
    memset(c, 0, sizeof(c));
    //int b[n]; //正解保存用
    //memset(b, 0, sizeof(b));
    priority_queue<int, vector<int>, greater<int>> G;
    for(int i = n; i >= 1; i --){
        int j = 2;
        int ans = 0;
        while(i * j <= n){
            ans += c[i * j];
            j ++;
        }
        if(ans % 2 != a[i]) {
            G.push(i);
            c[i] = 1;
        }
    }
    cout << G.size() << endl;
    while(!G.empty()){
        cout << G.top() << " ";
        G.pop();
    }
    cout << endl;

}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int x = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I') x++; else x--;
    if (x > ans) ans = x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($X,$K,$D) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$X = abs($X);

if (intdiv($X,$D)>$K) {
  $ans = $X-$D*$K;
}
else {
  $E = intdiv($X,$D);
  $K -= $E;
  $X -= $E*$D;
  if ($K%2 == 1) $X = abs($X-$D);
  $ans = $X;
}
printf("%d\n",$ans);



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

int main(){
  int n;
  cin >> n;
  if(n==1){
    cout << 1 << endl;
  }
  else if(n<4){
    cout << 2 << endl;
  }
  else if(n<8){
    cout << 4 << endl;
  }
  else if(n<16){
    cout << 8 << endl;
  }
  else if(n<32){
    cout << 16 << endl;
  }
  else if(n<64){
    cout << 32 << endl;
  }
  else{
    cout << 64 << endl;
  }
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

int solve(int n, const string& s) {
    int numr = 0;
    for (int i = 0; i < n; i++) {
        numr += (s[i] == 'R');
    }

    int ans = 0;
    for (int i = 0; i < numr; ++i) {
        ans += (s[i] == 'W');
    }
    return ans;
}

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

    // LAST: R...RW...W

    int n;
    cin >> n;

    string s;
    cin >> s;

    cout << solve(n, s) << newl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
ll sum(const vector<ll>& v) {
    ll res = 0;
    each(x, v) res += x;
    return res;
}
bool solve() {
    ll n; cin >> n;
    vector<ll> a(n), b(n); cin >> a >> b;
    ll sa = sum(a);
    ll sb = sum(b);
    ll T = sb - sa;
    if (T < 0) return false;
    ll ta = T, tb = T;
    auto A = [&](ll i, ll t) {
        ta -= t;
        a[i] += 2 * t;
    };
    auto B = [&](ll i, ll t) {
        tb -= t;
        b[i] += t;
    };
    rep(i, n) {
        if (abs(b[i] - a[i]) % 2 == 1) {
            B(i, 1);
        }
    }
    rep(i, n) {
        if (b[i] > a[i]) {
            A(i, (b[i] - a[i]) / 2);
        }
        else {
            B(i, a[i] - b[i]);
        }
    }
    // cout << ta << " " << tb << endl;
    assert(a == b);
    return ta >= 0 && tb >= 0;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (solve()) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#include<stdio.h>
buf[20000];char*p=buf;
i,j,w;
main(){
	read(0,buf,10200);
	while(*p>32)p+=1;
	for(p+=1;*p>10;p+=1)w=w*10+*p-48;w+=1;
	for(;i<w;i+=1)putchar_unlocked('#');
	for(;*p>0;p+=1){
		if(*p==10)putchar_unlocked('#'),putchar_unlocked(10),putchar_unlocked('#');
		else putchar_unlocked(*p);
	}
	for(;j<w;j+=1)putchar_unlocked('#');
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

int H, W;
ull ans;
priority_queue< ull, vector<ull>, greater<ull> > Qw, Qh;

void solve() {
	while (!Qw.empty() || !Qh.empty()) {
		if (Qw.empty()) {
			ull cur = Qh.top();
			Qh.pop();
			ans += cur;
		} else if (Qh.empty()) {
			ull cur = Qw.top();
			Qw.pop();
			ans += cur;
		} else if (Qw.top() > Qh.top()) {
			//cout << Qw.top() << "---" << Qh.top() << endl;
			ull cur = Qh.top();
			Qh.pop();
			ans += cur * (Qw.size() + 1);
		} else {
			//cout << Qw.top() << "---" << Qh.top() << endl;
			ull cur = Qw.top();
			Qw.pop();
			ans += cur * (Qh.size() + 1);
		}
		//cout << Qw.size() << " " << Qh.size() << endl;
	}
	cout << ans << endl;
}

int main() {
	cin >> W >> H;
	for (int i = 0; i < W; i++) {
		ull x;
		cin >> x;
		Qw.push(x);
	}
	for (int i = 0; i < H; i++) {
		ull x;
		cin >> x;
		Qh.push(x);
	}
	solve();
	return 0;
}




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

map<string,int> mp;
vector<string> nlst;

int getId(string s){
	if(mp.count(s))
		return mp[s];
	int id = mp.size();
	nlst.push_back(s);
	return mp[s] = id;
}

int readId(){
	string s;cin>>s;return getId(s);
}

int n;
vector<int> lst[321][321];

vector<int> src[1234],dst[1234];

bool done[1234];

bool reach[321][321];

int main(){
	int A=readId(),B=readId();

	cin>>n;

	rep(it,n){
		int m;cin>>m;

		rep(i,m){
			int u = readId(), v = readId();

			lst[u][v].push_back(it);

			src[it].push_back(u);
			dst[it].push_back(v);
		}
	}

	queue<int> que;

	que.push(A),que.push(B);
	reach[A][B] = 1;

	while(!que.empty()){
		int x = que.front();que.pop();
		int y = que.front();que.pop();
		//cout<<nlst[x]<<" "<<nlst[y]<<endl;

		rep(it,lst[x][y].size()){
			int id = lst[x][y][it];
			if(done[id])
				continue;
			done[id]=true;

			rep(t,src[id].size()){
				int u =src[id][t],v = dst[id][t];
				if(!reach[u][v]){
					reach[u][v]=1;
					que.push(u),que.push(v);
				}
			}
		}

		rep(xx,mp.size()) if(reach[xx][x] && !reach[xx][y]) {reach[xx][y] = 1;que.push(xx);que.push(y);}
		rep(yy,mp.size()) if(reach[y][yy] && !reach[x][yy]) {reach[x][yy] = 1;que.push(x);que.push(yy);}
	}

	bool ok = 1;
	rep(i,mp.size()) if(reach[i][i]) ok = 0;

	puts(ok?"Yes":"No");
}

Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll n1;
ll counta(ll x,ll n){
    ll res=0;
    string s0=to_string(x);
    ll n0=s0.length();
    ll l=atoi(s0.substr(0,1).c_str());
    ll r=atoi(s0.substr(n0-1,1).c_str());
    if(r==0)return 0;
    if(l==r){
        if(l<=n)++res;
        else return 0;
    }
    ll i=2,tmp=10;
    while(i<=n1){
        ll x1=r*tmp+l;
        //cout<<x1<<endl;
        ll x=x1+(tmp/10-1)*10;
        if(x<=n)res+=tmp/10;
        else{
            rep(0,j,tmp/10){
                if(x1+j*10<=n){
                    ++res;
                }
            }
        }
        tmp*=10;
        ++i;
    }
    return res;
}
int main(void){
    ll n;
    cin>>n;
    n1=to_string(n).length();
    ll ans=0;
    rep(0,i,n){
        //cout<<"i+1="<<i+1<<endl;
        //cout<<counta(i+1,n)<<endl;
        ans+=counta(i+1,n);
        
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
def bubbleSort( nums ):
	cnt = 0
	for i in range( 0, len( nums ) ):
		for j in range( len( nums )-1 , i, -1 ):
			if nums[j] < nums[ j-1 ]:
				nums[j], nums[ j-1 ] = nums[ j-1 ], nums[j]
				cnt += 1

	print( " ".join( map( str, nums) ) )
	print( cnt )


n = int( raw_input( ) )
nums = [ int( val ) for val in raw_input( ).split( " " ) ]
bubbleSort( nums )

Measured memory_bytes: 4228
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Feb 25 23:06:21 2018
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	acc := make([]int, N)
	for i := 0; i < N; i++ {
		var A int
		fmt.Scan(&A)
		arr[i] = A
		acc[i] = A
	}
	sort.Ints(arr)
	sort.Ints(acc)

	for i := 1; i < N; i++ {
		acc[i] += acc[i-1]
	}

	count := -1
	for i := 0; i < N; i++ {
		if i+1 < N && 2*acc[i] < arr[i+1] {
			count = i
		}
	}

	fmt.Println(N - (count + 1))
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define F first
#define S second
#define INF (1<<30)
#define LINF (1LL<<60)
using namespace std;
typedef pair<long long,long long> P;
long long a,b,c,d;
string s,s2,s3;
long long  sum=0,ans=0,pos=0;
long long n,m,h,w;
main(){
  cin>>a;
  b=a/11;
  b*=2;
  if(a%11!=0){
    if(a%11<=6) b++;
    else b+=2;
  }
  
  cout<<b<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int swapDown(int c) {
    int result=c;
    if(isupper(c)){
        result+=32;
    }
    return result;
}

int main(){
    char W[10]={0},T[1000]={0},end[]="END_OF_TEXT";
    int i,cnt=0;
    scanf("%s", W);
    for(i=0;i<10;i++)W[i]=swapDown(W[i]);
    while(1){
        scanf("%s", T);
        if(strcmp(T,end)==0)break;
        for(i=0;i<1000;i++){
            T[i]=swapDown(T[i]);
        }
        if(strcmp(T,W)==0){
            cnt++;
        }
        for(i=0;i<1000;i++){
            T[i]=0;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1760
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
//typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int N = 120010;
const long long MOD = 998244353;
const int INF = 1e9;

int n, k;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> k >> n;
    if (k % 2 == 0)
    {
        cout << k / 2 << " ";
        for (int i = 0; i < n - 1; i++) cout << k << " ";
        return 0;
    }

    {
        vector<int> kek;
        for (int i = 0; i < n; i++) kek.push_back(k / 2 + 1);
        int it = n / 2;
        while (it--)
        {
            if (kek.back() == 1)
                kek.pop_back();
            else
            {
                kek[kek.size() - 1]--;
                while (kek.size() < n) kek.push_back(k);
            }
        }
        for (auto it : kek) cout << it << " ";
        return 0;
    }
    return 1;
}


Measured memory_bytes: 3568
h, w = list(map(int, input().split()))
a = [input() for i in range(h)]
x_ = [-1, -1, -1, 0, 0, 1, 1, 1]
y_ = [-1, 0, 1, -1, 1, -1, 0, 1]
result = [['0' for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    count = 0
    if a[i][j] == '#':
      result[i][j] = '#'
      continue
    for k in range(8):
      x = i+x_[k]
      y = j+y_[k]
      if x<0 or y<0 or x>=h or y>=w:
        continue
      elif a[x][y] == '#':
        count += 1
    result[i][j] = str(count)
for i in result:
  print(''.join(i))
      
      


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//最大公約数
template <class T>
T gcd(T a, T b) {

    if(b == 0){
        return a;
    }
    else{
        gcd(b, a%b);
    }
}

//最小公倍数
template <class T>
T lcm(T a, T b){

    T g = gcd(a, b);

    return a / g * b;
}

int main() {

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }

    ll ans = 0;
    rep(i, n){
        ans += a[i] - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
//using System.Text;
//using System.Linq;
class Program
{
    static void Main()
    {
        while (true)
        {
            string r = Console.ReadLine();
            if (r == null) break;
            double[] a = new double[6];
            for (int i = 0; i < 6; i++) a[i] = double.Parse(r.Split(' ')[i]);
            double x = (a[2] * a[3] - a[0] * a[5]) / (a[1] * a[3] - a[0] * a[4]);
            Console.WriteLine(String.Format("{0:f3} {1:f3}", (a[2] - a[1] * x) / a[0], x));
        }
    }
}

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

int GetCombinationCount(int n)
{
	int Count = 0;
	for(int a = 0; a < 10; a++){
		for(int b = 0; b < 10; b++){
			for(int c = 0; c < 10; c++){
				for(int d = 0; d < 10; d++){
					if(a + b + c + d == n) Count++;
				}
			}
		}
	}
	return Count;
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(cin.eof() == true) break;
		cout << GetCombinationCount(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if s == strings.Repeat("A", len(s)) || s == strings.Repeat("B", len(s)) {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<numeric>
#include<cmath>

int main(){
    
    size_t n;
    size_t min = 0;
    
    std::cin >> n;

    std::vector<size_t> w(n);

    for(auto&& e : w){
        std::cin >> e;
    }

    for(size_t i = 0; i < w.size(); i++){
        auto s1 = std::accumulate(w.begin(), w.begin() + i, 0);
        auto s2 = std::accumulate(w.begin() + i, w.end(), 0);

        if(i == 0){
            min = std::abs(s2 - s1);
        }else if(min > static_cast<size_t>(std::abs(s2 - s1))){
            min = std::abs(s2 - s1);
        }
    }

    std::cout << min << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
typedef long long ll;
ll lparen=0;
ll rparen=0;

int main(){ _;
  int q,p,n;
  char c;
  cin>>q;
  REP(i,q){
    cin>>p>>c>>n;
    if(c=='(')lparen+=n;
    else rparen+=n;
    cout<<(lparen==rparen?"Yes":"No")<<endl;
  }
}

Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>

using ll = long long;

using namespace std;

long long x = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

int main() {
	int n;
	cin >> n;
	vector<string>s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	map<string, int> p;
	int max = 0;
	int tmp = 0;
	for (int i = 0; i < n; i++) {
		p[s[i]]++;
		if (p[s[i]] > max)max = p[s[i]];
	}
	for (auto it = p.begin(); it != p.end();it++) {
		pair<string, int>x = *it;
		if (x.second == max) {
			cout << x.first << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 26752
import java.io.*;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
 
    try {
      Scanner scan   = new Scanner(System.in);      
      Long    tax1   = Long.parseLong(scan.next());
      Long    tax2   = Long.parseLong(scan.next());
      double  price1 = tax1/0.08;
      double  price2 = tax2/0.1;
      double  result = -1.0;
      
      if (price1 >= price2 && Math.ceil(price1) < (tax2+1)/0.1) {
        result = Math.ceil(price1);
      }
      
      if (price2 >= price1 && Math.ceil(price2) < (tax1+1)/0.08) {
        result = Math.ceil(price2);
      }
      
      System.out.println((int)result);
      
    } catch (Exception e) {     
      System.out.print("error");
    }
  }
}


Measured memory_bytes: 35656
#include<stdio.h>
#include<stdlib.h>
#include<stdarg.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define reps(i,n,k) for((i)=0;(i)<(n);(i)+=(k))
#define MOD ((int)1e9+7)
#define INF INFINITY
typedef long long ll;
typedef unsigned long long ull;
typedef struct pair_{int x,y;}pair_t;
void swap(int *x, int *y){int t=*x;*x=*y;*y=t;}
void debug(char *f, ...){va_list a;va_start(a,f);vfprintf(stderr,f,a);va_end(a);}
int asc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return -1;else if(X>Y)return 1;else return 0;}
int desc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return 1;else if(X>Y)return -1;else return 0;}

int main(){
    int s,w;scanf("%d %d",&s,&w);
    if(s<=w)printf("unsafe\n");
    else printf("safe\n");

}


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

#define SIZE 100005
typedef long long int ll;
typedef pair <int,int> P;

vector<int> vec[SIZE];
int deg[SIZE];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n - 1; i++)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        vec[x].push_back(y);
        vec[y].push_back(x);
        deg[x]++;
        deg[y]++;
    }
    int mx = 0;
    for(int i = 0; i < n; i++) mx = max(mx, deg[i]);
    if(mx <=  2)
    {
        printf("1");
        return 0;
    }
    queue<int> que;
    for(int i = 0; i < n; i++)
    {
        if(deg[i] == 1)
        {
            que.push(i);
        }
    }
    while(!que.empty())
    {
        int v = que.front();
        que.pop();
        int to = 0;
        for(int i = 0; i < vec[v].size(); i++)
        {
            to = vec[v][i];
            if(deg[to] != 1) break;
        }
        if(deg[to]==2)
        {
            deg[to] = 1;
            que.push(to);
        }
    }
    int ret = 0;
    for(int i = 0; i < n; i++)
    {
        if(deg[i] == 1)continue;
        int nm = 0;
        for(int j = 0; j < vec[i].size(); j++)
        {
            int to = vec[i][j];
            if(deg[to]==1)nm++;
        }
        ret += max(0, nm - 1);
    }
    printf("%d\n", ret);
	return 0;
}


Measured memory_bytes: 7040
fun main(arr: Array<String>) {
    val (n,x) = readLine()!!.split(" ").map { it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }
    val map = mutableListOf(0)
    l.forEach { map.add(map.last() + it) }
    println(map.count{ it <= x })
}


Measured memory_bytes: 36444
def rec(n, u, k, s):
    if k == 1:
        if u < s <= n:
            return 1
        else:
            return 0

    ret = 0
    for i in range(u + 1, n - k + 2):
        ret += rec(n, i, k - 1, s - i)

    return ret

while True:
    n, k, s = map(int, input().split())
    if n == k == s == 0:
        break

    print(rec(n, 0, k, s))


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K, S; cin >> K >> S;
    int ans = 0;
    for(int X = 0; X <= K; X++){
        for(int Y = 0; Y <= K; Y++){
            int Z = S - X - Y;
            if(0 <= Z && Z <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <vector>
using namespace std;
#define i64 int64_t
i64 calixorsum(i64 x)
{
  if (x % 2 != 0)
  {
    if (((x + 1) / 2) % 2 == 0)
    {
      return 0ll;
    }
    else
      return 1ll;
  }
  else
  {
    if (x % 4 == 0)
      return x;
    else
      return x + 1;
  }
}
void d()
{
  i64 a, b;
  cin >> a >> b;
  if (a == b)
  {
    cout << a;
    return;
  }
  /*for (i64 i = a; i <= b; i++)
  {
    for (int j = 0; j < 64; j++)
    {
      if (i & (1ll << j))
      {
        count[j]++;
      }
    }
  }*/
  i64 sum_a_1, sum_b;
  sum_a_1 = calixorsum(a - 1ll);
  sum_b = calixorsum(b);
  cout << (sum_b ^ sum_a_1);
  /*for (int i = 0; i < 64; i++)
  {
    if (count[i] % 2 != 0)
    {
      sum += (1ll << i);
    }
  }*/
  /*for (int i = 0; i < 64; i++)
  {
    if ((1ll << i) > b)
      break;
    i64 osci = (b - a + 1) % (1ll << (i + 1));
    i64 even = (b - a + 1) % 2;
    i64 count = (1ll << (i + 1)) - (a % (1ll << (i + 1)));
    if ((even + count) % 2 != 0 && (a & (1ll << i)) != 0 && b & (1ll << i) == 0)
    {
      sum += (1ll << i);
    }
    else if ((even + count) % 2 != 0 && (a & (1ll << i)) == 0 && (b & (1ll << i)) != 0)
    {
      sum += (1ll << i);
    }
    else if ((even == 0 && count % 2 != 0 && (a & (1ll << i)) != 0 && (b & (1ll << i)) == 0))
    {
      sum += (1ll << i);
    }
    else if ((even != 0 && count % 2 == 0 && (a & (1ll << i)) == 0 && (b & (1ll << i)) == 0))
    {
      sum += (1ll << i);
    }
  }*/
  return;
}
void c()
{
  i64 n, m;
  cin >> n >> m;
  map<i64, i64> ab;
  for (int i = 0; i < n; i++)
  {
    i64 a, b;
    cin >> a >> b;
    auto itr = ab.find(a);
    if (itr == ab.end())
    {
      ab[a] = b;
    }
    else
      ab[a] += b;
  }
  i64 sum_x = 0;
  i64 sum_y = 0;
  for (auto itr = ab.begin(); itr != ab.end(); itr++)
  {
    //cout << itr->first << " " << itr->second << endl;
    if (m - sum_x - itr->second > 0)
    {
      sum_x += itr->second;
      sum_y += itr->second * itr->first;
    }
    else
    {
      sum_y += (m - sum_x) * itr->first;
      sum_x += m - sum_x;
    }
    if (sum_x == m)
      break;
  }
  cout << sum_y;
}
void b()
{
  int n, m, c;
  cin >> n >> m >> c;
  int b[m], a[n][m];
  for (int i = 0; i < m; i++)
    cin >> b[i];
  for (int j = 0; j < n; j++)
  {
    for (int i = 0; i < m; i++)
      cin >> a[j][i];
  }
  int count = 0;
  for (int j = 0; j < n; j++)
  {
    int sum = c;
    for (int i = 0; i < m; i++)
      sum += a[j][i] * b[i];
    if (sum > 0)
      count++;
  }
  cout << count;
}
void a()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << H * W - (h * W + H * w - h * w);
}
int main(void)
{
  //a();
  //b();
  //c();
  d();
  return 0;
}


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

int main(){
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < D; j++){
			cin >>X.at(i).at(j);
		}
	}
	int cnt = 0;
	
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			int a = 0;
			int dis = 0;
			while(a < D){
				dis += (X.at(i).at(a) - X.at(j).at(a)) * (X.at(i).at(a) - X.at(j).at(a));
				a++;
			}
			double ans = sqrt(dis);
			double check = floor(ans);
			if(ans == check) cnt++;
		}
	}
	
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int x, y, W, H, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if ((x + r <= W && x - r >= 0) && (y + r <= H && y - r >= 0))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int n; cin >> n;
	vector<int> v(n), w(n);
	for(int i=0; i<n; i++) cin >> v[i] >> w[i];
	int q; cin >> q;
	vector<int> u(q), l(q);
	for(int i=0; i<q; i++) cin >> u[i] >> l[i];

	vector<vector<pair<int, int>>> xs;

	const int H = 11;
	xs.push_back(vector<pair<int, int>>{{0, 0}, {w[0], v[0]}});
	for(int i=1; i<min(n, 1<<H); i++){
		vector<pair<int, int>> x(xs[(i-1)/2]);
		int m = x.size();
		for(int j=0; j<m; j++){
			x.push_back({x[j].first+w[i], x[j].second+v[i]});
		}
		sort(x.begin(), x.end());
		for(int j=1; j<x.size(); j++){
			x[j].second = max(x[j].second, x[j-1].second);
		}

		xs.push_back(x);
	}

	for(int i=0; i<q; i++){
		u[i]--;
		if(u[i]<(1<<H)){
			int ans = 0;
			int k = lower_bound(xs[u[i]].begin(), xs[u[i]].end(), pair<int, int>{l[i]+1, 0})-xs[u[i]].begin();
			if(k>0) ans = xs[u[i]][k-1].second;
			cout << ans << endl;
			continue;
		}

		vector<pair<int, int>> y(1, {0, 0});
		int t = u[i];
		while(t>=(1<<H)){
			int m = y.size();
			for(int j=0; j<m; j++){
				y.push_back({y[j].first+w[t], y[j].second+v[t]});
			}
			t = (t-1)/2;
		}

		int ans = 0;
		for(auto p: y){
			int k = lower_bound(xs[t].begin(), xs[t].end(), pair<int, int>{l[i]-p.first+1, 0}) - xs[t].begin();
			if(k==0) continue;
			ans = max(ans, p.second+xs[t][k-1].second);
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 28064