akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    string s;
    ci >> s;

    string a = ""; a += s[0]; a += s[1];
    string b = ""; b += s[2]; b += s[3];

    if("00" < a && a < "13" && "00" < b && b < "13") {
	co << "AMBIGUOUS" << en;
    } else if("00" < a && a < "13") {
	co << "MMYY" << en;
    } else if("00" < b && b < "13") {
	co << "YYMM" << en;
    } else {
	co << "NA" << en;
    }
    
    return 0;
}


Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
hlst=list(map(int,input().split()))

tmplst=[]
for i in range(n):
    tmp=abs(t-hlst[i]*0.006-a)
    tmplst.append(tmp)


print(tmplst.index(min(tmplst))+1)

Measured memory_bytes: 3060
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;
use std::io::*;

fn main() {
    let n = read().parse::<i64>().unwrap();

    println!("0");
    stdout().flush().ok();

    let s0 = read();
    if &s0 == "Vacant" {
        return;
    }
    
    println!("{}", n-1);
    stdout().flush().ok();
    let sn = read();
    if &sn == "Vacant" {
        return;
    }
    
    let mut head = 1;
    let mut tail = n-1;
    for _ in 1..20 {
        let now = (head + tail + 1) / 2;
        println!("{}", now);
        stdout().flush().ok();
        let s = read();
        if &s == "Vacant" {
            return;
        }

        if (now % 2 == 0) == (s == s0) {
            head = now + 1;
        } else {
            tail = now - 1;
        }
    }
}

fn read() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}


Measured memory_bytes: 3824
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Map<Integer, Long> m = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (m.containsKey(a[i])) {
                if (m.get(a[i]) == 0L) {
                    m.put(a[i], 1L);
                } else {
                    m.put(a[i], 0L);
                }
            } else {
                m.put(a[i], 1L);
            }
        }

        long ans = 0;
        for (Entry<Integer, Long> ent : m.entrySet()) {
            ans += ent.getValue();
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 56748
H, W = map(int, input().split())
s = []
for i in range(H):
    s_i = input()
    s.append([s_i[i] for i in range(len(s_i))])
direction = [[1, 0], [-1, 0], [0, -1], [0, 1]]
for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            # check isolated
            is_isolated = True
            for arrow in direction:
                neigh = [i + arrow[0], j + arrow[1]]
                if neigh[0] == -1 or neigh[0] == H or neigh[1] == -1 or neigh[1] == W:
                    continue
                if s[neigh[0]][neigh[1]] == "#":
                    is_isolated = False
                    break
            if is_isolated:
                print("No")
                exit()
print("Yes")


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

using namespace std;
using ll = long long;


int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n); for(int i = 0; i < n; i++)cin >> a[i];
	int nin = 2e9;
	sort(a.begin(), a.end());
	for(int i = k - 1; i < n; i++) {
		nin = min(nin, a[i] - a[i - k + 1]);
	}
	cout << nin << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 100005
