akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
using namespace std;
 int main(){ 
int a,W,b;
cin>>W>>a>>b;
if((a>=0)&&(W>=0)&&(b>=0)){
if(b>(a+W)){
cout<<b-(a+W);
}
else if((b+W)<a)
{
cout<<a-(b+W);
}
else
{
cout<<"0";
}
}}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, k ] <- readInts
	ps :: [ Double ] <- map fromIntegral <$> readInts
	let
		ps' = map ( ( / 2 ) . succ ) ps
		( as, bs ) = ( take k &&& drop k ) ps'
		s = sum as
-- 	printf "%.10f\n" $ maximum $ slide s as bs
	printf "%.10f\n" $ slide s ps' bs

slide s _ [] = s
slide s (a:as) (b:bs) = max s $ slide s' as bs
	where
		s' = s - a + b

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	int k, x; cin >> k >> x;
	if (k*500 >= x) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}


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

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

  int N, h; cin >> N >> h;
  vector<int> a(N), b(N);
  for (int i = 0; i < N; i++) cin >> a[i] >> b[i];

  int moa = 0;
  for (int i = 0; i < N; i++) moa = max(moa, a[i]);
  sort(b.begin(), b.end(), greater<int>());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (b[i] < moa) break;
    h -= b[i];
    ans++;
    if (h <= 0) {
      cout << ans << "\n";
      return 0;
    }
  }
  ans += (h + moa - 1) / moa;
  cout << ans << "\n";
}

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

int main() {
    // input
    int N;
    cin >> N;
    set<int> d;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        d.insert(a);
    }

    // solve & output
    cout << d.size() << endl;

    return 0;
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

const int MAX = 1000001;

// updating the bit array
void update(int idx, int val, int bit[], int n) {
    for (; idx <= n; idx += idx & -idx) {
        bit[idx] += val;
    }
}

