akhauriyash/Code-Regression huggingface dataset:
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1'000'000'007ll)
#define OO (1'050'000'000)
#define OOL (1'100'000'000'000'000'000ll)

//global
int a[N];


int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n,x;
	cin >> n >> x;
	if(x == 1 || x == 2*n-1) return cout << "No",0;
	if(x == n){
		cout << "Yes" << endl;
		rep(i,0,2*n-1){
			cout << i+1 << endl;
		}
		return 0;
	}
	cout << "Yes\n";
	if(x < n){
		rep(i,1,x-1){
			a[i] = i;
		}
		rep(i,x-1,n-1){
			a[i] = i+2;
		}
		a[n-1] = x-1;
		a[n] = x;
		rep(i,n+1,2*n){
			a[i] = i;
		}
		rep(i,0,2*n-1){
			cout << a[i+1] << endl;
		}
	}else{
		rep(i,1,n){
			a[i] = i;
		}
		a[n] = x;
		a[n+1] = x+1;
		rep(i,n+2,n+2+x-n){
			a[i] = i-2;
		}
		rep(i,n+2+x-n,2*n){
			a[i] = i;
		}
		rep(i,1,2*n){
			cout << a[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2304
from operator import mul
from functools import reduce
def main():
    n, m = map(int, input().split())
    fromN = 0
    fromM = 0
    if n > 1:
        fromN = cmb(n, 2)
    
    if m > 1:
        fromM = cmb(m, 2)
    
    print(fromN + fromM)
    return 


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


if __name__ == '__main__':
    main()


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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin >> c;
	if (c >= 'a' && c <= 'z') {
		cout << "a\n";
	} else {
		cout << "A\n";
	}
}



Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(void){
  long long H,W;
  cin >> H >> W;
  if(H == 1 || W == 1) cout << 1 << endl;
  else if(H % 2 != 0 && W % 2 != 0) cout << ((H * W) / 2) + 1 << endl;
  else cout << (H * W) / 2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#define MOD 1000000007
int main() {
	int n, m, a, way[100003] = {0};
	bool isBreak[100003];
	for (int i = 0; i < n; i++) {
		isBreak[i] = false;
	}
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &a);
		isBreak[a] = true;
	}
	way[0] = 1;
	for (int i = 0; i <= n; i++) {
		if (isBreak[i])
			continue;
		way[i + 1] += way[i];
		way[i + 1] %= MOD;
		way[i + 2] += way[i];
		way[i + 2] %= MOD;
	}
	printf("%d\n", way[n]);
	return 0;
}

Measured memory_bytes: 640
//agc033_b
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt(), N = sc.nextInt();
        int Sr = sc.nextInt(), Sc = sc.nextInt();
        String S = sc.next(), T = sc.next();
        sc.close();
        int left = 1, right = W, up = 1, down = H;
        boolean alive = true;
        for (int i = N - 1; i >= 0; i--) {
            switch (T.charAt(i)) {
                case 'L': right = Math.min(W, right + 1); break;
                case 'R': left = Math.max(1, left - 1); break;
                case 'U': down = Math.min(H, down + 1); break;
                case 'D': up = Math.max(1, up - 1); break;
            }
            switch (S.charAt(i)) {
                case 'L': left++; break;
                case 'R': right--; break;
                case 'U': up++; break;
                case 'D': down--; break;
            }
            if (left > right || up > down) {
                alive = false;
                break;
            }
        }
        boolean ans = alive && Sr >= up && Sr <= down && Sc >= left && Sc <= right;
        System.out.println(ans ? "YES" :"NO");
    }
}


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

int main(){
  int s1,s2,s3,s;
  cin >> s;
  s1 = s / 100;
  s2 = s / 10 - s1 * 10;
  s3 = s - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}
  

Measured memory_bytes: 256
#include<cmath>
#include<cstdio> 
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int vis[1010],n;