using namespace std;
typedef long long ll;
int n,tt,a[MN],b[MN],cnt[MN];
ll sumx,sumy,now,ans;
struct node{
	int x,y;
	friend bool operator<(node x,node y){return x.x<y.x;}
}num[MN<<1];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),num[++tt]=((node){a[i],i}),num[++tt]=((node){b[i],i}),sumx+=a[i],sumy+=b[i];
	sort(num+1,num+2*n+1);
	for(int i=1;i<=n;i++)now+=num[i].x,cnt[num[i].y]++;
	ans=min(sumx,sumy);
	for(int i=1;i<=n;i++)if(cnt[i]>1)return 0*printf("%lld\n",min(ans,now));
	--cnt[num[n].y],++cnt[num[n+1].y];if(cnt[num[n+1].y]>1)return 0*printf("%lld\n",min(ans,now-num[n].x+num[n+1].x));
	printf("%lld\n",min(ans,min(now-num[n-1].x+num[n+1].x,now-num[n].x+num[n+2].x)));
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T &val) {
    fill((T *)ary, (T *)(ary + size), val);
}

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;
    vector<i64> a(N);
    rep(i,0,N) cin >> a[i];

    map<i64,i64> cnt;
    rep(i,0,N) ++cnt[a[i]];

    if(cnt.size()==1){
        if(cnt[0]==N) cout << "Yes" << endl;
        else cout << "No" << endl;
        return;
    }

    if(N%3!=0){
        cout << "No" << endl;
        return;
    }

    if(cnt.size()==2){
        if(cnt[0]*3==N) cout << "Yes" << endl;
        else cout << "No" << endl;
        return;
    }

    if(cnt.size()!=3){
        cout << "No" << endl;
        return;
    }

    vector<i64> v;
    for(auto p:cnt){
        v.emplace_back(p.first);
    }
    rep(i,0,v.size()){
        if(cnt[v[i]]*3!=N){
            cout << "No" << endl;
            return;
        }
    }

    if((v[0]!=(v[1]^v[2])) and (v[1]!=(v[0]^v[2])) and (v[2]!=(v[0]^v[1]))){
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <climits>
using namespace std;
int main(void){
    long long D,G;
    cin >> D >> G;
    long long P[D];
    long long C[D];
    
    for(int i = 0; i < D; i++)cin >> P[i] >> C[i];
    long long cont = 0;
    long long sum = 0;
    long long PP[D];
    for(int i = 0; i < D; i++)PP[i] = P[i];
    
    long long ans = LLONG_MAX;
    
    //満点をとる帯域を決める
    for(int bit = 0; bit < (1<<D);bit++){
        
        for(int i = 0; i < D;i++){
            //cout << C[i] << endl;
            if(bit & (1<<i)){
                sum  += C[i];
                sum  += P[i]*100*(i+1);
                cont += P[i];
                P[i] = 0;        
                
            }
            
        }
        
        //cout <<sum <<" "<< cont << endl;
        if(sum<G){
            for(int i = D-1; i >=0;i--){
                //cout << i << endl;
                for(int j = 0; j < P[i];j++){
                    if(P[i]==0)continue;
                    if(sum >= G)continue;
                    cont++;
                    sum += (i+1)*100;
                    
                }
                
            }
            
        }
        
        if(G<=sum)ans = min(ans,cont);
        
        for(int i = 0; i < D; i++)P[i] = PP[i];
        cont = 0;
        sum = 0;
        
    }
    
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
A,B = map(int,input().split())
cnt = 0
for i in range(A,B+1):
  a = i//10000
  i = i%10000
  b = i//1000
  i = i%1000
  c = i//100
  i = i%100
  d = i//10
  e = i%10
  if b==d and a==e:
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e14 + 7;
ll inf = 1e14 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}





int main() {
    ll h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw; ch--; cw--; dh--; dw--;
    vector<vector<ll>>vec(h, vector<ll>(w, inf));
    vector<vector<bool>> mapp(h, vector<bool>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char c;
            cin >> c;
            if (c == '.')mapp[i][j] = 1;
        }
    }
    set<pair<ll,ll>>bfs;
    bfs.insert({ 0, ch * w + cw });
    while (!bfs.empty()) {
        auto g = *bfs.begin();
        bfs.erase(bfs.begin());
        int x = g.second % w;
        int y = g.second / w;
        vec[y][x] = min(g.first, vec[y][x]);
        if (x + 1 < w && x + 1 >= 0 && mapp[y][x + 1] == 1) {
            if (vec[y][x + 1] > vec[y][x]) {
                bfs.insert({ vec[y][x] , (y)*w + x + 1, });
            }
        }
        if (x - 1 < w && x - 1 >= 0 && mapp[y][x - 1] == 1) {
            if (vec[y][x - 1] > vec[y][x]) {
                bfs.insert({ vec[y][x] , (y)*w + x - 1});
            }
        }
        if (y + 1 < h && y + 1 >= 0 && mapp[y + 1][x] == 1) {
            if (vec[y + 1][x] > vec[y][x]) {
                bfs.insert({ vec[y][x], (y + 1) * w + x });
            }
        }
        if (y - 1 < h && y - 1 >= 0 && mapp[y - 1][x] == 1) {
            if (vec[y - 1][x] > vec[y][x]) {
                bfs.insert({vec[y][x], (y - 1) * w + x });
            }
        }
        for(int i = -2; i <=2;++i)
            for (int j = -2; j <= 2; ++j) {
                if (x + i < w && x + i >= 0 && y + j < h && y + j >= 0 && vec[y + j][x + i] > vec[y][x] + 1 && mapp[y + j][x + i] == 1) {
                    bfs.insert({ vec[y][x] + 1, (y + j) * w + x + i });
                }
            }
    }
    if (vec[dh][dw] >= inf)
        cout << -1;
    else
        cout << vec[dh][dw];
}

