akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from itertools import permutations

def warshall_floyd(dist):
    n = len(dist)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

def main():
    N, M, R = map(int, input().split())
    A = [int(i)-1 for i in input().split()]
    inf = float('inf')
    G = [[inf] * N for _ in range(N)]
    for i in range(N):
        G[i][i] = 0
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        G[a][b] = min(G[a][b], c)
        G[b][a] = min(G[b][a], c)
    warshall_floyd(G)
    ans = float('inf')
    for perm in permutations(A, R):
        tmp = 0
        for i in range(R-1):
            tmp += G[perm[i]][perm[i+1]]
        ans = min(ans, tmp)
    print(ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 55516
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int n;
long long w, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
   cin >>n>>w;
   for(int i = 0;i<n;i++) cin >> weight[i]>>value[i];
   
   for(long long i = 0;i<n;i++){
     for(long long s = 0;s<=w;s++){
       if(s - weight[i] >= 0) chmax(dp[i+1][s],dp[i][s-weight[i]]+value[i]);
       chmax(dp[i+1][s],dp[i][s]);
       
     }
   }
   cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 79360
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



vector<pair<long long, int>> prime_factor(long long n) {
	vector<pair<long long, int>> res;
	for (long long i = 2; i*i <= n; i++) {
		int c = 0;
		while (n%i == 0) {
			c++;
			n /= i;
		}
		if (c)res.emplace_back(i, c);
	}
	if (1 < n)res.emplace_back(n, 1);
	return res;
}


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

	long long n, p;
	cin >> n >> p;

	long long ans = 1;

	auto pf = prime_factor(p);
	for (auto p : pf) {
		rep(i, p.second / n) {
			ans *= p.first;
		}
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll arr[10];


int main() {
	int ind = -1;
	ll temp = 1e18;
	for(int i = 0; i < 5; i++) {
		scanf("%lld", &arr[i]);
		if(arr[i] % 10 < temp && arr[i] % 10 != 0) {
			temp = arr[i] % 10;
			ind = i;
		}
	}
	ll sum = 0;
	for(int i = 0; i < 5; i++) {
		if(ind != i) {
			ll X = arr[i] % 10;
			if(!X) {
				sum += arr[i];
				continue;
			}
			sum += arr[i] + (10 - X);
			// cout << sum  <<  " " << arr[i] << " \n";
		}
	}
	sum += arr[ind];
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;
const int inf=1001001001;
int main()
{
    int a,b,c;
    string s,t;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
H = [int(input()) for _ in range(n)]
H.sort()
ans = 10 ** 9
for i in range(n - k + 1):
    hmin = H[i]
    hmax = H[i + k - 1]
    ans = min(ans, hmax - hmin)
print(ans)

Measured memory_bytes: 7488
// ABC107 B- Grid Compression

package main

import (
    "fmt"
    "strings"
    "os"
)

var M [][]string
var R [][]string



func main() {
    var H,W int
    var In  string
    var FLAG   bool
    var rr,rc  []int

    fmt.Scan(&H,&W)


    M = make([][]string,H)

    for i := 0; i < H; i++ {
        M[i] = make([]string,W)
    }

    for i := 0; i < H; i++ {
        fmt.Scan(&In)
        slice := strings.Split(In,"")
        if len(slice) != W {
            fmt.Println("error")
            os.Exit(1)
        }
        M[i]   = slice
    }

//    fmt.Println(M)

// check row
    for i := 0; i < H; i++ {

        FLAG = false
        for j := 0; j < W; j++{
            if M[i][j] == "#" {
                FLAG = true
                break
            }
        }
        if FLAG == true {
            rr = append(rr,i)
        }

    }

//    fmt.Println(rr)


// check column
    for j := 0; j < W; j++{
            FLAG = false 
        for i := 0; i < H; i++ {
            if M[i][j] == "#" {
                FLAG = true
                break
            }
        }
        if FLAG == true {
            rc = append(rc,j)
        }
    }
//    fmt.Println(rc)



// result

    R = make([][]string,len(rr))

    for i := 0; i < len(rr); i++ {
        R[i] = make([]string,len(rc))
    }

    for i, s := range rr {
        for j, t := range rc {
            R[i][j] = M[s][t]
        }
    }

    for i:=0; i<len(rr); i++ {
      fmt.Println(strings.Join(R[i],""))
    }

}




Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>

int main(void) {

  int N, L, i;
  do {
    scanf("%d %d", &N, &L);
  } while (N < 2 || N > 200 || L < -100 || L > 100);

  int apple_taste_array[N];
  int N_applepie_taste;
  for (i = 0; i < N; i++) {
    apple_taste_array[i] = L + i;
    N_applepie_taste += apple_taste_array[i];
  }

  int N1_applepie_taste_array[N];
  for (i = 0; i < N; i++) {
    N1_applepie_taste_array[i] = N_applepie_taste - apple_taste_array[i];
  }

  int taste_difference_array[N];
  for (i = 0; i < N; i++) {
    taste_difference_array[i] = (N_applepie_taste - N1_applepie_taste_array[i]) * (N_applepie_taste - N1_applepie_taste_array[i]);
    taste_difference_array[i] = sqrt(taste_difference_array[i]);
  }

  int min = taste_difference_array[0];
  int min_taste = N1_applepie_taste_array[0];
  for (i = 1; i < N; i++) {
    if (min > taste_difference_array[i]) {
      min  = taste_difference_array[i];
      min_taste = N1_applepie_taste_array[i];
    }
  }
   
  printf("%d\n", min_taste);

  return 0;
}

Measured memory_bytes: 128
N, X, Y = map(int, input().split())
dists = [0] * N
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        dist = min(j - i, abs(j - Y) + abs(X - i) + 1)
        dists[dist] += 1
for dist in dists[1:]:
    print(dist)


Measured memory_bytes: 46044
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    map<ll,ll> mp;
    for(ll i = 0; i < n; i++){
        for(ll j = i + 1; j < n; j++){
            ll dist = INF;
            dist = min(dist, abs(j - i));
            dist = min(dist, abs(x - i) + abs(y - j) + 1);
            dist = min(dist, abs(y - i) + abs(x - j) + 1);
            mp[dist]++;
        }
    }

    for(ll i = 1; i < n; i++){
        cout << mp[i] << endl;
    }
}

Measured memory_bytes: 384
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int A, B;
    cin >> A >> B;
    if (A*B % 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  ll k;
  cin >> k;
  if(k % 2 == 0){
    cout << "-1";
    return 0;
  }
  if(k % 5 == 0){
    cout << "-1";
    return 0;
  }
  vector<ll> vec(k);
  
  rep(i,k){
    if(i == 0){
      vec[0] = 7;
    }
    else{
      vec[i] = (vec[i-1] * 10) % k;
    }
    
  }
  
  ll ans = 0;
  ll n = 0;
  rep(i,k){
    if(i == 0){
      n = vec[0];
      if(n % k == 0){
        cout << 1;
        return 0;
      }
      ans = ans + 1;
    }
    else{
    if((n + vec[i]) % k == 0){
      cout << ans + 1;
      return 0;
    }
    else{
      ans = ans + 1;
      n = (n + vec[i]) % k;
    }
    }
  }
    
    
    
  return 0;
}

Measured memory_bytes: 11164
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int K = sc.nextInt();
        // 文字列の入力
        String S = sc.next(); 
      //変換
      char[] A = S.toCharArray();
      
      int M = K-1;
     int sabun ='A'-'a';

      int z = (int)A[M]-sabun;
      
      A[M] = (char)z;

   
        // 出力
        System.out.println(A);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S, T;
    cin >> S;
    cin >> T;
    map<char, ll> S_map;
    map<char, ll> T_map;
    for(size_t i=0;i<S.size(); i++)
    {
        S_map[S[i]]++;
        T_map[T[i]]++;
    }

    //for(auto m : S_map) cerr << m.first << ":" << m.second << " "; cerr << endl;
    //for(auto m : T_map) cerr << m.first << ":" << m.second << " "; cerr << endl;

    map<ll, vector<char>> diff_S;
    map<ll, vector<char>> diff_T;
    for(auto m : S_map)
    {
        if(m.second != T_map[m.first]) diff_S[m.second].push_back(m.first);
    }
    for(auto m : T_map)
    {
        if(m.second != S_map[m.first]) diff_T[m.second].push_back(m.first);
    }
    bool ok = true;
    for(auto m: diff_S)
    {
        if(m.second.size() != diff_T[m.first].size()) ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ar array

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int mod = 998244353, maxn = 3005;

int f[maxn][maxn][2];
int A, B, C, D;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> A >> B >> C >> D;
  f[A][B][1] = 1;
  for(int i = A; i <= C; ++i){
    for(int j = B; j <= D; ++j) if(i != A || j != B){
      f[i][j][0] = 1ll * j * (f[i - 1][j][0] + f[i - 1][j][1]) % mod;
      f[i][j][1] = (1ll * i * f[i][j - 1][1] % mod + f[i][j - 1][0]) % mod;
    }
  }
  #ifdef LOCAL
  for(int i = A; i <= C; ++i)
    for(int j = B; j <= D; ++j)
      cerr << f[i][j][0] << " \n"[j == D];
  cerr << '\n';
  for(int i = A; i <= C; ++i)
    for(int j = B; j <= D; ++j)
      cerr << f[i][j][1] << " \n"[j == D];

  #endif // LOCAL
  cout << (f[C][D][0] + f[C][D][1]) % mod;

}


Measured memory_bytes: 73940
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<x2+y1-y2<<" ";
	cout<<y2-x1+x2<<" ";
	cout<<x1+y1-y2<<" ";
	cout<<y1-x1+x2<<"\n";
	return 0;
}






Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    int num = 0;
    scanf("%d", &n);

long sum =0;
int max = 0;
int min = 0;

    int i = 0;
for (; i < n; i++){
    if (scanf("%d", &num) == 0){
        break;
    };
    sum += num;
    if(i == 0){
        max = num;
        min = num;
    }
    else{
     if (max < num){ max = num;}
     if (min > num){ min = num;}
    }
}
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2140
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)
	var cost int
	if c*2 < a+b {
		n := Min(x, y)
		cost += c * 2 * n
		x -= n
		y -= n
	}
	if c*2 < a {
		cost += c * 2 * x
		x = 0
	}
	if c*2 < b {
		cost += c * 2 * y
		y = 0
	}
	cost += a * x
	cost += b * y

	fmt.Println(cost)
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int n, q;

class DisjointSet {
public:
    DisjointSet(int size) {
        rank_.resize(size, 0);
        p_.resize(size, 0);
        for (int i = 0; i < size; i++) {
            p_[i] = i;
            rank_[i] = 0;
        }
    }

    bool same(int x, int y) {
        return 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]++;
            }
        }
    }

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

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

    std::vector<int> rank_, p_;
};

