akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int p;
    int n, k;
    int ar[100003];
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&ar[i]);
    }
    for(int i=1;i<=n;i++)
    {
        if(ar[i]==1)
        {
            p=i;
            break;
        }
    }
    int ans;
    if((n-1)%(k-1)==0)
    {
        ans=(n-1)/(k-1);
    }
    else
    {
        ans=(n-1)/(k-1)+1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;

ll wt[105] , Val[105];

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

    ll sum =0;
    for(int i=1; i<=N; i++)
    {
        cin >> wt[i] >> Val[i];
        sum += Val[i];
    } 

    ll dp[sum+1][N+1];

    for(ll i =0; i<=sum; i++)
    {
        for(int j=0; j<=N;j++)
        {
            if(i==0) dp[i][j] = 0;
            else
            {
                dp[i][j] = 1000000000000LL;
            }
        }
    }

    dp[Val[1]][1] = wt[1];

    for(ll s=1; s<=sum ; s++)
    {
        for(int j=1; j<=N; j++)
        {
            if(s >=Val[j])
            {
                dp[s][j] = min(dp[s][j-1], dp[s-Val[j]][j-1]+wt[j]);
            }
            else
            {
                dp[s][j] = dp[s][j-1];
            }
            // cout<< dp[s][j]<< endl;
        }
        
    }
    // ll result;
    for(ll s=sum; s>=0; s--){
        if(dp[s][N] <=W){
            cout << s <<endl;
            break;
        }
    }
    // cout << INT64_MAX;
    return 0;
}

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

int main() {

  int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  int ma = max(a,max(b,c));
  int po = ma * pow(2, k);
  
  cout << a+b+c-ma + po << endl;
  
  
}


Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    string s,t;
    cin>>s>>t;
    ll n=s.size(),c=0,n1=t.size();
    f(i,min(n,n1))
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 3848
n, d = map(int,input().split())
X = [0] * n
Y = [0] * n
ans = 0

for i in range(n):
    X[i], Y[i] = map(int,input().split())

for j in range(n):
    a = ((X[j] ** 2) + (Y[j] ** 2)) ** 0.5
    if a <= d:
        ans += 1
print(ans)

Measured memory_bytes: 73704
package main
import (
  "fmt"
)
func main() {
  var s string
  fmt.Scan(&s)
  var k int64
  fmt.Scan(&k)
  result := "1"
  for i := int64(0); i < k; i++ {
    if int64(len(s)) <= i {
      break
    }
    if s[i] != '1' {
      result = string(s[i])
      break
    }
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
//まだ理解していない
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	int x[N], y[N], h[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}

	int Cx, Cy, H;
	for (Cx = 0; Cx <= 100; Cx++) {
		for (Cy = 0; Cy <= 100; Cy++) {
			for (int i = 0; i < N; i++) {
				if (h[i] > 0) {
					H = abs(Cx - x[i]) + abs(Cy - y[i]) + h[i];
					break;
				}
			}

			bool flag = true;
			for (int i = 0; i < N; i++) {
				if (max(H - abs(Cx - x[i]) - abs(Cy - y[i]), 0) != h[i]) {
					flag = false;
					break;
				}
			}
			if (flag) {
				cout << Cx << " " << Cy << " " << H << endl;
				return 0;
			}
		}
	}
}

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

int main() {
	string s;
	cin >> s;
	int a = s.size();
	int z = -1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') a = min(a, i);
		if (s[i] == 'Z') z = max(z, i);
	}
	printf("%d\n", z - a + 1);
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
b = [0]*(n+1)
for i in range(n+1):
    b[i] = abs(a[i]-a[i+1])
sum_b = sum(b)
for i in range(n):
    print(sum_b - b[i] - b[i+1]+abs(a[i]-a[i+2]))
# print(sum_b)
# print(b)


Measured memory_bytes: 57580
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	double r = 0;
	if(N%2 == 1){
		r = (double)(N+1)/2 / N;
	} else {
		r = (double)N/2/N;
	}

	cout << r << endl;	
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static final boolean TEST = false;

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int m = in.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = in.nextInt() - 1;
			b[i] = in.nextInt() - 1;
		}
		solve(n, m, a, b);
		in.close();
	}

	private static void solve(int n, int m, int[] a, int[] b) {
		long[] ans = new long[m];
		ans[m - 1] = (long) n * (long) (n - 1) / 2L;

		int[] grp = new int[n];
		int[] mem = new int[n];
		for (int i = 0; i < n; i++) {
			grp[i] = -1;
			mem[i] = 1;
		}
		for (int i = m - 1; i > 0; i--) {
			if (getGrp(a[i], grp) == getGrp(b[i], grp)) {
				ans[i - 1] = ans[i];
				continue;
			}
			ans[i - 1] = ans[i] - (long) getMem(a[i], grp, mem) * (long) getMem(b[i], grp, mem);
			joinGrp(a[i], b[i], grp, mem);
		}
		for (int i = 0; i < m; i++)
			System.out.println(ans[i]);
	}

	private static void joinGrp(int i, int j, int[] grp, int[] mem) {
		mem[getGrp(i, grp)] += mem[getGrp(j, grp)];
		grp[getGrp(j, grp)] = getGrp(i, grp);
	}

	private static int getMem(int i, int[] grp, int[] mem) {
		return mem[getGrp(i, grp)];
	}

	private static int getGrp(int i, int[] grp) {
		if (grp[i] == -1)
			return i;
		if (grp[grp[i]] == -1)
			return grp[i];
		grp[i] = grp[grp[i]];
		return getGrp(grp[i], grp);
	}
}

