akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1000000000;
using namespace std;
int n,h[100005],mem[100005],i;
int dp(int i){
  if(i==1){
    return 0;
  }
  if(i<1){
    return INF;
  }
  if(mem[i]!=-1){
    return mem[i];
  }
  int a1=dp(i-1)+abs(h[i-1]-h[i]);
  int a2=dp(i-2)+abs(h[i-2]-h[i]);
  return mem[i]=min(a1,a2);
}
signed main(){
  cin>>n;
  memset(mem,-1,sizeof(mem));
  for(int i=1;i<=n;i++){
    cin>>h[i];
  }
  cout<<dp(n)<<'\n';
  return(0);
}


Measured memory_bytes: 4096
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [(Int,Int,Int)] -> Int
solve bN wsvs = VU.maximum theVec
  where

  wLim = bN * 10^4
  sorted = sortOn (\(w,s,_) -> w+s) wsvs

  theVec = VU.create $ do
    vec <- VUM.replicate (wLim+1) 0
    forM_ sorted $ \(w0,s0,v0) -> do
      let st = min s0 (wLim - w0)
      forM_ [st, st-1 .. 0] $ \w -> do
        v1 <- VUM.read vec w
        v2 <- VUM.read vec (w+w0)
        when (v0 + v1 > v2) $ VUM.write vec (w+w0) (v0+v1)
    return vec

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      wsvs = map (\[x1,x2,x3] -> (readBInt x1,readBInt x2,readBInt x3)) remLines1
  in solve bN wsvs

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "3\n2 2 20\n2 1 30\n3 1 40\n"
inp2 = "4\n1 2 10\n3 1 10\n2 4 10\n1 6 10\n"
inp3 = "5\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000\n"
inp4 = "8\n9 5 7\n6 2 7\n5 7 3\n7 8 8\n1 9 6\n3 3 3\n4 1 7\n4 5 5\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
test1 = tv1 == 50
test2 = tv2 == 40
test3 = tv3 == 5000000000
test4 = tv4 == 22
alltest = test1 && test2 && test3 && test4



Measured memory_bytes: 80636
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,t,l,b;
    while(true) {
        cin >> n >> t >> l >> b;
        if(n==0)break;
        vector<int> stat(n,0);
        for (int i = 0; i < l; ++i) {
            int t;
            cin>>t;
            stat[t]=1;
        }
        for (int i = 0; i < b; ++i) {
            int t;
            cin>>t;
            stat[t]=2;
        }
        vector<vector<double>> dp(t+1,vector<double>(n+1,0));
        dp[0][0]=1;
        long double ans=0;
        for (int i = 1; i <= t; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int m = j+1; m <= j+6; ++m) {
                    int k=m;
                    if(m>n)k=2*n-k;
                    if(stat[j]== 0){
                        if(dp[i-1][j]==0)break;
                        if(stat[k]==2)dp[i][0]+=dp[i-1][j]/6;
                        else dp[i][k]+=dp[i-1][j]/6;
                    }
                    else {
                        if(i==1)continue;
                        if(dp[i-2][j]==0)break;
                        if(stat[k]==2)dp[i][0]+=dp[i-2][j]/6;
                        else dp[i][k]+=dp[i-2][j]/6;
                    }
                }
            }
            ans+=(long double)dp[i][n];
        }
        cout<<fixed<<setprecision(12);
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3308
import sys
import heapq
import time
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, H] = [long(input_raw[0]), long(input_raw[1])]
    a_list = []
    b_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [-long(input_raw[0]), -long(input_raw[1])]
        heapq.heappush(a_list, (a, i))
        heapq.heappush(b_list, (b, i))
    (max_a, max_a_i) = a_list[0]
    count = 0
    while (H > 0):
        if len(b_list) > 0:
            (max_b, max_b_i) = b_list[0]
        else:
            max_b = 0
        if -max_a >= -max_b:
            attack_num = (H ) / (-max_a)
            attack_num += (1 if ( H % (-max_a) >0 ) else 0)
            H += attack_num  * max_a
            count += attack_num
            #print "max a", H, count
        #elif max_a_i != max_b_i:
        else:
            heapq.heappop(b_list)
            H += max_b
            count += 1
            #print "max_b",H, count
        '''
        elif H + max_b <= 0:
            heapq.heappop(b_list)
            H += max_b
            count += 1
            print "max_a_i == max_b_i and max b can ",H, count
        else:
            attack_num = (H  + max_b) / (-max_a)
            attack_num += 1 if ( ((H + max_b)  % (-max_a)) >0 ) else 0
            H += attack_num * max_a
            count += attack_num
            print "max_a_i == max_b_i and max b cant ", H, count
        '''
    print count;