int main()
{
	vis[1]=1;
	for(int i=2;i<=1000;i++)
	{
		int tmp=i*i;
		while(tmp<=1000)
		{
			vis[tmp]=1;
			tmp*=i;
		}
	 } 
	 int n,ans=0;
	 cin>>n;
	 for(int i=1;i<=n;i++)
	 {
	 	if(vis[i])
	 	{
	 		ans=i;
		 }
	 }
	 printf("%d\n",ans);
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define inf 1001001007
int min(int a,int b){return a < b ? a: b;}
int main(){
    int n, k;
    scanf("%d%d",&n,&k);
    int h[n], dp[n];
    for(int i = 0; i < n; i++)
        scanf("%d",&h[i]);
    for(int i = 1; i < n; i++)
        dp[i] = inf;
    dp[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j = 1; j <= k && j + i < n; j++)
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[j + i]));
    printf("%d\n",dp[n - 1]);
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)
	C := make([]int, N)
	A := make([][]int, N)
	var num, c int
	for i := 0; i < N; i++{
		a := make([]int, M)
		fmt.Scan(&c)
		C[i] = c
		for j := 0; j < M; j++{
			fmt.Scan(&num)
			a[j] = num
		}
		A[i] = a
	}
	
	n := N

	var a int = math.MaxInt64
	res := a
	
	for i := 0; i < (1<<uint(n)); i++ {
		exp := make([]int, M)
		amount := 0
		for j:= 0; j < n; j++ {
			if (i >> uint(j))&1 == 1 {
				for k := 0; k < M; k++ {
					exp[k] += A[j][k]
				}
				amount += C[j]

			}
			ok := true
			for l := 0; l < M; l++{
				if exp[l] < X{
					ok = false
				}
			}
			if ok {
				res = int(math.Min(float64(res), float64(amount)))
			}
		}
	}

	if res == a {
		res = -1
	}

	fmt.Println(res)
}


Measured memory_bytes: 2224
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005], b[200005];
llint acnt[200005], bcnt[200005];
set<P> S;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	
	for(int i = 1; i <= n; i++){
		acnt[a[i]]++, bcnt[b[i]]++;
	}
	for(int i = 1; i <= n; i++){
		if(acnt[i] + bcnt[i] > n){
			cout << "No" << endl;
			return 0;
		}
	}
	
	for(int i = 1; i <= n; i++){
		if(bcnt[i] > 0) S.insert(P(-(acnt[i]+bcnt[i]), i));;
	}
	for(int i = 1; i <= n; i++){
		llint x;
		for(auto it = S.begin(); it != S.end(); it++){
			if(it->second != a[i]){
				x = it->second;
				break;
			}
		}
		b[i] = x;
		
		S.erase(P(-(acnt[x]+bcnt[x]), x));
		bcnt[x]--;
		if(bcnt[x] > 0) S.insert(P(-(acnt[x]+bcnt[x]), x));
		
		S.erase(P(-(acnt[a[i]]+bcnt[a[i]]), a[i]));
		acnt[a[i]]--;
		S.insert(P(-(acnt[a[i]]+bcnt[a[i]]), a[i]));
	}
	
	cout << "Yes" << endl;
	for(int i = 1; i <= n; i++) cout << b[i] << " "; cout << endl;
	
	return 0;
}