int query(int idx, int bit[], int n) {
    int sum = 0;
    for (; idx > 0; idx -= idx & -idx)
        sum += bit[idx];
    return sum;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int N, Q;
    string S;
    cin >> N >> S >> Q;

    int bit[30][N + 1];
    rep(i, 30) rep(j, N + 1) bit[i][j] = 0;
    rep(i, N) {
        update(i + 1, 1, bit[S[i] - 'a'], N);
    }

    while (Q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            update(i + 1, -1, bit[S[i] - 'a'], N);
            S[i] = c;
            update(i + 1, 1, bit[S[i] - 'a'], N);
        } else {
            int l, r;
            cin >> l >> r;
            l--, r--;
            int ans = 0;
            rep(i, 26) {
                char c = 'a' + i;
                if (query(r + 1, bit[i], N) - query(l, bit[i], N) > 0) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 118172
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    string s, s1, s2="";
    cin>>s>>s1;
    for(i=0; i+1<s1.size(); i++) s2+=s1[i];

    if(s==s2) cout<<"Yes\n";
    else cout<<"No\n";

  //  main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define pqll priority_queue<ll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX


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

	int n;
	cin>>n;
	string s[n];
	map<string,int> ma;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		ma[s[i]]++;
	}
	cout<<"AC x "<<ma["AC"]<<'\n';
	cout<<"WA x "<<ma["WA"]<<'\n';
	cout<<"TLE x "<<ma["TLE"]<<'\n';
	cout<<"RE x "<<ma["RE"];
	return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
//Lはn,mの公倍数
//L-L/N+1まで見る
lint gcd(lint a, lint b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

lint lcm(lint a, lint b)
{
    return (a / gcd(a, b)) * b;
}

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

    lint l = lcm(n, m);
    lint ans=l;
    string s;
    cin >> s;
    string t;
    cin >> t;
    //vector<char> c(l);
    map<lint, char> c;

    REP(i,n){
        lint x = i * (l / n) + 1;
        c[x] = s[i];
    }
    REP(i, m)
    {
        lint x = i * (l / m) + 1;
        if (c.count(x)&& c[x] != t[i]){
            ans = -1;
            break;
        }
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, ans, cnt, w, s[5];
string a;
int main()
{
	ll i;
	cin >> a;
	s[0] = 1;
	for (i = 0; i < a.size(); i++) {
		if (a[i] == '?') {
			s[3] = (s[2] + s[3] * 3) % M;
			s[2] = (s[1] + s[2] * 3) % M;
			s[1] = (s[0] + s[1] * 3) % M;
			s[0] = (s[0] * 3) % M;
		} else if (a[i] == 'A') {
			s[1] = (s[1] + s[0]) % M;
		} else if(a[i] == 'B') {
			s[2] = (s[2] + s[1]) % M;
		} else {
			s[3] = (s[3] + s[2]) % M;
		}
	}
	cout << s[3];
    return 0;
}


Measured memory_bytes: 512
class PriorityQueue
  attr_reader :elements

  def initialize(array = nil)
    @elements = [nil]
    if array
      array.each{|e| push(e)}
    end
  end

  def push(element)
    @elements << element
    bubble_up(@elements.size - 1)
  end
  alias << push

  def pop
    exchange(1, @elements.size - 1)
    max = @elements.pop
    bubble_down(1)
    max
  end

  private

  def bubble_up(idx)
    parent_idx = idx / 2

    return if idx <= 1
    return if @elements[parent_idx] >= @elements[idx]

    exchange(idx, parent_idx)
    bubble_up(parent_idx)
  end

  def bubble_down(idx)
    child_idx = (idx * 2)

    return if child_idx > @elements.size - 1

    not_the_last_element = child_idx < @elements.size - 1
    left_element = @elements[child_idx]
    right_element = @elements[child_idx + 1]
    child_idx += 1 if not_the_last_element && right_element > left_element

    return if @elements[idx] >= @elements[child_idx]

    exchange(idx, child_idx)
    bubble_down(child_idx)
  end

  def exchange(source, target)
    @elements[source], @elements[target] = @elements[target], @elements[source]
  end
end

#n = gets.chomp.to_i
n, m = gets.chomp.split().map(&:to_i)
hash = {}
n.times do
  a, b = gets.split.map(&:to_i)
  hash[a] ||= []
  hash[a].push b if a <= m
end
#p hash

pq = PriorityQueue.new
ans = 0
1.upto(m).each do |i|
  hash[i].each{|e| pq.push e} if hash.has_key?(i)
  max = pq.pop
  #p [i,max]
  ans += max unless max.nil?
end

puts ans


Measured memory_bytes: 15100
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
//int max(int a, int b) {if(b>a) return b; else return a;}
//int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;


signed main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    cout << fixed << setprecision(12);
    double pi = 3.1415926535897932;

    double arg = abs((H*30.0+(M/2.0) - M*6.0));
    arg = min(arg, 360.0-arg);
    double C = A*A+B*B-2.0*A*B*cos(pi*(arg/180.0));

    cout << sqrt(C) << endl;


    return 0;
}

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

using namespace std;

int main() {
    string A, B;
    cin >> A >> B;

    if (A.length() > B.length()) {
        cout << "GREATER" << endl;
        return 0;
    } else if (A.length() < B.length()) {
        cout << "LESS" << endl;
        return 0;
    }

    for (int i = 0; i < A.length(); i++) {
        if (A[i] > B[i]) {
            cout << "GREATER" << endl;
            return 0;
        } else if (A[i] < B[i]) {
            cout << "LESS" << endl;
            return 0;
        }
    }

    cout << "EQUAL" << endl;
    return 0;
}


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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
#define VN(v) # v
#define print(a) cout << a << "#" << VN(a) << endl;

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    rep(i, n) {
        set<string> memo;
        string s; cin >> s;
        rep(i, s.length()-1) {
            string x = s.substr(0, i+1);
            string xr = x; reverse(all(xr));
            string y = s.substr(i+1, s.length()-i-1);
            string yr = y; reverse(all(yr));
            memo.insert(x + y); memo.insert(xr + y); memo.insert(x + yr); memo.insert(xr + yr);
            memo.insert(y + x); memo.insert(yr + x); memo.insert(y + xr); memo.insert(yr + xr);
        }
        cout << memo.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3160
if __name__=="__main__":
    n = int(input())
    args = input().split()
    p = []
    for i in range(len(args)):
        p.append(int(args[i]))

    cnt = 1
    p_pre = [p[0]]
    min_p_pre = p[0]
    for i in range(1,len(args)):
        p_pre.append(p[i])
        min_p_pre = min(min_p_pre, p[i])
        if p[i] == min_p_pre:
            cnt += 1

    print(cnt)

Measured memory_bytes: 27304
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S,T;
    cin >> S >> T;
    ll s = S.size();
    ll cnt  = 0;
    rep(i,s){
        if(S[i] != T[i])cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3800
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();
			int c = sc.nextInt();	
			int[] b = new int[m];
			
			for(int i=0;i<m;i++) {
				b[i] = sc.nextInt();
			}
			
			int ret = 0;
			
			for(int i=0;i<n;i++) {
				int x = 0;
				for(int j=0;j<m;j++) {
					x += b[j]*sc.nextInt();
				}
				
				if((x+c)>0) {
					ret++;
				}
			}
			
			System.out.println(ret);
			
		}
	}


Measured memory_bytes: 36532
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int sx=read(),sy=read(),tx=read()-sx,ty=read()-sy;
int main(){
cout<<string(ty,'U')<<string(tx,'R');
cout<<string(ty,'D')<<string(tx,'L');
cout<<"L"<<string(ty+1,'U')<<string(tx+1,'R')<<"D";
cout<<"R"<<string(ty+1,'D')<<string(tx+1,'L')<<"U";
}

Measured memory_bytes: 256
input = gets
k,a,b = input.split.map { |e| e.to_i }

biscuit = 1

if k > a && b - a > 2 && a < b
  addbis = b - a;
  biscuit = ((k + 1 - a) / 2 ) * addbis
  biscuit += (k + 1 - a) % 2 + a
end

if biscuit > k + 1
  puts biscuit
else
  puts k + 1
end


Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>

int main()
{
    while(1)
    {
         
        int i,n=0;
    char x[1000];
         
        scanf("%s",&x);
        if(x[0]=='0')
         break;
         
         else 
         {
             for(i=0;i<strlen(x);i++){
                 n+=x[i]-'0';
             }
             printf("%d\n",n);
         }
     }
    
   return 0; 
    
    
    
}


Measured memory_bytes: 2112
from sys import stdin

n,x = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

point = 0
for i in range(n-1):
    if li[i]+li[i+1] > x:
        total = li[i]+li[i+1]-x
        if total > li[i+1]:
            point += li[i+1]
            total = total-li[i+1]
            if total > li[i]:
                point += li[i]
                li[i] = 0
                li[i+1] = 0
            else:
                point += total
                li[i] -= total
                li[i+1] = 0
        else:
            point += total
            li[i+1] -= total

print(point)

Measured memory_bytes: 14812
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPll(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007 //1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
//////////////////////////////////////////
int main()
{
  
  int h, w;cin >> h >> w;
  vec2int c(10, vecint(10, 0));
  REP(i,10)REP(j,10) cin >> c[i][j];
  vecint num(10,0);
  REP(i,h){
    REP(j,w){
    int tmp;cin >> tmp;
    if(tmp == -1)continue;
    num[tmp] ++;
    } 
  }  
  int cmax = 1e9;
  vecint cost(10, cmax);
  REP(i,10)  cost[i] = c[i][1];
  queue<int > q;
  REP(i,10){
    q.push(i);
  }
  while(!q.empty()){
    int x = q.front();q.pop();
    REP(y,10){
      if(x == y )continue;
      if(cost[y] > c[y][x] + cost[x] ){
        cost[y] = c[y][x] + cost[x];
        q.push(y);
      }
    }    
  }
  //REP(i,10){
  //    cout << cost[i] << endl;
  //  }
  int ans = 0;
  REP(i,10){
    ans += cost[i]*num[i];
  }
  cout << ans << endl;
}


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

from collections import *
S = input()

seen = set()
dq = deque()

ok = False
seen.add(0)
while len(seen) > 0:
    pos = sorted(list(seen))[0]
    seen.remove(pos)
    if pos == len(S):
        ok = True
        break

    part = S[pos:]
    if part.startswith('dream'):
        seen.add(pos + 5)
    if part.startswith('dreamer'):
        seen.add(pos + 7)
    if part.startswith('erase'):
        seen.add(pos + 5)
    if part.startswith('eraser'):
        seen.add(pos + 6)
if ok:
    print('YES')
else:
    print('NO')

    
    
        
        


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

#define pb push_back
#define mp make_pair
#define ll long long int
#define all(x) x.begin(), x.end()

unordered_set<int> seen;

void dfs(int start, vector<vector<int>> & graph) {
    if(seen.find(start) != seen.end()) {
        return;
    } 

    seen.insert(start);
    for(auto child: graph[start]) dfs(child, graph);
}

void solve() {

    int n, m;
    cin >> n >> m;

    vector<vector<int>> graph(n);

    for (size_t i = 0; i < m; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    int cc = 0;
    for (size_t i = 0; i < n; i++)
    {
        if(seen.find(i) == seen.end()) {
            dfs(i, graph);
            cc += 1;
        }
    }
    
    cout << cc << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);

    solve();
    return 0;
}

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

class Program
{
    static void Main()
    {
        var Nx = Console.ReadLine().Split(' ').Select(n=>Int64.Parse(n)).ToArray();
        var N = Nx[0];
        var x = Nx[1];
        var a = Console.ReadLine().Split(' ').Select(n => Int64.Parse(n)).ToArray();
        var count = 0L;
        for (int i=0;i<a.Length;++i)
        {
            if (x < a[i])
            {
                count += a[i] - x;
                a[i] = x;
            }
            if (i != 0)
            {
                if(x < a[i - 1] + a[i])
                {
                    var c = a[i - 1] + a[i] - x;
                    count += c;
                    a[i] -= c;
                }
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 33500
#include <iostream>
#include <cmath>

int main()
{
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり

N = I()
xy = [LS() for _ in range(N)]

ans = 0
for i in range(N):
    x,y = xy[i]
    x = float(x)
    if y == 'JPY':
        ans += x
    else:
        ans += 380000*x

print(ans)

Measured memory_bytes: 61896
#include<bits/stdc++.h>
using namespace std;
int n;
map<int,int> mp;
int path[110],pl,flag;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		mp[x]++;
	}
	for(map<int,int>::iterator it = mp.begin(); it != mp.end(); it++)
	{
		if(pl == 0)
		{
			if(it -> second <= 2)
			{
				path[++pl] = it -> first;
				if(it -> second == 1) flag = 1;
			}
			else
			{
				cout << "Impossible" << endl;
				return 0;
			}
		}
		else
		{
			if(it -> second < 2)
			{
				cout << "Impossible" << endl;
				return 0;
			}
			if(it -> first != path[pl] + 1)
			{
				cout << "Impossible" << endl;
				return 0;
			}
			path[++pl] = it -> first;
		}
	}
	if(flag && pl != path[1] + 1)
	{
		cout << "Impossible" << endl;
		return 0;
	}
	if(!flag && pl != path[1])
	{
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

    string s;
    cin >> s;
    int day = 0;
    if(s == "SUN"){
        day = 7;
    }else if(s == "MON"){
        day = 6;
    }else if(s == "TUE"){
        day = 5;
    }else if(s == "WED"){
        day = 4;
    }else if(s == "THU"){
        day = 3;
    }else if(s == "FRI"){
        day = 2;
    }else if(s == "SAT"){
        day = 1;
    }
    cout << day << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  switch(n){
    case 22:
      printf("Christmas Eve Eve Eve\n");
      break;
    case 23:
      printf("Christmas Eve Eve\n");
      break;
    case 24:
      printf("Christmas Eve\n");
      break;
    case 25:
      printf("Christmas\n");
      break;
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

int main() {
	string S,T;
	std::cin >> S;
	ll N = S.length();
	ll H = N / 2;

	bool flg = true;
	rep(i, 0, N / 2) {
		if (S[i] != S[N - 1 - i]) {
			flg = false;
		}
	}

	rep(i, 0, H / 2) {
		if (S[i] != S[H - 1 - i]) {
			flg = false;
		}
	}

	if (flg) {
		std::cout << "Yes" << endl;
	}
	else {
		std::cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

long long ans;
void dfs(char *s,long long num,long long tot)
{
	if(*s=='\0')
		ans+=tot+num;
	else
	{
		dfs(s+1,(*s)-48,tot+num);
		dfs(s+1,num*10+(*s)-48,tot);
	}
}
int main()
{
	char str[12];
	scanf("%s",str);
	dfs(str,0,0);
	printf("%lld",ans/2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
///#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 1000000007

int main() {
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x, ll y){ll r;while((r = x % y) != 0){x = y;y = r;}return y;}

ll MAX_V = 1e5 + 5; //頂点数
struct edge {
    ll to;
    ll cost;
};

// <最短距離, 頂点の番号>
using P = pair<ll, ll>;

vector<vector<struct edge>> G(MAX_V); //隣接リスト
vector<ll> d(MAX_V); //各頂点への最短距離
void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(ALL(d), INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); i++) {
            struct edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll> u(n),v(n),a(n);
  for(i=0;i<n-1;i++){
    cin>>u[i]>>v[i]>>a[i];
    struct edge e ={v[i],a[i]};
    G[u[i]].push_back(e);
    e ={u[i],a[i]};
    G[v[i]].push_back(e);
  }
  ll q,k; cin>>q>>k;
  dijkstra(k);
  vector<ll> x(q),y(q);
  for(i=0;i<q;i++){
    cin>>x[i]>>y[i];
  }
  for(i=0;i<q;i++){
    cout<<d[x[i]]+d[y[i]]<<endl;
  }


  return 0;
}

Measured memory_bytes: 13952
#include <cstdio>

int main(){
  int n,k,x,y;
  scanf("%d%d%d%d",&n,&k,&x,&y);
  if(n<=k){
    printf("%d\n",n*x);
  }
  else{
    printf("%d\n",k*x+(n-k)*y);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long n,m;
    cin>>n>>m;
    if(n==1&&m==1){
        cout<<1<<endl;
    }
    else if(n==1||m==1){
        cout<<n*m-2<<endl;
    }
    else{
        cout<<(n-2)*(m-2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main()
{
  int input;
  int five_h;
  int five;
  
  scanf("%d", &input);
  
  five_h = (input / 500);
  input = input% 500;
  five = input / 5;
  
  printf("%d\n", (five_h * 1000) + (five * 5));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int input;
    
    cin >> input;
    
    int hour = input/3600;
    int minute = (input - hour*3600)/60;
    int second = input - hour*3600 - minute*60;
    
    cout << hour << ":" << minute << ":" << second << endl;
    
    return 0;
}


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

struct Node
{
    int key;
    Node *parent, *left, *right;
};

Node *NIL, *root;

void insert(int key)
{
    Node *x, *y, *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    y = NIL;
    x = root;
    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }

    z->parent = y;

    if (y == NIL)
    {
        root = z;
    }
    else if (z->key < y->key)
    {
        y->left = z;
    }
    else
    {
        y->right = z;
    }
}

// 先行順巡回
void preorder(Node *node)
{
    if (node == NIL)
        return;
    cout << " " << node->key;
    if (node->left != NIL)
        preorder(node->left);
    if (node->right != NIL)
        preorder(node->right);
}

// 中間順巡回
void inorder(Node *node)
{
    if (node == NIL)
        return;
    if (node->left != NIL)
        inorder(node->left);
    cout << " " << node->key;
    if (node->right != NIL)
        inorder(node->right);
}

void print()
{
    inorder(root);
    cout << "\n";
    preorder(root);
    cout << "\n";
}

int main()
{
    int i, m, key;
    string command;

    cin >> m;
    for (i = 0; i < m; i++)
    {
        cin >> command;
        if (command[0] == 'i')
        {
            cin >> key;
            insert(key);
        }
        else
        {
            print();
        }
    }

    return 0;
}


Measured memory_bytes: 26500
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    vector<long long> v(10000), s(10000);
    while (cin >> n, n) {
        for (int i = 0; i < n; ++i) cin >> v[i];
        sort(v.begin(), v.begin()+n);
        s[0] = 0;
        long long res = 0;
        for (int i = 0; i < n-1; ++i) s[i+1] = s[i] + v[i];
        for (int i = 0; i < n; ++i) res += s[i];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 0
k,a,b=map(int,input().split())

if (b-a)/2<=1:
    print(k+1)
else:
    s=k-a-1
    if s%2==0:
        print(int((s//2+1)*b-(s*a)//2))
    else:
        s1=s-1
        print(int((s1//2+1)*b-(s1*a)//2+1))

Measured memory_bytes: 3060
#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;
  else if(a+b==c+d)
    cout<<"Balanced"<<endl;
  else 
    cout<<"Right"<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);


void main() {
    int n, l;
    readf("%d %d\n",&n,&l);
    auto aji = new int[n];
    foreach (i; 0..n) aji[i] = l + i;
    int mini = 1<<29;
    int ans;
    int sm = aji.sum();
    foreach (i; 0..n) {
        int x = sm - aji[i];
        int d = abs(x - sm);
        if (d < mini) {
            mini = d;
            ans = x;
        }
    }
    writeln(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(abs(a-b) > pow(10,18)) cout << "Unfair" << endl;
    else cout << ((k%2)*2-1)*(b-a) << endl;
}

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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> p(n+1,0);
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(p[i]==i){
			continue;
		}
		ans++;
	}
	if(ans==2 || ans==0){
		printf("YES\n");
		return 0;
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

        def lower_bound(self, w):
            if w <= 0:
                return 0
            x = 0
            k = 1 << (self.size.bit_length() - 1)
            while k:
                if x + k <= self.size and self.tree[x + k] < w:
                    w -= self.tree[x + k]
                    x += k
                k >>= 1
            return x + 1

    for _ in range(int(input())):
        N = int(input())
        Llike = []
        Rlike = []
        ans = 0
        for _ in range(N):
            k, l, r = map(int, input().split())
            if l > r:
                Llike.append([l-r, k])
                ans += l
            elif r > l:
                if k == N:
                    ans += l
                else:
                    Rlike.append([r-l, N-k])
                    ans += r
            else:
                ans += r
        bitL = Bit(len(Llike))
        bitR = Bit(len(Rlike))
        Llike.sort(key=lambda x: x[0], reverse=True)
        Rlike.sort(key=lambda x: x[0], reverse=True)
        for i in range(len(Llike)):
            bitL.add(i+1, 1)
        for i in range(len(Rlike)):
            bitR.add(i+1, 1)
        for v, k in Llike:
            if k > len(Llike):
                k = len(Llike)
            u = bitL.sum(k)
            if u == 0:
                ans -= v
                j = bitL.lower_bound(bitL.sum(len(Llike)))
                bitL.add(j, -1)
            else:
                j = bitL.lower_bound(u)
                bitL.add(j, -1)
        for v, k in Rlike:
            if k > len(Rlike):
                k = len(Rlike)
            u = bitR.sum(k)
            if u == 0:
                ans -= v
                j = bitR.lower_bound(bitR.sum(len(Rlike)))
                bitR.add(j, -1)
            else:
                j = bitR.lower_bound(u)
                bitR.add(j, -1)
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 107044
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[1010][20010] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,N;
    cin >> H >> N;
    ll A[1010], B[1010];
    rep(i,0,N) cin >> A[i] >> B[i];
    rep(i,0,N+1){
        rep(j,0,20001){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    rep(i,0,N){
        rep(j,0,20001){
            if(j < A[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j], dp[i+1][j - A[i]] + B[i]);
            }
        }
    }
    ll ans = INF;
    rep(i,H,20001){
        ans = min(ans, dp[N][i]);
    }
    print(ans);

    

}

Measured memory_bytes: 157952
from collections import deque
n = int(input())
ls = [list(input()) for i in range(n)]
graph = [[] for i in range(n+1)]
visited = [0 for i in range(n+1)]
parity = [-1 for i in range(n+1)]
dist = [0 for i in range(n+1)]
for i in range(n):
  for j in range(i,n):
    if ls[i][j] == "1":
      graph[i+1].append(j+1)
      graph[j+1].append(i+1)
que = deque([(1,0)])
parity[1] = 0
visited[1] = 1
while que:
  x,cnt = que.popleft()
  dist[x] = cnt
  for y in graph[x]:
    if visited[y] == 0:
      que.append((y,cnt+1))
      visited[y] = 1
      parity[y] = 1-parity[x]
ans = []
for v in range(1,n+1):
  que.append((v,0))
  visited = [0 for i in range(n+1)]
  visited[v] = 1
  dist = [0 for i in range(n+1)]
  while que:
    x,cnt = que.popleft()
    dist[x] = cnt
    for y in graph[x]:
      if visited[y] == 0:
        que.append((y,cnt+1))
        visited[y] = 1
      if parity[y] == parity[x]:
        print(-1)
        exit()
  ans.append(max(dist))
print(max(ans)+1)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF pow(10,10)
#define M 1000000007


int main(void){
    ll n; cin >> n;
    vector<double>p(n);
    for(int i=0;i<n;i++) cin >> p[i];
    vector<vector<double>>dp(n,vector<double>(n+1,0));
    dp[0][0] = p[0],dp[0][1] = 1-p[0];
    for(int i=1;i<n;i++){
        dp[i][0]=dp[i-1][0]*p[i];
    }
    for(int i=1;i<n;i++){
        dp[i][i+1] = dp[i-1][i]*(1-p[i]);
    }
    

    for(int i=1;i<n;i++){
        for(int j=1;j<=n;j++){
            if(j<=i) dp[i][j] = dp[i-1][j-1]*(1-p[i]) + dp[i-1][j] * p[i];
            else break;
        }
    }

    // for(int i=0;i<n;i++){
    //     for(int j=0;j<=n;j++){
    //         cout << dp[i][j] << ' ';
    //     }cout << endl;
    // }cout << endl;

    printf("%.10f\n",accumulate(dp[n-1].begin(),dp[n-1].begin()+n/2+1,0.0));
    return 0;
}

Measured memory_bytes: 70784
n,k = map(int,input().split())
a = list(map(int,input().split()))

a0 = a[:n-k]
a1 = a[k:]

ans = []

for x,y in zip(a0,a1):
    if(x<y):
        ans.append('Yes')
    else:
        ans.append('No')

print('\n'.join(ans))

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

int main() {
	int h, w;

	while(cin >> h >> w) {
		if(h==0 && w==0) break;

		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(i==0 || j==0 || i==h-1 || j==w-1) {
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(string, s, t);

  int res = 0;
  for (int i = 0; i < t.length(); ++i) {
    if (s[i] == t[i]) ++res;
  }

  OUTL(res);

  return 0;
}


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

int main()
{
    int s, w;
    cin >> s >> w;
    string ans = "unsafe";
    if(w < s) ans = "safe";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(int a, int b) {
	return a > b;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << a - b + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
let rec isSquare acc num =
    if num = acc * acc then true
    elif num < acc * acc then false
    else isSquare (acc + 1) num

//for i in [| 121; 100100; 1210 |] do (isSquare i 4 |> printfn "%b")

[<EntryPoint>]
let main argv =
    stdin.ReadLine().Split(' ')
    |> String.concat ""
    |> int
    |> isSquare 4 // 1 以上の数を連結しているから 3^2=9以下は考えなくていい
    |> fun x -> if x then "Yes" else "No"
    |> printfn "%s"

    0


Measured memory_bytes: 29612
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    pairs = []

    for i in range(N):
        x, y = MI()
        pairs.append((x, y))

    modified = []

    max_a = -1 * 10 ** 9
    min_a = 10 ** 9
    max_b = -1 * 10 ** 9
    min_b = 10 ** 9

    for i in range(len(pairs)):
        x, y = pairs[i]
        modified.append([x - y, x + y])

        max_a = max(max_a, x-y)
        min_a = min(min_a, x-y)
        max_b = max(max_b, x+y)
        min_b = min(min_b, x+y)

    ans = max(max_a - min_a, max_b - min_b)
    print(ans)


main()


Measured memory_bytes: 108964