Measured memory_bytes: 12384
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,K = I(),I()
ans = 10**6
for i in range(N+1):
    a = 2**i
    a += K*(N-i)
    ans = min(ans,a)

print(ans)


Measured memory_bytes: 61940
#include <set>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>

using namespace std;

int N = 1000;
int K = 8;

set<char> acceptable;

int solve(const string& buf) {
    if (!buf.empty()) {
        int i = stoi(buf);
        if (i >= N) {
            return i;
        } else if (i == 0) {
            return 99999999;
        }
    }

    vector<int> res;
    for (const char& c: acceptable) {
        int r = solve(buf + c);
        res.push_back(r);
    }

    return *min_element(res.begin(), res.end());
}

int main() {
    const set<char> all_num = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

    set<char> yack;
    cin >> N >> K;
    for (int i = 0; i < K; i++) {
        int b;
        scanf("%d", &b);
        yack.insert(b + '0');
    }

    set_difference(all_num.begin(), all_num.end(),
                   yack.begin(), yack.end(),
                   inserter(acceptable, acceptable.end()));

    cout << solve("") << endl;
}


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

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

  vector<char> ans;

  while(N>0){
    N--;
    ll c = N%26;
    N++;
    ans.push_back(c+'a');
    N -= c;
    N /= 26;
    if(N==0)break;
  }

  reverse(all(ans));

  for(char x: ans){
    cout<<x;
  }
  cout<<endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
 
using namespace std;
 
int main(){
    int m,f,r;
    char grade;
    while(true){
        scanf("%d %d %d",&m,&f,&r);
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1){
            grade = 'F';
        }else if(m+f >= 80){
            grade = 'A';
        }else if(m+f >= 65){
            grade = 'B';
        }else if(m+f >= 50){
            grade = 'C';
        }else if(m+f >= 30){
            grade = (r >= 50)? 'C':'D';
        }else{
            grade = 'F';
        }
        printf("%c\n",grade);
    }
}




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