int main() {
    std::cin >> n >> q;
    DisjointSet DS(n);
    for (int i = 0; i < q; i++) {
        int c, x, y;
        std::cin >> c >> x >> y;
        if (c) {
            if (DS.same(x, y)) {
                std::cout << 1 << std::endl;
            }else{
                std::cout << 0 << std::endl;
            }
        }
        else {
            DS.unite(x, y);
        }
    }
}


Measured memory_bytes: 3196
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    if (s[0] == 'S')
        cout << "Cloudy";
    else if (s[0] == 'C')
        cout << "Rainy";
    else
        cout << "Sunny";
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  int ret = 0;
  for(int i = 0; i < N; i += 2) {
    if(A[i] % 2 == 1) ret++;
  }
  cout << ret << "\n";
}

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

LL l,r,L,R,tmp,ans;
int b1[75],b2[75],tp,tp1,tp2;

int main(){
	cin>>L>>R,l=L;r=R;
	if(l==r) return printf("1"),0;
	while(l) b1[++tp1]=l&1LL,l=l>>1;
	while(r) b2[++tp2]=r&1LL,r=r>>1;
	tp=max(tp1,tp2);
	while(b1[tp]==b2[tp]) tp--;
	tmp=1LL<<(--tp);
	L&=(tmp-1),R&=(tmp-1),ans=tmp-L;
	while(!((1LL<<(tp2-1))&R)&&tp2>0) tp2--;
	R=(1LL<<tp2)-1;
	if(L>R) ans+=tmp-L+R+1;
	else ans+=tmp;
	cout<<ans;
}

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

