akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

long long a,b,c,d;
int t;
long long gcd(long long x,long long y)
{
    if(x>y)swap(x,y);
    if(x==0)return y;
    return gcd(y%x,x);
}

int main()
{
    int i,j,k,times;
    cin>>t;
    for(times=1;times<=t;times++)
    {

    cin>>a>>b>>c>>d;
    if(d<b)
    {
        cout<<"No"<<endl;
        continue;
    }

    if(a<b)
    {
        cout<<"No"<<endl;
        continue;
    }

    if(a<=c)
    {
        cout<<"Yes"<<endl;
        continue;
    }


    long long g=gcd(b,d);
    long long x=(a-c-1)/g;
    long long r=a-x*g;
    //cout<<r<<"  rrr"<<endl;
    if(r>=b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    }
    return 0;
}


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

int main() {
	int n, m;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++)
		cin >> s[i];
	cin >> m;
	vector<string> t(m);
	for (int i = 0; i < m; i++)
		cin >> t[i];
	int max = 0;
	for (int i = 0; i < n; i++) {
		int ans = 0;
		for (int j = 0; j < n; j++)
			if (s[i] == s[j])
				ans++;
		for (int k = 0; k < m; k++)
			if (s[i] == t[k])
				ans--;
		if (max < ans)
			max = ans;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    vector<string> v;
    int t,i,flag=1;
    string s,k,l;
    cin>>t;
    while(t--)
    {
        cin>>s;
        if(find(begin(v), end(v),s)!=end(v))
        {
            flag=0;
            break;
        }
        v.push_back(s);
    }
    if(flag==1)
    {
        for(i=1;i<v.size();i++)
        {
            k=v[i-1];l=v[i];
            if(k.back()!=l.front())
            {
                flag=0;
                break;
            }
        }
    }
    if(flag==0)
        cout<<"No";
    else
        cout<<"Yes";
}        

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

using namespace std;

int abs(int x) {
  if(x < 0) {
    return (-1) * x;
  }
  else {
    return x;
  }
}

int main(void) {
  int n;
  cin >> n;
  vector <int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int anslarge, anssmall;
  sort(a.begin(), a.end());
  decltype(a)::iterator it = upper_bound(a.begin(), a.end(), a[n - 1] / 2);
  if((it - a.begin()) == n - 1) {
    it -= 1;
  }
  int tmp1 = abs(a[n - 1] / 2 - *it);
  int tmp2 = abs(a[n - 1] / 2 - *(it - 1));

  if(tmp1 <= tmp2) {
    anslarge = a[n - 1];
    anssmall = *it;
  }
  else {
    anslarge = a[n - 1];
    anssmall = *(it - 1);
  }
  cout << anslarge << " " << anssmall << endl;
  
}

Measured memory_bytes: 640
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cout << fixed << setprecision(12);

    int w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << (w * 1LL * h) / 2.0 << " ";
    cout << (x * 2 == w && y * 2 == h ? 1 : 0) << "\n";


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> a(n);
    loop(i,0,n) cin >> a[i];
    vector < vector <ll> > dp(n, vector<ll>(n));
    // dp[l][r] = X-Y for a[l...r]
    // X=Score of current player
    // Y=Score of other player
    for (int i=n-1; i>=0; --i)
    {
        for (int j=i; j<n; ++j)
        {
            if (i==j) dp[i][i]=a[i];
            else dp[i][j] = max(a[i] - dp[i+1][j], a[j]-dp[i][j-1]);

            /* For a[i...j], if player chooses left element a[i],
            *  dp[i+1][j] will then be equal to Y-X from player 1 perspective
            *  a[i]-(Y-X) = a[i] + X - Y = (a[i] + X) - Y
            *  Similarly for right element.
            */

        }
    }
    cout << dp[0][n-1] << "\n";
    return 0;
}

Measured memory_bytes: 70784
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

bool test(long[][] a) {
    foreach(i; iota(a.length)) {
        foreach(j; iota(a.length)) {
            foreach(k; iota(a.length)) {
                if(a[i][j] > a[i][k] + a[k][j]) {
                    return false;
                }
            }
        }
    }
    return true;
}