if __name__ == '__main__':
    main()


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1e9+7) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

const int INF = 1e18;

// idx, (未処理, 偶数左, 奇数, 偶数右)
const int VARI = 5;
int dp[200010][VARI];

signed main() {
  int N;
  cin >> N;
  vec<int> v(N);
  rep (i, N) {
    cin >> v[i];
  }

  const int one = 0; // 左のゼロ区間
  const int two = 1; // 右のゼロ区間
  const int three = 2; // 左の偶数区間
  const int four = 3; // 右の偶数区間
  const int five = 4; // 奇数区間

  // 初期化
  fill(dp[0], dp[N+1], INF);
  dp[0][one] = 0;
  dp[0][two] = 0;
  dp[0][three] = 0;
  dp[0][four] = 0;
  dp[0][five] = 0;

  // DP
  rep (i, N) {
    // 左のゼロ区間
    chmin(dp[i+1][one], dp[i][one] + v[i]);

    // 左の偶数区間
    int cost1 = (v[i] == 0 ? 2 : (v[i] % 2));
    chmin(dp[i+1][two], min(dp[i][two], dp[i][one]) + cost1);

    // 奇数
    int cost3 = 1 - (v[i] % 2);
    int mi = min({dp[i][two], dp[i][three], dp[i][one]});
    chmin(dp[i+1][three], mi + cost3);

    // 右の偶数区間
    int cost2 = (v[i] == 0 ? 2 : (v[i] % 2));
    chmin(dp[i+1][four], min(dp[i][three], dp[i][four]) + cost2);


    // 未処理右
    int mi2 = min({dp[i][two], dp[i][four], dp[i][three], dp[i][five]});
    chmin(dp[i+1][five], mi2 + v[i]);
  }

  int ans = INF;
  rep (i, VARI) {
    chmin(ans, dp[N][i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
#include <atcoder/all>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)
using namespace atcoder;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(0);
}


int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); 
    int n, k; cin >> n >> k;
    segtree<int, op, e> seg(300001);
    rep(i, n)
    {
        int a; cin >> a;
        int tmp = seg.prod(max(0, a - k), min(300001, a + k + 1));
        seg.set(a, tmp + 1);
    }
    cout << seg.all_prod();
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string a;cin>>a;
  flag2func(a[0]=='9' || a[1]=='9');
}

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

using namespace std;

void c()
{
	long long mod = 1000000007;
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}

	// たどりつけない
	for (int i = 0; i < m - 1; i++) {
		if (a[i] + 1 == a[i + 1]) {
			cout << 0 << endl;
			return;
		}
	}

	vector<int> t(n + 1);
	t[0] = 1;
	int count = 0;
	for (int i = 1; i < n + 1; i++) {
		t[i] = 0;
		if (count < m && i == a[count]) {
			count++;
			//cout << t[i] << endl;
			continue;
		}
		// 2歩進む
		if (i >= 2) {
			t[i] = (t[i] + t[i - 2]) % mod;
		}
		// 1歩進む
		t[i] = (t[i] + t[i - 1]) % mod;
		//cout << t[i] << endl;
	}

	cout << t[n] << endl;
}

int main()
{
	c();
}


Measured memory_bytes: 768
#include <stdio.h>
#define k 10001

int C[k] = {};

int CountingSort(int *A, int *B, int n) {
    int i, j;

    for (j = 1; j <= n; j++) C[A[j]]++;
    for (i = 1; i <= k; i++) C[i] += C[i - 1];
    
    for (j = n; j >= 1; j--) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}

int main(void) {
    int n, i, j;
    scanf("%d", &n);
    int A[n+1]; int B[n+1];

    for (i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
    }

    CountingSort(A, B, n);

    for (i = 1; i <= n; i++) {
        printf("%d", B[i]);
        if (i < n) printf(" ");
        else printf("\n");
    }

    return 0;
}


Measured memory_bytes: 17380
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N;
    cin >> N;

    cout << N * (N + 1) / 2 - N << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define gt first
