akhauriyash/Code-Regression huggingface dataset:
a, b, c, d = list(map(int, input().split()))

def f(a, b, c, d):
    if abs(a - c) <= d:
        return "Yes"
        
    if abs(a - b) <= d and abs(b - c) <= d:
        return "Yes"
    
    return "No"

print(f(a, b, c, d))


Measured memory_bytes: 2940
na = 0
a = []
b = []
n = int(input())

for i in range(n):
    a.append(int(input()))

for i in range(n):
    b.append(a[na])
    if a[na] == 2:
        print(i + 1)
        break
    na = a[na] - 1
else:
    print(-1)

Measured memory_bytes: 13848
use std::cmp::{max, min};

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

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let (n, a, b): (i64, i64, i64) = {
        let t = reads();
        (t[0], t[1], t[2])
    };

    let rep = (n + a - 1) / a;

    if rep > b || a + b - 1 > n {
        println!("-1");
        return;
    }

    let mut ans: Vec<i64> = vec![];

    for i in 0..a {
        ans.push(i);
    }

    let mut base = -1;
    let mut rest = n - a;
    let mut rest_b = b - 1;
    while (rest + a - 1) / a < rest_b {
        rest -= 1;
        rest_b -= 1;
        ans.push(base);
        base -= 1;
    }

    while rest > 0 {
        let c = min(a, rest);
        for i in 0..c {
            ans.push(base - c + 1 + i);
        }
        base -= c;
        rest -= c;
    }

    assert_eq!(n as usize, ans.len());

    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans[i as usize] - base);
    }
    println!();
}


Measured memory_bytes: 11384
#include <stdio.h>
//#define scanf scanf_s

// N個の整数を受け取って逆順に出力
int main()
{
	int iInputN;
	int aiInputValue[100] = { 0 };
	int iCnt;

	scanf("%d", &iInputN);
	
	for (iCnt = 0; iCnt < iInputN; iCnt++)
	{
		scanf("%d", &aiInputValue[iCnt]);
	}
	iCnt--;

	for (;iCnt > 0; iCnt--)
	{
		printf("%d ", aiInputValue[iCnt]);
	}

	printf("%d\n", aiInputValue[0]);
	
	return 0;
}


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