void main(){
    auto n = readLong();
    long[][] a;
    foreach(i; iota(n)) {
        a ~= readLongs();
    }
    if(!test(a)) {
        writeln(-1);
        return;
    }
    long ans;
    foreach(i; iota(a.length)) {
        foreach(j; iota(i+1, a.length)) {
            bool f;
            foreach(k; iota(a.length)) {
                if(k == i || k == j) {
                    continue;
                }
                if(a[i][k] + a[k][j] == a[i][j]) {
                    f = true;
                    break;
                }
            }
            if(!f) {
                ans += a[i][j];
            }
        }
    }
    writeln(ans);
}



Measured memory_bytes: 5372
n = int(input())
A = list(map(int,input().split()))
A.sort()
dict = [0 for _ in range(8)]
B = []
for a in A:
    if 3200 <= a:
        B.append(a)
        continue
    for i in range(8):
        if i*400 <= a and a < (i+1)*400:
            dict[i]+=1
            break
ds = 8-dict.count(0)
maxNum = ds
minNum = ds
if len(B) > 0:
    maxNum += len(B)
    minNum = max(minNum,1)
print(minNum,maxNum)

Measured memory_bytes: 3064
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let l: f64 = sc.read();
    let ans: f64 = l * l * l / 27f64;
    println!("{:.12}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int ans = 1e9;
	for(int x=-100;x<=100;x++) {
		int cost = 0;
		rep(i,n) cost += (a[i]-x)*(a[i]-x);
		ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	long n,k,i,j,cur=0,ans,res,jud1,jud2;
	cin >> n >> k;
	vector<long> a(n);
	for(i=0; i<n; i++){
		cin >> a[i];
		cur+=a[i];
	}
	sort(a.begin(),a.end());
	
	set<long> div;
	for(i=1; i*i<=cur; i++){
		if(cur%i==0){
			div.insert(i);
			div.insert(cur/i);
		}
	}
	auto itr=div.end();
	vector<long> mod(n);
	for(i=0; i<div.size(); i++){
		itr--; jud1=0; jud2=0;
		cur=0; res=*itr;
		for(j=0; j<n; j++){
			mod[j]=a[j]%res;
			jud1+=mod[j];
		}
		if(jud1<=k){
			cout << res; return 0;
		}
		sort(mod.begin(),mod.end());
		
		for(j=n-1; j>=0; j--){
			jud1-=mod[j];
			jud2+=res-mod[j];
			
			if(abs((jud1-jud2)%res)){
				continue;
			}
			
			if(max(abs(jud1),abs(jud2))<=k){
				cout << res; return 0;
			}
		}
		
	}

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            int n = sc.nextInt();
            if (n == 0) break;
            solve(n);
        }
    }
    
    private static void solve(int n) {
        Map<String, String> map = new HashMap<>();
        for (int i = 0;i < n;i++) {
            String k = sc.next();
            String v = sc.next();
            map.put(k,v);
        }
        int m = sc.nextInt();
        for (int i = 0;i < m;i++) {
            String s = sc.next();
            if (map.containsKey(s)) {
                s = map.get(s);
            }
            System.out.print(s);
        }
        System.out.println("");
    }
}



Measured memory_bytes: 66824
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 200100

ll n,Q;
vector<ll> adj[MAX];
ll counter[MAX];

vector<pii> ans;