using namespace std;

int main(void)
{
	int a, b;
	cin >> a >> b;
	bool d[3] = {true, true, true};
	d[a-1] = false;
	d[b-1] = false;
	for (int i = 0; i < 3; i++) {
		if (d[i]) {
			cout << i+1 << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3528
#include <iostream>
 using namespace std;
 
int main() {
  int x,y;
  
  while (cin >> x >> y)
  {
    if(x == 0 && y == 0){
        break;
    }
    
    if(x > y){
        cout << y << " "<< x << endl;
    } else {
        cout << x << " "<< y << endl;
    }    
  }

  return 0;
}



Measured memory_bytes: 3084
//#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
using namespace std;

#define ios ios::sync_with_stdio(false)
#define ll long long
#define pa pair<int,int>
#define mk make_pair
#define sc(n) scanf("%d",&n)
#define ss(s) scanf("%s",s)
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define of(i, a, b) for(int i = a; i >= b; i--)
#define mem(a, b) memset(a, b, sizeof a)
#define copy(a,b) memcpy(a, b, sizeof b)
#define pi acos(-1)
#define in freopen("input.in", "r", stdin);
#define out freopen("output.out", "w", stdout);

const ll inf = 0x3f3f3f3f;
const ll mod = 998244353;
const ll N = 2e5 + 10;
const ll M = 1e4 + 10;
const double eps = 1e-10;

int n, m, t;
double f[20][20];
int x[20], y[20];
int a[20];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		sc(x[i]);
		sc(y[i]);
	}
	for (int i = 1; i < n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			double dis = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + 0.0);
			f[i][j] = f[j][i] = dis;
		}
	}
	ll fz = 1;
	for (int i = 2; i <= n; i++)
		fz *= i;
	for (int i = 1; i <= n; i++)
		a[i] = i;
	double fm = 0;
	do
	{
		double sum = 0;
		int x = a[1];
		for (int i = 2; i <= n; i++)
		{
			sum += f[x][a[i]];
			x = a[i];
		}
		fm += sum;

	} while (next_permutation(a + 1, a + n + 1));
	printf("%.8f\n", fm / fz);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int n, d, c = 0; cin >> n >> d;
    For(i, 0, n) {
        long double x, y, dist; cin >> x >> y;
        dist = sqrt(x*x + y*y);
        if(dist <= d) ++c;
    }
    cout << c;
    
    
    
    return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int a, b;
    cin >> a >> b;
    if(b % a)
        cout << b - a << endl;
    else
        cout << a + b << endl;
}

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