int main() {
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int count=0;
  
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if(i*500+j*100+k*50==X){
          count++;
        }
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int n;cin >> n;
    vector<P> v(n);
    rep(i, n) cin >> v[i].first >> v[i].second;
    int count = 0;
    for(int i = 0;i<n;i++) {
        if(v[i].first==v[i].second)count++;
        else count=0;
        if(count>=3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

int main(void) {
    int N;
    cin >> N;
    VI ts(N);
    rep(i, N) cin >> ts[i];

    int T = accumulate(ALL(ts), 0) + 1;

    // dp[N][T1][T2] = min(t2)
    VVVI dp(2, VVI(T, VI(T, INF)));
    dp[0][0][0] = 0;

    rep(i, N) {
        int cur = i % 2;
        int next = (i + 1) % 2;
        int t = ts[i];
        dp[next] = VVI(T, VI(T, INF));

        rep(j, T) {
            rep(k, T) {
                if (dp[cur][j][k] == INF) continue;
                int cur_t3 = dp[cur][j][k];

                MINUD(dp[next][j + t][k], cur_t3);
                MINUD(dp[next][j][k + t], cur_t3);
                MINUD(dp[next][j][k], cur_t3 + t);
            }
        }
    }

    int ans = INF;
    int i = N % 2;
    rep(j, T) {
        rep(k, T) {
            MINUD(ans, max({j, k, dp[i][j][k]}));
        }
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 66980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10, mod = 1e9 + 7;

int a[maxn], b[maxn];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    cin >> n;
    for (int i = 1; i <= n + 1; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) cin >> b[i];
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        if (a[i] + a[i + 1] >= b[i]){
            ans += b[i];
            b[i] -= a[i];
            if (b[i] < 0) b[i] = 0;
            a[i + 1] -= b[i];
        }else{
            ans += a[i] + a[i + 1];
            a[i] = a[i + 1] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	n++;
	vi t(n), x(n), y(n);
	t[0] = x[0] = y[0] = 0;
	repr(i, 1, n) {
		cin >> t[i] >>x[i]>>y[i];
	}

	rep(i, n-1) {
		if (t[i + 1] - t[i] < (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]))) {
			cout << "No" << endl;
			return 0;
		}

		if (t[i] % 2 == 0) {
			if ((x[i] + y[i]) % 2 != 0) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if ((x[i] + y[i]) % 2 == 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void){
    char S[4] = {};
    scanf("%s",S);
    if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[3]){
        printf("Yes");
        return 0;
    }else if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[3]){
        printf("Yes");
        return 0;
    }else if(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1]){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    a, b, c, x, y = [int(x) for x in input().rstrip().split(" ")]

    a_count = 0
    b_count = 0
    ab_count = 0
    if a + b > 2 * c:
        # abのが割安なら、買えるだけabを買う
        min_pizza = min(x,y)
        ab_count += min_pizza * 2
        x = x - min_pizza
        y = y - min_pizza

    # aを買う
    if c * 2 < a:
        # abでaを用意した方が安いなら
        ab_count += x * 2
    else:
        # aでaを買う
        a_count += x

    # bを買う
    if c * 2 < b:
        # abでbを用意した方が安いなら
        ab_count += y * 2
    else:
        # aでaを買う
        b_count += y

    print(a_count * a + b_count * b + ab_count * c)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve2440();
	}

	public static void solve2440() {
		Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int p = sc.nextInt();
            int pfst = p;
            int out = 0;
            if(0 == n&&0 == p){
                break;
            }
            int[] s = new int[n];
            int i = 0;
            while(true){
            	if((s[i]>0&p>0)||(s[i]==0&p>0) ) {
		        	s[i]+=1;
		        	p-=1;
		        }
            	else if(p==0&s[i]>0) {
		        	p=s[i];
		        	s[i]=0;
		        }
	        	for(int j=0;j<n;j++) {
	        		if(s[j]==pfst) {
	        			System.out.println(j);
	        			pfst = 0;
	        			break;
	        		}
	        	}
		        if(pfst==0) {
		        	break;
		        }
		        i++;
		        if(i==n) {
		        	i=0;
		        }
            }
        }

	}

}



Measured memory_bytes: 27268
#include<cstdio>
int a1;
int a[6];
int main()
{
	scanf("%d",&a1);
	a[1]=a1%10;
	a1/=10;
	a[2]=a1%10;
	a1/=10;
	a[3]=a1%10;
	a1/=10;
	a[4]=a1%10;
	for(int i=1;i<4;i++)
		if(a[i]==a[i+1])
		{
			printf("Bad");
			return 0;
		}
	printf("Good");
}


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

template <class T1, class T2>
using dict = std::unordered_map<T1, T2>;

int main(){
    char c;
    cin >> c;
    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u') cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

D1 = 0
for i in range(n):
    D1 += abs(x[i] - y[i])
D2 = 0
for i in range(n):
    D2 += (x[i] - y[i]) ** 2
D2 = math.sqrt(D2)
D3 = 0
for i in range(n):
    D3 += (abs(x[i] - y[i])) ** 3
D3 = math.pow(D3, 1.0/3.0)
Dinf = []
for i in range(n):
    Dinf.append(abs(x[i]- y[i]))
Dinf = max(Dinf)

print(format(D1, '.6f'))
print(format(D2, '.6f'))
print(format(D3, '.6f'))
print(format(Dinf, '.6f'))


Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	int H,W,K;cin>>H>>W>>K;
  vector<string> c(H);
  rep(i,H)cin>>c[i];
  int ans=0;

  for(int i=0; i<(1<<H); i++){
    for(int j=0; j<(1<<W); j++){
      int cnt = 0;
      for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
          if(i&(1<<h) || j&(1<<w))continue;
          if(c[h][w]=='#')cnt++;
        }
      }

      if(cnt==K)ans++;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a, v, b, w, t;
    cin>>a>>v>>b>>w>>t;
    if(a<b){
        if(a+v*t>=b+w*t)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }else if(a>b){
        if(a-v*t<=b-w*t)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }    
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int main(){
  string S;
  cin >> S;

  map<int, int> num;
  int cnt = 0;

  for(int i = 1; i < S.size(); i++){
    cnt++;

    if((S[i-1] == 'R' && S[i] == 'L') && (i == (S.size() - 1))){
      num[i-1] += (cnt/2) + (cnt%2);
      num[i] += cnt/2 + 1;
      cnt = 0;
    } else if((S[i-1] == 'R' && S[i] == 'L')){
      num[i-1] += (cnt/2) + (cnt%2);
      num[i] += cnt/2;
      cnt = 0;
    } else if(S[i-1] == 'L' && S[i] == 'R'){
      num[i-cnt] += (cnt/2) + (cnt%2);
      num[i-cnt-1] += (cnt/2);
      cnt = 0;
    }else if(i == (S.size() - 1)){
      cnt++;
      num[S.size()-cnt] += (cnt/2) + (cnt%2);
      num[S.size()-cnt-1] += (cnt/2);
    } 
  }

  for(int i = 0; i < S.size(); i++) cout << num[i] << " ";

  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct BinomialCoefficient  {
    BinomialCoefficient() {
        
    }
    
    BinomialCoefficient(int n) : fac(n + 2), finv(n + 2), inv(n + 2) {
        initialize(n, false);
    }
    
    void initialize(int n, bool resize = true) {
        if (resize) {
            fac.resize(n + 2);
            finv.resize(n + 2);
            inv.resize(n + 2);
        }
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    
    ll factorial(int n) {
        return fac[n];
    }
    
    ll combination(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
    
    ll permutation(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * finv[n - r] % mod;
    }
    
private:
    int mod = 1e9 + 7;
    vector<ll> fac, finv, inv;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll apb = (x + y) / 3;
    ll a = y - apb;
    ll b = x - apb;
    BinomialCoefficient bc(a + b);
    cout << bc.combination(a + b, a) << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
long long N, A, B;
void solve() {
    cin >> N;
    cin >> A;
    for (int i = 0; i < N; i++) {
        cin >> B;
        A = __gcd(A, B);
    }
    cout << A << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    bool same = (S[0] == S[1]) && (S[1] == S[2]);
    
    cout << (same ? "No" : "Yes") << endstr;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];
  using P = pair<Int, Int>;
  Int ans=0;
  for(Int i=0;i<n;i++){
    map<P, Int> cnt;
    for(Int j=0;j<n;j++){
      if(i==j) continue;
      Int a=x[j]-x[i],b=y[j]-y[i];
      if(a==0) b=1;
      if(b==0) a=1;
      if(a*b!=0){
	if(a<0) a*=-1,b*=-1;
	Int k=__gcd(a,b);
	a/=k;b/=k;
      }
      ans|=++cnt[P(a,b)]+1>=k;
    }    
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int ui32;
const long long INFLL = 1e18;
using namespace std;

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

    int n, m;
    cin >> n >> m;
    ll ans = (100 * (n - m) + 1900 * m) * (1LL << m);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int x;
	cin >> x;

	if (x < 600)
		cout << 8 << endl;
	else if (x < 800)
		cout << 7 << endl;
	else if (x < 1000)
		cout << 6 << endl;
	else if (x < 1200)
		cout << 5 << endl;
	else if (x < 1400)
		cout << 4 << endl;
	else if (x < 1600)
		cout << 3 << endl;
	else if (x < 1800)
		cout << 2 << endl;
	else
		cout << 1 << endl;
}



Measured memory_bytes: 3632
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(){
  int i,j,n;
  scanf("%d",&n);
  vector<pair<int, int> > a;
  for(i=0;i<n;i++){
    int x,y;
    scanf("%d %d",&x,&y);
    a.push_back(make_pair(x,y));
  }
  sort(a.begin(),a.end());
  int L=int(pow(10, 10));
  int dist;
  for(i=1;i<n-1;i++){
    for(j=i;j>=0;j--){
      if (pow(a[i+1].first-a[j].first,2)>=L)
        break;
      dist=int(pow(a[j].first-a[i+1].first,2)+pow(a[j].second-a[i+1].second,2))\
;
      L=min(L, dist);
    }
  }
  printf("%d\n",L);
  return 0;
}

Measured memory_bytes: 5236
s = input()
ans = 10**18
for i in range(97,97+26):
  x = chr(i)
  ls = []
  tt = 0
  for j in s:
    if j != x:
      tt += 1
    else:
      ls.append(tt)
      tt = 0
  ls.append(tt)
  ans = min(ans,max(ls))
print(ans)

Measured memory_bytes: 39024
s=input()+'R'
l=len(s)
ans=[0]*(l-1)
rcnt=0
lcnt=0
rpos=0
lpos=0
flag=0
for i in range(l):
  if s[i]=='R':
    if flag==1:
      if rcnt%2==0:
        ans[lpos]+=rcnt//2
        ans[rpos]+=rcnt//2
      else:
        ans[lpos]+=rcnt//2
        ans[rpos]+=1+rcnt//2
      if lcnt%2==0:
        ans[lpos]+=lcnt//2
        ans[rpos]+=lcnt//2
      else:
        ans[lpos]+=1+lcnt//2
        ans[rpos]+=lcnt//2
      rcnt=0
      lcnt=0
    flag=0
    rcnt+=1
    rpos=i
  elif s[i]=='L':
    if flag==0:
      lpos=i
    lcnt+=1
    flag=1
print(*ans)

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

using namespace std;

int main(void){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += k <= a[i] ? 1 : 0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

void swap(int *p1,int *p2){
		int keep;
		keep = *p1;
		*p1 = *p2;
		*p2 = keep;
}
	
		

int main()
{
		int a,b;
		while(1){
		scanf("%d %d",&a,&b);
		if(a>b)
				swap(&a,&b);	
		if(a==0 && b ==0)
				break;
		printf("%d %d\n",a,b);
		}
		return 0;
}


Measured memory_bytes: 2056
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
n = int(input())
x = [int(input()) for i in range(n)]

yoko1 = ((a in x) and (b in x) and (c in x))
yoko2 = ((d in x) and (e in x) and (f in x))
yoko3 = ((g in x) and (h in x) and (i in x))
yoko = yoko1 or yoko2 or yoko3

tate1 = ((a in x) and (d in x) and (g in x))
tate2 = ((b in x) and (e in x) and (h in x))
tate3 = ((c in x) and (f in x) and (i in x))
tate = tate1 or tate2 or tate3

naname1 = ((a in x) and (e in x) and (i in x))
naname2 = ((c in x) and (e in x) and (g in x))
naname = naname1 or naname2

bingo = tate or yoko or naname

print("Yes") if bingo else print("No")


Measured memory_bytes: 3064
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int n;
	cin>>n;
	cin.get();
	string s;
	cin>>s;
	if(n>=s.size()) cout<<s<<endl;
	else cout<<s.substr(0,n)<<"..."<<endl;
	return 0;
}


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



int main(){
    long long N,K;
    cin >> N >> K;
    int INF = 100010100;
    vector<int> AList(N+1);
    vector<int> firstStep(N+1,INF);
    vector<int> history;
    rep(i,N){
        int s;
        cin >> s;
        AList[i+1] = s;
    }
    int next = 1;
    long long sum = 0;

    while(1){
        if(firstStep[next] != INF) break;
        firstStep[next] = sum;
        history.push_back(next);
        next = AList[next];
        sum++;
    }
    
    int tail = firstStep[next];
    int l = sum - firstStep[next];

    if(K < tail){
        cout << history[K] << endl;
    }else{
        K = K - tail;
        int targetIndex =  (K%l) + tail;
        int ans = history[targetIndex];
        cout << ans << endl;
    }

    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int n = S.length();
  string res ="Yes";
  for (size_t i = 0; i < n; i++) {
    if ((S[i] == 'R' && i % 2 != 0) || (S[i] == 'L' && i % 2 == 0)) {
      res = "No";
    }
  }
    cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll x;
ll sum = 0;

int main() {
	cin >> x;
	ll now = 1;
	while (1) {
		if (sum <= x&&x <= sum + now) {
			cout << now << endl;
			return 0;
		}
		sum += now;
		now++;
	}
}

Measured memory_bytes: 256
N,Q = map(int,input().split(' '))
S = input()
#文字列のパターン
pattern = 'AC'
X = [0] * (N+1)

for i in range(N):
  X[i+1] = X[i] +(1 if S[i:i+2] =='AC' else 0)

for j in range(Q):
  l,r = map(int, input().split(' '))
  print(X[r-1]-X[l-1])

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

int main()
{
  int h, w;
  bool ans = true;
  cin >> h >> w;
  vector<vector<char>> s(h + 2, vector<char>(w + 2, '.'));
  for (int i = 1; i < h + 1; i++)
  {
    for (int j = 1; j < w + 1; j++)
    {
      cin >> s[i][j];
    }
  }

  for (int i = 1; i < h + 1; i++)
  {
    for (int j = 1; j < w + 1; j++)
    {
      if (s[i][j] == '#' && s[i - 1][j] == '.' && s[i][j - 1] == '.' && s[i + 1][j] == '.' && s[i][j + 1] == '.')
      {
        ans = false;
      }
    }
  }
  if (ans)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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

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

    string answer;
    rep(i, n)
    {
        answer += s.at(i);
        answer += t.at(i);
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();

        // 両端が同じ
        // 最後3文字

        // 違う
        // 最後2文字C#

        Console.WriteLine(((s[0] == s[s.Length - 1]) ^ (s.Length % 2 == 1)) ? "First" : "Second");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	if(a + b + c >= 22) cout << "bust";
	else cout << "win" << endl;
} 

Measured memory_bytes: 256
L, R = map(int, input().split())
if R - L > 2019:
  print(0)
else:
  L, R = L % 2019, R % 2019
  if L > R:
    print(0)
  else:
    ans = 2019
    for i in range(L, R+1):
      for j in range(i+1, R+1):
        ans = min(ans, i * j % 2019)
    print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>/*
int max(int a,int b){
  if(a > b)return a;
  return b;
}
int min(int a,int b){
  if(a < b)return a;
  return b;
}
int zet(int a){
  if(a > 0)return a;
  return -a;
}
void swap(int *x,int *y) {
  int temp = *x;
  *x = *y;
  *y = temp;
}
int partition(int array[],int left,int right) {
  int i,j,pivot;
  i = left;
  j = right + 1;
  pivot = left;
  do{
    do{ i++; } while(array[i] < array[pivot]);
    do{ j--; } while(array[pivot] < array[j]);
    if(i < j)swap(&array[i],&array[j]);
  }while (i < j);
  swap(&array[pivot],&array[j]);
  return j;
}
void quick_sort(int array[],int left,int right) {
  int pivot;
  if(left < right) {
    pivot = partition(array,left,right);
    quick_sort(array,left,pivot-1);
    quick_sort(array,pivot+1,right);
  }
}
*/
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  c /= a;
  printf("%d\n",c * b);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007


int main() {
  int N;
  cin >> N;
  int ans = 1;
  while(2*ans <= N){
    ans *= 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

int main(){
  int t;
  cin >> t;
  for(int i=0; i<t; ++i){
    int n;
    cin >> n;
    priority_queue<P> que1;
    priority_queue<P> que2;
    ll ans = 0;
    for(int i=0; i<n; ++i){
      int k, l, r;
      cin >> k >> l >> r;
      if(l == r) ans += l;
      else if(l > r){
        que1.push(make_pair(k,l-r));
        ans += r;
      }else{
        que2.push(make_pair(n-k,r-l));
        ans += l;
      }
    }
    //cout << "minans" << ans << endl;
    int n1 = que1.size();
    priority_queue<int> que3;
    for(int i=n1; i>0; --i){
      while(!que1.empty() && que1.top().first >= i){
        que3.push(que1.top().second);
        que1.pop();
      }
      if(!que3.empty()){
        ans += que3.top();
        que3.pop();
      }
    }
    int n2 = que2.size();
    //cout << n1 << " " << n2 << endl;
    priority_queue<int> que4;
    for(int i=n2; i>0; --i){
      while(!que2.empty() && que2.top().first >= i){
        que4.push(que2.top().second);
        que2.pop();
      }
      if(!que4.empty()){
        ans += que4.top();
        que4.pop();
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 5832
class UnionFind:

    def __init__(self, n):
        self.par =  [-1] * n
        self.rank = [0] * n
    
    def root(self,x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

N,M = list(map(int,input().split()))
Tree = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    Tree.union(a-1,b-1)
print(-min(Tree.par))

Measured memory_bytes: 82160
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> A(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	int goal = 0;
	int start = 0;
	for (int i = 0; i < M; i++) {
		if (X < A[i]) {
			goal++;
		}
		if (A[i] < X) {
			start++;
		}
	}
	cout << min(goal, start) << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int N;
double X[10009], Y[10009];

double getscore(double px, double py) {
	double maxn = 0;
	for (int i = 1; i <= N; i++) {
		double dst = sqrt((px - X[i]) * (px - X[i]) + (py - Y[i]) * (py - Y[i]));
		maxn = max(maxn, dst);
	}
	return maxn;
}

double getscore_Y(double px) {
	double L = -1e9, R = 1e9, c1, c2, ans = 1e9;
	for (int i = 0; i < 100; i++) {
		c1 = (L + L + R) / 3.0;
		c2 = (L + R + R) / 3.0;
		double a1 = getscore(px, c1);
		double a2 = getscore(px, c2);
		ans = min(ans, min(a1, a2));
		if (a1 > a2) L = c1;
		else R = c2;
	}
	return ans;
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i] >> Y[i];

	double L = -1e9, R = 1e9, c1, c2, ans = 1e9;
	for (int i = 0; i < 100; i++) {
		c1 = (L + L + R) / 3.0;
		c2 = (L + R + R) / 3.0;
		double a1 = getscore_Y(c1);
		double a2 = getscore_Y(c2);
		ans = min(ans, min(a1, a2));
		if (a1 > a2) L = c1;
		else R = c2;
	}

	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;


ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M)%M;
}


int main(){
  ll q,a,b;
  cin >> q >> a >> b;
  ll d= RepeatSquaring(2,q,mod)-1;
  ll ax=1,bx=1;
  ll ay=1,by=1;
  ll g,h;
  
  for(ll i=q;i>=q-a+1;i--){
    ax=(ax*i)%mod;
  }
  for(ll i=a;i>1;i--){
    ay=(ay*i)%mod;
  }
  ay=RepeatSquaring(ay,mod-2,mod);
  g=(ax*ay)%mod;
  
  for(ll i=q;i>=q-b+1;i--){
    bx=(bx*i)%mod;
  }
  for(ll i=b;i>1;i--){
    by=(by*i)%mod;
  }
   by=RepeatSquaring(by,mod-2,mod);
  h=(bx*by)%mod;
  
  cout <<  ((d-g-h)%mod+mod)%mod << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
#include <cstdint>
#include <unordered_set>
typedef long long int llint;

int main(void){
  int n, u, v;
  std::cin >> n >> u >> v;
  u--;
  v--; // 0-origin

  std::vector<std::unordered_set<int> > adjacent(n);
  for(int i=0; i<n-1; i++){
    int a, b;
    std::cin >> a >> b;
    a--;
    b--;
    adjacent[a].insert(b);
    adjacent[b].insert(a);
  }


  std::vector<int> distance_from_u(n, -1);
  std::stack<int> st;
  distance_from_u[u] = 0;
  st.push(u);
  while(!st.empty()){
    int now = st.top();
    st.pop();
    for(const auto& elem: adjacent[now]){
      if(distance_from_u[elem] == -1){
	distance_from_u[elem] = distance_from_u[now]+1;
	st.push(elem);
      }
    }
  }

  
  std::vector<int> distance_from_v(n, -1);
  distance_from_v[v] = 0;
  st.push(v);
  while(!st.empty()){
    int now = st.top();
    st.pop();
    for(const auto& elem: adjacent[now]){
      if(distance_from_v[elem] == -1){
	distance_from_v[elem] = distance_from_v[now]+1;
	st.push(elem);
      }
    }
  }

  int best = 0;
  for(int i=0; i<n; i++){
    //std::cout << distance_from_u[i] << " " << distance_from_v[i] << std::endl;
    if(distance_from_u[i] >= distance_from_v[i]) continue;
    if(distance_from_u[i] != distance_from_v[i]) distance_from_v[i]-=1;
    if(best < distance_from_v[i]) best = distance_from_v[i];
  }

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


Measured memory_bytes: 17280
N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if p[i] == i + 1:
        ans += 1
        p[i], p[i + 1] = p[i + 1], p[i]
if p[-1] == N:
    ans += 1
print(ans)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, k, n);
	vector<int> a(n);
	cin >> a;
	a.PB(k + a[0]);
	
	int ans = k;
	inc(i, n) { setmin(ans, k - (a[i + 1] - a[i])); }
	OUT(ans);
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int d[30][30];
int cnt[3][30];

int main(int argc, char* argv[])
{
    int n,c;
    scanf("%d%d", &n,&c);

    int i,j;
    for(i=0; i<c; i++) {
        for(j=0; j<c; j++) {
            scanf("%d", &d[i][j]);
        }
    }
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            int tmp;
            scanf("%d", &tmp);
            cnt[(i+j)%3][tmp-1]++;
        }
    }

    ll ans=LINF;
    int col[3];
    for(col[0]=0; col[0]<c; col[0]++) {
        for(col[1]=0; col[1]<c; col[1]++) {
            for(col[2]=0; col[2]<c; col[2]++) {
                if(col[0]==col[1]||col[1]==col[2]||col[2]==col[0]) continue;

                ll val=0;
                for(i=0; i<3; i++) {
                    for(j=0; j<c; j++) {
                        val += cnt[i][j]*d[j][col[i]];
                    }
                }
                ans = MIN(ans, val);
            }
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
int main() {
    int n = read(), k = read();
    long long res;
    res = (long long)(n / k) * (long long)(n / k) * (long long)(n / k);
    if (!(k & 1)) {
        res += (long long)((n + k / 2) / k) * (long long)((n + k / 2) / k) * (long long)((n + k / 2) / k);
    }
    printf("%lld", res);
    return 0;
}

Measured memory_bytes: 256
process.stdin.on("data",function(c){
	(c+"").trim().split("\n").slice(1).some(function(n){
		n=n.split(" ").map(function(a){return +a}).sort(function(a,b){return b-a});
		console.log(n[0]*n[0]===n[1]*n[1]+n[2]*n[2]?"YES":"NO");
	});
}).resume();

Measured memory_bytes: 10520
#include <bits/stdc++.h>
using i64 = long long;

auto sieve(long long n) {
    using i64 = long long;
    std::vector<i64> ps, lp(n + 1);
    for (int i = 2; i <= n; i++) {
        if (!lp[i]) {
            lp[i] = i;
            ps.push_back(i);
        }
        for (int j = 0; j < (int)ps.size() && ps[j] <= lp[i] && i * ps[j] <= n; j++) {
            lp[i * ps[j]] = ps[j];
        }
    }
    return ps;
}

int main() {
    i64 x;
    std::cin >> x;
    auto v = sieve(1000000);
    std::cout << *std::lower_bound(v.begin(), v.end(), x) << std::endl;

    return 0;
}


Measured memory_bytes: 9208
def main():
    num_node = int(input())
    nodes = [int(x) for x in input().split()]

    for i in range(num_node):
        idx = i + 1
        print("node {}: key = {}, ".format(idx, nodes[i]), end="")
        # print parent key
        parent_idx = idx // 2
        if parent_idx != 0:
            print("parent key = {}, ".format(nodes[parent_idx-1]), end="")
        # print left_key
        left_idx = idx * 2
        if left_idx <= num_node:
            print("left key = {}, ".format(nodes[left_idx-1]), end="")
        # print right_key
        right_idx = idx * 2 + 1
        if right_idx <= num_node:
            print('right key = {}, '.format(nodes[right_idx-1]), end="")
        print("")
    return


main()


Measured memory_bytes: 5700