void f(ll s,ll p,ll count){
	count+=counter[s];
	ans.pb({s,count});
	for(ll x:adj[s]) if(x!=p){
		f(x,s,count);
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	memset(counter,0,sizeof(counter));
	cin>>n>>Q;
	For(i,0,n-1){
		ll x,y;cin>>x>>y;x--;y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	while(Q--){
		ll p,x;cin>>p>>x;p--;
		counter[p]+=x;
	}
	f(0,-1,0);
	sort(ans.begin(),ans.end());
	for(pii x:ans){
		cout<<x.se<<" ";
	}
	cout<<endl;






























	
}

Measured memory_bytes: 31344
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	int[] onndosa = {1,2,3,4,5,6,7};
	public void nyuuryoku(){
			for(n = 0;n <= 6;n++){
				int saikou = sc.nextInt();
				int saitei = sc.nextInt();
				onndosa[n] = saikou - saitei;
		}
	}
	public void syuturyoku(){
		for(n = 0;n <= 6;n++){
			System.out.println(onndosa[n]);
		}
	}
		public static void main(String[] args) {
			Main toi = new Main();
			toi.nyuuryoku();
			toi.syuturyoku();
	}

}

Measured memory_bytes: 17168
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var mod = 998244353;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var facn=1,finv=[];
function fset(n){
  if(n<8500000){
    for(var i=2;i<=n;i++)facn=facn*i%mod;
    finv.length=n+1,finv[0]=finv[1]=1;
    finv[n]=inv(facn);
    for(i=n;2<i;i--)finv[i-1]=finv[i]*i%mod;
  }
  else{
    facn=488985182;
    for(var i=8500001;i<=n;i++)facn=mul(facn,i);
    finv.length=n+1,finv[0]=finv[1]=1;
    finv[n]=inv(facn);
    for(i=n;2<i;i--)finv[i-1]=mul(finv[i],i);
  }
}
function inv(a){for(var b=mod,u=1,v=0,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(facn,finv[r],finv[n-r]);}

console.log(main());
function main(){
  var n = o.a();
  var ans = pow(3,n);
  fset(n);
  var p2 = 1;
  for(var i = n, m = n>>1; m < i; i--){
    p2 += p2;
    if(mod <= p2)p2 -= mod;
    ans -= mul(ncr(n,i),p2);
  }
  ans%=mod
  return ans<0?ans+mod:ans;
}

Measured memory_bytes: 168524
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int dp[3030][3030];
int path[3030][3030]; // 左上:1 上:2 左:3

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

    rep(i,s.size()) {
        rep(j,t.size()) {
            if (s[i]==t[j]) {
                dp[i+1][j+1] = dp[i][j]+1;
                path[i+1][j+1] = 1;
            }
            else {
                if (dp[i+1][j]>dp[i][j+1]) {
                    dp[i+1][j+1] = dp[i+1][j];
                    path[i+1][j+1] = 3;
                }
                else {
                    dp[i+1][j+1] = dp[i][j+1];
                    path[i+1][j+1] = 2;

                }
            }
        }
    }
    string ans = "";
    int i = s.size();
    int j = t.size();
    while (i > 0 && j > 0) {
        //cout << i <<  " " << j << endl;
        switch(path[i][j]) {
            case 1:
                --i, --j;
                ans += s[i];
                break;
            case 2:
                --i;
                break;
            case 3:
                --j;
                break;
        }
    }
    reverse(all(ans));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 71936
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int N,ans=0;
	int a[200];
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}

	for(int i=0;i<50;i++){
		for(int j=0;j<N;j++){
			if(a[j]%2==1){
				cout << ans << endl;
				return 0;
			}
			a[j]=a[j]/2;
		}
		ans++;
	}
}

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

int main() {

	std::string s, t;
	std::cin >> s >> t;

	std::vector<std::vector<int>>
		v( s.size() + 1,
			std::vector<int>(t.size() + 1, 0)
		);

	
	for (decltype(s.size()) i{ 1 }; i <= s.size(); ++i) {

		for (decltype(t.size()) j{ 1 }; j <= t.size(); ++j) {

			if (s[i - 1] == t[j - 1])
				v[i][j] = v[i - 1][j - 1] + 1;
			else
				v[i][j] = std::max(v[i][j - 1], v[i - 1][j]);
		}
	}

	/*
	for (auto&&e : v) {
		for (auto&&ee : e)
			std::cout << ee << " ";
		std::cout << "\n";
	}*/

	std::string ans;
	ans.reserve( std::min( s.size(), t.size() ) );
	const decltype(s.size()) size = v[s.size()][t.size()];
//	std::cout << size << "\n";
	auto si = s.size() ;
	auto ti = t.size() ;

	while ( ans.size()<size) {
		
		if (s[si-1] == t[ti-1]) {
//			std::cout << s[si-1] << " ";
			ans += s[si-1];
			--si; --ti;
		}
		else if (v[si][ti] == v[si][ti - 1])
			--ti;
		else if (v[si][ti] == v[si - 1][ti])
			--si;
	}
//	std::cout << ans.size() << "\n";

	auto it = std::crbegin(ans);
	while (it != std::crend(ans)) {
		std::cout << *it;
		++it;
	}
	std::cout << "\n";

	return 0;
}