Measured memory_bytes: 86332
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int x, a, b; cin>>x>>a>>b;
    int n; cin>>n;
    while(n--){
        string s; cin>>s;
        if(s[0] == 'n') x += a;
        else if(s[0] == 't') x += b;
        else x = 0;

        x = max(0, x);
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <string.h>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
		ll N,K,ans;
		 
		cin >> N >> K >>ans;

		cout << (N+K)*ans/2 << endl;

		return 0;
    }

Measured memory_bytes: 256
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::iter::{self, Product, Sum};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Deref,
    DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        a: u32,
        p: u32,
    }
    let r = (3 * a + p) / 2;
    println!("{}", r);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    ll n,k; cin >> n >> k;
    if(k == 1) {
        cout << 0 << endl; return 0;
    }
    cout << min(n%k, k - n%k) << endl;
    return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}


int main() {
  int n,k;cin >>n>>k;
  ll x[n];
  int left=0;ll ans=INF;
  rep(i,n)cin >>x[i];
  
  rep(i,n-k+1){
    ll p=(ll)abs(x[i]);
    ll q=(ll)abs(x[i+k-1]);
    if(x[i]*x[i+k-1]>0)chmin(ans,(ll)max(p,q));
    else {
    chmin(ans,p+2*q);
    chmin(ans,2*p+q);
    }
  }
  cout <<ans;
}

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


int main() {

  long long int N;
  long long int Ans=0;
cin >> N;
  vector<long long int>Height(N);
  for(int i=0; i<N; i++){
    cin >> Height.at(i);
  }

  for(int i=1; i<N; i++){
    if(Height.at(i-1)>Height.at(i)){
      Ans=Ans+Height.at(i-1)-Height.at(i);
      Height.at(i)=Height.at(i-1);
    }
  }
  cout << Ans;
  
}

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

using namespace std; 
int main()
{
	int n,d,in=0,f=1,i=0;
	cin>>n>>d;
	if(d>=n||2*d+1>=n)
	{
		f=0;
		in++;
		i=n;
	}
	while(f)
	{
		if(i+2*d+1<=n)
		{
		
			i+=2*d+1;
			in++;
		}
		else
			f=0;
	}
	if(i<n)
		in++;
	cout<<in<<endl;
	
	return 0;		
}




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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> vec(H);

  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
  }

  cout << string(W + 2, '#') << endl;

  for (int i = 0; i < H; i++) {
      cout << '#' << vec.at(i) << '#' << endl;
  }

  cout << string(W + 2, '#') << endl;
}


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