#define gc second.first
#define gr second.second
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i;
	ll a[123456],sum=0ll,ans;
	cin >> n;
	a[0] = 0ll;
	a[n+1] = 0ll;
	for(i=1; i<=n; ++i){
		cin >> a[i];
		sum += abs(a[i]-a[i-1]);
	}
	sum += abs(a[n]-a[0]);
	for(i=1; i<=n; ++i){
		ans = sum - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2048
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846

#define MAXN 300003
#define UNDEF 0
ll n, t[4 * MAXN];
int segTreeOp(int a, int b) {
  //to be changed with the appropriate operation
  return max(a, b);
}

int query(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return UNDEF;
    if (l == tl && r == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    return segTreeOp(query(v*2, tl, tm, l, min(r, tm)),
               query(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = segTreeOp(t[v*2], t[v*2+1]);
    }
}

int main(){
	FASTIO;
  memset(t, 0, sizeof t);
  ll m; cin >> n >> m;
  ll a[n]; parseArray(a, n);
  ll ans = 0;
  for (ll e: a) {
    ans = max(ans, 1ll + query(1, 0, MAXN, max(0ll, e - m), min((ll)MAXN, e + m)));
    update(1, 0, MAXN, e, query(1, 0, MAXN, max(0ll, e - m), min((ll)MAXN, e + m)) + 1);
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15316
import math
def prime(n):
    plist = [1 for i in range(n)]
    pivot = int(math.sqrt(n))
    plist[0] = 0
    if n <= 1:
        return 0
    if n == 2:
        return 1
    if n == 3:
        return 2
    else:
        for i in range(2,pivot+1):
            if plist[i-1] == 0:
                continue
            else:
                for j in range(2*i,n+1,i):
                    plist[j-1] = 0
    psum = sum(plist)
    return psum

import sys
while True:
    line = sys.stdin.readline()
    if not line: break
    n = int(line.rstrip('\r\n'))
    print(prime(n))


Measured memory_bytes: 17000
#include <bits/stdc++.h>
using namespace std;
 
vector<long long> Gauss(vector<long long> a) {
	sort(a.begin(), a.end());
	for (int i = 59; i >= 0; i--) {
		int pos = 0;
		for (int j = 0; j < a.size(); j++) {
			if (a[j] < (1LL << (i + 1))) { pos = j; }
		}
		for (int j = pos - 1; j >= 0; j--) {
			if (a[j] >= (1LL << i)) a[j] ^= a[pos];
		}
		sort(a.begin(), a.end());
	}
	vector<long long> b = a;
	b.erase(unique(b.begin(), b.end()), b.end());
	return b;
}
 
int main() {

	long long N, e = 0; cin >> N;
	vector<long long> a(N, 0);
	for (int i = 0; i < N; i++) { cin >> a[i]; e ^= a[i]; }
 
	vector<long long> F;
	for (int i = 0; i < 60; i++) { if ((e & (1LL << i)) != 0) F.push_back(i); }
	for (int i = 0; i < 60; i++) { if ((e & (1LL << i)) == 0) F.push_back(i); }
 
	for (int i = 0; i < N; i++) {
		long long r = 0;
		for (int j = 0; j < 60; j++) { if ((a[i] & (1LL << F[j])) != 0) r += (1LL << j); }
		a[i] = r;
	}
 
	vector<long long> b = Gauss(a);
	long long c = 0;
	for (int i = b.size() - 1; i >= 0; i--) {
		c = max(c, c^b[i]);
	}
 
	long long ans = 0;
	for (int i = 0; i < 60; i++) {
		if ((e & (1LL << F[i])) != 0) {
			ans += (1LL << F[i]);
		}
		else {
			if ((c & (1LL << i)) != 0) ans += (2LL << F[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int[] aa, rr;
	int count(int n, int md) {
		int rsum = 0;
		for (int i = 0; i < n; i++)
			rsum += rr[i] = aa[i] % md;
		if (rsum == 0)
			return 0;
		Arrays.sort(rr);
		int p = 0, q = n * md - rsum;
		for (int i = 0; i < n && p != q; i++) {
			p += rr[i];
			q -= md - rr[i];
		}
		return p;
	}
	void main() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		aa = new int[n]; rr = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++)
			sum += aa[i] = sc.nextInt();
		int ans = 0;
		for (int a = 1, b; a <= (b = sum / a); a++) {
			if (sum % a != 0)
				continue;
			if (count(n, b) <= k) {
				ans = b;
				break;
			}
			if (count(n, a) <= k)
				ans = a;
		}
		println(ans);
	}
}


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

int main(){
  int n,y;
  cin >> n >> y;
  bool frag=false;
  int i=0,j=0,k=0;
  for(i=0;i<=n;i++){
    for(j=0;j<=n-i;j++){
      k=n-j-i;
      int sum=10000*i+5000*j+1000*k;
      if(sum==y){
        frag=true;
        cout << i << ' ' << j << ' ' << k << endl;
        return 0;
      }
    }
  }
  if(frag==false){
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep2(i, 1, n + 1) if(i % 3 != 0 && i % 5 != 0) ans += i;
  cout << ans << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

class Main{
    private static final DecimalFormat fmt = new DecimalFormat("0.########");
    private static final StringBuilder sb = new StringBuilder();
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        sb.append("0 0\n");
        koch(0, 0, 100, 0, n);
        sb.append("100 0\n");
        System.out.print(sb);
    }
    private static void koch(double x0, double y0, double x1, double y1, int n){
        if(n==0) return;
        n--;
        final double sx = (x0+x0+x1)/3;
        final double sy = (y0+y0+y1)/3;
        final double ux = (x0+x1)/2-(y1-y0)*Math.sqrt(3)/6;
        final double uy = (y0+y1)/2+(x1-x0)*Math.sqrt(3)/6;
        final double tx = (x0+x1+x1)/3;
        final double ty = (y0+y1+y1)/3;
        koch(x0, y0, sx, sy, n);
        sb.append(fmt.format(sx)).append(' ').append(fmt.format(sy)).append('\n');
        koch(sx, sy, ux, uy, n);
        sb.append(fmt.format(ux)).append(' ').append(fmt.format(uy)).append('\n');
        koch(ux, uy, tx, ty, n);
        sb.append(fmt.format(tx)).append(' ').append(fmt.format(ty)).append('\n');
        koch(tx, ty, x1, y1, n);
    }
}

Measured memory_bytes: 34948
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int n , m , arr[N] ;
int main(){
    cin >> n >> m;
    for(int i = 0  ; i < m ; i++){
        int a , b;
        cin >> a >> b;
        arr[a]++;
        arr[b + 1]--;
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++){
        arr[i] += arr[i - 1];
        if(arr[i] == m) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
// AtCoder ABC064 C - Colorful Leaderboard
// 2020.1.25 bal4u

#include <stdio.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

char color[10];

int main()
{
	int i, N, a, f = 0;
	int mi, ma;
	
	N = in();
	while (N--) {
		a = in();
		if (a >= 3200) f++;
		else color[a/400] = 1;
	}
	mi = 0; for (i = 0; i < 10; ++i) {
		if (color[i]) mi++;
	}
	ma = mi+f;
	if (mi < 1) mi = 1;
	printf("%d %d\n", mi, ma);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int tkkw; 

tkkw dp[16][16];
	
tkkw kuwa(int x, int y){
	if(x <0  || y<0) return 0;
	if (dp[x][y] !=-1) return dp[x][y];

	return (kuwa(x-1,y) + kuwa(x,y-1));
}
int main(){
	while(1){
	for(int i=0;i<16;i++){
		for(int j=0;j<16;j++){
			dp[i][j] =-1;
		}
	}
	int a,b,n;
	cin >> a>>b;
	if(a==0 && b==0)break;
	cin >> n;
	dp[0][0] = 1;
	for(int i=0; i<n ; i++ ){
		int l,m;
		cin >> l>>m;
		dp[l-1][m-1] = 0;
	}
	cout << kuwa(a-1,b-1) <<endl;
}

	return 0;
}

Measured memory_bytes: 1156
temp=input().split()
N=int(temp[0])
L=int(temp[1])
a=[int(i) for i in input().split()]
flag=False
ans=[]

for i in range(N-1):
	if a[i]+a[i+1]>=L:
		print("Possible")
		flag=True
		ans.append(i)
		break
else:
	print("Impossible")

if flag==True:
	while ans[-1]>0:
		ans.append(ans[-1]-1)
	if ans[0]<N-1:
		ans.append(ans[0]+1)
		while ans[-1]<N-2:
			ans.append(ans[-1]+1)
	for i in range(N-2,-1,-1):
		print(ans[i]+1)

Measured memory_bytes: 14620
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;


int main(void){
    
    int buildings[4][3][10];
    int num,b,f,v,r;
    
    for(int i = 0;i < 4;++i){
        for(int j = 0;j < 3;j++){
            for(int k = 0;k < 10;++k){
                buildings[i][j][k] = 0;
            }
        }
    }
    
    
    cin >> num;
    
    for(int i = 0;i < num;++i){
        cin >> b >> f >> r >> v;
        buildings[b - 1][f - 1][r - 1] += v;
    }
    
    for(int i = 0;i < 4;++i){
        for(int j = 0;j < 3;j++){
            for(int k = 0;k < 10;++k){
                cout << " " << buildings[i][j][k];
            }
            cout << endl;
        }
        if(i + 1 < 4){
            cout << "####################" << endl;
        }
    }
    
    return 0;
}



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

using namespace std;

typedef long long LL;

int bitcount(int val)
{
  int ret = 0;
  while (val > 0) {
    ret += (1 & val);
    val >>= 1;
  }
  return ret;
}

int solve(int n, string s)
{
  int ret = 0;
  for (int i = 1; i < n; ++i) {
    string s1 = s.substr(0, i);
    string s2 = s.substr(i);
    int k1 = 0, k2 = 0;
    // fprintf(stderr, "DEBUG: s1=%s, s2=%s\n", s1.c_str(), s2.c_str());
    for (int j = 0; j < (int)s1.size(); ++j) {
      k1 |= (1 << (s1[j] - 'a'));
    }
    for (int j = 0; j < (int)s2.size(); ++j) {
      k2 |= (1 << (s2[j] - 'a'));
    }
    ret = max(ret, bitcount(k1 & k2));
  }
  return ret;
}

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

  // fprintf(stderr, "DEBUG: n=%d, s=%s\n", n, s.c_str());
  int ans = solve(n, s);
  printf("%d\n", ans);
  return 0;
}

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

using ll = long long;

template <typename T>
class node {
public:
	node<T> *l, *r;
	T val;
	node() {}
	node(T val_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) : l(l_), r(r_), val(val_) {}
	void init(T val_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) {
		val = val_;
		l = l_;
		r = r_;
	}
};

template <typename T>
class DynamicSegmentTree {
	using func_t = function<T(T, T)>;
	const ll n;
	const T id;
	func_t merge;
	node<T> *root;
	vector<node<T>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node() {
		pool[it].init(id);
		return &pool[it++];
	}
	T sub(ll l, ll r, node<T>* n, ll lb, ll ub) {
		if (n == nullptr || ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return n->val;
		return merge(sub(l, r, n->l, lb, (lb + ub) / 2), sub(l, r, n->r, (lb + ub) / 2, ub));
	}
	node<T> *suc(ll v, node<T>* n, ll lb, ll ub, T val) {
		if (n == nullptr) n = new_node();
		if (lb + 1 == ub) {
			n->val = val;
			return n;
		}
		ll c = (lb + ub) / 2;
		if (v < c) {
			n->l = suc(v, n->l, lb, c, val);
		}
		else {
			n->r = suc(v, n->r, c, ub, val);
		}
		n->val = merge(n->l != nullptr ? n->l->val : id, n->r != nullptr ? n->r->val : id);
		return n;
	}
public:
	DynamicSegmentTree(ll n_, T id_, func_t merge_, int max_ = 1e7) :
		n(size(n_)), id(id_), merge(merge_), root(nullptr), pool(max_), it(0) {}
	void Update(ll p, T val) {
		root = suc(p, root, 0, n, val);
	}
	T Find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	DynamicSegmentTree<int> st(n, INT_MAX, [](int l, int r) { return min(l, r); }, 3e5);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.Find(x, y));
		}
		else {
			st.Update(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 5872
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<queue>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long
#define trio tuple<int,int,int>

using namespace std;

int K;
vector<LL>lst;

int main() {
	cin>>K;
	for(int i=1;i<10;i++)lst.push_back(i);
	vector<LL>par,chi;
	par=lst;
	while(1){
		if((int)par.size()>=K)break;
		for(int i=0;i<par.size();i++){
			LL now=par[i],btm=par[i]%10ll;
			if(btm!=0ll){
				chi.push_back(now*10ll+btm-1ll);
				lst.push_back(now*10ll+btm-1ll);
			}
				chi.push_back(now*10ll+btm);
				lst.push_back(now*10ll+btm);
			if(btm!=9ll){
				chi.push_back(now*10ll+btm+1ll);
				lst.push_back(now*10ll+btm+1ll);
			}
			if((int)par.size()>=K)break;
		}
		par=chi;
		chi.clear();
	}
	sort(lst.begin(),lst.end());
	cout<<lst[K-1]<<endl;
	return 0;
}



Measured memory_bytes: 4428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    vector<string> p;
    rep(i,n){
        string s;
        cin >> s;
        if(mp[s]==0){
            p.push_back(s);
        }
        mp[s]++;
    }
    vector<pair<int, string>> vs;
    rep(i,p.size()){
        vs.emplace_back(mp[p[i]], p[i]);
    }
    sort(vs.begin(), vs.end(), greater<>());
    int tmp = vs[0].first;
    vector<string> ans;
    rep(i,p.size()){
        if(tmp == vs[i].first){
            ans.push_back(vs[i].second);
        }else{
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 35180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
XY = list(map(int, input().split()) for _ in range(m))

Ball = [1] * n
Done = [False] * n
Done[0] = True

for i in range(m):
	x, y = XY[i]
	x -= 1
	y -= 1
	if Done[x]:
		Done[y] = True
	
	Ball[x] -= 1
	Ball[y] += 1
	
	if Ball[x] == 0:
		Done[x] = False
				
res = 0
for i in range(n):
	if Done[i]:
		res += 1

print(res)


Measured memory_bytes: 50444
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

const int N = 500000;
int n;
vector<int> graph[N];
ll dp[N];
ll sz[N];

void dfs(int v, int p)
{
    dp[v] = 1;
    sz[v] = 1;
    int acc = 0;
    for (auto u : graph[v]) if (u != p)
    {
        dfs(u, v);
        sz[v] += sz[u];
        dp[v] = dp[v] * dp[u] % MOD * cnk(acc + sz[u], sz[u]) % MOD;
        acc += sz[u];
    }
}

ll dp2[N];

void dfs2(int v, int p)
{
    ll ways = dp2[p];
    ways = ways * rev(dp[v]) % MOD * rev(cnk(n - 1, sz[v])) % MOD;
    dp2[v] = dp[v] * cnk(n - 1, n - sz[v]) % MOD * ways % MOD;
    for (auto u : graph[v]) if (u != p) dfs2(u, v);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(1, 1);
    cout << dp[1] << "\n";
    dp2[1] = dp[1];
    for (auto u : graph[1])
    {
        dfs2(u, 1);
    }
    for (int i = 2; i <= n; i++)
    {
        cout << dp2[i] << "\n";
    }
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 41588
#!/usr/bin/env python3

X, N = map(int, input().split())

if N == 0:
    print(X)
    exit()

P = set(map(int, input().split()))

current_small = current_big = X

while True:
    if current_small not in P:
        print(current_small)
        break

    if current_big not in P:
        print(current_big)
        break

    current_small -= 1
    current_big += 1


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  ll n;
  cin>>n;
  vll a(0);
  a.pb(0);
  ll i=1;
  while(1){
    a.pb(a[i-1]+i);
    if(a[i]>=n) break;
    i++;
  }
  COUT(i);
}
    


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	cout << (H - h) * (W - w) << endl;

	return 0;
}

Measured memory_bytes: 256
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 200001
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,cnt,v[N],x[N],tl[N][19],tr[N][19];
int fl[1<<19],fr[1<<19];
int main()
{
	re(n),re(v[0]);
	while(v[cnt])
	{
		++cnt;
		v[cnt]=v[cnt-1]>>1;
	}
	for(int i=1;i<=n;++i)re(x[i]);
	for(int i=0;i<=cnt;++i)
	{
		int last=1;
		for(int j=1;j<=n;++j)
			if(j==n || x[j+1]-x[j]>v[i])
			{
				for(int k=last;k<=j;++k)
					tl[k][i]=last,tr[k][i]=j;
				last=j+1;
			}
	}
	for(int i=0;i<(1<<cnt+1);++i)
	{
		fl[i]=0;
		fr[i]=n+1;
		for(int j=0;j<=cnt;++j)
			if(i>>j&1)
			{
				fl[i]=max(fl[i],tr[min(fl[i^(1<<j)]+1,n)][j]);
				fr[i]=min(fr[i],tl[max(fr[i^(1<<j)]-1,1)][j]);
			}
	}
	int gg=0,l=1;
	while(l<=n)
	{
		int r=tr[l][0];
		if(gg>cnt)
		{
			for(int i=l;i<=r;++i)
				puts("Impossible");
		}
		else
		{
			bool ok=0;
			for(int i=0;i<(1<<cnt+1);++i)
			{
				int gl=i,gr=((1<<cnt+1)-1)^i;
				if(gl&1)gl^=1;
				if(gr&1)gr^=1;
				if(fl[gl]>=l-1 && fr[gr]<=r+1)
				{
					ok=1;
					break;
				}
			}
			for(int i=l;i<=r;++i)
				puts(ok?"Possible":"Impossible");
		}
		l=r+1;
		++gg;
	}
}


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

int main()
{
    int n;
    cin >> n;
    int a[3][107] = {0};
    for(int i = 1; i <= 2; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> a[i][j];
            a[i][j] += max(a[i-1][j],a[i][j-1]);
        }
    }
    cout << a[2][n] << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
scd = {}
for i in range(m):
    if (sc[i][0] in scd.keys()):
        if (sc[i][1] != scd[sc[i][0]]):
            print('-1')
            break
    scd[sc[i][0]] = sc[i][1]
else:
    if n == 1:
        s = ['0']
    elif n == 2:
        s = ['1', '0']
    else:
        s = ['1', '0', '0']
    scdkey = list(scd.keys())
    for i in range(len(scd)):
        s[scdkey[i] - 1] = str(scd[scdkey[i]])
    if (len(s) > 1) & (s[0] == '0'):
        print('-1')
    else:
        st = ''.join(s)
        print(st)

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    double R;
    cin >> R;
    cout << R * 2.0 * 3.141592 << endl;
}


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

lgcd = Array.new(N+1,0)
rgcd = Array.new(N+1,0)

# 左側のGCD (L[0]は0)
N.times { |i| lgcd[i+1] = lgcd[i].gcd(A[i]) }
# 右側のGCD (R[N]は0)
N.times.reverse_each { |i| rgcd[i] = rgcd[i+1].gcd(A[i]) }

# 左端からiまでのgcdと,右端からi+1までのgcdのgcdを取る
maxgcd = N.times.map { |i| lgcd[i].gcd(rgcd[i+1]) }.max

puts maxgcd

Measured memory_bytes: 11780
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define MOD 998244353
#define N 1000006
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

int power(int a, int b, int p){
    int ans = 1;
    while (b > 0) 
    {
        if (b & 1) 
            ans = (ans*a)%p; 
        
        b = b>>1;
        a = (a*a)%p;
    }
    return ans; 
}

void solve(){
    int n,maxx=0,ans=1,a,c=1;
    cin>>n;
    int arr[n];
    vector<int> freq(n,0);
    bool poss=false;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        freq[arr[i]]++;
        maxx=max(maxx, arr[i]);
        if(i>0 && arr[i]==0) poss=true;
    }
    if(arr[0]!=0 || poss){
        cout<<0<<"\n";
        return;
    }
    for(int i=1;i<=maxx;i++){
        if(freq[i]==0){
            ans=0;
            break;
        }
        ans = (ans * power(freq[i-1], freq[i], MOD))%MOD;
        //cout<<ans<<"\n";
    }
    cout<<ans<<"\n";
}

signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

int main(){
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0; i < n ; ++i){
		cin >> a[i];
	}
	int dp[n];
	memset(dp,INT_MAX,sizeof(dp));
	if(n==1)return 0;
	dp[0]=0;
	dp[1] = abs(a[1]-a[0]);
	
	for(int i=2; i<n ; ++i){
		int res = INT_MAX;
		for(int j=1;j<=k && (i-j)>=0 ; ++j ){
			res = min(dp[i-j] + abs(a[i-j]-a[i]) , res);
		}
		dp[i] = res;
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end(), greater<int>());
  int m = n - 2;
  int64 ret = a[0];
  for (int i = 0; i < m; ++i) {
    ret += a[i / 2 + 1];
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int main()
{
    long long n,k,r;
    int a[10000],i=0;
    cin>>n>>k;
    while(n)
    {
        r=n%k;
        n=n/k;
        a[i]=r;
        i++;

    }
   cout<<i;

}


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

int main(){
  int n;
  cin >> n;
  int a[n+1], s[n+1], sum[n+1];
  vector<int> v;
  for ( int i = 1; i <= n; i++){
    cin >> a[i];
    sum[i] = 0;
  }
  for ( int i = n; i >=1; i--){
    if ( a[i] != sum[i]%2){
      v.push_back(i);
      for ( int j = 1; j <= floor(sqrt(i)); j++ ){
        if ( i % j == 0){
          sum[j] ++;
          if ( j * j != i){
            sum[i/j]++;
          }
        }
      }
    }
  }

  cout << v.size() << endl;
  for ( int i = 0; i < v.size(); i++){
    if (i)cout<< " ";
    cout << v[i];
  }

  return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;

template<class T> struct EdgeF{
  int to, rev;
  T cap;
  EdgeF(int to_ = 0, T cap_ = 0, int rev_ = 0)
	:to(to_), rev(rev_), cap(cap_)
  {}
};
template<class T> using GraphF = vector<vector<EdgeF<T>>>;

template<class T>
void add_edge(GraphF<T>& G, int from, int to, T cap){
  G[from].emplace_back(to, cap, G[to].size());
  G[to].emplace_back(from, 0, G[from].size()-1);
}

template<class T>
T max_flow(GraphF<T>& G, int s, int t) {
  int N = G.size();
  T total = 0;
  for(bool up=true;up;){
	up = false;
	// bfs
    vector<int> level(N, -1);
	level[s] = 0;
    queue<int> Q;
	Q.push(s);
	while(!Q.empty()){
      int u = Q.front(); Q.pop();
      if(u == t) break;
      for(auto& e: G[u])
		if(e.cap > 0 && level[e.to] == -1){
		  Q.push(e.to);
		  level[e.to] = level[u] + 1;
		}
    }

	// dfs
    vector<bool> finished(N);
	function<T(int,T)> dfs = [&](int u, T f){
	  if(u == t || f == 0) return f;
	  if(finished[u]) return static_cast<T>(0);
	  finished[u] = true;
	  for(auto& e: G[u]){
		if(level[e.to] > level[u]){
		  T fp = dfs(e.to, min(f, e.cap));
		  if(fp > 0){
			e.cap -= fp;
			G[e.to][e.rev].cap += fp;
			finished[u] = false;
			return fp;
		  }
		}
	  }
	  return static_cast<T>(0);
	};

	while(true){
      T f = dfs(s, INF);
      if (f == 0) break;
      total += f;
	  up = true;
    }
  }
  return total;
}

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

  int N;
  cin >> N;
  LL sum = 0;
  VL xs(N+1);
  REP(i,N){
	cin >> xs[i+1];
	if(xs[i+1] > 0)
	  sum += xs[i+1];
  }

  int S = N+1, T = S+1;
  GraphF<LL> G(N+3);
  FOR(i,1,N+1){
	if(xs[i] <= 0)
	  add_edge(G, S, i, -xs[i]);
	if(xs[i] > 0)
	  add_edge(G, i, T, xs[i]);
  }
  FOR(i,1,N+1){
	for(int j=i+i;j<=N;j+=i){
	  add_edge<LL>(G, i, j, 1e15);
	}
  }
  cout << sum - max_flow<LL>(G, S, T) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100];
int d;
int main()
{
	int n,k,sum=0;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		cin>>d;
		for(int j=0;j<d;j++)
		{
			int t;
			cin>>t;
			a[t-1]=1;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]==0)
			sum++;
	}
	cout<<sum<<endl;
	
	return 0;
} 

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
	int k;
	scanf("%d",&k);
	int odd = 0;
	int even = 0;
	for(int i = 1;i<=k;i++){
		if(i%2 == 0){
			even++;
		}else{
			odd++;
		}
	}
	printf("%d",even*odd);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
	int n, v = 0, j;
	cin >> n;
	vector<int> a1(n);
	vector<int> a2(n);
	for (int a = 0; a < 2; a++) {
		for (int b = 0; b < n; b++) {
			if (a == 0) {
				cin >> a1[b];
			}
			if (a == 1) {
				cin >> a2[b];
			}
		}
	}
	for (int a = 0, b, c; a < n; a++) {
		j = 0;
		for (b = 0; b <= a; b++) {
			j += a1[b];
		}
		for (c = (b - 1); c < n; c++) {
			j += a2[c];
		}
		if (v < j) {
			v = j;
		}
	}
	cout << v << endl;
	return 0;
}

Measured memory_bytes: 256