Measured memory_bytes: 35584
N,M=map(int,input().split())
MOD=(10**9)+7
a=[0 for i in range(N+1)]
for _ in range(M):
  A=int(input())
  a[A]=-1
a[0]=1

for i in range(N):
  if a[i]==-1:
    continue
  if a[i+1]!=-1:
    a[i+1]+=a[i]
    a[i+1]%=MOD
  if i+2<=N and a[i+2]!=-1:
    a[i+2]+=a[i]
    a[i+2]%=MOD
print(a[N])

Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
int main()
{
    int h,n;
    cin >> h >> n;
    
    vector<int> dp(h+1,INF);
    dp[0] = 0;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        rep(j,h){
            int nj = min(j+a,h);
            dp[nj] = min(dp[nj],dp[j]+b);

        }
    }
    cout << dp[h] << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999
#define ll long long int
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;

int main(int argc, char const *argv[])
{
    ll dp[100010];
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }
    rep(i,100010){
        dp[i] = INF;
    }
    dp[0] = 0;
    rep(i, n)
    {
        chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1408
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toLong)

    val result = when (n * m) {
        1L, 3L -> 1L
        2L, 4L, 6L -> 0L
        else -> when {
            n == 1L || m == 1L -> n * m - 2
            else -> m * n - (m * 2 + (n - 2) * 2)
        }
    }
    println(result)
}



Measured memory_bytes: 36076
time = [int(input()) for _ in range(5)]
sub = [0]*5
time = sorted(time, key=lambda x:10-(x%10) if x % 10 != 0 else 0)
total = 0
for n, i in enumerate(time):
    total += i
    if i % 10 != 0 and n != 4:
        total += 10 - (i % 10)
print(total)

Measured memory_bytes: 3060
N,M = map(int,input().split())
S = []
for _ in range(M):
    t , *s = map(int,input().split())
    S.append(s)
P = list(map(int,input().split()))
answer = 0

for i in range(1 << N):
    switch = [0] * N
    
    for j in range(N):
        if (i >> j) & 1:
            switch[j] = 1
    
    for k in range(M):
        cnt = 0
        for l in range(N):
            if switch[l]:
                if (l+1) in S[k]:
                    cnt += 1
        if cnt % 2 != P[k]:
            break
    else:
        answer += 1
print(answer)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

int main() {
  while (true) {
    string text;
    cin >> text;
    if (text == "-") { break; }

    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      int h;
      cin >> h;
      string tmp = text.substr(0, h);
      text.erase(0, h);
      text += tmp;
    }
    cout << text << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: i64 = read();
    if n == 0 {
        println!("{}", 0);
    } else {
        let mut powm2 = vec![0; 48];
        for i in 0..48 {
            powm2[i] = 1<<i;
            if i % 2 == 1 {
                powm2[i] *= -1;
            }
        }

        let mut ans: Vec<i32> = vec![0; 48];
        let abs = n.abs();
        let mut sum: i64 = 0;
        let mut idx = 0;
        if n < 0 {
            idx = 1;
        }

        {
            while sum.abs() < abs {
                sum += powm2[idx];
                ans[idx] = 1;
                idx += 2;
            }
        }
        {
            loop {
                if sum.abs() - (powm2[idx]).abs() >= n.abs() {
                    if ans[idx] == 1 {
                        sum -= powm2[idx];
                    } else {
                        sum += powm2[idx];
                    }
                    ans[idx] ^= 1;
                }
                if idx == 0 {
                    break;
                }
                idx -= 1;
            }
        }
        let mut nonzero = 0;
        for i in (0..48).rev() {
            if ans[i] == 1 {
                nonzero = 1;
            }
            if nonzero == 1 {
                if ans[i] == 0 {
                    print!("0")
                } else {
                    print!("1")
                }
            }
        }
        println!();
    }


    // 1, (-2), 4, (-8), 16, (-32), 64, (-128),...
    // 1   0    1   1    1         = 13
    // 0   1    1   0    1     1   = -13
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,x,z=0,d=0,e=0;
  cin>>a>>b>>x;
  d=x/1000;
  e=x%1000;
  if(a>b){
    if(a>b*2){
      z=x/500;
      x%=500;
      if(x!=0){
	z++;
      }
      cout<<z*b<<"\n";
    }
    else{
      if(e==0){
	cout<<d*a<<"\n";
      }else if(e<=500){
	cout<<d*a+b<<"\n";
      }else{
	if(a>b*2){
	  cout<<d*a+b*2<<"\n";
	}else{
	  cout<<d*a+a<<"\n";
	}
      }
    }
  }
  else{
    if(d==0){
      cout<<a<<"\n";
    }else if(e==0){
      cout<<d*a<<"\n";
    } else{
      cout<<d*a+a<<"\n";
    }
  }
}



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