import sys
import math
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B = readline().decode().rstrip().split()
A = int(A)
B = 100 * int(B[0]) + 10 * int(B[2]) + int(B[3])

ans = A * B // 100

print(ans)


Measured memory_bytes: 27160
using System;
using static System.Console;

    class Program
    {
        static void Main(string[] args)
        {
            short[] abc = new short[] { Convert.ToInt16(ReadLine()), Convert.ToInt16(ReadLine()), Convert.ToInt16(ReadLine()) };
            short x = Convert.ToInt16(ReadLine());
            int res=0;
            for(short a = 0; a <= abc[0]; a++)
            {
                for(short b = 0; b <= abc[1]; b++)
                {
                    for(short c = 0; c <= abc[2]; c++)
                    {
                        short total = (short)((500 * a) + (100 * b) + (50 * c));
                        if (total == x) res++;
                    }
                }
            }
            WriteLine(res.ToString());
        }
    }

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

int main(){
    int n,m;
    cin >> n >> m;
    vector <vector <int>> c(m+1);

    int a,b;
    rep(i,n){
        cin >> a >> b;
        if(a<=m){
            c[a].push_back(b);
        }
    }

    priority_queue <int> q;
    ll su;
    su=0;
    int u;
    int l;
    rep(i,m){
        l=c[i+1].size();
        rep(j,l){
            q.push(c[i+1][j]);
        }
        if(q.size()==0){
            continue;
        }
        u=q.top();
        q.pop();
        su+=u;
    }

    cout << su << endl;

    return 0;
}