int main() {
  int N;
  string S;
  int X = 1;
  cin >> N >> S;
  for(int i=0; i<N-1; i++){
    if(S.at(i) != S.at(i+1)) X++;
  }
  cout << X << endl;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ds = readLine()!!.split(" ").map { it.toLong() }
    val sum = ds.sum()
    val subSum = (1..(n - 2) step 2).map { ds[it] }.sum() * 2L
    val xs = LongArray(n)
    xs[0] = sum - subSum
    for (i in 1 until n) {
        xs[i] = (ds[i - 1] - xs[i - 1] / 2) * 2
    }
    println(xs.joinToString(" "))
}

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    string s, t;
    cin >> s >> t;
    REP(i, 3){
        if(s[i]==t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int flag[105][105];
int main()
{
	int a=read()-1,b=read()-1;
	for (int i=1;i<=50;i++)
		for (int j=1;j<=100;j++) flag[i][j]=1;
	for (int i=1;i<=50;i+=2)
		for (int j=1;j<=100;j+=2)
		{
			if ((a--)<=0) break;
			flag[i][j]=0;
		}
	for (int i=52;i<=100;i+=2)
		for (int j=1;j<=100;j+=2)
		{
			if ((b--)<=0) break;
			flag[i][j]=1;
		}
	puts("100 100");
	for (int i=1;i<=100;i++)
	{
		for (int j=1;j<=100;j++) printf("%c",flag[i][j]?'#':'.');
		puts("");
	}
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

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

int main() {
  ll n, q; string s; 
  cin >> n >> q >> s;

  
  vector<int> sum(n+1, 0);
  rep(i, n) {
      if (s[i] == 'A' && s[i+1] == 'C') sum[i+1] = sum[i] + 1;
      else sum[i+1] = sum[i];
  }
  
  vector<pair<int, int>> l_r(q); int ans[q];
  rep(i, q) {
      cin >> l_r[i].first >> l_r[i].second;
      ans[i] = sum[l_r[i].second-1] - sum[l_r[i].first-1];
  }

  /* debug */
//   rep(i, n+1) {
//       cout << sum[i] << endl;
//   }

  rep(i, q) {
      cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define PI (acos(-1.0))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); 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;}
// head

int main() {
	ll n, sum = 0;
	scanf("%lld", &n);
	rep(i,1,n+1){
		rep(j,1,n+1){
			rep(k,1,n+1){
				sum += gcd(gcd(i, j), k);
			}
		}
	}
	printf("%lld", sum);
	return 0; 
}


Measured memory_bytes: 3824
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;
#define DEBUG 0
#define lli long long int

const lli N_MAX = 100001;
lli N;
lli H[N_MAX];
lli ans = 0;


int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> H[i];
	lli count = 0;
	for (int i = 0; i < N - 1; i++) {
		if (H[i] >= H[i + 1]) {
			count += 1;
		}
		else {
			ans = max(ans, count);
			count = 0;
		}
	}
	ans = max(ans, count);
	cout << ans << endl;
}

Measured memory_bytes: 1024
n = int(input())
s = input()
 
m = [[0] * n for _ in range(n)]
lcs = 0
 
for j in range(1, n):
    if s[j] == s[0]:
        m[0][j] = 1
        lcs = 1
 
for i in range(1, n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            m[i][j] = min(m[i-1][j-1] + 1, j - i)
            lcs = max(m[i][j], lcs)
        else:
            m[i][j] = 0
 
print(lcs)

Measured memory_bytes: 230536
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, ct, i, j, k;
	cin >> n;
	vector<long double> x(n), y(n);
	long double s, ans;
	vector<int> id(n);
	for (i = 0; i < n; i++) id[i] = i;
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];
	ct = 0;
	s = 0;
	do {
		ct++;
		for (i = 1; i < n; i++) s += sqrt((x[id[i]] - x[id[i - 1]]) * (x[id[i]] - x[id[i - 1]]) + (y[id[i]] - y[id[i - 1]]) * (y[id[i]] - y[id[i - 1]]));
	} while (next_permutation(id.begin(), id.end()));

	ans = s * 1.0 / ct;
	cout << setprecision(10) << fixed << ans << "\n";


	return 0;
}



Measured memory_bytes: 888
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++) // for loop
#define RREP(x,l,u) for(ll x = l;x>=u;x--) // reverse for loop

/**
 *  debugging stuff
 */
string to_string(string s) {return s;}
string to_string(char c) {return string(1,c);}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

/**
 *  more debugging stuff
 */
void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL; 
typedef pair<ll,ll> PLL;
typedef vector<string> VS;

template <typename A, typename B> void in(A & a, B & b) { in(a); in(b); }
template <typename A, typename B, typename C> void in(A & a, B & b, C & c) { in(a); in(b); in(c); }

const ll inf = (ll)1e18 + 5;

ll N, W;
VLL weights, values;
VVLL memoize;