namespace ConsoleApp
{
    class Program
    {
        static int N, A, B, C;
        static List<int> mp = new List<int>();
        static List<int> ls;

        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var strs = str.Split(' ');
            N = int.Parse(strs[0]);
            A = int.Parse(strs[1]);
            B = int.Parse(strs[2]);
            C = int.Parse(strs[3]);

            ls = new List<int>(N);
            for (int i = 0; i < N; i++)
            {
                ls.Add(int.Parse(Console.ReadLine()));
            }

            var list = new List<int>();
            for (int i = 0; i < N; i++)
            {
                list.Add(0);
            }

            Dfs(0, list);

            Console.WriteLine(mp.Min());
        }

        static void Dfs(int depth, List<int> list)
        {
            if (depth == N)
            {
                Calc(list);
                return;
            }

            for (int i = 0; i < 4; i++)
            {
                list[depth] = i;
                Dfs(depth + 1, list);
            }
        }

        static void Calc(List<int> list)
        {
            if (!list.Contains(0) || !list.Contains(1) || !list.Contains(2))
            {
                return;
            }

            var lA = 0;
            var lB = 0;
            var lC = 0;

            var synthesis = 0;
            for (int i = 0; i < N; i++)
            {
                switch (list[i])
                {
                    case 0:
                        if (lA != 0)
                        {
                            synthesis += 10;
                        }
                        lA += ls[i];
                        break;
                    case 1:
                        if (lB != 0)
                        {
                            synthesis += 10;
                        }
                        lB += ls[i];
                        break;
                    case 2:
                        if (lC != 0)
                        {
                            synthesis += 10;
                        }
                        lC += ls[i];
                        break;
                    default:
                        break;
                }
            }

            mp.Add(Math.Abs(lA - A) + Math.Abs(lB - B) + Math.Abs(lC - C) + synthesis);
        }
    }
}


Measured memory_bytes: 13652
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
-- A
local A = read.nn()
local ans = A*A
print(ans)


Measured memory_bytes: 1132
import sys
input = sys.stdin.readline

def modPow(a, x, p):
    res = 1
    while x > 0:
        if x % 2 != 0:
            res = res * a % p
        a = a * a % p
        x = x // 2
    return res

