akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// 二分探索で目的の値より大きいインデックスを返す
func upperBound(list []int64, n int64) int64 {
	var l int64 = 0
	var r int64 = int64(len(list) - 1)
	for l <= r {
		var mid int64 = l + (r-l)/2
		if list[mid] <= n {
			l = mid + 1
		} else {
			r = mid - 1
		}
	}
	return l
}

func main() {
	list := getStdinIntArr64()
	N := list[0]
	M := list[1]
	K := list[2]
	A := getStdinIntArr64()
	B := getStdinIntArr64()
	Asum := make([]int64, N+1)
	Bsum := make([]int64, M+1)

	var i int64 = 0
	var ans int64 = 0

	for i = 0; i < N; i++ {
		Asum[i+1] = Asum[i] + A[i]
	}
	for i = 0; i < M; i++ {
		Bsum[i+1] = Bsum[i] + B[i]
	}

	var apos int64 = 0
	for ; apos <= N; apos++ {
		if Asum[apos] > K {
			break
		}
		if M > 0 {
			var bpos int64 = upperBound(Bsum, K-Asum[apos])
			if bpos != 0 {
				bpos--
			}
			if apos+bpos > ans {
				ans = apos + bpos
			}
		}
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 21272
# include<bits/stdc++.h>
# include<vector>
using namespace std;
vector < int > vc;
int main () {
int a,b,c;
cin>>a>>b>>c;
vc.push_back( a );
vc.push_back( b );
vc.push_back( c );
sort(vc.begin(), vc.end());
int j=0;
int y=vc[1]-vc[0];
int k =vc[2]-vc[1];
cout<<j+y+k;
}


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

int n;
vector<int> a;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	int mi = 1e9, ma = -mi, pma = -1, pmi = -1;
	for(int i=0; i<n; ++i){
		cin >> a[i];
		if(mi > a[i]){
			mi = a[i];
			pmi = i+1;
		}
		if(ma < a[i]){
			ma = a[i];
			pma = i+1;
		}
	}
	if(mi < 0 && 0 < ma){
		cout << 2*n-1 << "\n";
		if(-mi < ma){
			for(int i=1; i<=n; ++i)
				cout << pma << " " << i << "\n";
			for(int i=1; i<n; ++i)
				cout << i << " " << i+1 << "\n";
		}else{
			for(int i=1; i<=n; ++i)
				cout << pmi << " " << i << "\n";
			for(int i=n; i>1; --i)
				cout << i << " " << i-1 << "\n";
		}
	}else if(mi >= 0){
		cout << n-1 << "\n";
		for(int i=1; i<n; ++i)
			cout << i << " " << i+1 << "\n";
	}else if(ma <= 0){
		cout << n-1 << "\n";
		for(int i=n; i>1; --i)
			cout << i << " " << i-1 << "\n";
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int N,H,W;
	int buf,tmp;
	int i;
	cin>>H>>W>>N;

	buf=H;
	if(H<W) buf=W;
	tmp=N/buf;
	if(buf*tmp<N) tmp++; 

	cout<<tmp<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    for(int i=0;i<10000;i++)
    {
        vector<int> a(2,0);
        cin >> a.at(0) >> a.at(1);
        if(a.at(0)==0&&a.at(1)==0)
        {
            return(0);
        }
        sort(a.begin(),a.end());
            cout << a.at(0) << " " << a.at(1) << endl;
    }
    return(0);
}


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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007



int main() {
    ll N; cin >> N;
    cout << (N * (N - 1)) / 2 << endl;
}





Measured memory_bytes: 256
H, W = map(int, input().split())
S = []
l1 = []
for i in range(H):
  s = str(input())
  S.append(s)
  tmp = []
  cnt = 0
  flag = False
  for j in s:
    if flag:
      if j == '.':
        cnt += 1
      else:
        for k in range(cnt):
          tmp.append(cnt)
        cnt = 0
        tmp.append(0)
        flag = False
    else:
      if j == '.':
        flag = True
        cnt += 1
      else:
        tmp.append(0)
  if cnt > 0:
    for k in range(cnt):
      tmp.append(cnt)
  l1.append(tmp)

l2 = []
for i in range(W):
  tmp = []
  cnt = 0
  flag = False
  for j in range(H):
    x = S[j][i]
    if flag:
      if x == '.':
        cnt += 1
      else:
        for k in range(cnt):
          tmp.append(cnt)
        cnt = 0
        tmp.append(0)
        flag = False
    else:
      if x == '.':
        flag = True
        cnt += 1
      else:
        tmp.append(0)
  if cnt > 0:
    for k in range(cnt):
      tmp.append(cnt)
  l2.append(tmp)

ans = [[0]*W for i in range(H)]
m = 0
for i in range(H):
  for j in range(W):
    if (l1[i][j]>0) and (l2[j][i]>0):
      ans[i][j] = l1[i][j] + l2[j][i] - 1
    else:
      ans[i][j] = l1[i][j] + l2[j][i]
    m = max(m, ans[i][j])
print(m)

Measured memory_bytes: 178244
def s(a,i,b,c):
	return  b==sorted(b) and c==sorted(c) if i==10 else s(a,i+1,b+[a[i]],c) or s(a,i+1,b,c+[a[i]])
	
for roop in range(int(raw_input())):
	print "YES" if s(map(int,raw_input().split()),0,[],[]) else "NO"

Measured memory_bytes: 4208
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,l,tot,Min=(int)1e8,t,f;
int Abs(int a)
{
	if(a<0)
		return -a;
	return a;
}
int main()
{
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)
	{
		t=l+i-1;
		if(Abs(t)<Min)
		{
			Min=Abs(t);
			if(t<0)
				f=0;
			else
				f=1;
		}
		tot+=t;
	}
	if(f==0)
		printf("%d\n",tot+Min);
	else
		printf("%d\n",tot-Min);
	return 0;
}


Measured memory_bytes: 256
import numpy as np

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

if N == 1:
  if M == 1:
    ans = 1
  else:
    ans = M - 2
elif M == 1:
  ans = N - 2
else:
  ans = (N - 2) * (M - 2)
  
print(ans)

Measured memory_bytes: 12488
#include <iostream>
using namespace std;
int a[6];
int main()
{
  int n,i,j;
  float h;
  cin >> n;
  while(n--){
    cin >> h;
    if(h < 165.0) a[0]++;
    else if(h < 170.0) a[1]++;
    else if(h < 175.0) a[2]++;
    else if(h < 180.0) a[3]++;
    else if(h < 185.0) a[4]++;
    else a[5]++;
  }
  for(i=0; i<6; i++){
    cout << (i+1) << ":";
    for(j=0; j<a[i]; j++){
      cout << "*";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
//
//  main.cpp

#include <iostream>
#include <vector>
using namespace std;

//0???????´?????????????

int main(){
	while(1){
		int n,k;
		cin >> n >> k;
		if(n == 0 && k == 0){
			break;
		}
		bool array[100002]={};
		int input;
		for(int i=0;i<k;i++){
			cin >> input;
			array[input] = true;
		}
		int ruiseki[100002]={};
		for(int i=1;i<=n;i++){
			if(array[i]){
				ruiseki[i] = ruiseki[i-1]+1;
			}
		}
		
		vector<int> vec;
		for(int i=1;i<=n;i++){
			if(ruiseki[i]==0){
				vec.push_back(0);
			}else if(ruiseki[i] > 0 && ruiseki[i+1] == 0){
				vec.push_back(ruiseki[i]);
			}
		}
		
		
		if(array[0]){
			vector<pair<int,int> >vecpr;
			for(int i=1;i<vec.size()-1;i++){
				if(vec[i-1] > 0 && vec[i] == 0 && vec[i+1] > 0){
					vecpr.push_back(make_pair(vec[i-1],vec[i+1]));
				}
			}
			
			int answer = 0;
			for(int i=0;i<vecpr.size();i++){
				answer = max(answer,vecpr[i].first + vecpr[i].second + 1);
			}
			
			cout << answer << endl;
		}else{
			int answer = 0;
			for(int i=0;i<vec.size();i++){
				answer = max(answer,vec[i]);
			}
			cout << answer << endl;
		}
	
	}
	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL p=7+1e+9;

int main(){
  int n;
  while(cin >> n && n){
    int field = 0;
    int human[10] = {0};
    string S;
    cin >> S;
    REP(i, S.size()){
      if(S[i] == 'M'){
        human[i % n]++;
      }
      else if(S[i] == 'S'){
        field += human[i % n] + 1;
        human[i % n] = 0;
      }
      else{
        human[i % n] += field + 1;
        field = 0;
      }
    }
    sort(human, human + n);
    REP(i,n){
      cout << human[i] << " ";
    }
    cout << field << endl;
  }
}

Measured memory_bytes: 1228
// Author : Chi
// created : Sunday 2020-05-31
// Sawal : https://www.codechef.com/LTIME84B/problems/TREDIFF

//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//namespaces
using    namespace __gnu_pbds;
using    namespace std;
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb(x)       push_back(x)
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         998244353
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define pdp(d,i)    fixed<<setprecision(i)<<d
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define db(...)     __f(#__VA_ARGS__, __VA_ARGS__)                      //for debugging
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
//LOVE ALGO
void solve(){
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

// Driver Code
int main(){
    CHI
    TEST1
    return 0;
}



Measured memory_bytes: 3620
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    int height[n];
    for (int i = 0; i < n; i++) cin >> height[i];

    long long dp[n];

    fill(dp, dp + n, 1000000007);

    dp[0] = 0;
    dp[1] = abs(height[1] - height[0]);

    for (int i = 2; i < n; i++) {
        for (int j = max(i - k, 0); j < i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(height[j] - height[i]));
        }
    }

    cout << dp[n - 1] << endl;
}


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

  rep(i, 3){
    if(n.at(i)=='7'){
      cout << "Yes" << endl;
      return 0;
    }  
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B = MI_()
    print(ceil(B/A))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut aa: [i64; n],
    }
    aa.sort();

    let mut left = aa[0];
    let mut right = aa[n-1];

    let mut ops = vec![];
    for i in 1..n-1 {
        if aa[i] < 0 {
            ops.push((right, aa[i]));
            right -= aa[i];
        } else {
            ops.push((left, aa[i]));
            left -= aa[i];
        }
    }
    ops.push((right, left));
    let ans = right - left;
    puts!("{}\n", ans);
    for op in ops {
        puts!("{} {}\n", op.0, op.1);
    }
}


Measured memory_bytes: 10108
A, B = map(int, input().split())

while B:
    A, B = B, A % B
n = A



if n == 1:
    print(1)
else:
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            while temp%i == 0:
                temp //= i
            arr.append(i)
    if temp != 1:
        arr.append(temp)

    print(len(arr)+1)


Measured memory_bytes: 40044
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

void go(int n){
	if(n>0){
		n-- ;
		go(n/26) ;
		cout << char(n%26+'a') ;
	}
}

void solve(){
	int n ;
	cin >> n ;
	go(n) ;
}

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int h, w, n;
    cin >> h >> w >> n;
    cout << min((n + h - 1) / h, (n + w - 1) / w) << endl;

    return 0;
}


Measured memory_bytes: 256
# マンハッタン距離の総和を最小化するときは、中央値を使うという典型がある。

N = int(input())
A = [int(a)-i for i, a in enumerate(input().split(), 1)]
A.sort()

b = A[N//2]
ans = sum([abs(a-b) for a in A])

print(ans)


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

int main()
{
  bool flag;
  int N, M,count=0,loop=1;
  cin>>N>>M;
  vector<int> a(M),b(M),A;
  vector<vector<bool>> get(N,vector<bool>(N,false));
  rep(i,M){cin>>a.at(i)>>b.at(i);}
  rep(i,N){A.push_back(i+1);}//初期値
  rep(i,M)
  {
    get.at(a.at(i)-1).at(b.at(i)-1)=true;get.at(b.at(i)-1).at(a.at(i)-1)=true;
  }
  rep(i,N-1){loop*=(i+1);}//一桁目は1で固定。
  rep(i,loop)
  {
    flag=true;
    rep(j,N-1)
    {
      if(!(get.at(A.at(j)-1).at(A.at(j+1)-1)))flag=false;
    }
    if(flag){count++;}
    next_permutation(A.begin()+1,A.end());//一桁目は1で固定し次の順列へ。
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
  double a, b, C, S, L, h, rad_C, PI=acos(-1);
  cin>>a>>b>>C;
  rad_C = PI * (C / 180);
  S = 0.5 * a * b * sin(rad_C);
  L = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cos(rad_C));
  h = b * sin(rad_C);
  printf("%.5f\n%.5f\n%.5f\n", S, L, h);
  return 0;
}



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

#define ll long long
#define pb push_back
#define INF 1'000'000'007
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	ll h,w;
	cin>>h>>w;
	char a[h][w];
	ll dp[h][w];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,0,h){
		rep(j,0,w){
			cin>>a[i][j];
		}
	}
	rep(i,1,w){
		if(a[0][i]=='#'){
			dp[0][i]=0;
		}
		else{
			dp[0][i]=dp[0][i-1];
		}
	}
	rep(i,1,h){
		if(a[i][0]=='#'){
			dp[i][0]=0;
		}
		else{
			dp[i][0]=dp[i-1][0];
		}
	}
	rep(i,1,h){
		rep(j,1,w){
			if(a[i][j]=='#'){
				dp[i][j]=0;
				continue;
			}
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%INF;
		}
	}
	cout<<dp[h-1][w-1]%INF;
	
	
	
	return 0;
}

Measured memory_bytes: 12400
n, x = map(int, input().split())
a = list(map(int, input().split())) + [0]
ans = 0
for i in range(1, n + 1):
    if a[i] + a[i - 1] > x:
        ans += a[i] + a[i - 1] - x
        a[i] -= a[i] + a[i - 1] - x
print(ans)

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int n,x;
      cin >> n >> x;
      int m[n];
      rep(i,n)cin >> m[i];
      sort(m,m+n);
      int res=x;
      rep(i,n)res-=m[i];
      int ans=n;
      ans+=res/m[0];
      cout << ans << endl;
      return 0;}

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

int main(){
    int r,d,x;
    cin >> r >> d >> x;
    ll tmp=x;
    for(int i=0; i<10; i++){
        cout << tmp*r-d << endl;
        tmp=tmp*r-d;        
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(size_t i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(size_t i = 0; i < n; i++)
#define asort(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.begin(), a.end(), greater<int>())

typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;


int32_t main()
{
    fast_io;
    string s, t;
    cin >> s >> t;
    int lens = s.length(), lent = t.length();    
    vii dp(lent+1, vi(lens+1));
    for(int i = 1; i <= lent; i++)
    {
        for(int j = 1; j <= lens; j++)
        {
            if(s[j-1] == t[i-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
            
        }
    }
    string ans = "";
    for(int r = lent, c = lens; r > 0 && c > 0;)
    {
        if(dp[r][c] == dp[r][c-1])
            c--;
        else if(dp[r][c] == dp[r-1][c])
            r--;
        else
        {
            ans += t[r-1];
            r--;
            c--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}   

Measured memory_bytes: 73664
import java.util.*;
import java.math.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int cnt = 0;
	    for(int i = sc.nextInt(); i >= 1; --i){
		BigInteger bi = new BigInteger(sc.next());
		if(bi.isProbablePrime(5)) ++cnt;
	    }
	    System.out.printf("%d\n", cnt);
	}
    }
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ll long long
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define lowbit(x) (x&-x)
#define ms(x,a) memset(x,a,sizeof x)
using namespace std;
template <class T> inline bool Max(T &x, T y){
	return x<y?x=y,1:0;
}
template <class T> inline bool Min(T &x, T y){
	return x>y?x=y,1:0;
}
template <class T> inline T rd() {
	static char ch;static bool neg;
	static T x=0;
	for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
	for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
	return x=(neg?-x:x);
}
const int mod=1e9+7,oo=1e9,N=3000;
ll sum[N][N],ans[N],fpow[N];
int p;


int main(){
	p=rd<int>();
	sum[1][1]=1;
	rep(i,0,p){
		sum[i][0]=1;
		rep(j,1,i) sum[i][j]=(sum[i-1][j]+sum[i-1][j-1])%p;
//		rep(j,0,p) printf("sum[%d][%d] = %lld ",i,j,sum[i][j]);
//		puts("");
	}
	fpow[0]=1;
	repp(i,0,p){
		int x=rd<int>();
		if(!x) continue;
		ans[0]=(ans[0]+1)%p;
		fpow[0]=1;
//		printf("fpow[%d] == %lld\n",0,fpow[0]);
		rep(j,1,p){
			fpow[j]=fpow[j-1]*(p-i)%p;
//			printf("fpow[%d] == %lld\n",j,fpow[j]);
		}
		repp(j,0,p){
//			printf("ans[%d] = %lld	fpow[%d] = %lld	sum[%d][%d] = %lld\n",j,ans[j],p-1-j,fpow[p-1-j],p-1,j,sum[p-1][j]);
			ans[j]=((ans[j]-fpow[p-1-j]*sum[p-1][j])%p+p)%p;
		}
	}
	repp(i,0,p) printf("%lld%c",ans[i]," \n"[i==p-1]);
	return 0;
}

Measured memory_bytes: 69120
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  cout<<(S[2]==S[3] and S[4]==S[5]?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[10000];
		int k = Integer.MIN_VALUE;
		StringTokenizer st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; i++) {
			int num = Integer.parseInt(st.nextToken());
			k = Math.max(k, num);
			c[num]++;
			a[i] = num;
		}
		countingSort(a, b, c, k);
		System.out.println(Arrays.toString(b).replaceAll("[\\[\\],]", ""));
	}

	private static void countingSort(int[] a, int[] b, int[] c, int k) {
		for (int i = 1; i <= k; i++) {
			c[i] = c[i] + c[i - 1];
		}
		for (int i = a.length - 1; i >= 0; i--) {
			c[a[i]]--;
			b[c[a[i]]] = a[i];
		}
	}
}


Measured memory_bytes: 270172
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int n=sc.nextInt();
      int x=sc.nextInt();
      if(n==0&&x==0) break;
      int count=0;
      for(int i=n;0<i;i--){
        for(int j=n;0<j&&j!=i;j--){
          for(int k=n;0<j&&k!=i&&k!=j;k--){
            if(i+j+k==x) count+=1;
          }
        }
      }
      System.out.println(count);
    }
    sc.close();
  }
}


Measured memory_bytes: 26384
#include <stdio.h>

int main ()
{
	int mo,min,max,ans;	
	scanf("%d", &mo);
	scanf("%d %d", &min, &max);
		for (min;min<=max;min++)
		{
			if(min%mo==0)
			{
			ans++;
			}	
		}
	if(ans!=0)
	{
		printf("OK");
	}
	else
	{
		printf("NG");
	}
	
	
	return 0;
}

Measured memory_bytes: 1688
import collections
n = int(input())
v = list(map(int, input().split()))
v_even = v[::2]
v_odd = v[1::2]
c_even = collections.Counter(v_even)
c_odd = collections.Counter(v_odd)
even_list = c_even.most_common()+[(-1, int(0))]
odd_list = c_odd.most_common()+[(-1, int(0))]
# print(even_list, odd_list)
for test in even_list:
    if odd_list[0][0] != test[0]:
        even_cd = test
        cost1 = odd_list[0][1] + test[1]
        break
for  test in odd_list:
    if even_list[0][0] != test[0]:
        odd_cd = test
        cost2 = even_list[0][1] + test[1]
        break

if cost1>=cost2:
    print(n-cost1)
else:
    print(n-cost2)

Measured memory_bytes: 21952
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
a = na()
a.sort()
if a[-m] >= sum(a) * 1/(4*m):
    print('Yes')
else:
    print('No')

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

int main() {
    string s; cin >> s;
    rep(i, s.size()-1){
        if(s[i] == s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;

    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin>>n;
    int k=n%1000;
    if(k==0)
    {
        cout<<0<<"\n";
    }
    else{
        cout<<1000-k<<"\n";
    }
    return 0;
}

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

typedef struct UNION_FIND{
    std::vector<int> par;
    UNION_FIND(int size) : par(size){
        for(int i=0; i<size; ++i) par[i] = i;
    }
    int find(int x){
        return ( (x == par[x]) ? x : (par[x] = find(par[x])) );
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if( x == y ) return;

        par[y] = x;
    }
    bool same(int x, int y){
        return ( find(x) == find(y) );
    }
} UnionFind;

int n, q;
int c, x, y;

int main(void){
    std::cin >> n >> q;

    UnionFind uf(n);
    for(int i=0; i<q; ++i){
        std::cin >> c >> x >> y;
        if(c == 0){
            uf.unite(x,y);
        }else{
            if(uf.same(x,y)){
                std::cout << "1\n";
            }else{
                std::cout << "0\n";
            }
        }
    }
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
using namespace std;
using int64 = long long;

int main()
{
  int64 n;
  cin >> n;
  int64 s = 0;
  for (int i = 0; i < n; ++i)
  {
    s += i;
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

int arr[100002];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n;
    cin >> n;

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

    int cnt = 0;

    for(int i = 1; i <= n; ++i){
        if(i > arr[i]) continue;
        if(arr[arr[i]] == i)
            ++cnt;
    }

    cout << cnt;



    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int num,i,j=1,k,big=-1,avg,max,total=0,count[50];
    scanf("%d",&max);
    for(i=0; i<max; i++)
    {
        scanf("%d",&count[i]);
        if(count[i]!=j)
        {
            total++;
        }
        j++;

    }
    if(total>2)
    {
        printf("NO");
    }
    else
    {
        printf("YES");
    }
    return 0;
}

Measured memory_bytes: 1704
// Created by new_sm
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int l,r,d;
cin>>l>>r>>d;
int cnt=0;
for(int i=l;i<=r;i++)
{
	if(i%d==0)
	cnt++;
}
cout<<cnt;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N; cin>>N;
    vec d(N);
    rep(i,N) cin>>d.at(i);
    sort(ALL(d));
    reverse(ALL(d));
    ll K=d.at(0);
    vec co(101,0);
    rep(i,N) co.at(d.at(i))++;
    bool able=true;
    rep(i,K+1){
        ll x=(2*K+1-i)/2;
        if(co.at(x)<=0) able=false;
        co.at(x)--;
    }
    ll MIN=(K+1)/2;
    rep(i,MIN+1) if(co.at(i)>0) able=false;
    if(able) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int l; cin >> l;
  ld L = l;
  ld ans = (L/3) * (L/3) * (L/3);
  
  cout << std::setprecision(12);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, k;
  scanf("%d%d", &n, &k);
  int h[n];
  for(int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(h[i] >= k) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

void print(int a, int b, string str) {
  for (int i=a; i<=b; ++i) {
    cout << str[i];
  }
  cout << endl;
}

string replace(int a, int b, string str, string p) {
  int j=0;
  for(int i=a; i<=b; ++i){
    str[i]=p[j];
    j++;
  }
  return str;
}

string reverse(int a, int b, string str) {
  char tmp;
  for (int i=0; i<(b-a+1)/2; ++i) {
    tmp=str[b-i];
    str[b-i]=str[a+i];
    str[a+i]=tmp;
  }
  return str;
}

int main(int argc, char *argv[])
{
  string str, p, order;
  int a, b, q;
  cin >> str >> q;

  for (int i=0; i<q; ++i) {
    cin >> order;
    if (order == "print") {
      cin >> a >> b;
      print(a, b, str);
    } else if(order == "reverse"){
      cin >> a >> b;
      str=reverse(a, b, str);
    } else if (order == "replace") {
      cin >> a >> b >> p;
      str=replace(a, b, str, p);
    }
  }

  return 0;
}



Measured memory_bytes: 3184
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	while (cin >> n, n) {
		vector<int>v(n);
		for (int i = 0; i < n; i++)cin >> v[i];
		int cnt = 0;
		for (int i = 0; i < n - 1; i++) {
			for (int j = n - 1; i < j; j--) {
				if (v[j - 1] > v[j]) {
					swap(v[j - 1], v[j]);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3652
#include <vector>
#include <list>
#include <map>
#include <set>
#include <tuple>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

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();}

template<class T> inline T sqr(T x) {return x*x;}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#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;

long long mergecount(vector<int> &a) {
  long long count = 0;
  int n = a.size();
  if (n > 1) {
    vector<int> b(a.begin(), a.begin() + n/2);
    vector<int> c(a.begin() + n/2, a.end());
    count += mergecount(b);
    count += mergecount(c);
    for (int i = 0, j = 0, k = 0; i < n; ++i)
      if (k == c.size())       a[i] = b[j++];
      else if (j == b.size())  a[i] = c[k++];
      else if (b[j] <= c[k])   a[i] = b[j++];
      else                   { a[i] = c[k++]; count += (long long) (n/2 - j); }
  }
  return count;
}

typedef tuple<int, int, int> edge;

int main(void){
  int W, H;
  cin >> W >> H;

  int nW = W+1, nH = H+1;
  long long cost = 0;
  long long this_cost;
  edge tp;
  priority_queue<edge> pq;
  vector<int> p(W), q(H);

  REP(i, W){
    int buf;
    cin >> buf;
    tp = make_tuple(-buf, i, 0);
    pq.push(tp);
  }

  REP(i, H){
    int buf;
    cin >> buf;
    tp = make_tuple(-buf, i, 1);
    pq.push(tp);
  }

  while(pq.size() != 0){
    tp = pq.top();
    pq.pop();
    this_cost = (long long) (-get<0>(tp));
    if(get<2>(tp) == 0){
      cost += this_cost*((long long) nH);
      nW--;
    }
    else{
      cost += this_cost*((long long) nW);
      nH--;
    }
  }

  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 4212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
       int a,b,c,x;
       scanf("%d%d%d%d",&a,&b,&c,&x);
       int n=0;
       for(int i=0;i<=a;i++){
              for(int j=0;j<=b;j++){
                     for(int k=0;k<=c;k++){
                            if(i*500+j*100+k*50==x){
                                   n++;
                            }
                     }
              }
       }
       printf("%d",n);
       return 0;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

typedef double D;

int C,X;
int dp[1<<5][55][55][6];
int calc(vint L){
    int N=L.size();
    memset(dp,0,sizeof(dp));
    dp[0][0][X-1][N]=1;
    for(int i=0;i<1<<N;i++){
        for(int j=0;j<C;j++){
            for(int k=0;k<=C;k++){
                for(int l=0;l<=N;l++){
                    if(dp[i][j][k][l]==0)continue;
                    int sup=(1<<N)-1-i;
                    int sub=sup;
                    do{
                        bool ok=true;
                        if(j==k)ok&=(((1<<l)-1)&sub)!=0;
                        if(ok){
                            pint ma(k,l);
                            rep(s,N)if(sub>>s&1)chmax(ma,pint(min(j+L[s],C),s));
                            dp[i|sub][j+1][ma.fi][ma.se]+=dp[i][j][k][l];
                        }
                        sub=(sub-1)&sup;
                    }while(sup!=sub);
                }
            }
        }
    }
    int ans=0;
    rep(i,N)ans+=dp[(1<<N)-1][C][C][i];
    return ans;
}

signed main(){
    int N;
    cin>>N>>C;
    vint L(N);rep(i,N)cin>>L[i];
    sort(all(L));
    X=L.back();

    vint p(N-1);
    rep(i,N-1)p[i]=i;

    int ei=0;
    do{
        vint l(N-1);
        rep(i,N-1)l[i]=L[p[i]];
        ei+=calc(l);
    }while(next_permutation(all(p)));

    D ans=ei;
    for(int i=1;i<=N-1;i++)ans/=i;
    for(int i=0;i<N-1;i++)ans/=C;
    printf("%.20f\n",ans);
    return 0;
}


Measured memory_bytes: 4736
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  cin >> S;
  const int64_t length = static_cast<int64_t>(S.length());
  int64_t black_count = 0;
  int64_t total_count = 0;
  for (int64_t i = 0; i < length; ++i) {
    if (S.c_str()[i] == 'W') {
      total_count += black_count;
    } else {
      ++black_count;
    }
  }
  cout << total_count << endl;

  return 0;
}


Measured memory_bytes: 720
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M,Q;
    cin >> N >> M >> Q;
    ll A[N][N];
    ll B[N][N];
    rep(i,N){
        rep(j,N){
            A[i][j] = 0;
            B[i][j] = 0;
        }
    }
    rep(i,M){
        ll L,R;
        cin >> L >> R;
        A[L-1][R-1]++;
    }
    rep(i,N){
        rep(j,N){
            if(j==0) B[i][j] = A[i][j];
            else B[i][j] = B[i][j-1]+A[i][j];
        }
    }
    rep(i,Q){
        ll p,q;
        cin >> p >> q;
        ll out = 0;
        for(ll j=p-1;j<q;j++){
            if(p==1) out += B[j][q-1];
            else out += B[j][q-1]-B[j][p-2];
        }
        cout << out << endl;
    }
    return 0;
}


Measured memory_bytes: 4864
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

const int INF = 1e9;

int main() {
  	int cnt[10][3][4];
	memset(cnt, 0, sizeof cnt);

	int n;
	cin >> n;

	rep(i,0,n) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		cnt[r-1][f-1][b-1] += v;
	}

	rep(i,0,4) {
		if (i>0) cout << "####################" << endl;
		rep(j,0,3) {
			rep(k,0,10) {
				cout << " " << cnt[k][j][i];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3080
import java.math.BigInteger;
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        if (b - a + 1 <= 2 * k) {
            for (int i = 0; i <= b - a; i++) {
                System.out.println(a + i);
            }
        } else {
            for (int i = 0; i < k; i++) {
                System.out.println(a + i);
            }
            for (int i = 0; i < k; i++) {
                System.out.println(b - (k - i) + 1);
            }
        }
    }

}

Measured memory_bytes: 22608
using System;

    class Program
    {
        static void Main(string[] args)
        {
            string[] num = Console.ReadLine().Split(' ');

            int w, h, x, y, r;
            w = int.Parse(num[0]);
            h = int.Parse(num[1]);
            x = int.Parse(num[2]);
            y = int.Parse(num[3]);
            r = int.Parse(num[4]);

            if (x - r < 0 || x + r > w)
            {
                Console.WriteLine("No");
            }else if (y - r < 0 || y + r > h)
            {
                Console.WriteLine("No");
            }
            else if (x - r >= 0 && x + r <= w)
            {
                Console.WriteLine("Yes");
            }else if (y - r >= 0 && y + r <= h)
            {
                Console.WriteLine("Yes");
            }
        }
    }


Measured memory_bytes: 8932
N = int(input())
H = list(map(int,input().split()))
new_H = H + [H[-1]+1]
M = [1 if new_H[i] < new_H[i+1] else 0 for i in range(N)]
set_M = set(M)
if set_M == {1}:
    print(0)
else:
    new_M = M + [1]
    a,b = 1,0
    for j in range(N):
        if new_M[j] == 0:
            if new_M[j] == new_M[j+1]:
                a += 1
            else:
                b = max(a,b)
                a = 1
    print(b)


Measured memory_bytes: 14252
#include <stdio.h>

int gcd(int x, int y){
    int r;

    while((r = x % y) != 0){
        x = y;
        y = r;
    }
    return y;
}

long long lcm(int x, int y){
    return ((long long)x * y / gcd(x, y));
}

int main() {
	long long a,b;
	scanf("%lld%lld", &a,&b);
	printf("%lld\n", lcm(a,b));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=200000000000005LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	ll x;
	ll y;
	bool operator<(const edge& e)const{
		return x+y<e.x+e.y;
	}
	bool operator>(const edge& e)const{
		return x+y>e.x+e.y;
	}


};
struct road{ll cost;int to;};
int n;
int a,b;
int t=0;
int main() {
	cin>>a>>b;
	if(b%a==0)cout<<a+b<<endl;
	else cout<<b-a<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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();
		
		int ans = Math.min(a+b, Math.min(b+c, c+a));
		
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 23124
import sys
input = lambda: sys.stdin.readline().rstrip()

def set_w(c, s):
    # sをWの位置にセット
    while s < len(c):
        if c[s] == 'W':
            return s
        else:
            s += 1
    return s

def main():
    n = int(input())
    c = list(input())
    s = 0
    e = len(c) - 1
    ans = 0

    # sを最初のWにセット
    s = set_w(c, s)

    while e > s:
        if c[e] == 'R':
            c[s] = 'R'
            c[e] = 'W'
            s = set_w(c, s)
            ans += 1
        e -= 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77636