struct Pair {
	Pair(const int &a = 0, const int &b = 0) :x{ a }, size{ b } {};
	int x, size;
};
std::vector<std::vector<int>> to_size(const std::vector<std::vector<char>> &map) {
	std::vector<std::vector<int>> res(map.size(), std::vector<int>(map.front().size(), 0));
	for (auto i = 0; i < map.at(0).size(); ++i) {
		if (map.at(0).at(i) == '.') {
			res.at(0).at(i) = 1;
		}
	}
	for (auto i = 1; i < map.size(); ++i) {
		for (auto j = 0; j < map.at(i).size(); ++j) {
			if (map.at(i).at(j) == '.') {
				res.at(i).at(j) = res.at(i - 1).at(j) + 1;
			}
		}
	}
	return res;
}
int stack_operation(std::stack<Pair> &stack) {
	auto last = stack.top();
	stack.pop();
	if (stack.top().size < last.size) {
		stack.push(last);
		return 0;
	}
	else if (stack.top().size > last.size) {
		auto sus = 0;
		Pair l;
		while (stack.top().size > last.size) {
			auto sus2 = (last.x - stack.top().x) * stack.top().size;
			if (sus < sus2) {
				sus = sus2;
			}
			l = stack.top();
			stack.pop();
		}
		stack.push(Pair(l.x, last.size));
		return sus;
	}
	else {
		return 0;
	}

}
int get_max(const std::vector<std::vector<int>> &map) {
	int max = 0;
	for (const auto &line : map) {
		std::stack<Pair> stack;
		stack.push(Pair(0, 0));
		for (auto i = 0; i < line.size(); ++i) {
			stack.push(Pair(i, line.at(i)));
			auto sus = stack_operation(stack);
			if (sus > max) {
				max = sus;
			}
		}
		stack.push(Pair(line.size(), 0));
		auto sus = stack_operation(stack);
		if (sus > max) {
			max = sus;
		}
	}
	return max;
}
int main() {
	int h, w;
	while (std::cin >> h >> w && h != 0 && w != 0) {
		std::vector<std::vector<char>> state(h, std::vector<char>(w));
		for (auto &line : state) {
			std::string arg;
			std::cin >> arg;
			for (auto i = 0; i < w; ++i) {
				line.at(i) = arg[i];
			}
		}
		auto map = to_size(state);
		std::cout << get_max(map) << '\n';
	}
	return 0;
}

Measured memory_bytes: 4124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<math.h>
#include<stdio.h>
#include<cmath>
using namespace std;
using ll = long long;