Measured memory_bytes: 22280
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.pb(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
vec primefactorization(ll N){
  ll i=2;
  vec res;
  while(i*i<=N){
    while(!(N%i)){
      res.pb(i);
      N/=i;
    }
    i++;
  }
  if(N-1)res.pb(N);
  return res;
}
int main(){
  ll i,j,N,K,p[3],ans=0;
  cin>>N>>K>>p[0]>>p[1]>>p[2];
  string s;cin>>s;
  vec v(N);
  rep(i,N){
    if(s[i]=='r'){
      v[i]=2;
    }else if(s[i]=='s'){
      v[i]=0;
    }else{
      v[i]=1;
    }
    if(i<K||v[i]!=v[i-K]){
      ans+=p[v[i]];
    }else{
      v[i]=-1;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

int main(){
  int n;
  cin >> n;
  vector<ll> l(n+1,0);
  rep(i,n) {
    cin >> l[i+1];
  }

  int ans = 0;
  vector<ll> sides;
  sides.reserve(4);
  for(int i = 1; i <= n-2; ++i) {
    for(int j = i+1; j <= n-1; ++j) {
      if (l[i] == l[j]) continue;
      for(int k = j+1; k <= n; ++k) {
        if ((l[i] == l[k]) || (l[j] == l[k])) continue;
        //cout << "ijk:" << i << "," << j << "," << k << endl;
        sides.clear();
        sides.push_back(l[i]);
        sides.push_back(l[j]);
        sides.push_back(l[k]);
        sort(sides.begin(), sides.end(), std::greater<ll>());
        //cout << "sides:" << sides[0] << "," << sides[1] << "," << sides[2] << endl;
        if (sides[0] < sides[1] + sides[2]) {
          ++ans;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0,l = 1;
	while(1){
		l = pow(2,ans);
		if(l * 2 > n) break;
		ans++;
	}
	cout << l;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <string>
#define int string
using namespace std;

priority_queue<int, vector<int >, greater<int > > q;
long n, l;

signed main() {
	cin >> n >> l;
	for (long i = 1; i <= n; ++i) {
		int t;
		cin >> t;
		q.push(t);
	}
	while (!q.empty()) {
		cout << q.top();
		q.pop();
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (int)(n);i++)
using namespace std;
int main(){
  int64_t n,sum=0;
  cin >> n;
  vector<int64_t> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(), a.end());
  //cout << a.at(0) << endl;
  sum+=a.at(n-1);
  if(n%2==0){
    int x=(n-1)/2;
    for(int64_t i=2;i<=n/2;i++){
      sum=sum+2*a.at(n-i);
      //cout << a.at(n-i) << endl;
      //cout << sum << endl;
    }
  }
  else{
    int x=(n-1)/2;
    for(int64_t i=2;i<=n/2;i++){
      sum=sum+2*a.at(n-i);
      //cout << sum << endl;
    }
    sum+=a.at(n-n/2-1);
  }
  cout << sum << endl;
}
   
  
  


Measured memory_bytes: 4840
package main
import (
  "fmt"
  "sort"
)

func main() {
  var N int
  fmt.Scan(&N)
  A := make([]int, N)
  for i := 0; i < N; i++ {
    fmt.Scan(&A[i])
  }
  //sort.Slice(A, func(i, j int) bool { return A[i] > A[j] })
  sort.Sort(sort.Reverse(sort.IntSlice(A)))
  var alice, bob int
  for i, a := range A {
    if i % 2 == 0 {
      alice += a
    } else {
      bob += a
    }
  }
  fmt.Println(alice - bob)
}


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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int a = 1; a < n; a++) {
    ans += (n - 1) / a;
  }
  cout << ans << endl;
  return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  string ss;
  each (c, s) {
    if (c == 'x') continue;
    ss.push_back(c);
  }
  string rss = ss;
  reverse(rss.begin(), rss.end());
  if (ss != rss) {
    cout << -1 << endl;
    return 0;
  }

  string rs = s;
  reverse(rs.begin(), rs.end());

  ll mid = ss.size()%2 == 0 ? ss.size()/2 : ss.size()/2+1;
  ll l = 0;
  ll r = 0;
  ll ans = 0;
  for (ll i = 0; i < mid;) {
    if (s[l] == rs[r]) {
      if (s[l] != 'x') ++i;
      ++l; 
      ++r; 
    } else if (s[l] != rs[r]) {
      if (s[l] == 'x') ++l;
      else if (rs[r] == 'x') ++r;
      ++ans;
    }
  }

  cout << ans << endl;
  
  return 0;
}


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

int main() {
    ll n,m;
    std::cin >> n>>m;
    
    vector<ll> s(m);
    vector<ll> c(m);
    for (int i = 0; i < m; i++) {
        std::cin >> s[i]>>c[i];
    }
    
    for (int i = 0; i <= 999; i++) {
        string x = to_string(i);
        if(to_string(i).size()==n){
            bool ok = true;
            for (int j = 0; j < m; j++) {
                // std::cout << x[s[j]-1]-'0' << std::endl;
                if(x[s[j]-1]-'0'!=c[j]){
                    // std::cout << i << std::endl;
                    ok = false;
                    break;
                }
            }
            if(ok){
                std::cout << i << std::endl;
                return 0;
            }
        }
    }
    std::cout << -1 << std::endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int no = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o') no++;
  }
  if ((no + 15 - s.size()) >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
vertex = [[0 for j in range(N+1)] for i in range(N+1)]
AB = [list(map(int,input().split())) for _ in range(M)]

for i in range(M):
    a,b = AB[i]
    vertex[a][b] = 1
    vertex[b][a] = 1

from itertools import permutations

ans = 0
for v in permutations([i+2 for i in range(N-1)], N-1):
    v = [1] + list(v)
    canmake = 1
    for j in range(N-1):
        if not vertex[v[j]][v[j+1]]:
            canmake = 0
            break
    if canmake:
        ans += 1
print(ans)

Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    vector<string> s(N);
    
    for(int i=0; i<N; i++){
        cin >> s.at(i);
    }
    
    sort(s.begin(), s.end());
    
    int count=1;
    
    for(int i=0; i<N-1; i++){
        if(s.at(i)!=s.at(i+1))
            count++;
    }
    
    cout <<count << endl;
    
    return 0;
}

Measured memory_bytes: 9556
/* author   : mpily :-()
title : Competing.cpp
time :Sat Apr 18 13:22:36 2020

*/
#include<bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932;
int main(){
	int r;
	cin>>r;
	cout<<setprecision(9);
	cout<<fixed;
	cout<<PI*r*2.0<<"\n";
	return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  rep(i, h) {
    rep(j, w) {
      int k = (i < b) ^ (j < a);
      cout << k;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	ll arr[100010]={};
	cin>>n>>k>>y;
	m=y;
	while(y--){
		cin>>x;
		arr[x]++;
	}
	for(ll i=1;i<=n;i++){
		arr[i]+=k-m;
		cout<<(arr[i]>0?"Yes\n":"No\n");
	}
}

Measured memory_bytes: 4480
N = int(input())
P = list(map(int, input().split()))

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

Pi = [0] * (N + 1)
for i, n in enumerate(P, 1):
    Pi[n] = i

T = [0] * N
f = [0] * N

if Pi[N] > Pi[N - 1]:
    T[N - 1] = 0
    f[N - 1] = N - 1
else:
    T[N - 1] = 1
    f[N - 1] = N

for i in range(N - 2, 0, -1):
    if T[i + 1] == 0:
        i_i = Pi[i]
        i_ii = Pi[i + 1]
        if i_ii > i_i:
            T[i] = T[i + 1]
            f[i] = f[i + 1]
        else:
            T[i] = T[i + 1] + 1
            f[i] = i + 1
    else:
        i_f = Pi[f[i + 1]]
        i_i = Pi[i]
        i_ii = Pi[i + 1]
        if i_f < i_i < i_ii or i_ii < i_f < i_i or i_i < i_ii < i_f:
            T[i] = T[i + 1]
            f[i] = f[i + 1]
        else:
            T[i] = T[i + 1] + 1
            f[i] = i + 1

print(T[1])

Measured memory_bytes: 35624
#n:
#m:
#k:
n,m,k=map(int,input().split())
friend={}
block={}

#resultは、ある人が何人の友達候補を持つかを保持する。
result=[]
#friendGroupは、ある人が何グループに所属するかを保持する。
friendGroup=[]

#初期化
for i in range(1,n+1):
    friend[i]=set([])
    block[i]=set([])
    result.append(0)
    friendGroup.append(0)

#友達関係を作る
for _ in range(m):
    a,b=map(int,input().split())
    friend[a].add(b)
    friend[b].add(a)

#DFS
checked=set([])
bfbf=[]
for i in range(1,n+1):
    #print(i,checked)
    if i not in checked:
        checked.add(i)
        group=set([i])
        bf=set([i])
        friendGroup[i-1]=i
        while len(group)!= 0:
            temp=group.pop()
            for item in friend[temp]:
                if item not in checked:
                    checked.add(item)
                    group.add(item)
                    bf.add(item)
                    #誰がどのグループに所属するかを保持する
                    friendGroup[item-1]=i
        lenbf=len(bf)
        for item1 in bf:
            result[item1-1]=lenbf-1-len(list(friend[item1]))

#block関係を確認する
for _ in range(k):
    a,b=map(int,input().split())

    #block関係にあるペアが、同じfirendGroupだったらマイナス１する
    if friendGroup[a-1]!=0 and friendGroup[a-1]==friendGroup[b-1]:
        result[a-1]-=1
        result[b-1]-=1

result=list(map(str,result))
print(" ".join(result))







Measured memory_bytes: 125540
#include<stdio.h>
int main(void)
{
	int a,s,d=0,f,g,h,j,i;
	scanf("%d %d",&a,&s);
	if(a<0&&s<0){
		a=a*-1;
		s=s*-1;
		d=a+s;
		if(d%2==0){
			printf("Negative\n");
		}
		if(d%2==1){
			printf("Positive\n");
		}
		a*=-1;
		s*=-1;
	}
	if(a>0&&s>0){
		printf("Positive\n");
	}
	if(a<=0&&s>=0){
		printf("Zero\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int h = sc.nextInt();
			if (h >= K) ans++;
		}
		System.out.println(ans);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 24248
#include<iostream>
using namespace std;
#define maxx 10
int A[maxx];
int cnt=0;//交换次数 
//选择排序：找出未排序部分最小值的序号
//由于直接交换两个不相邻的元素，不具有稳定性，时间复杂度为O(n^2)
//冒泡排序从局部入手减少逆序元素，选择排序放眼大局逐个选择最小值
//但都有通过i次外层循环，从数据中顺次求出i个最小值
//插入排序是通过i次外层循环，直接将原数组的i个元素重新排序，数据依赖性大 
int trace(int num[],int n)
{
	for(int i=0;i<n;i++)
	{
		if(i>0)
		cout<<" ";
		cout<<num[i];
	}
	cout<<endl<<cnt<<endl;
	return 0;
}
//先找后交换 
int selectionSort(int num[],int n)
{
	for(int i=0;i<n-1;i++)
	{
		int flag=0;
		int v=num[i];
		int kk=i;//未排序部分最小值的序号 
		for(int j=i+1;j<n;j++)
		{
			if(num[j]<v)
			{
				flag=1;
				v=num[j];
				kk=j;	
			} 
		}
		if(flag==1)
		{
			int tt=num[kk];
			num[kk]=num[i];
			num[i]=tt;
			cnt++;
		}
	} 
	return 0;
}
//边找边交换,这种不叫选择排序 
/*int selectionSort(int num[],int n)
{
	for(int i=0;i<n;i++)
	{
		int minj=i;
		for(int j=i+1;j<n;j++)
		{
			if(num[j]<num[minj])
			{
				int tt=num[minj];
				num[minj]=num[j];
				num[j]=tt;
				cnt++;//此处cnt含义发生变化，总共的交换次数 
			}
			
		}	
	}	
} */
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>A[i];
	}
	selectionSort(A,n);
	trace(A,n);
	return 0;
}
 


Measured memory_bytes: 3072
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;


public class Main {
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int M=sc.nextInt();
		solve(N,M);
	}
	void solve(int N,int M) {
		int s0=0,t0=1;
		int s1=N/2,t1=(N/2+2)%N;
		ArrayList<int[]> ans=new ArrayList<>();
		boolean[] vis=new boolean[N];
		for (int i=0;i<M;++i) {
			if (!vis[s0]&&!vis[t0]) {
				vis[s0]=true;vis[t0]=true;
				ans.add(new int[] {s0,t0});
			}
			if (!vis[s1]&&!vis[t1]) {
				vis[s1]=true;vis[t1]=true;
				ans.add(new int[] {s1,t1});
			}
			s0=(s0+N-1)%N;
			t0=(t0+1)%N;
			s1=(s1+N-1)%N;
			t1=(t1+1)%N;
		}
		PrintWriter pw=new PrintWriter(System.out);
		for (int i=0;i<M;++i) {
			pw.println(ans.get(i)[0]+1+" "+(ans.get(i)[1]+1));
		}
		pw.close();
	}
	
	// 1 2
	// 3 5
	// 4 
	// 1+2+3+...+M/2=N/2*
	
	
	
	// 1 4
	// 2 5
	// 3 6
	
	// 
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}




class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}

Measured memory_bytes: 46140
import sys
import re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
    D,T,S = i_map()
    time = 0
    if D%S == 0 :
        time = D//S
    else:
        time = D//S+1

    if time <= T:
        print("Yes")
    else:
        print("No")

    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 10336
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N,A,B;
    cin>>N>>A>>B;

    vector<char>S(N);
    int X=A+B;
    int Y=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    for(int i=0;i<N;i++){
        if(S[i]=='c'){
            cout<<"No"<<endl;
        }
        else if(S[i]=='a'){
            X--;
            if(X>=0){
                cout<<"Yes"<<endl;
            }
            else{
                cout<<"No"<<endl;
            }
        }
        else{
            Y++;
            if(X>0&&Y<=B){
                cout<<"Yes"<<endl;
                X--;
            }
            else{
                cout<<"No"<<endl;
            }
        }
    }   
}


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

using namespace std;

int main () {
  int n, k;
  cin >> n >> k;
  long double ans = 0;
  for (int i = 1; i <= n; i++) {
    int cur = i, tot = 0;
    while (cur < k) {
      tot++;
      cur *= 2;
    }
    ans += ((long double)1.0 / (long double)n) * pow(((long double)1.0 / (long double)2.0), (long double)tot);
  }
  cout << fixed << setprecision(20) << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
int main(){
	double x1,y1,x2,y2,l;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	l=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
	printf("%0.8f\n",l);
	return 0;
}


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

static const int LEN = 100005;

struct Round { char name[100]; int time; };
Round Q[LEN];
int head, tail;

Round dequeue() {
	Round x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

void enqueue(Round x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

int min(int x,int y) {
	if (x > y) {
		return y;
	}
	else {
		return x;
	}
}

int main() {
	int n, p;
	int tmp_t = 0, c;
	Round T;
	cin >> n >> p;
	head = 0;
	tail = n;
	for (int i = 0; i < n; i++) {
		cin >> Q[i].name >> Q[i].time;
	}
	while (head != tail) {
		T = dequeue();
		c = min(T.time, p);
		T.time -= c;
		tmp_t += c;
		if (T.time > 0) {
			enqueue(T);
		}
		else {
			cout << T.name << " " << tmp_t << endl;
		}
	}

}


Measured memory_bytes: 13164
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A + B + C) >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);

    rep(i,n)cin >> a[i];

    sort(a.begin(),a.end());

    cout << a.back()-a[0] <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	//
	int N;
	cin >> N;

	vector<int> vX(N, 0);
	rep(i, N) cin >> vX[i];

	vector<int> sortvec = vX;
	sort(sortvec.begin(), sortvec.end());

	int mid1 = sortvec[sortvec.size() / 2 - 1];
	int mid2 = sortvec[sortvec.size() / 2];

	for (int i = 0; i != N; ++i) {
		if (vX[i] <= mid1) {
			cout << mid2 << endl;
		}
		else {
			cout << mid1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3840
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    X,Y=[0]*n,[0]*n
    for i in range(n):
        X[i],Y[i]=map(int,input().split())

    from itertools import permutations
    from math import factorial
    ans=0
    for perm in permutations(range(n)):
        score=0
        for i in range(n-1):
            tmp=(X[perm[i+1]]-X[perm[i]])**2+(Y[perm[i+1]]-Y[perm[i]])**2
            tmp=tmp**.5
            score+=tmp
        ans+=score
    print(ans/factorial(n))
resolve()

Measured memory_bytes: 40560
#include<stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int H[N];
    int max = -1;
    for(int i = 0; i < N; i++){
        scanf("%d", &H[i]);
        if(max < H[i]){max = H[i];}
    }
    /*for(int i = 0; i < N; i++){printf("%d ", H[i]);}
    printf("max:%d\n", max);
    return 0;*/
    int tmp[N];
    int idx[N];
    int sum = 0;
    int loop = 0;
    while(loop < max){
        int count = 0;
        int v = 0;
        for(int i = 0; i < N; i++){
            if(H[i] != 0){
                tmp[i] = 1; H[i]--;
                idx[v] = i; v++;
                count++;//idxに入れた数
            }else{
                tmp[i] = 0;
            }
        }
        int num = count;
        //printf("tmpを表示します\n");
        //for(int i = 0; i < N; i++){printf("%d ", tmp[i]);}
        //printf("num:%d\n", num);
        if(num > 1){
            for(int i = 0; i < count-1; i++){
                if(idx[i+1] - idx[i] == 1){num--;}
            }
        }
        //printf("num:%d\n", num);
        sum += num;
        loop++;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	long long int*** dp = new long long int**[10];
	for(int i = 1; i <= 9; i++){
		dp[i] = new long long int*[101];
		for(int k = 0; k <= 100; k++){
			dp[i][k] = new long long int[1001];
			for(int p = 0; p <= 1000; p++)dp[i][k][p] = 0;
		}
	}

	for(int i = 0; i <= 100; i++){
		dp[1][i][i] = 1;
	}

	for(int i = 2; i <= 9; i++){
		for(int k = 0; k <= 100; k++){
			for(int a = 0; a <= k-1; a++){
				for(int p = k; p <= 1000; p++){
					dp[i][k][p] += dp[i-1][a][p-k];
				}
			}
		}
	}

	long long int ans;
	int n,s;

	while(true){
		scanf("%d %d",&n,&s);
		if(n == 0 && s == 0)break;

		ans = 0;
		for(int i = 0; i <= 100; i++)ans += dp[n][i][s];

		printf("%lld\n",ans);

	}

    return 0;
}

Measured memory_bytes: 9788
n = int(input())
s = input()

b = [0 for k in range(n+1)]
c = 0
for k in range(n):
    if s[k] == "#":
        c += 1
    b[k+1] = c

w = [0 for k in range(n+1)]
c = 0
for k in range(n):
    if s[-k-1] == ".":
        c += 1
    w[-k-2] = c

ans = 10**9
for k in range(n+1):
    ans = min(ans,b[k]+w[k])

print(ans)


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

using namespace std;

const int CMax = 100002;

int n, a, b, ats;

int main() {
    scanf("%d %d %d", &n, &a, &b);
    printf("%d\n", min(a*n, b));
}



Measured memory_bytes: 256
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr long long INF = 1000000000000000000LL + 8;

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

    int n, k;
    cin >> n >> k;
    vector<int> p(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < n; i++) cin >> c[i];

    // 1回以上移動しなければならない。得点は負になることがある。そのため-INFを番兵とする。
    int ans = -INF;

    // このコードではマス番号は0-based

    // 初期位置を全部試す
    // iマスにコマをおくときの得点を計算する
    for (int i = 0; i < n; i++) {
        int pos = i;
        int score = 0;

        // コマの遷移には周期性がある
        // 1周の移動回数と1周で得る得点を計算する
        int period = 0; /* 1周期の移動回数 */
        int cyclic_score = 0;
        pos = i;
        do {
            pos = p[pos];
            cyclic_score += c[pos];
            period++;
        } while (pos != i);

        // 1周だけ、1周できないならできるだけ移動したときの得点を計算する
        pos = i, score = 0;
        for (int j = 0; j < min(period, k); j++) {
            pos = p[pos];
            score += c[pos];
            ans = max(score, ans);
        }

        // k/period周するときの得点を計算する
        if (cyclic_score > 0 && k / period > 0) {
            score = cyclic_score * (k / period);
            ans = max(score, ans);

            // 残りの回数だけ移動したときの得点を調べる
            pos = i;
            for (int j = 0; j < k % period; j++) {
                pos = p[pos];
                score += c[pos];
                ans = max(score, ans);
            }
        }

        // k/period-1周するときの得点を計算する
        if (cyclic_score > 0 && k / period > 1) {
            score = cyclic_score * (k / period - 1);
            ans = max(score, ans);

            // 残りの回数だけ移動したときの得点を調べる
            pos = i;
            for (int j = 0; j < period; j++) {
                pos = p[pos];
                score += c[pos];
                ans = max(score, ans);
            }
        }
    }

    cout << ans << endl;
}

// 1周できないとき
// →移動中の得点を調べる

// 1周できるとき
// →1周の移動中の得点を調べる
// →1周で得る得点が正ならば、できるだけ周回して残りの回数だけ移動する得点を調べる


Measured memory_bytes: 3692
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define rep(i,n) for(int i=0;i<n;i++)

double D,px,py,vx,vy;

int main(){
	while(cin>>D&&D){
		cin>>px>>py>>vx>>vy;
		if(fabs(px*vy-py*vx)>EPS)cout<<"impossible"<<endl;
		else{
			if(px*vx>0||py*vy>0){
				if(2-sqrt(px*px+py*py)>D)cout<<"impossible"<<endl;
				else printf("%.7f\n",2-sqrt(px*px+py*py));
			}
			else{
				if(sqrt(px*px+py*py)>D)cout<<"impossible"<<endl;
				else printf("%.7f\n",sqrt(px*px+py*py));
			}
		}
	}
}

Measured memory_bytes: 0
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
func readInt() -> Int {
    return Int(readLine()!)!
}

func main() {
    _ = readInt()
    let cards = readInts().sorted { $0 > $1 }.enumerated()
    var point = 0
    cards.forEach {
        if $0.offset % 2 == 0 {
            point += $0.element
        } else {
            point -= $0.element
        }
    }
    print(point)
}

main()

Measured memory_bytes: 8308
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = vs[0];
			int M = vs[1];
			int C = vs[2];
			int[] B = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			int ans = 0;
			for (int i = 0; i < N; i++) {
				int[] A = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
				int sum = C;
				for (int j = 0; j < M; j++) {
					sum += A[j] * B[j];
				}
				if (sum > 0) {
					ans++;
				}
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13268
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(a: [i64]);
    let n = a.len();
    let odd = a.iter().filter(|&&x| x % 2 == 1).count();
    let &mi = a.iter().min().unwrap();
    if n % 2 == 1 {
        puts!("{}\n", if odd % 2 == 0 { "Second" } else { "First" });
    } else {
        puts!("{}\n", if mi % 2 == 0 && odd % 2 == 0 { "Second" } else { "First" });
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 11128
def main():
	def query(*args):
		print("? " + " ".join(str(x + 1) for x in args), flush=True)
		answer = input()
		if answer == '-1':
			exit()
		return answer[0]
	
	def answer():
		print("! " + "".join(arr))
		exit()
	
	n = int(input())
	
	B = 'B'
	R = 'R'
	
	arr = [' '] * 2 * n
	
	tmp = query(*range(0, n))
	
	if n == 1:
		if tmp == B:
			arr = ['B', 'R']
		else:
			arr = ['R', 'B']
		answer()
	
	if tmp == B:
		B, R = R, B
	
	# l = n - 1
	# for i in range(1, n - 1):
	# 	tmp = query(*range(i, i + n))
	# 	if tmp == B:
	# 		l = i - 1
	# 		break
	l = 0
	r = n
	while r - l != 1:
		m = l + r >> 1
		tmp = query(*range(m, m + n))
		if tmp == B:
			r = m
		else:
			l = m
	
	arr[l] = R
	arr[l + n] = B
	
	for i in range(l + 1, l + n):
		lst = list(range(l, i)) + list(range(i + 1, l + n + 1))
		tmp = query(*lst)
		if tmp == R:
			arr[i] = B
		else:
			arr[i] = R
	
	for i in range(l):
		tmp = query(i, *range(l + 1, l + n))
		arr[i] = tmp
	
	for i in range(l + n + 1, 2 * n):
		tmp = query(i, *range(l + 1, l + n))
		arr[i] = tmp
	
	answer()
	
	return 0

main()


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

using namespace std;

bool qu;
struct line
{
    long long m,b;
    mutable function<const line*()> succ;
    bool operator<(const line &rhs) const
    {
        if (!qu)
        return (m<rhs.m);
        const line *s=succ();
        if (!s)
        return 0;
        return b-s->b>rhs.m*(s->m-m);
    }
};
struct hull:public multiset<line>
{
    bool bad(iterator y)
    {
        auto z=next(y);
        if (y==begin())
        {
            if (z==end())
            return 0;
            return (y->m==z->m && y->b>=z->b);
        }
        auto x=prev(y);
        if (z==end())
        return (y->m==x->m && y->b>=x->b);
        return 1.0*(x->b-y->b)*(z->m-y->m)<=1.0*(y->b-z->b)*(y->m-x->m);
    }
    void add(long long m,long long b)
    {
        auto it=insert({m,b});
        it->succ=[=] { return (next(it)==end())? 0:&*next(it); };
        if (bad(it))
        {
            erase(it);
            return;
        }
        while (next(it)!=end() && bad(next(it)))
        erase(next(it));
        while (it!=begin() && bad(prev(it)))
        erase(prev(it));
    }
    long long eval(long long x)
    {
        qu=1;
        line l=*lower_bound((line){x,0});
        qu=0;
        return l.m*x+l.b;
    }
};
hull h;

int n;
long long c;
int arr[200005];
long long mem[200005];

int main()
{
    // (hi - hj)^2 + C
    // hi^2 - 2*hihj + hj^2 + C
    cin >> n >> c;
    for(int i=0;i<n;i++)
        cin >> arr[i];
    h.add(arr[n-1],1LL*arr[n-1]*arr[n-1]);
    for(int i=n-2;i>=0;i--)
    {
        mem[i]=h.eval(-2*arr[i])+c+1LL*arr[i]*arr[i];
        h.add(arr[i],mem[i]+1LL*arr[i]*arr[i]);
    }
    cout << mem[0] << endl;
}

Measured memory_bytes: 21376