Measured memory_bytes: 5632
//default
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed main(){
  int N,ans=0;
  cin >> N;
  int A[N],B[N],C[N];
  rep(i,N){
    cin >> A[i];
  }
  sort(A,A+N);
  rep(i,N){
    cin >> B[i];
  }
  rep(i,N){
    cin >> C[i];
  }
  sort(C,C+N);
  rep(i,N){
    int a_num=lower_bound(A,A+N,B[i])-A;
    int c_num=N-(lower_bound(C,C+N,B[i]+1)-C);
    ans+=a_num*c_num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>

using std::vector;
using std::printf;
using std::cout;
using std::endl;
using std::string;
using std::cin;
using std::pair;
using std::sort;

#define i64t long long int
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

template<typename T>
void dump(vector<T> vec) {
    for (auto x : vec) {
        std::cout << x << " ";
    }
    std::cout << std::endl;
}

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

const i64t MOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    int cnt = 0;
    int score = 0;
    for (int n = 0; n < N-1; ++n) {
        if (S[n] != S[n+1]) {
            cnt += 1;
        }
        else {
            score += 1;
        }
    }

    for (int k = 0; k < K; ++k) {
        if (cnt >= 2) {
            cnt -= 2;
            score += 2;
        }
        else if (cnt == 1) {
            cnt -= 1;
            score += 1;
        }
    }
 
    printf("%d\n", score);
    
}

Measured memory_bytes: 512
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    vector<double> vs(n);
    for (ll i = 0; i < n; ++i) {
        cin >> vs[i];
    }
    sort(vs.begin(), vs.end());
    double ans = vs[0];
    for (ll i = 1; i < n; ++i) {
        ans = (ans + vs[i])/(double)2;
    }
    cout << fixed << setprecision(17) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int N, K;
    cin >> N >> K;
    set<int> a;
    for (int i = 0; i < K; i++){
        int b;
        cin >> b;
        for (int j = 0; j < b; j++){
            int h;
            cin >> h;
            a.insert(h);
        }
    }
    cout << N - a.size() << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

long long score(const long long x, const long long d, const long long e) {
    return e * (x + d - e + 1);
}

bool can(const long long x, const long long y, const long long d) {
    long long e = (x + d + 1) / 2;
    if (1 <= e && e <= d && x * y <= score(x, d, e)) {
        return false;
    }
    if (1 <= e + 1 && e + 1 <= d && x * y <= score(x, d, e + 1)) {
        return false;
    }
    return true;
}

long long num(long long x, long long y) {
    long long ret = x - 1;
    if (1 < y) {
        if (can(x, y, y - 1)) {
            ret += y - 1;
        } else if (can(x, y, 1)) {
            long long lb = 1;
            long long ub = y - 1;
            while (lb + 1 < ub) {
                long long mid = (ub + lb) / 2;
                if (can(x, y, mid)) {
                    lb = mid;
                } else {
                    ub = mid;
                }
            }
            ret += lb;
        }
    }
    return ret;
}

const int MAX_Q = 1000;
int Q;
long long A[MAX_Q], B[MAX_Q];

int main(int argc, char **argv) {
    std::cin >> Q;

    for (int i = 1; i <= Q; i++) {
        std::cin >> A[i] >> B[i];
    }

    for (int i = 1; i <= Q; i++) {
        std::cout << num(std::min(A[i], B[i]), std::max(A[i], B[i])) << std::endl;
    }
    
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int  a, b, c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n; 
	scanf("%d", &n);
	int v[n+1], c[n+1];
	for(int i = 0; i < n; i++){
		scanf("%d", &v[i]);
	}
	for(int i = 0; i < n; i++){
		scanf("%d", &c[i]);
	}
	int dif[n+1], cont = 0;
	for(int i = 0; i < n; i++){
		dif[i] = v[i] - c[i];
		if(dif[i] > 0)
			cont = cont + dif[i];
	}
	printf("%d\n", cont);

	return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  char a,b;
  cin>>a>>b;
  if(a=='H'&&b=='H')cout<<'H'<<endl;
  else if(a=='H'&&b=='D')cout<<'D'<<endl;
  else if(a=='D'&&b=='H')cout<<'D'<<endl;
  else cout<<'H'<<endl;
}
  

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, c>9&c!=253);
	b=(c==253);
	for(a=b?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;

const int N=1e5+1, M=2e5;
int deg[N];
std::vector<int> c[N], key;
int main() {
	int n=rd(), m=rd(), sum=0;
	for(int i=0, j=0; i<m; ++i) {
		int a=rd(), b=rd();
		++deg[a], ++deg[b];
		c[a].push_back(b);
		c[b].push_back(a);
	}
	for(int i=1; i<=n; ++i)
		if(deg[i]%2==1) {
			puts("No");
			return 0;
		}
	for(int i=1; i<=n; ++i) {
		if(deg[i]>=6) {
			puts("Yes");
			return 0;
		}
		if(deg[i]==4) key.push_back(i);
	}
	if(key.size()>=3) {
		puts("Yes");
		return 0;
	}
	if(key.size()<=1) {
		puts("No");
		return 0;
	}
	for(int x=1; x<=n; ++x) if(deg[x]==2) {
		int y=c[x][0], z=c[x][1];
		for(int i=0; i<c[y].size(); ++i) if(c[y][i]==x) c[y][i]=z;
		for(int i=0; i<c[z].size(); ++i) if(c[z][i]==x) c[z][i]=y;
	}
	int x=key[0], y=key[1];
	for(int i=0; i<c[x].size(); ++i) if(c[x][i]==x) {puts("Yes"); return 0;}
	puts("No");
	return 0;
}

Measured memory_bytes: 6144
import collections

h, w, n = [int(i) for i in input().split()]
s = [tuple(int(i) for i in input().split()) for j in range(n)]

def dictadd(d, si):
    dc = d
    for i in range(si[0]-2, si[0]+1):
        if 1 <= i <= h-2:
            for j in range(si[1]-2, si[1]+1):
                if 1 <= j <= w-2:
                    dc[(i, j)] += 1
    return dc


d = collections.defaultdict(lambda: 0)
dc = d

for i in s:
    dc = dictadd(dc, i)

dcv = list(dc.values())
ans = []
tot = 0

for i in range(1, 10):
    x = dcv.count(i)
    ans.append(x)
    tot += x

z = (w-2)*(h-2)-tot

print(z)
for i in ans:
    print(i)

Measured memory_bytes: 168440
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int v[5], k;
    for (int i = 0; i < 5; i++) {
        cin >> v[i];
    }
    cin >> k;

    int sub = v[4] - v[0];
    
    if (sub > k) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
S = input()

if S[0] == 'R':
    tmp = 'RL'
else:
    tmp = 'LR'
cnt = 0
ans = 0
for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        ans += 1
    if S[i:i + 2] == tmp:
        cnt += 1

if cnt > M:
    ans += 2 * M
else:
    ans += 2 * cnt

if N == ans:
    ans -= 1
print(ans)

Measured memory_bytes: 3316
a,b,c,x,y=map(int,input().split())


if a+b>=2*c:
    ans=min(2*c*max(x,y), 2*c*min(x,y)+a*(x-min(x,y))+(b*(y-min(x,y))))
else:
    ans=a*x+b*y
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        long[] ldp = new long[n];
        long[] rdp = new long[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }

        ldp[0] = as[0];
        for (int i = 1; i < n; i++) {
            ldp[i] = as[i] + ldp[i - 1];
        }

        long min = Long.MAX_VALUE;
        int right = n - 1;
        int left = 0;

        for (int i = 0; i < n - 1; i++) {
            long lv = ldp[i];
            long rv;
            if (i > 0) {
                rv = ldp[right] - ldp[i];
            } else {
                rv = ldp[right] - ldp[i];
            }
            long diff = Math.abs(lv - rv);
            min = Math.min(diff, min);
        }

        System.out.println(min);
    }
}