ll get_value(ll index, ll weight) {

    if (weight < 0) return -inf;

    if (index == -1) return 0;

    if (memoize[index][weight] != -1) return memoize[index][weight];
    
    memoize[index][weight] = max(get_value(index - 1, weight), values[index] + get_value(index-1, weight - weights[index]));

    return memoize[index][weight];
}

namespace SOLVE {	
	void main() {
        cin >> N >> W;

        REP(i,0,N) {
            ll w, v;

            cin >> w >> v;

            weights.push_back(w);
            values.push_back(v);
        }

        memoize.resize(N,VLL(W+1,-1));

        ll maximum = get_value(N-1, W);

        cout << maximum << endl;
	}
}

signed main() {
	ll t;
	t = 1;
    // cin >> t;
	REP(i,0,t) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ins(s);
    // vl A(n); in1(A); 
    ll n= s.size();
    ll f=1;
    if(n%2==0){
        REP(i,n/2){
            if(s[i*2]=='h' && s[i*2+1]=='i'){}
            else f=0; 
        }
    }else f=0;
    if(f) out("Yes");
    else out("No");
}

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

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int dp[100000];

int main()
{
    int h,n;
    cin >> h >> n;
    int a[n],b[n];
    int m=0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        m = max(m,a[i]);
    }
    for(int i = 0; i < 100000; i++){
        dp[i] = inf;
    }
    dp[0] = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < n; j++){
            dp[i+a[j]] = min(dp[i+a[j]],dp[i]+b[j]);
        }
    }
    int ans = inf;
    for(int i = 0; i < m; i++){
        ans = min(ans,dp[h+i]);
    }
    cout << ans;
}

