akhauriyash/Code-Regression huggingface dataset:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

mark = [[0]*3, [0]*3, [0]*3]

for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark[j][k] = 1


if mark[0][0] == mark[1][1] == mark[2][2] == 1 or  mark[0][2] == mark[1][1] == mark[2][0] == 1:
    print("Yes")
    exit()
else:
    for i in range(3):
        if mark[i][0] == mark[i][1] == mark[i][2] == 1:
            print('Yes')
            exit()
        if mark[0][i] == mark[1][i] == mark[2][i] == 1:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

    vector<char> ans;
    REP(i, s.size()){
        if(i % 2 == 0){
            ans.pb(s[i]);
        }
    }

    REP(i, ans.size()){
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<ll> v(n+1);
    rep(i, n+1) {
        if (i==0) v[i] = 2;
        if (i==1) v[i] = 1;
        if (i>1) {
            v[i] = v[i-2] + v[i-1];
        }
    }
    ll ans = v[n];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())

using namespace std;
typedef long long  ll;
const int N = 1e5 + 4 , LG = log2(N) + 1;
int gcd[N][LG];
int n , getlg[N];
vector<int> a;
// take care of long long

void pre(){
    for(int i = 1 ; i < N ; ++i)
        getlg[i] = (int)log2(i);
}

void build(){
    int lg = getlg[n];

    for(int i = 0 ; i < n ; ++i)
        gcd[i][0] = a[i];           // base case

    for(int j = 1 ; j <= lg ; ++j){
        for(int i = 0 ; i + (1 << j) - 1 < n ; ++i){
            gcd[i][j] = __gcd(gcd[i][j - 1] , gcd[i + (1 << (j - 1))][j - 1]);
        }
    }

}

int getGCD(int l , int r){          // query in log(N) s.t. N = max(gcd[l][lg] , gcd[l + dif][lg])
    int sz = r - l + 1 , lg = getlg[sz] , dif = sz - (1 << lg);
    return __gcd(gcd[l][lg] , gcd[l + dif][lg]);
}



int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> n;
    a.resize(n);
    for(int &x : a)
        cin >> x;

    pre();
    build();
    int mx = 1;
    for(int i = 0 ; i < n ; ++i){

        int f1 = 0 , f2 = 0;
        if(i)f1 = getGCD(0 , i - 1);
        if(i < n - 1)f2 = getGCD(i + 1 , n - 1);
        mx = max(mx , __gcd(f1 , f2));
    }

    cout << mx << "\n";
 }


Measured memory_bytes: 7680
N,W = map(int, input().split())
weight = [0]*N
value = [0]*N
for i in range(N):
    w, v = map(int, input().split())
    weight[i] = w
    value[i] = v
    
dp = [[10**13]*(sum(value)+1) for _ in range(N+1)]

for i in range(N):
    dp[i][0] = 0
    for j in range(sum(value)+1):
        if j < value[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i][j-value[i]]+weight[i])
            
for j in range(sum(value), -1, -1):
    if dp[N][j] <= W:
        ans = j
        break
        
print(ans)

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    const ll mod=998244353;
    const ll inv=(mod+1)/2;
    int n,s;
    cin >> n >> s;
    vector<ll> dp(s+1,0);
    dp[0]=1;
    for(int i=0;i<n;i++) dp[0]=(2*dp[0])%mod;
    for(int i=0;i<n;i++)
    {
        int a;
        cin >> a;
        for(int j=s-a;j>=0;j--) dp[j+a]=(dp[j+a]+dp[j]*inv)%mod;
    }
    cout << dp[s] << "\n";
    return 0;
}


Measured memory_bytes: 3668
#include<stdio.h>
#include<string.h>

int main(){
	int k,j;
	char s[1000];
	
	scanf("%d",&k);
	scanf("%s",s);
	
	if(k>0){
		if(strlen(s)<= k){
			printf("%s",s);
		}
		else{
			for(j=0;j<k;j++){
				printf("%c",s[j]);
			}
			printf("...");
		
		}	
	}
	
	
	
	return 0;
	
  
 
  
}