Measured memory_bytes: 90816
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        char[] charArray = input.toCharArray();
        int length = charArray.length;

        char[] shiroKuro = new char[length];
        char[] kuroShiro = new char[length];
        for (int i=0; i<length; i++) {
            if (i % 2 == 0) {
                shiroKuro[i] = '0';
                kuroShiro[i] = '1';
            } else {
                shiroKuro[i] = '1';
                kuroShiro[i] = '0';
            }
        }

        int shiroKuroCount = 0;
        int kuroShiroCount = 0;

        for (int i=0; i<length; i++) {
            if (charArray[i] != shiroKuro[i]) {
                shiroKuroCount++;
            }

            if (charArray[i] != kuroShiro[i]) {
                kuroShiroCount++;
            }
        }

        System.out.println(Math.min(shiroKuroCount, kuroShiroCount));
    }
}


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

char s[101];
void solve(){
	int flag = 0;
	scanf("%s",&s);
	for(int i = 0;i < strlen(s);i ++){
		if(s[i] < 'a' || s[i] > 'z') flag = 1;
	}
	if(s[2] != s[3] || s[4] != s[5]) flag = 1;
	if(flag) cout << "No" << endl;
	else cout << "Yes" << endl;
	return;
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
/*input
1900
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	cout << (1000-n%1000)%1000;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>

int main(void){
  int N,K;
  int a[200000];
  std::cin>>N>>K;
  for(int i=0;i<N;i++){
    std::cin>>a[i];
  }
  for(int i=K;i<N;i++){
    if(a[i]>a[i-K])std::cout<<"Yes"<<std::endl;
    else std::cout<<"No"<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 4400
import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w):
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def sum(self,x):
        x += 1
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
bits = [BinaryIndexedTree(N) for _ in range(26)]

for i,c in enumerate(S):
    bits[ctoi(c)].add(i,1)

s = list(S)
ans = []
for a,b,c in qs:
    if a=='1':
        x = int(b)-1
        bits[ctoi(c)].add(x,1)
        bits[ctoi(s[x])].add(x,-1)
        s[x] = c
    else:
        b,c = int(b)-1,int(c)-1
        tmp = 0
        for i in range(26):
            if bits[i].sum(c) - bits[i].sum(b-1) > 0:
                tmp += 1
        ans.append(tmp)
print(*ans, sep='\n')

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 5)
    {
        cout << 0 << endl;
        return 0;
    }
    else if (a < 13)
    {
        cout << b / 2 << endl;
        return 0;
    }
    else
    {
        cout << b << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    int ans=0,m=0;
    vector<int> data{'A','T','G','C'};
    cin >>s;
    for(int i=0;i<s.size();i++){
        m++;
        if(find(data.begin(),data.end(),s[i])==data.end())m=0;
        ans=max(ans,m);
    }
    cout <<ans;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll T;
  cin >> T;
  for (ll testcase = 0; testcase < T; ++testcase) {
    ll N;
    cin >> N;
    vector<vector<ll>> left(N);
    vector<vector<ll>> right(N);
    ll ans = 0;
    for (ll i = 0; i < N; ++i) {
      ll K, L, R;
      cin >> K >> L >> R;
      K -= 1;
      ans += min(L, R);
      if (L > R) {
        left.at(K).push_back(L - R);
      }
      else {
        if (K != N - 1) {
          right.at(K + 1).push_back(R - L);
        }
      }
    }
    multiset<ll> ls;
    for (ll i = 0; i < N; ++i) {
      for (ll j = 0; j < left.at(i).size(); ++j) {
        ls.insert(left.at(i).at(j));
      }
      while (ls.size() > (i + 1)) {
        ls.erase(ls.begin());
      }
    }
    for (auto itr = ls.begin(); itr != ls.end(); ++itr) {
      ans += *(itr);
    }
    multiset<ll> rs;
    for (ll i = N - 1; i >= 0; --i) {
      for (ll j = 0; j < right.at(i).size(); ++j) {
        rs.insert(right.at(i).at(j));
      }
      while (rs.size() > (N - 1 - i + 1)) {
        rs.erase(rs.begin());
      }
    }
    for (auto itr = rs.begin(); itr != rs.end(); ++itr) {
      ans += *(itr);
    }
    cout << ans << "\n";
  }
}


Measured memory_bytes: 26640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N, i, j;
	double dp[3001][3001];
	double p[3001];
	cin >> N;
	for(i = 0; i < N; i++)
	{
		cin >> p[i];
		for(j = 1; j <= N; j++)
			dp[i][j] = 0;
	}
	dp[0][1] = p[0];
	dp[0][0] = 1 - p[0];
	for(i = 1; i < N; i++)
	dp[i][0] = dp[i - 1][0] * (1 - p[i]);
	for(j = 1; j <= N; j++)
	{
	    for(i = 1; i < N; i++)
	    {
	            dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
	    }
	}
	double ans = 0.0;
	for(j = (N / 2) + 1; j <= N; j++)
	{
	    ans += dp[N - 1][j];
	}
	cout << setprecision(12) << ans;
	return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define MEM 105
#define sanic ios_base::sync_with_stdio(0)
#define MOD 1000000
using namespace std;
long long n,r,b;
int main()
{
    cin >> n >> b >> r;
    cout << b*(n/(b+r))+(n%(b+r)<=b ? n%(b+r):b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vint a(5);
  rep(i,5){
    cin>>a[i];
  }
  sort(all(a));
  int min=INF;
  do{
    int count=0;
    rep(i,5){
      count+=a[i];
      if(i!=4){
        while(count%10!=0){
          count++;
        }
      }
    }
    chmin(min,count);
  }while(next_permutation(all(a)));
  cout<<min<<'\n';
  return(0);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    K=ii()
    S=input()
    if len(S)<=K:
        print(S)
    else:
        print(S[:K]+'...')

main()



Measured memory_bytes: 9988
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
using namespace std;
int n, d,x;
const int INF = 2000000005;

int main() {
	cin >> n >> d >> x;
	int cntr[105] = { 0 };
	int eat[105] = { 0 };
	int ans = x;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		int day = 1;
		while (day <= d) {
			ans++;
			day += a;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
void solve(){
	cin >> n;
	
	i64 ans = 1;
	for(i64 i = 1; i <= n; i++){
		ans *= i;
		ans %= INF;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,m,i,w=1,s;
  cin >> n >> m;
  for (i=0;i<m;i++) w <<= 1;
  s=100*(n-m)+1900*m;
  cout << s*w << endl;
  return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Palindromic Numbers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int DN = 5;

/* typedef */

/* global variables */

int ds[5];

/* subroutines */

/* main */

int main() {
  int a, b;
  scanf("%d%d", &a, &b);

  int cnt = 0;
  for (int n = a; n <= b; n++) {
    for (int i = 0, m = n; i < DN; i++, m /= 10) ds[i] = m % 10;

    bool p = true;
    for (int i = 0, j = DN - 1; i < j; i++, j--)
      if (ds[i] != ds[j]) {
	p = false;
	break;
      }

    if (p) cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}


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

using namespace std;

int main() {

  string str;
  cin >> str;
  if("MON" == str){
    cout << 6;
  }if("TUE" == str){
    cout << 5;
  }if("WED" == str){
    cout << 4;
  }if("THU" == str){
    cout << 3;
  }if("FRI" == str){
    cout << 2;
  }if("SAT" == str){
    cout << 1;
  }if("SUN" == str){
    cout << 7;
  }

  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;cin>>a>>b;
    int ans=0;

    for(int i=a;i<=b;i++){

        int keta=0;
        int tmp=i;
        while(tmp>0){
            keta++;
            tmp/=10;
        }

        bool ok=true;

        int left;
        int right;
        for(int j=0;j<keta/2;j++){
            left=pow(10,keta-1-j);
            right=pow(10,j);
            if((i/right)%10 != (i/left)%10) ok=false;
        }
        
        if(ok) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 512