Measured memory_bytes: 640
#include <cstdio>
int main(){
	int n,m,a,p,i,x;
	for(;scanf("%d%d",&n,&m),n|m;printf("%d\n",x)){
		int a[2001]={},b[2001]={};
		for(x=p=i=0;i<n;++i)
			scanf("%d",a+i);
		for(i=0;i<m;++i)
			scanf("%d",b+i);
		for(;p<n-1;p+=a[p])
			p+=b[x++];
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
//#define Nmax 50005
using namespace std;
static const int INF = (1<<29);
static const int Nmax = 50005;
int T[50005];
int main()
{
    int n,m;
    int a[21];
    scanf("%d%d",&n,&m);

    for(int i=1;i<=m;i++)
        scanf("%d",&a[i]);

    for(int i=0;i<=Nmax;i++)
        T[i] = INF;
    //memset(T,-1,sizeof(T));
    T[0] = 0;
    for(int i=1;i<=m;i++)
    {
        for(int j=0;j+a[i]<=n;j++)
        {
            T[j+a[i]] = min(T[j+a[i]],T[j]+1);
        }
    }
    printf("%d\n",T[n]);
    return 0;
}

Measured memory_bytes: 3416
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }


int main() {
    string s;
    cin >> s;
    rep(i, 2) {
        rep(j, 2) {
            rep(k, 2) {
                int num = s[0] - '0';
                (i == 0) ? num += s[1] - '0' : num -= s[1] - '0';
                (j == 0) ? num += s[2] - '0' : num -= s[2] - '0';
                (k == 0) ? num += s[3] - '0' : num -= s[3] - '0';
                if (num == 7) {
                    cout << s[0] << ((i == 0) ? "+" : "-") << s[1] << ((j == 0) ? "+" : "-") << s[2] << ((k == 0) ? "+" : "-" ) << s[3] << "=7";
                    return 0;
                }
            }
        }
    }
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
lli modexp(lli x, lli y)
{
	lli res = 1ll;
	while (y > 0ll)
	{
		if (y & 1ll)
			res = (res * x) % MOD;
		x = (x * x) % MOD;
		y >>= 1ll;
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int s = 0; lli res = 0ll;
	cin >> s;
	vector<lli> a(s + 1);
	a[0] = 1ll;
	for (int i = 1; i <= s; ++i)
		a[i] = (1ll * i * a[i - 1]) % MOD;
	auto NCR = [&](lli n, lli r)
	{
		return a[n] * modexp(a[n - r], MOD - 2) % MOD * modexp(a[r], MOD - 2) % MOD;
	};
	for (int i = s / 3; i > 0; --i)
		res = (res + NCR(i + s - 3 * i - 1, i - 1)) % MOD;
	if (res < 0ll)
		res += MOD;
	cout << res << endl;
}

Measured memory_bytes: 3616
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll h;
	cin>>h;
	if(h==1)
	{
		cout<<"1"<<endl;
	}
	else if(h<=0)
	{
		cout<<"0"<<endl;	
	}
	else 
	{
		ll cnt=1;
		ll ans=0;
		while(h!=1)
		{
			h/=2;
			ans+=cnt;
			cnt*=2;
		}
		ans+=cnt; 
		cout<<ans<<endl;
	}
	return 0;
}


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

const long long MOD = 1e9 + 7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;

    vector<long long> neg, pos;
    for (int i = 0; i < n; i++){
        long long a;
        cin >> a;

        if (a < 0)
            neg.push_back(a);
        else
            pos.push_back(a);
    }

    if (n == k){
        long long ans = 1;
        for (auto i: neg)
            ans = (ans * i) % MOD;
        for (auto i: pos)
            ans = (ans * i) % MOD;

        while (ans < 0)
            ans += MOD;

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

    if (k % 2 && (int) pos.size() == 0){
        sort(neg.begin(), neg.end(), greater<long long>());

        long long ans = 1;
        for (int i = 0; i < k; i++)
            ans = (ans * neg[i]) % MOD;
        
        while (ans < 0)
            ans += MOD;

        cout << ans << '\n';
    }
    else{
        sort(pos.begin(), pos.end());
        sort(neg.begin(), neg.end());

        long long ans = 1;
        if (k % 2){
            ans *= pos.back();
            ans %= MOD;
            pos.pop_back();
            k -= 1;
        }

        reverse(pos.begin(), pos.end());
        
        vector<long long> mul;
        for (int i = 0; i < (int) pos.size() && i + 1 < (int) pos.size(); i += 2)
            mul.push_back((pos[i] * pos[i + 1]));

        for (int i = 0; i < (int) neg.size() && i + 1 < (int) neg.size(); i += 2)
            mul.push_back((neg[i] * neg[i + 1]));

        sort(mul.begin(), mul.end(), greater<long long>());

        for (int i = 0; i < k / 2; i++)
            ans = ((ans % MOD) * (mul[i] % MOD)) % MOD;

        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 6588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

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

	ll ans = 0;

	// 最初が+ - の2通りを試す

	// まずは+
	ll sum = a[0];
	if (a[0] <= 0) {
		ans += -a[0] + 1;
		sum = 1;
	}
	Rep(i, 1, n) {
		if (sum > 0) {
			// -にしたい
			if (sum + a[i] < 0) {
				sum += a[i];
			}
			else {
				sum += a[i];
				ans += sum + 1;
				sum = -1;
			}
		}
		else {
			// + にしたい
			if (sum + a[i] > 0) {
				sum += a[i];
			}
			else {
				sum += a[i];
				ans += -sum + 1;
				sum = 1;
			}
		}
	}

	// 最初-にする
	ll tmp = 0;
	sum = a[0];
	if (a[0] >= 0) {
		tmp = a[0] + 1;
		sum = -1;
	}
	Rep(i, 1, n) {
		if (sum > 0) {
			// -にしたい
			if (sum + a[i] < 0) {
				sum += a[i];
			}
			else {
				sum += a[i];
				tmp += sum + 1;
				sum = -1;
			}
		}
		else {
			// + にしたい
			if (sum + a[i] > 0) {
				sum += a[i];
			}
			else {
				sum += a[i];
				tmp += -sum + 1;
				sum = 1;
			}
		}
	}

	cout << min(ans, tmp) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#include <fstream>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int main() {
	int i, j, k;
	int N, M, K;

	int ans = 0;
	cin >> N >> M;
	vector<vecI> X(N);
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		X[a].push_back(b);
		X[b].push_back(a);
	}

	vecI color(N,0);
	int d = 0;
	rep(i, 0, N) {
		if (color[i] != 0)continue;
		d++;
		int num = 0;
		color[i] = d;
		
		queue<int> que;
		que.push(i);
		while (que.empty() == false) {
			int p = que.front();
			que.pop();
			num++;
			for (auto q : X[p]) {
				if (color[q] != 0)continue;

				color[q] = d;
				que.push(q);
			}
		}
		ans = max(num, ans);
	}

	cout << ans;
	return 0;
}


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

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


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

int main(){
int N;
cin >> N;
vector<int> vec(N);
for(int i = 0;i < N;i++){
cin >> vec.at(i);
}
sort(vec.begin(), vec.end());
reverse(vec.begin(), vec.end());
int Alice, Bob;
Alice = 0;
Bob = 0;
for(int i = 0; i < N; i++){
if(i %2 == 0){
Alice += vec.at(i);
}
else{
Bob += vec.at(i);
}
}
cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		System.out.print((double) w * h / 2 + " ");
		if (x * 2 == w && y * 2 == h) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

vector<P>E[200000],G[200000];
ll d[200000],e[200000];
int main(){
	int n,m,s,t;cin>>n>>m>>s>>t;s--;t--;
	rep(i,m){
		int u,v,a,b;cin>>u>>v>>a>>b;u--;v--;
		E[u].push_back(P(a,v));E[v].push_back(P(a,u));
		G[u].push_back(P(b,v));G[v].push_back(P(b,u));
	}
	priority_queue<P,vector<P>,greater<P>>que;
	memset(d,0x3f,sizeof(d));
	d[s]=0;que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(d[p.second]!=p.first)continue;
		for(auto u:E[p.second]){
			if(d[u.second]>p.first+u.first){
				d[u.second]=p.first+u.first;
				que.push(P(d[u.second],u.second));
			}
		}
	}
	memset(e,0x3f,sizeof(e));
	e[t]=0;que.push(P(0,t));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(e[p.second]!=p.first)continue;
		for(auto u:G[p.second]){
			if(e[u.second]>p.first+u.first){
				e[u.second]=p.first+u.first;
				que.push(P(e[u.second],u.second));
			}
		}
	}
	deque<P>v;
	rep(i,n){
		v.push_back(P(d[i]+e[i],i));
	}
	sort(v.begin(),v.end());
	ll C=1e15;
	rep(i,n){
		while(v.front().second<i)v.pop_front();
		printf("%lld\n",C-v.front().first);
	}
}

Measured memory_bytes: 26616
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
ll tans(ll s,ll k){
    ll res = 0;
    for(ll i = 0;i <= k;++i){
        for(ll j = 0;j <= k;++j){
            for(ll m = 0;m <= k;++m){
                if(i + j + m == s) res ++;
            }
        }
    }
    return res;
}
ll f(ll s,ll k){
    if(s < 0) return 0;
    if(k >= s) return s+1;
    if(s%2 == 0 && k < s/2) return 0;
    if(s%2 != 0 && k <= s/2) return 0;
    return s+1-(s-k)*2;
}
int main(){
    ll k,s;
    while(scanf("%lld%lld",&k,&s)!=EOF){
       // cout << tans(s,k) << endl;
        ll ans = 0;
        for(ll i = 0;i <= k;++i){
            ans += f(s-i,k);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<utility>
using namespace std;

int W,H;
int c[51][51]={0};
int d[51][51]={0};
int island=0;

bool valid(pair<int,int> a){
    return (a.first>=1 && a.first<=W && a.second>=1 && a.second<=H);
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

void bfs(pair<int,int> s){
    queue<pair<int,int>> Q;

    if(c[s.first][s.second]==1 && d[s.first][s.second]==0 && valid(s)){
        Q.push(s);
        d[s.first][s.second]=1;
        ++island;

        while(!Q.empty()){
            pair<int,int> cur=Q.front();
            Q.pop();

            for(int i=-1;i<=1;++i){
                for(int j=-1;j<=1;++j){
                    pair<int,int> dst=make_pair(cur.first+i,cur.second+j);

                    if(d[dst.first][dst.second]==0 && c[dst.first][dst.second]==1 && valid(dst)){
                        Q.push(dst);
                        d[dst.first][dst.second]=1;
                    }
                }
            }
        }
    }
}

int main(){
    
    while(cin>>W>>H && W!=0){
        for(int i=1;i<=H;++i){
            for(int j=1;j<=W;++j){
                cin>>c[j][i];
            }
        }

        for(int i=1;i<=W;++i){
            for(int j=1;j<=H;++j){
                pair<int,int> start=make_pair(i,j);
                bfs(start);
            }
        }
        cout<<island<<"\n";
        island=0;
        Fill(c,0);
        Fill(d,0);
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> dp(n+1);
    dp[0] = 1;
    dp[1] = 1;
    for(int i=2;i<=n;++i){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3104
#include <stdio.h>

int main()
{
	int i, x, N, K;
	scanf("%d", &N);
	scanf("%d", &K);
	for (i = 0, x = 1; i < N; i++) {
		if (x > K) x += K;
		else x *= 2;
	}
	printf("%d\n", x);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1700
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;


int n,k,a,onepos,onep;

int main(){
    I(n);
    I(k);
    REP(i,n){
        I(a);
        if(a == 1) onep = i;
    }
    if(n == k){
        cout << 1 << endl;
        return 0;
    }

    n--;
    int ret = n/(k-1);
    if (n%(k-1)) ret++;
    cout << ret << endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split().map(&:to_i)

m = A.min
while true do
  a = A.map { |i| i % m if i % m != 0 }.compact
  break if a.empty? || a.min == m
  m = [a.min, m].min
end

puts m


Measured memory_bytes: 24480
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
#include<unordered_set>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100 * 1000 + 47;

LL A[MAX];

void no()
{
	cout << -1 << endl;
	exit(0);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	A[0] = 1;
	FOR(i, 1, n + 1) cin >> A[i];
	LL k = 2;
	if (A[n] != 2) no();

	LL a = 2;
	LL b = 2;

	RFOR(i, n + 1, 1)
	{
		b = b + A[i] - 1;
		a = ((a + A[i - 1] - 1) / A[i - 1]) * A[i - 1];
		b = (b / A[i - 1]) * A[i - 1];
		if (a > b) no();
	}

	cout << a << " " << b << endl;
}

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

void solve(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++){
      cin>>h[i];
  }
  int dp[n];
  dp[0] = 0;
  dp[1] = abs(h[0]-h[1]);
  for(int i=2;i<n;i++){
      dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1];
}


int main(){
  solve();
}

Measured memory_bytes: 4388
#include <iostream>
#include <set>
#include <string>

using namespace std;


int main(){
    int h,w,n;
    cin >> h >> w >> n;
    int a[n];
    int c[h][w];
    int x=0;
    int y=0;
    int d=0;
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            c[i][j]=0;
        }
    }
    int i=0;
    while(i<n){
        c[x][y]=i+1;
        if(x+dx[d]>=h || x+dx[d]<0 || y+dy[d]>=w || y+dy[d]<0){
            d=(d+1)%4;
        }else if(c[x+dx[d]][y+dy[d]]!=0){
            d=(d+1)%4;
        }
        x+=dx[d];
        y+=dy[d];
        a[i]--;
        if(a[i]==0){
            i++;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << c[i][j];
            if (j==w-1){
                cout <<endl;
            }else{
                cout <<" ";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384