int main() {
	cout << fixed;
	ll N, ans = 0;
	double D;
	cin >> N >> D;

	for (ll i = 0; i < N; i++) {
		ll X, Y;
		cin >> X >> Y;

		ll A = X * X;
		ll B = Y * Y;

		if (sqrt(A + B) <= D)ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3776
#include <stdio.h>

int main(void){
  int k,n,a[200005],max;
  scanf("%d %d",&k,&n);
  for(int i=0;i<=n-1;i++){
    scanf("%d",&a[i]);
  }
  max=k-a[n-1]+a[0];
  for(int i=0;i<n-1;i++){
      if(max<a[i+1]-a[i]) max=a[i+1]-a[i];
  }
  printf("%d\n",k-max);
  return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(4e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}
pair<ll,pii>a[15];
ll ans[16];
int n,ax[16]={0},ay[16]={0},countx=0,county=0;
void road(int i){
    if(i==n){
        int count=countx+county;
        ll curr=0;
        f(i,0,n){
            ll curr1=inf,curr2=inf;
            f(j,0,countx+1)curr1=min(curr1,a[i].first*abs(ax[j]-a[i].second.first));
            f(j,0,county+1)curr2=min(curr2,a[i].first*abs(ay[j]-a[i].second.second));
            curr+=min(curr1,curr2);
        }
        ans[count]=min(curr,ans[count]);
        return;
    }
    road(i+1);
    ++countx;ax[countx]=a[i].second.first;
    road(i+1);--countx;
    ++county;ay[county]=a[i].second.second;
    road(i+1);--county;
}
int main() {
    fastio;
    // clock_t tm = clock();
    cin>>n;
    f(i,0,n)cin>>a[i].second.first>>a[i].second.second>>a[i].first;
    f(i,0,n+1)ans[i]=inf;
    road(0);
    f(i,0,n+1)cout<<ans[i]<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

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

int main (){
    int sl, i, j, k=0, ans=0;
    string s;
    
    cin >> s;
    sl=s.length();
    
    s[sl-2]=0;
    s[sl-1]=0;
    
    for(i = sl-2; i > 0; i--){
        if(i%2==0){
            for(j=0; j<i/2; j++){
                if(s[j]==s[j+i/2]){
                    k++;
                }
            }
            if(k==i/2){
                cout<<2*k<<endl;
                return 0;
            }
            k=0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int a, b; cin >> a >> b;
    string ans;
    if (a + b == 15) ans = "+";
    else if (a * b == 15) ans = "*";
    else ans = "x";
    cout << ans << endl;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

const int MN = 200010;
const ll INF = TEN(18);

int L;
ll A[MN];
ll dp[MN][5];

int main() {
	cin >> L;
	rep(i, L) {
		cin >> A[i];
	}

	rep(i, MN) rep(j, 5) {
		dp[i][j] = INF;
	}

	dp[0][0] = A[0];
	dp[0][1] = (A[0] == 0 ? 2 : (A[0] & 1));
	dp[0][2] = !(A[0] & 1);

	for (int i = 1; i < L; ++i) {
		ll c[5];
		c[0] = c[4] = A[i];
		c[1] = c[3] = (A[i] == 0 ? 2 : (A[i] & 1));
		c[2] = !(A[i] & 1);

		rep(j, 5) {
			if (dp[i-1][j] == INF) {
				continue;
			}
			for (int k = j; k < 5; ++k) {
				dp[i][k] = min(dp[i][k], dp[i-1][j] + c[k]); 
			}
		}
	}

	ll ans = *min_element(dp[L-1], dp[L-1] + 5);

	cout << ans << endl;

	return 0;
}

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

int main(){
    int long long a , b , k;
    int long long i,j;
    cin >> a; 
    cin >> b; 
    cin >> k;

    i = a - k;
    j = b - abs(i);

    if (i >= 1){
        a = i;
        b = b;
    }

    else if(i <= 0 and j > 0){
        a = 0;
        b = j;
    }

    else{
        a = 0;
        b = 0;
    }

    cout << a << endl;
    cout << b << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
    subt;
    return 0;
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	ll ans = 0;
	if(C*2>A+B) ans = A*X+B*Y;
	else {
		if(X<Y){
			ans += C*2*X;
			ans += (C*2<B)? C*2*(Y-X):B*(Y-X);
		}else if(X==Y){
			ans = C*2*X;
		}else{
			ans += C*2*Y;
			ans += (C*2<A)? C*2*(X-Y):A*(X-Y);
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL N;
std::vector<long double>p;
std::vector<std::vector<long double>>memo;

long double dp(LL i, LL j)
{
	if (i == N)
	{
		if (j > i - j) return 1.;
		else return 0.;
	}
	if (memo[i][j] != -1) return memo[i][j];
	auto res1 = dp(i + 1, j + 1)*p[i], res2 = dp(i + 1, j)*(1. - p[i]);
	return memo[i][j] = res1 + res2;
}

int main()
{
	in >> N;
	p.resize(N);
	rep(i, N) in >> p[i];

	memo.resize(N);
	rep(i, memo.size()) memo[i].resize(N, -1.);
	out << std::fixed << std::setprecision(10);
	out << dp(0, 0) << std::endl;
}


Measured memory_bytes: 141184
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict,deque
import bisect
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))

g = defaultdict(list)
for i in range(N-1):
    u, v = map(int,input().split())
    g[u].append(v)
    g[v].append(u)

def eulerTour(g,s):
    n = len(g)
    dq = [s]
    ls = [-1]*(n+1)
    rs = [-1]*(n+1)
    index = []
    visited = [False]*(n+1)
    def dfs(v):
        visited[v] = True
        ls[v] = len(index)
        index.append(v)
        for nv in g[v]:
            if not visited[nv]:
                dfs(nv)
        rs[v] = len(index)
        index.append(v)
    dfs(s)
    return ls,rs,index

ls,rs,index = eulerTour(g,1)
dq = deque([1])
visited = [False]*(N+1)

inf = 10**10
l = [inf] * (N+1)

ans = [0] * (N+1)
ans[1] = 1

visited = [False]*(N+1)
rollback = []

k = 1
for v in index:
    if visited[v]:
        i, pa = rollback.pop()
        l[i] = pa
        if pa == inf:
            k -= 1
    else:
        A = a[v-1]
        i = bisect.bisect_left(l,A)
        rollback.append((i,l[i]))
        if k <= i:
            k += 1
        l[i] = A
        #ans[v] = l.index(inf)
        ans[v] = k
        visited[v] = True


for i in range(1,N+1):
    print(ans[i])







Measured memory_bytes: 579036
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stack>
#include <stdio.h>
#include <ios>     // std::left, std::right
#include <iomanip>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
//const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int digitlen(long long i){
    long long t = i;
    int count = 0;
    while(t){
        count += 1;
        t /= 10;
    }
    return count;
}

vector<int> cumsum(vector<int> arr){
    vector<int> ret;
    int l = arr.size();
    ret.push_back(arr[0]);
    for(int i = 1; i < l; i++){
        ret.push_back(ret[i-1] + arr[i]);
    }
    return ret;
}

vector<int> eratosthenes(int n){
    int arr[n+1];
    rep(i,0,n+1){
        arr[i] = 1;
    }
    arr[0] = 0; arr[1] = 0;
    for(int i = 2; i < n; i++){
        if(arr[i]==1){
            for(int j = 2*i; j < n+1; j+=i){
                arr[j] = 0;
            }
        }
    }
    
    vector<int> ret;
    for(int i = 2; i<n+1; i++){
        if(arr[i] == 1){
            ret.push_back(i);
        }
    }
    return ret;

}


int main(){
    while(true){
        string s;
        getline(cin, s);
       
        if(s.size() == 1 && s[0] == '.') return 0;

        stack<char> stk;

        bool ischecked = false;

        for(auto e: s){
            if(e == '(' || e == '['){
                stk.push(e);
            }

            if(e == ')'){
                if(stk.size() < 1 || stk.top() != '('){
                    cout << "no" << endl;
                    ischecked = true;
                    break;
                }else{
                    stk.pop();
                }
            }

            if(e == ']'){
                if(stk.size() < 1 || stk.top() != '['){
                    cout << "no" << endl;
                    ischecked = true;
                    break;
                }else{
                    stk.pop();
                }

            }
        }
        if(!ischecked){
            if(stk.size() == 0){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }

    }
}




Measured memory_bytes: 3180
def main():
    N, K = map(int, input().split())
    if K % 2:
        print((N // K) ** 3)
    elif N // K * K + K // 2 <= N:
        print((N // K) ** 3 + (N // K + 1) ** 3)
    else:
        print(2 * (N // K) ** 3)
    return


main()


Measured memory_bytes: 2940
S = list(input())
mini = 800

for i in range(len(S)-2):
  s_num =  100 * int(S[i]) + 10 * int(S[i+1]) + int(S[i+2])
  a = abs(753 - s_num) 
  if a < mini:
    mini = a
    
print(mini)

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}


#define PRIME_MAX 1000010
typedef pair<li, li> PI;
bool isp[PRIME_MAX] = {false};
vector<li> primes;

inline void prime_init() {
    repp(i, 2, PRIME_MAX)isp[i] = true;
    repp(i, 2, sqrt(PRIME_MAX) + 2) {
        if (isp[i]) {
            for (li j = 2; i * j < PRIME_MAX; j++) {
                isp[i * j] = false;
            }
        }
    }
    rep(i, PRIME_MAX)if (isp[i])primes.pb(i);
}

inline vector<PI > decom(li x) {
    vector<PI> res;
    rep(i, sz(primes)) {
        li tres = 0;
        while (x % primes[i] == 0) {
            tres++;
            x /= primes[i];
        }
        if (tres > 0)res.pb({primes[i], tres});
        if (x <= 1)break;
    }
    if (x > 1) {
        res.pb({x, 1});
    }
    return res;
}

int main() {
    prime_init();
    li n, p;
    cin >> n >> p;
    auto vv = decom(p);

    li res = 1;
    for (auto& item : vv) {
        if (item.S >= n) {
            rep(i, item.S / n) {
                res = res * item.F;
            }
        }
    }
    cout << res << endl;


    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p )
{
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v )
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu ()
{
    cerr << endl;
}

template <typename T>
void faltu( T a[], int n )
{
    for(int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


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

void f()
{
    ll a[6],mn=INT_MAX,sum;
    for(int i=0; i<5; i++)
    {
        cin>>a[i];
    }
    do
    {
        sum=a[0];
        for(int i=1; i<5; i++)
        {
            if(sum%10!=0)
                sum=ceil(sum/10.0)*10;
            sum+=a[i];
        }
        mn=min(mn,sum);
    }
    while(next_permutation(a,a+5));

    cout<<mn<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3664
import java.util.*;

public class Main {
 public static void main(String... args) {
   Scanner scan = new Scanner(System.in);
   String S = scan.next();

   boolean res = true;
   char target=0;
   for(int i=0; i<S.length(); i++) {
     target = S.charAt(i);
     if((i%2 != 0) && (target == 'R') ||
        (i%2 == 0) && (target == 'L')) {
       res = false;
       break;
     }
   }
   System.out.println(res ? "Yes" : "No");
 }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=1e5+5,mod=1e9+7;
typedef long long ll;
int n;
int main()
{
    Elhabashy
    input();
    cin>>n;
    map<string,int>mp;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;

}


Measured memory_bytes: 3644
import sys

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    L, R = mi()

    mod = 2019
    min_mod = mod
    if R - L >= mod:
        print(0)
        return
    
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            if i * j % mod < min_mod:
                min_mod = i * j % mod
        
    print(min_mod)

    return

main()


Measured memory_bytes: 9208
import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L = sorted(L)

    ans = 0

    for i in range(N):
        for j in range(i+1, N):
            X = L[i] + L[j]
            l = bisect.bisect_left(L, X, lo=j+1)
            ans += (l-(j+1))
            #print(L[j + 1:l])
    print(ans)
    return 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 43100
import sys
import math

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

a,b,x = map(int, input().split())

s = a * b

theta = 0
if a * a * b / 2 < x:
    theta = math.atan(2 * (a**2 * b - x) / a**3)
else:
    theta = math.atan((a * b**2) / (2 * x))

deg = math.degrees(theta)

print('{:.10f}'.format(deg))


Measured memory_bytes: 9288
public class Main {

  private static void solve() {
    long n = nl();

    for (long k = (long) Math.sqrt(n); k >= 1; k--) {
      if (n % k == 0) {
        System.out.println(n / k + k - 2);
        return;
      }
    }


  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 23508
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

// グラフ用ヘッダ

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    int limit;
    Edge(int src, int dst, Weight weight, int limit) :
        src(src), dst(dst), weight(weight), limit(limit) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

#include <queue>

// d,speed,v,from
typedef tuple<double,int,int,int> State;

const double inf = 1e100;

// speed,v,from
double dp[32][32][32];
Graph g;
int src,dst;

const char* solve(){
    priority_queue<State> q;
    q.emplace(0.0,0,src,31);
    rep(i,32)rep(j,32)rep(k,32) dp[i][j][k] = inf;
    dp[0][src][31] = 0;
    while(q.size()){
        double d; int speed, v, from;
        tie(d,speed,v,from) = q.top(); q.pop();
        d = -d;
        if(v==dst && speed==1){
            static char ans[100];
            sprintf(ans,"%.12lf",d);
            return ans;
        }
        if(d > dp[speed][v][from]) continue;
        for(Edge & e : g[v]){
            for(int diff : {-1,0,1}){
                int ns = speed + diff;
                if(ns < 1 || e.limit < ns) continue;
                double nd = d + (double)e.weight / ns;
                int nv = e.dst;
                if(nv == from) continue;
                if(dp[ns][nv][v] > nd){
                    dp[ns][nv][v] = nd;
                    q.emplace(-nd,ns,nv,v);
                }
            }
        }
    }
    return "unreachable";
}

int main(){
    int n,m;
    while(~scanf("%d%d", &n,&m) && n){
        scanf("%d%d",&src,&dst);
        g.assign(n+1,{});
        rep(i,m){
            int x,y,d,c;
            scanf("%d%d%d%d", &x,&y,&d,&c);
            g[x].eb(x,y,d,c);
            g[y].eb(y,x,d,c);
        }
        puts(solve());
    }
}

Measured memory_bytes: 1972
#include<bits/stdc++.h>
using namespace std;
long long n,num;
pair<int,int> p[200010];
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>p[i].second>>p[i].first;
	sort(p,p+n);
	for (int i=0;i<n;){
		int j=i;
		while (p[i].first==p[j].first) num+=p[j++].second;
		if (num>p[i].first){
			cout<<"No"<<endl;
			return 0;
		}
		i=j;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1792
import copy
import math


def main():
    n=int(input())
    temp=input().split(" ")
    nums=list(map(int,temp))
    nums.reverse()
    l=2 # min 
    r=2 # max
    for num in nums:
       # if num<=l and num>=r:
        r=(int(r/num)+1)*(num)-1
        l= math.ceil(l/num)*num
        
        if l>r:
             print("-1")
             return 0
    print(str(l)+" "+str(r))      
    



if __name__ == '__main__':
    main()


Measured memory_bytes: 14764
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int digitSum(int n,int digit=8) {
	// digit > 2
	int x = 1;
	FOR(i,0,digit){
		x *= 10;
	}
	int sum = 0;
	FOR(i, 0, digit) {
		sum += n / x;
		n %= x;
		x /= 10;
	}
	sum += n;
	return sum;
}

int main()
{
	vector<int> l(50);
	fill(l.begin(), l.end(), 0);
	int n, k;
	cin >> n >> k;
	FOR(i, 0, n) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	int sum = 0;
	FOR(i,0,k){
		sum += l[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
N=int(input())
h=list(map(int,input().split()))
min=h[0]
piv=0
l=0
r=0
i=0
cnt=0
while sum(h)>0:
    while (h[l]==0)and(l<=N-1):
        l=l+1
    if l==N:
        break
    else:
        min=h[l]
    for i in range(l,N):
        if h[i]<min:
            if h[i]!=0:
                min=h[i]
            else:
                piv=piv-1
                break
    piv=piv+i
    #print(l,piv)
    for i in range(l,piv+1):
        h[i]=h[i]-min
    cnt=cnt+min
    l=0
    piv=0
    #print(h,cnt)
    #input()
print(cnt)

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s, t;
  std::cin >> s >> t;
  int64_t a, b;
  std::cin >> a >> b;
  std::string u;
  std::cin >> u;

  if (s == u) {
    std::cout << a - 1 << " " << b << std::endl;
  } else {
    std::cout << a << " " << b - 1 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,nyuryoku;
  vector<int> A;
  vector<int> B;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>nyuryoku;
    A.push_back(nyuryoku);
  }
  for(int P=0;P<100;P++){
    int count=0;
    for(int i=0;i<N;i++){
     count+=(abs(A.at(i)-P))*(abs(A.at(i)-P));
    }
    B.push_back(count);
  }
  int min=10000000;
  for(int i=0;i<100;i++){
    if(B.at(i)<min){
      min=B.at(i);
    }
  }
  cout<<min<<endl;
}




    

    


    
    


     


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

int main()
{
    using namespace std;

    string str;

    cin >> str;

    if(str == "AAA" || str == "BBB")
    {
        cout << "No" << endl;
    } else
    {
        cout << "Yes" << endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;

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

	vector<int> V = {105,135,165,189,195 };

	int ans = 0;

	for (int i = 0; i < 5; i++) {
		if (V[i] <= N)ans++;
	}

	cout << ans << endl;
}

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

int main(){
        int len;
        char s[1000];
        scanf("%s", s);
        len=strlen(s);
        if(s[len-1]=='s'){
                printf("%ses", s);
        }else{
                printf("%ss", s);
        }

        return 0;
}


Measured memory_bytes: 1736