def modInverse(a, p):
    return modPow(a, p - 2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p


def main():
    X, Y = [int(x) for x in input().split()]

    MOD = 10 ** 9 + 7
    y = (X - 2 * Y) // (-3)
    x = (X - y) // 2

    if y < 0 or x < 0:
        print(0)
        exit()
    if X == x * 2 + y and Y == x + 2 * y:
        print(modBinomial(x + y, x, MOD))
    else:
        print(0)









if __name__ == '__main__':
    main()



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int M;
int D[202020];
ll C[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	ll A=0;
	ll sum=0;
	cin>>M;
	FOR(i,M) {
		cin>>D[i]>>C[i];
		sum+=D[i]*C[i];
		A+=C[i];
	}
	ll ret=A-1;
	if(sum>9) ret+=(sum+8)/9-1;
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

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

int main(){
	string s;
	cin>>s;
	int n=s.length();
	cout<<s[0]<<n-2<<s[n-1];
}

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

constexpr int INF = 2e9;

int main(){
  int n, m;
  cin >> n >> m;
  vector<P> p;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    p.emplace_back(make_pair(a, b));
  }
  sort(p.begin(), p.end());
  ll now = 0;
  ll res = 0;

  for (int i = 0; i < n; i++) {
    if (now == m) break;
    int a = p[i].first, b = p[i].second;
    ll d = min(m - now, (ll)b);
    res += (ll)a * d;
    now += d;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

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

using ll = long long;
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll k;
	ll k50;
	int am;
	ll a[50];
	REP(i, 50){
		a[i] = 49;
	}

	cin >> k;
	k50 = k / 50;
	am = k % 50;
	REP(i, 50){
		a[i] += k50;
		if(i < am){
			a[i] += (50 - am + 1);
		}
		else{
			a[i] -= am;
		}
	}
	cout << "50\n";
	REP(i, 50){
		if(i != 0) cout << " ";
		cout << a[i];
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int a,b,k;
	cin>>a>>b>>k;
	int co=0;
	for(int i=100;i>=0;i--){
	    if(a%i==0 && b%i==0)co++;
	    if(co==k){
	        cout<<i<<endl;
	        return 0;
	    }
	}
}

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

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

using namespace std;

int main() {
    float n;
    cin >> n;

    cout << ceil(n / 2) << endl;
}

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

int main(){

    int A,B;
    cin >> A >> B;
    int ans = -1;

    for (int i = 0; i < 12501; i++) {
        if(floor(i*0.08) == A && floor(i*0.1) == B){
            ans = i;
            break;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
  #define assert(e) if(!(e)){stod("");}
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  int n, k;
  scan(n, k);
  vi p(n);
  scan(p);
  sort(all(p));
  ll ans = 0;
  rep (i, k) {
    ans += p.at(i);
  }
  print(ans);
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 3248
const B = 'JPY';
var n,i,j :integer; c:char; s:packed array[1..3] of char; a,x,y,z:real;
begin
  x:=0.0;y:=0.0;
  readln(n);
  for i:=1 to n do begin
    j:=1;
    read(a); read(c);
    repeat read(c); s[j]:=c; j:=j+1 until eoln;
    if (s = B) then x:=x+a else y:=y+a
  end;
  z:=1.0*x+380000.0*y;
  write(z)
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	string s;
	cin >> s;
	int N = s.size();
	int P = 0;
	rep(i, 0, N) if(s[i] == 'p') P++;

	cout << N / 2 - P << endl;


}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
constexpr ll mod[2] = {1000000007,998244353};
struct rolling_hash{
	ll z = 100,ex[2][100010];
	vector<ll> v,w[2];
	rolling_hash(string &s){
		int i,j,n = s.size();
		for(i=0;i<n;i++){
			v.push_back(s[i] - 'a' + 1);
		}
		w[0].assign(n + 1,0),w[1].assign(n + 1,0);
		ex[0][0] = 1,ex[1][0] = 1;
		for(i=0;i<n;i++){
			for(j=0;j<2;j++){
				w[j][i + 1] = (w[j][i]*z + v[i])%mod[j];
				ex[j][i + 1] = ex[j][i]*z%mod[j];
			}
		}
	}
	inline ll get(int l, int r){//[l,r)
		//ll x = (w[0][r] - ex[0][r - l]*w[0][l]%mod[0] + mod[0])%mod[0];
		ll y = (w[1][r] - ex[1][r - l]*w[1][l]%mod[1] + mod[1])%mod[1];
		return y;
		//return {x,y};
	}
};

string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,j,n,ans = 0;
	cin >> n >> s;
	rolling_hash rh(s);
	for(i=0;i<n;i++){
		for(j=i + 1;j<n;j++){
			if(s[i]!=s[j]) continue;
			int l = 0,r = min(j - i,n - j);
			if(rh.get(i,i + r)==rh.get(j,j + r)){
				ans = max(ans,r);
				continue;
			}
			while(r - l>1){
				int mid = (l + r)/2;
				if(rh.get(i,i + mid)==rh.get(j,j + mid)) l = mid;
				else r = mid;
			}
			ans = max(ans,l);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    rep(i,n){
        int x;
        cin >> x;
    }
    cout << (n+m-3)/(m-1)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

#define N 8

const int n;
const int x[N], y[N];

int factorial(int i){
  if(i==0){
    return 1;
  }
  else{
    return i*factorial(i-1);
  }
}

double totalDist(int *route){
  double sum=0.0;
  for(int k=0; k<n-1; k++){
    int dx = x[route[k+1]] - x[route[k]];
    int dy = y[route[k+1]] - y[route[k]];
    sum += sqrt(dx*dx + dy*dy);
  }
  return sum;
}

int permSearch(int a, int *isPass, int *route, double *ave){
  if(a==n){
    *ave += totalDist(route);
  }
  else{
    for(int i=0; i<n; i++){      
      if(isPass[i]==1){
        isPass[i] = 0;
        route[a] = i;
        permSearch(a+1, isPass, route, ave);
        isPass[i]=1;
      }
    }
  }  
  return 0;
}

int main(){
  scanf("%d",&n);
  for(int i=0; i<n; i++){
    scanf("%d %d", &x[i], &y[i]);
  }
  
  int route[n], isPass[n];   // isPass[]=0 : have passed, isPass[]=1 : haven't passed yet 
  double ave=0;
  for(int i=0; i<n; i++){
    isPass[i]=1;
  }
  permSearch(0, isPass, route, &ave);
  
  ave /= factorial(n);
  printf("%lf",ave);  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

int main(int argc, char const* argv[])
{
    string S;
    cin >> S;
    if(S == "Sunny")
        cout << "Cloudy" << endl;
    if(S == "Cloudy")
        cout << "Rainy" << endl;
    if(S == "Rainy")
        cout << "Sunny" << endl;


    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.a = Long.parseLong(sa[0]);
			o.b = Long.parseLong(sa[1]);
			arr[i] = o;
		}
		br.close();

		for (Obj o : arr) {
			if (o.a != 0 || o.b != 0) {
				long gcd = gcd(o.a, o.b);
				o.a /= gcd;
				o.b /= gcd;
				if (o.a < 0) {
					o.a *= -1;
					o.b *= -1;
				}
			}
		}

		int zero = 0;
		Map<Obj, Integer> map = new HashMap<>();
		for (Obj o : arr) {
			if (o.a == 0 && o.b == 0) {
				zero++;
			} else {
				if (map.containsKey(o)) {
					map.put(o, map.get(o) + 1);
				} else {
					map.put(o, 1);
				}
			}
		}

		int mod = 1000000007;
		long ans = 1;
		Obj[] keys = map.keySet().toArray(new Obj[0]);
		for (Obj k : keys) {
			if (!map.containsKey(k)) {
				continue;
			}
			int v1 = map.get(k);
			long a = power(2, v1, mod);

			Obj k2 = new Obj();
			if (k.b > 0) {
				k2.a = k.b;
				k2.b = -k.a;
			} else if (k.b == 0) {
				k2.b = 1;
			} else {
				k2.a = -k.b;
				k2.b = k.a;
			}
			Integer v2 = map.get(k2);
			if (v2 != null) {
				long a2 = power(2, v2, mod) - 1;
				a += a2;
				map.remove(k2);
			}
			ans *= a;
			ans %= mod;
		}
		ans--;
		ans += zero + mod;
		ans %= mod;
		System.out.println(ans);
	}

	static class Obj {
		long a, b;

		@Override
		public boolean equals(Object o) {
			Obj o2 = (Obj) o;
			if (a == o2.a && b == o2.b) {
				return true;
			}
			return false;
		}

		@Override
		public int hashCode() {
			return (int) (31 * a + b);
		}
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			val = val * x % m;
		}
		return val;
	}

	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}


Measured memory_bytes: 66232
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main(void){

    string target, str;
    int answer = 0;
    cin >> target;
    transform(target.begin(), target.end(), target.begin(), ::toupper);

    while (true) {
        cin >> str;
        if (str == "END_OF_TEXT") {
            break;
        }
        transform(str.begin(), str.end(), str.begin(), ::toupper);
        if (target == str) {
            answer++;
        }
    }
    cout << answer << endl;
}

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

namespace {
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define LEN(x) (int)((x).size())
#define X first
#define Y second

#define FOR(i, begin, end)  \
  for (__typeof(end) i = (begin) - ((begin) > (end));  \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

  
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>;

ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

struct IOS { IOS() { ios::sync_with_stdio(0); cin.tie(0); } } IOS;
}

const int MAX_N = 200000;
const ll MODD = 1000000009LL;
const ld EPS = 1e-9;

int main() {
	ll N, x;
	cin >> N >> x;
	
	vll a(N);
	FOR(i,0,N) cin >> a[i];
	
	vector<vector<ll>> cost(N, vll(N, LLONG_MAX));
	
	// Best cost for slime i using up to j cylic shifts
	FOR(i, 0, N) FOR(j, 0, N) {
		if (j == 0)
			cost[i][j] = a[i];
		else {
			cost[i][j] = min(cost[i][j-1], a[(i - j + N) % N]);
		}
	}
	
	ll best = LLONG_MAX;
	
	// Try all number of cyclic shifts
	FOR(j, 0, N) {
		ll cur = j * x;
		FOR(i, 0, N) cur += cost[i][j];
		best = min(best, cur);
	}

	cout << best << endl;

}


Measured memory_bytes: 31616
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N, Q, A[100000], X[100000], cs1[100001], cs2[100000];
    cin >> N >> Q;
    REP(i, N) cin >> A[i];
    REP(i, Q) cin >> X[i];
    cs1[0] = 0, cs2[0] = A[0], cs2[1] = A[1];
    REP(i, N) cs1[i + 1] = A[i] + cs1[i];
    FOR(i, 2, N) cs2[i] = A[i] + cs2[i - 2];

    map<ll, ll> bm;
    REP(i, (N - 1) / 2) {
        ll r = N - i - 2, l = r - i - 1;
        ll b = (A[r] + A[l]) / 2 + 1;
        ll index = N;
        bm[b] += cs1[index] - cs1[index - i - 1];
        index -= 2 * i + 3;
        bm[b] += cs2[index];
    }

    ll sum = 0;
    REP(i, (N + 1) / 2) sum += A[N / 2 + i];

    REP(q, Q) {
        ll x = X[q];
        auto it = bm.upper_bound(x);
        if (it == bm.begin()) cout << sum << endl;
        else cout << (--it)->second << endl;
    }

    return 0;
}

Measured memory_bytes: 8576
S = input()
SENW = ['S','N','E','W']
dic = {}
for s in SENW:
    dic[s] = 0
for s in S:
    dic[s] += 1

ch = 0
if dic['S'] > 0:
    if dic['N'] == 0:
        ch = 1

if dic['N'] > 0:
    if dic['S'] == 0:
        ch = 1

if dic['E'] > 0:
    if dic['W'] == 0:
        ch = 1

if dic['W'] > 0:
    if dic['E'] == 0:
        ch = 1


if ch == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	int s, w;
	cin >> s >> w;
	if (w>=s) cout << "unsafe\n";
	else cout << "safe\n";
}

Measured memory_bytes: 3620
// AtCoder Grand Contest 019
// A - Ice Tea Store

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


ll Q, H, S, D;
ll N;

int main() {

    ll l1, l2;

    cin >> Q >> H >> S >> D;
    cin >> N;

    l1 = min(Q * 4, H * 2);
    l1 = min(l1, S);
    l2 = min(l1 * 2, D);

    cout << (N / 2 * l2) + (N % 2 * l1) << endl;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int s,m=0,h=0;
	cin>>s;
	if(s>=60){
		m=s/60;
		s=s%60;

	}
		if(m>=60){
		h=m/60;
		m=m%60;

	}

	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;

}

Measured memory_bytes: 1164