Measured memory_bytes: 1696
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
int N, H[101010], dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> H[i];
    
    rep(i, 0, N) dp[i] = inf;
    dp[0] = 0;
 
    rep(i, 0, N) {
        chmin(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
    }
 
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include<iostream>

int main(){
	int l,a,b,c,d;
	std::cin>>l>>a>>b>>c>>d;
	int e=a/c,f=b/d;
	if(a%c!=0)e+=1;
	if(b%d!=0)f+=1;
	std::cout<<std::min(l-e,l-f)<<std::endl;
	return 0;
}

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

int main(){
	int n,a;
	cin>>n;
	int A[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin>>a;
		A[i]=a;
	}
	b[0]=0;
	int x=A[0],m=0;
	for(int i=1;i<n;i++)
	{
		if(A[i]<=x){b[i]=b[i-1]+1;m=max(m,b[i]);}
		else b[i]=0;
		x=A[i];
	}
	cout<<m;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int w[300000],e[300000];
int main(void){
    int n;
    cin >> n;
    char a[n];
    for(int i = 0;i < n;i++) cin >> a[i];
    if(a[0] == 'W'){
        w[0] = 1;
    }else{
        w[0] = 0;
    }
    for(int i = 1;i < n-1;i++){
        if(a[i] == 'W') w[i] += (1+w[i-1]);
        else w[i] = w[i-1];
    }
    
    if(a[n-1] == 'E'){
        e[0] = 1;
    }else{
        e[0] = 0;
    }
    for(int i = 1;i < n-1;i++){
        if(a[n-i-1] == 'E') e[i] += (1+e[i-1]);
        else e[i] = e[i-1];
    }
    int ans = 0;
    ans = e[n-2];
    ans = min(ans,w[n-2]);
    for(int i = 1;i < n-2;i++){
        ans = min(ans,w[i-1]+e[n-i-2]);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

class U {
public:
  int n;
  vector<int> p, s;

  U(int _) {
    n = _;
    p.resize(n);
    s.resize(n);
    for (int i = 0; i < n; i++) {
      p[i] = i;
      s[i] = 1;
    }
  }

  bool connect(int a, int b) {
    int ap, bp;
    for (ap = p[a]; ap != p[ap]; ap = p[ap]);
    for (bp = p[b]; bp != p[bp]; bp = p[bp]);
    if (ap == bp)
      return true;
    int mi = min(ap, bp), ma = max(ap, bp);
    p[ma] = mi;
    s[mi] += s[ma];
    s[ma] = 0;
    for (int pp = a; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    for (int pp = b; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    return false;
  }

  int q(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return s[ap];
  }

  int parent(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return p[ap];
  }

  bool query(int a, int b) { return parent(a) == parent(b); }
};

struct Q {
  int a, b, c;
};

bool operator<(const Q &l, const Q &r) {
  return l.c < r.c;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, m, q;
  cin >> n >> m >> q;
  U u(n);
  vector<Q> qs(q);
  for (int i = 0; i < q; i++) cin >> qs[i].a >> qs[i].b >> qs[i].c;
  sort(qs.begin(), qs.end());
  int qc = q;
  for (int i = 0; i < q; i++) {
    if (qs[i].c) {
      qc = i;
      break;
    }
    u.connect(qs[i].a, qs[i].b);
  }
  ll nn = 0;
  for (int i = 0; i < n; i++) {
    if (u.parent(i) == i) {
      nn++;
    }
  }
  for (int i = qc; i < q; i++) {
    int ap = u.parent(qs[i].a);
    int bp = u.parent(qs[i].b);
    if (ap == bp) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (qc < q && (nn == 2 || m == n - 1)) {
    cout << "No" << endl;
    return 0;
  }
  ll emax = n - nn + nn * (nn - 1) / 2;
  if (m <= emax) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

long long solve0(long long n1, long long n2, int c, int N) {
  if (c == N) {
    return n2;
  }
  return solve0(n2, n1 + n2, c+1, N);
}

long long solve(long long N){
  return solve0(2, 1, 1, N);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N;
  scanf("%lld",&N);
  cout << solve(N) << endl;
}


Measured memory_bytes: 256
N,K = gets.chomp.split.map(&:to_i)
P = gets.chomp.split.map(&:to_i)
C = gets.chomp.split.map(&:to_i)

abc = []

(0..N-1).each do |i|
  cnt = 0
  ans = [0]
  y = i+1
while (cnt < K) do
  y = P[y-1]
  ans << ans.last+C[y-1]
  cnt += 1
  break if y == i+1
end
a = ans[1..-1].max
if cnt == K
abc << a
else
abc << [((ans.last)*(K/cnt)+ ans[0..K%cnt].max),((ans.last)*(K/cnt-1)+ ans[0..-2].max),a].max 
end
end

puts abc.max



  
  




Measured memory_bytes: 103556
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef tuple<ll,ll,ll> t3;

using namespace std;

int h,w;
map<char, int> m;

string yes = "Yes";
string no = "No";

void solve_oo()
{
    int count = 0;
    vector<int> ss;
    for(auto e : m)
    {
        if(e.second % 2 == 1)
        {
            ss.push_back(e.second-1);
            count++;
        }
        else
        {
            ss.push_back(e.second);
        }
    }
    if(count != 1)
    {
        cout << no << endl;
        return;
    }
    int f = 0;
    int s = 0;
    for(int i = 0;i < ss.size();i++)
    {
        f += ss[i] / 4;
        ss[i] -= (ss[i] / 4) * 4;
        s += ss[i] / 2;
        ss[i] -= (ss[i] / 2) * 2;
        if(ss[i] != 0)
        {
            cout << no << endl;
            return;
        }
    }
    auto fc = (h * w - h - w + 1) / 4;
    if(fc > f)
    {
        cout << no << endl;
        return;
    }
    cout << yes << endl;
}

void solve_oe()
{
    int f = 0;
    int s = 0;
    for(auto e : m)
    {
        auto c = e.second;
        f += c / 4;
        c -= (c / 4) * 4;
        s += c / 2;
        c -= (c / 2) * 2;
        if(c != 0)
        {
            cout << no << endl;
            return;
        }
    }
    auto fc = (h * w - h) / 4;
    if(fc > f)
    {
        cout << no << endl;
        return;
    }
    cout << yes << endl;
}

void solve_ee()
{
    for(auto e : m)
    {
        if(e.second % 4 != 0)
        {
            cout << no << endl;
            return;
        }
    }
    cout << yes << endl;
}

int main() {
    cin >> h >> w;
    for(int y = 0;y < h;y++)
    {
        string s;
        cin >> s;
        for(int x = 0;x < w;x++)
        {
            m[s[x]]++;
        }
    }
    if(h % 2 == 1)
    {
        swap(w,h);
    }
    if(h % 2 == 0 && w % 2 == 0)
    {
        solve_ee();
        return 0;
    }
    if(h % 2 == 1 && w % 2 == 1)
    {
        solve_oo();
        return 0;
    }
    solve_oe();
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){

	int n;
	cin >> n;
	map<int, int> even, odd;
	for(int i=0; i<n; i++){	
		int v;
		cin >> v;
		if(i%2 == 0) even[v]++;
		else 	odd[v]++;
	}

	typedef pair<int, int> P;
	vector<P> even2, odd2;
	for(P x : even){
		even2.emplace_back(x.second, x.first);
	}
	for(P x : odd){
		odd2.emplace_back(x.second, x.first);
	}

	sort(even2.rbegin(), even2.rend());
	sort(odd2.rbegin(), odd2.rend());
	int even_cnt = even2[0].first;
	int odd_cnt = odd2[0].first;
	if(even2[0].second != odd2[0].second){//一番多い数字の値がそれぞれ違うなら
		int ans = n - even_cnt - odd_cnt;
		cout << ans << endl;
		return 0;
	}
	if(even2.size() == 1 && odd2.size() == 1){
		cout << n/2 << endl;
		return 0;
	}

	// if(even2.size() == 1){
	// 	int ans = n - even_cnt - odd2[1].first;
	// 	cout << ans << endl;
	// 	return 0;
	// }
	// if(odd2.size() == 1){
	// 	int ans = n - odd_cnt - even2[1].first;
	// 	cout << ans << endl;
	// 	return 0;
	// }


	int even_cnt2 = even2[1].first;
	int odd_cnt2 = odd2[1].first;
	int ans;
	if(even_cnt + odd_cnt2 > even_cnt2 + odd_cnt) ans = n - even_cnt - odd_cnt2;
	else ans = n - even_cnt2 - odd_cnt;

	cout << ans << endl;

}



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

using namespace std;

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


int main(){
	while(1){
		int n,r;
		cin >> n >> r;
		if(n == 0 && r == 0){
			break;
		}

		vector<int> m(n);
		rep(i,n){
			m[i] = n - i;
		}

		rep(i,r){
			int p, c;
			cin >> p >> c;
			vector<int> w;

			REP(i,p-1,p-1+c){
				w.push_back(m[i]);
			}

			REP(i,0,p-1){
				w.push_back(m[i]);
			}

			REP(i,p-1+c,n){
				w.push_back(m[i]);
			}
			m = w;
		}
		cout << m[0] << endl;
	}
	return 0;
}

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

int main()
{
    ll n, d, res = 0;
    cin >> n >> d;

    for(int i = 0; i < n; ++i)
    {
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d * d)
            res++;
    }
    cout << res << "\n";
    return 0;
}

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


int main(int argc, char const* argv[])
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << char((int)s1[0]-32) << char((int)s2[0]-32) << char((int)s3[0]-32) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,j,k) for(i = j;i <= k;i++)

int main(){
  int a,b,n,amari;
  while(scanf("%d%d%d",&a,&b,&n) != EOF){
    int i,sum,temp;
    amari = a - (a / b) * b;
    sum = 0;
    rep(i,1,n){
      temp = (amari * 10) / b;
      sum += temp;
      amari = amari*10 - b*temp;
    }
    printf("%d\n",sum);
  }    
  return 0;
}

Measured memory_bytes: 0
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=a[0]+k-a[n-1]
list=[b]
for i in range(n-1):
    b=a[i+1]-a[i]
    list.append(b)
list.sort(reverse=True)
b=list[0]
print(k-b)


Measured memory_bytes: 26436
## for use in beginner level questions where speed is key
## and also for single test case code
## mastercopy for x,y,z

import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict

# read line as a string
# strr = input()

# read line as an integer
# k = int(input())

# read one line and parse each word as a string
# lst = input().split()

# read one line and parse each word as an integer
n,k = list(map(int,input().split()))
arr = list(map(int,input().split()))

# arr = [math.log(arr) for arr in n,k]

for i in range(n-k):
    if arr[i] < arr[i+k]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 105236
#include<bits/stdc++.h>
using namespace std;
#define long long long
const int MOD=1e9+7;

int main(){
  long N, K;
  cin >> N >> K;
  long ans =1;
  for(int i=K; i<=N; i++){
    long a = (i*(N-i+1)+1)%MOD;
    ans = (ans+a)%MOD;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;


int main(){
    long long a,b;
    cin >> a >> b;
    if((a+b)%2) cout <<"IMPOSSIBLE"<<endl;
    else cout << (a+b)/2 <<endl;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read

N, *ab = map(int, read().split())
mod = 10 ** 9 + 7
ab = list(zip(ab[:N], [0] * N)) + list(zip(ab[N:], [1] * N))
ab.sort()

remain_pc = 0
remain_power = 0
answer = 1

for x, p in ab:
    if p == 0:
        if remain_power == 0:
            remain_pc += 1
            continue
        answer *= remain_power
        remain_power -= 1
    else:
        if remain_pc == 0:
            remain_power += 1
            continue
        answer *= remain_pc
        remain_pc -= 1
    answer %= mod

print(answer)


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 10;
const int MOD = 998244353;

int N;
ll X[MAX], Y[MAX];

ld dist(int a, int b) {
    return sqrt(pow(X[a] - X[b], 2) + pow(Y[a] - Y[b], 2));
}

ld solve() {
    ld res = 0;
    vi idx(N);
    REP (i, N) idx[i] = i;
    do {
        REP (i, N-1) res += dist(idx[i], idx[i+1]);
    } while (next_permutation(idx.begin(), idx.end()));
    FOR (i, 1, N+1) res /= i;
    return res;
}

int main() {
    cin >> N;
    REP (i, N) cin >> X[i] >> Y[i];
    cout << fixed << setprecision(10) << solve() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int N, K;
string S;

int main() {
    cin >> N >> K;
    cin >> S;
    int face = 0;
    char tmp = S[0], nxt;
    for (int i = 1; i < N; i++) {
        nxt = S[i];
        if (tmp == 'R' && nxt == 'L') face++;
        tmp = nxt;
    }
    int left = S[0] == 'L'? 1 : 0, right = S[N - 1] == 'R'? 1 : 0;
    if (face >= K) {
        cout << N - (face - K) * 2 - left - right << endl;
    } else {
        cout << N - 1 << endl;
    }
}



Measured memory_bytes: 512
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] p = new int[n];
        int h = 0, sum = 0;
        for (int i = 0; i < n; i++){
            p[i] = input.nextInt();
            if (p[i] > h){
                sum += h;
                h = p[i];

            } else {
                sum += p[i];
            }
        }

        System.out.print(sum + h/2);
    }
}


Measured memory_bytes: 22608
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
using namespace std;
typedef long long ll;
const int N=4000,mo=998244353;
ll jc[N+10],ny[N+10],_2[N+10];
ll C(int m,int n){
	if(m<n) return 0;
	return jc[m]*ny[n]%mo*ny[m-n]%mo;
}
ll pow(ll x,int y){
	ll b=1;
	for(;y;y>>=1,x=x*x%mo) if(y&1) b=b*x%mo;
	return b;
}
ll f(int x,int y,int z){
	int t=min(x,z);
	ll tmp=0;
	fo(i,0,t) 
	if(y+i-1>=0) tmp=(tmp+C(x,i)*_2[i]%mo*C(z+y-1,y+i-1)%mo)%mo;
	return tmp;
}
int main()
{
	jc[0]=_2[0]=1;
	fo(i,1,N) jc[i]=jc[i-1]*i%mo,_2[i]=_2[i-1]*2%mo;
	ny[N]=pow(jc[N],mo-2);
	fd(i,N-1,0) ny[i]=ny[i+1]*(i+1)%mo;
	int n,k;
	scanf("%d %d",&k,&n);
	fo(i,2,k*2){
		int t=0;
		fo(j,1,k) if(i-j>=1 && i-j<=k) t++;
		if(i&1) printf("%lld\n",f(t/2,k-t,n));
		else printf("%lld\n",(f((t-1)/2,k-t,n)+f((t-1)/2,k-t,n-1))%mo);
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		int value = Integer.parseInt(str);
		int divNum = 0;
		for (int i = 0; i < str.length(); ++i) {
			Character c = str.charAt(i);
			divNum += Integer.parseInt(c.toString());
		}
		if (value % divNum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		in.close();

	}

}

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

using namespace std;
const int N = 100;
struct point{
	long long x,y;
}p[N];
bool cmp(point a,point b){
	if(a.x==b.x) return a.y<b.y;
	return a.x<b.x;
}
map<pair<long long,long long>,long long>re;
int main(){
	long long n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y;
	long long maxx=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i!=j){
				re[{p[i].x-p[j].x,p[i].y-p[j].y}]++;
				maxx=max(maxx,re[{p[i].x-p[j].x,p[i].y-p[j].y}]);
			}
		}
	}
	cout<<n-maxx<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int dp[10001];
int deq[10001];
int deqv[10001];
int deq_h,deq_t;

void deq_push(int j, int val) {
  while(deq_h < deq_t && deqv[deq_t-1] <= val)deq_t--;
  deq[deq_t] = j;
  deqv[deq_t++] = val;
}

void deq_pop() {
  deq_h++;
}

int main() {
  int N, W;
  cin>>N>>W;
  vector<int> v(N, 0),w(N, 0),m(N, 0);
  for (int i=0;i<N;++i){
    cin>>v[i]>>w[i]>>m[i];
  }

  for (int i=0;i<N;++i) {
    for (int md=0;md<w[i];++md) {
      deq_h=0,deq_t=0;
      for (int j=0;j*w[i]+md<=W;++j) {
        int val = dp[j*w[i]+md] - j*v[i];
        deq_push(j, val);
        dp[j*w[i]+md] = deqv[deq_h] + j*v[i];
        if (deq[deq_h] <= j-m[i]) {
          deq_pop();
        }
      }
    }
  }

  cout<<dp[W]<<endl;

  return 0;
}


Measured memory_bytes: 3260
#include <iostream>
using namespace std;
int main(void){
 
    int x;
    
    for(int i = 0;i < 10000;i++){
        cin >>x;
        
        if(x == 0){
            break;
        }
        
        cout << "Case " << i + 1<< ": " << x << endl;
    }
    
    
 
}


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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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 <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> long long iterate_sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

struct union_find {
    int size;
    vector<int> par;
    union_find(int N) : size(N), par(N) { REP(i, N) par[i] = i; }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        else {
            par[rx] = ry;
            return;
        }
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

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

int main() {
    int n=50;
    double v[1005];
    cin>>n;
    for (int i = 0; i < n; i++) {
        cin>>v[i];
    }
    sort(v, v+n);
    double ans=0;
    ans = (v[0]+v[1])/2;
    for (int i = 2; i < n; i++) {
        ans = (ans + v[i])/2;
    }
    cout<<ans<<endl;
}


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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	rep(i, n)cin >> l[i];
	int cnt = 1;
	int d = 0;
	rep(i,n) {
		d += l[i];
		if (d > x) {
			break;
		}
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

/* define const */

/* finish defineing const */

long x;

int main()
{
  cin >> x;
  // input
  
  long t = x / 11;
  long cnt = t*2;
  long tmp = t*11;
  while (tmp < x) {
    tmp += 6;
    ++cnt;
    if (tmp >= x) break;
    tmp += 5;
    ++cnt;
    if (tmp >= x) break;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); itr++)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); itr++)
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 200001
const string alpha = "abcdefghijklmnopqrstuvwxyz";

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n;
	cin >> n;
	vector<vector<ll>> abc(n, vector<ll>(3)), dp(n, vector<ll>(3));
	loop(i, n)	cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
	dp[0][0] = abc[0][0];
	dp[0][1] = abc[0][1];
	dp[0][2] = abc[0][2];
	FOR(i, 1, n - 1)
	{
		dp[i][0] = abc[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = abc[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = abc[i][2] + max(dp[i - 1][1], dp[i - 1][0]);
		// cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << END;
	}
	cout << *max_element(all(dp[n - 1])) << END;
// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
int INF = 1e9+7;


int main() {
    string S;
    int A[4];
    for (int i=0; i<4; i++) A[i]=0;
    cin >> S;
    for (int i=0; i<4; i++) {
        for (int j=0; j<4; j++) {
            if (S[i]==S[j]) A[i]++;
        }
    }

    if (A[0]==2 &A[1]==2 &A[2]==2 &A[3]==2) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

int main(){
  int pa,pb,pc,ja,jb;
  int total;

  cin >> pa;
  cin >> pb;
  cin >> pc;
  cin >> ja;
  cin >> jb;

  total = min({pa,pb,pc}) + min({ja,jb}) - 50;

  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 3060
#include <iostream>

int sx,sy,tx,ty;

int main() {
	std::cin>>sx>>sy>>tx>>ty;
	for(int i=0;i<tx-sx;++i)
		std::cout<<'R';
	for(int i=0;i<ty-sy;++i)
		std::cout<<'U';
	for(int i=0;i<tx-sx;++i)
		std::cout<<'L';
	for(int i=0;i<ty-sy;++i)
		std::cout<<'D';
	std::cout<<'D';
	for(int i=0;i<tx-sx+1;++i)
		std::cout<<'R';
	for(int i=0;i<ty-sy+1;++i)
		std::cout<<'U';
	std::cout<<'L';
	std::cout<<'U';
	for(int i=0;i<tx-sx+1;++i)
		std::cout<<'L';
	for(int i=0;i<ty-sy+1;++i)
		std::cout<<'D';
	std::cout<<'R'<<std::endl;
	return 0;
}

Measured memory_bytes: 888
N,K=map(int,input().split())
d=[0]*K
A=[0 for _ in range(K)]
S=set([i+1 for i in range(N)])
for i in range(K):
  d[i]=int(input())
  A[i]=list(map(int,input().split()))
  for p in A[i]:
    if p in S:
      S.remove(p)
      
#print(S)
print(len(S))

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	int n,k;
	cin >> n >> k;
	LL a[n];
	// nyuryoku
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	// keisan
	for(int i=k;i<n;i++){
		if(a[i] > a[i-k]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	// syutsuryoku
}

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

template <int mod = (int)(998244353)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const noexcept { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const noexcept { return x != p.x; }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is, ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

long long n;
string s;
vector<int> cnt(3, 0);

int c_to_i(char c) {
  if (c == 'R') return 0;
  if (c == 'G') return 1;
  return 2;
}
ModInt<> solve();

int main() {
  cin >> n >> s;
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  ModInt<> res = 1;
  for (int i = 0; i < 3 * n; ++i) {
    int id = c_to_i(s[i]), num = -1;
    ++cnt[id];
    for (int j = 0; j < 3; ++j)
      if (cnt[id] > cnt[j]) num = max(num, cnt[j]);
    if (num == -1) num = cnt[id] - 1;
    res *= cnt[id] - num;
  }
  for (int i = 1; i <= n; ++i) res *= i;
  return res;
}


Measured memory_bytes: 900
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n=0,t,l;
	char s[81];
	while(~scanf("%s",s)){
		t=0;
		l=strlen(s);
		rep(i,l){
			if(s[i]<='9' && s[i]>='0')t=t*10+s[i]-'0';
			else {
				n+=t;
				t=0;
			}
		}
		n+=t;
	}
	printf("%d\n",n);
	
	return 0;
}

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    lvec a(n+1), b(n);
    ll sum=0;
    for (int i=0; i<n+1; i++) cin >> a[i];
    for (int i=0; i<n; i++) cin >> b[i];
    b.push_back(0);
    sum += fmin(a[0], b[0]);
    b[0] = fmax(b[0] - a[0], 0);
    int i;

    for (i=1; i<n; i++) {
        sum += fmin(a[i], b[i-1]);
        ll aa = fmax(a[i]-b[i-1], 0);
        sum += fmin(aa, b[i]);
        b[i] = fmax(b[i]-aa, 0);
    }
    sum +=fmin(a[i], b[i-1]);
    cout << sum << endl;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        String rslt = null;
      
        if (a+b+c >= 22) {
          rslt = "bust";
        } else {
          rslt = "win";
        }

      System.out.println(rslt);
	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}



int main()
{
    fastio();
    int x,y,a,b;
    cin>>x>>y;
    if(y&1) cout<<"No"<<endl;
    else {
        if(y>4*x || y<2*x) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
N, W = map(int, input().split())
vs = [0]*N; ws = [0]*N; ms = [0]*N
for i in range(N):
    vs[i], ws[i], ms[i] = map(int, input().split())

def solve(N, W, ws, vs, ms):
    vs0 = []; ws0 = []
    for i in range(N):
        v = vs[i]; w = ws[i]; m = ms[i]
        b = 1
        while b <= m:
            vs0.append(v * b)
            ws0.append(w * b)
            m -= b
            b <<= 1
        if m:
            vs0.append(v * m)
            ws0.append(w * m)

    dp = [0] * (W+1)
    N0 = len(vs0)
    for i in range(N0):
        v = vs0[i]; w = ws0[i]
        for j in range(W, w-1, -1):
            dp[j] = max(dp[j-w] + v, dp[j])
    return max(dp)

print(solve(N, W, ws, vs, ms))


Measured memory_bytes: 6064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl;
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	while (true) {
		int t, h, s; cin >> t >> h >> s;
		if (t == -1 && h == -1 && s == -1)break;

		int ns = 2 * 3600 - (t * 3600 + h * 60 + s);
		int ns3 = ns * 3;

		printf("%02d:%02d:%02d\n", ns / 3600, ns % 3600 / 60, ns % 60);
		printf("%02d:%02d:%02d\n", ns3 / 3600, ns3 % 3600 / 60, ns3 % 60);
	}
}


Measured memory_bytes: 3232
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<double> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	vector<vector<double>> dp(n + 1, vector<double>(n + 1));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			if (j == 0) dp[i + 1][j] = dp[i][j] * (1 - p[i]);
			else dp[i + 1][j] = dp[i][j - 1] * p[i] + dp[i][j] * (1 - p[i]);
		}
	}
	double ans = 0;
	for (int i = n; i >= (n + 1) / 2; i--) {
		ans += dp[n][i];
	}
	cout << setprecision(20) << fixed << ans << endl;
	return 0;	
}

Measured memory_bytes: 70784
#include<stdio.h>
#include<stdlib.h>

int main(){
	int N;
	int *p;
	int i, cnt = 0;
	int min;

	scanf("%d", &N);
	p = (int *)malloc(sizeof(int)*N);

	for(i=0; i<N; i++){
		scanf("%d", p+i);
	}

	min = p[0];
	for(i=0; i<N; i++){
		if(p[i] <= min){
			cnt++;
			min = p[i];
		}
	}

	printf("%d", cnt);

	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>

using namespace std;

class DisjointSet{
  public:
    vector<int> rank, p;

    DisjointSet(){}
    DisjointSet(int size){
      rank.resize(size, 0);
      p.resize(size, 0);
      for(int i=0 ; i<size ; ++i) makeSet(i);
    }
    ~DisjointSet(){}

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

    void unite(int x, int y){
      link(findSet(x), findSet(y));
    }

    void link(int x, int y){
      if(rank[x] > rank[y]){
        p[y] = x;
      }else{
        p[x] = y;
        if(rank[x] == rank[y]) rank[y] = rank[y]+1;
      }
    }

    bool same(int x, int y){
      return findSet(x) == findSet(y);
    }

    int findSet(int x){
      if(x != p[x]) p[x] = findSet(p[x]);
      return p[x];
    }
};

int main(){
  int n=0, q=0;
  int x=0, y=0, com=0;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  for(int i=0 ; i<q ; ++i){
    cin >> com >> x >> y;

    if(com == 0) ds.unite(x, y);
    else if (com == 1){
      if(ds.same(x, y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
}



Measured memory_bytes: 3184
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

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

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

  double bunbo=0;

  for(int i=0;i<n;i++){
    bunbo+=1/(double)a[i];
  }

  cout<<1/bunbo<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main(){
	string s;
	getline(cin, s);
	
	for(int i = 0; i < s.size(); i++){
		if(s.at(i) >= 65 && s.at(i) <= 90){
			s.at(i) += 32;
		}else if(s.at(i) >= 97 && s.at(i) <= 122){
			s.at(i) -= 32;
		}
	}
	
	cout << s << endl;
	
}





Measured memory_bytes: 3152
n, m = gets.chomp.split.map(&:to_i)
ab = []
m.times do
    ab << gets.chomp.split.map(&:to_i)
end

ab.sort! {|a, b| (a[0] <=> b[0]).nonzero? || (a[1] <=> b[1])}

a = ab[0][0]
b = ab[0][1]
ans = 1
for i in 1..(m-1) do
    if a <= ab[i][0] && ab[i][1] <= b
        a = ab[i][0]
        b = ab[i][1]
    elsif ab[i][0] < b && b <= ab[i][1]
        a = ab[i][0]
    elsif b <= ab[i][0] 
        ans += 1
        a = ab[i][0]
        b = ab[i][1]        
    end
end
puts ans

Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define io std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int mo=998244353; const int mod=1000000007;

const int manx=100000+5;



int main(){
    io;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        c-=b;
        if(c<=0) break;
        a-=d;
    }
    if(c<=0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] x=new long[N];
        long[] y=new long[N];
        long[] x2=new long[N];
        long[] y2=new long[N];
        for(int i=0; i<N; i++){
            x[i]=sc.nextLong();
            y[i]=sc.nextLong();
            x2[i]=x[i]+y[i];
            y2[i]=x[i]-y[i];
        }


        Arrays.sort(x2);
        Arrays.sort(y2);

        long res = Math.max(Math.abs(x2[N-1]-x2[0]),Math.abs(y2[N-1]-y2[0]));




        
        
        System.out.println(res);
        
        }
    }

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


int main(){
	string s;
	cin >> s;
	int ans = 0;
	for (auto ch:s)
		if (ch == 'R') ans ++;
	if (s[1] == 'S' && ans != 0)
		ans = 1;
    cout<<ans<<endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    vector<string> W(N); REP(i,N) cin >> W[i];

    REP(i,N-1){
        if(W[i].back() != W[i+1][0]){
            cout << "No" << endl;
            return 0;
        }
    }

    set<string> s;
    REP(i,N){
        if(s.find(W[i]) != s.end()){
            cout << "No" << endl;
            return 0;
        }
        s.insert(W[i]);
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int player[1001];
vector<string> p;
int n,m;
int now=0;
int res;
int stoi(string s)
{
	int t;
	istringstream is(s);
	is >> t;
	return t;
}
int next()
{
	int a=-1;
	for(int i=now+1;;i++)
	{
		if(player[i%n]==0)
		{
			a=i%n;
			break;
		}
	}
	return a;
}
int main()
{
	while(1)
	{
		p.clear();
		memset(player,0,sizeof(player));
		now=0;
		cin >> n >> m;
		if(n==0&&m==0)break;
		res=n;
		for(int i=0;i<m;i++)
		{
			string s;
			cin >> s;
			p.pb(s);
		}
		for(int i=0;i<m;i++)
		{
			if((i+1)%3==0&&(i+1)%5==0)
			{
				if(p[i]!="FizzBuzz")
				{
					player[now]=1;
					res--;
				}
			}
			else if((i+1)%3==0&&(i+1)%5!=0)
			{
				if(p[i]!="Fizz")
				{
					player[now]=1;
					res--;
				}
			}
			else if((i+1)%5==0&&(i+1)%3!=0)
			{
				if(p[i]!="Buzz")
				{
					player[now]=1;
					res--;
				}
			}
			else
			{
				if((i+1)!=stoi(p[i]))
				{
					player[now]=1;
					res--;
				}
			}
			if(res==1)break;
			now=next();
		}
		bool k=true;
		for(int i=0;i<n;i++)
		{
			if(player[i]==0)
			{
				if(k)
				{
					cout << i+1;
					k=false;
				}
				else
				{
					cout << ' ' << i+1;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int MAX = 100005;
int H[MAX], n, dp[MAX], inf = 1e9;

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

	int K;
  cin >> n >> K;
  forn(i, 0, n)cin >> H[i];
  fill(dp, dp+n, inf);
  dp[n-1] = 0;
  for(int i = n-1; i >= 0; i--){
      forn(k, 1, K+1){
				if(i-k >= 0)dp[i-k] = min(dp[i-k], dp[i]+abs(H[i]-H[i-k]));
      }
  }
  cout << dp[0] << endl;

}





Measured memory_bytes: 4424
def prime_TorF(n):
    p = [True for i in range(n)]
    p[0] = p[1] = False
    for i in range(2, 100000):
        if p[i]:
            for j in range(2 * i, 100000, i):
                p[j] = False

    return p


def solve():
    q = int(input())
    l, r = [], []
    for _ in range(q):
        tmp_l, tmp_r = list(map(int, input().split(" ")))
        l.append(tmp_l)
        r.append(tmp_r)

    p = prime_TorF(100000)

    s = [0 for i in range(100000)]
    for i in range(1, 100000, 2):
        if p[i] and p[(i + 1) // 2]:
            s[i] = 1

    for i in range(100000 - 1):
        s[i + 1] += s[i]

    for i in range(q):
        print(s[r[i]] - s[l[i] - 1])


solve()

Measured memory_bytes: 15528